FORD FREESTAR ENGINE PROBLEM

my check engine light is on I have replaced plugs and wires and fuel filter and air filter but the light is still on it doesnt have any power and the engine light mostly flashes all the time I have also used several differant fuel injector cleaners and fuel sys cleaners but no help. What else I think is strange is that the air works really well but not at the moment it works real good but when you try to get on the gas it gets warm? I dont understand whats wrong, This may be a stupid question but would the battery have anything to do with this the reason I ask is early in the spring the battery went dead and I got one from a junk yard and its alot smaller than the original but it woks fine as far as starting the car which by the way starts good the engune doesnt sound like its running smooth kind of rough please help asap thank you