HiCustomerthis is lostrider, the problem is with the electronic throttle body assembly, when the battery was replaced the PCM lost its memory, when trying to build a new one there is a concern with the carbon deposits in the throttle body, the PCM needs to be re-calibrated and possibly the throttle body replaced, here is a service bulletin for the concern, the down fall is you will have to take the truck to the dealer for the calibration update. hope this helps.
Some 2004 - 2005 Explorer and Mountaineer vehicles equipped with a 4.0L engine may exhibit one or more of the following symptoms: drive-away hesitation, loss of RPM on deceleration, difficulty starting, and/or idle RPM less than desired. Malfunction indicator lamp (MIL) may be illuminated with diagnostic trouble codes (DTCs) P0506 and/or P0505. These conditions may appear after battery disconnect, dead battery condition, or keep alive memory (KAM) reset. The symptoms may be due to engine deposits in the throttle leading to airflow less than desired.
Follow the Service Procedure steps to correct the condition.