Couple of quick questions.
First, do you or did you have any check engine lights before the battery swap? Second, how many miles are on the X?
My first thought is that something in the emissions system is going out, but because you drove so long before without a computer reset, the computer learned its way around the problem, and by resetting the computer it now has to start all over.
The other big thing to check is the IAC. This is a common problem on Explorers, the IAC starts sticking after high mileage. Its easy to clean and commonly solves idle/stall problems. Just do a search for "clean IAC" or "cleaning IAC" and you should get tons of hits.
Good luck, and keep us up to date.