2000 Mazda Protege

Engine Performance problem
2000 Mazda Protege 4 cyl Front Wheel Drive Automatic 111000 miles

I have owned my 2000 Mazda for about 18 months and shortly after buying it the check engine light came on. Long story short, I had both converters replaced, both O2 sensors, new spark plugs, and new coil pack. It was only after the new coil pack did the problem get solved - or so I thought. A few months ago the CEL came back on. I was told that one of the 02 sensors had failed (b/c I went with a cheap brand) and it was replaced with a Bosch. This did not solve the problem and the CEL would come on for a few days and off for a few days. The CEL has been on non-stop over the last couple weeks. Up until today, the car drove great. However, the idling became rough today and actually stalled out twice while waiting at a stop light. The car (when not idling) drives very nice. I have spent enough money on this car already and am at my breaking point!
October 19, 2009.

You will need to scan and get the code(s)and get back to me, I'll help.
Engine stalling could be Mass air flow sensor, or problem with the idle control valve.
To be more precise we will need the code(s).

Oct 19, 2009.
P0171 and P1569. Thanks.

Oct 19, 2009.
Thank you for coming back with codes.
I was good at guessing for the mass air flow sensor :-)
P0171 is your mass air flow sensor.
Remove it and clean it with brake fluid or electronic cleaner , sometime it does the triks.
There could be a vacuum leak downstream of the MAF sensor, or the sensor is just faulty .
if the fuel filter have never been changed, it time to do it.

P1569 , this is a variable tumble control system solenoid is between the egr valve and egr boost sensor solenoid valve. it may be faulty.
there is also a variable tumble control system vacuum switch. check the ground at the switch and check the switch.
I have send the diagram in your email and it should be clear there.

Oct 20, 2009.