Have you tried a new fuel filter? That was part of my problem.
Embarrassing story: Last week on the way to class it stalled out six times. I HAD to be at this class because it was review for my test this coming week. My wife was dropping out son off at school and was unavailable to come back and take me in.
Was unable to get it back home and was stranded next to an auto-shop. I always do my own work, but it was -10 out and wind was picking up. So I swallowed my price and had him replace my fuel filter. That filter was trashed! Water was in my fuel because temperatures were up and down and the filter was clogged like no other. -All the fuel that was coming out was very brown.
Turns out my fuel pump trainer was also missing, it rotted off.
Had the shop owner replace the fuel pump and make sure the truck was in time on top of the filter. Also, was out of gas

-Because it was so dang cold out my fuel gauge was hung up. I thought there was at-least 12 gallons left.
Anyways, this fixed my problem. I am going to replace the O2 sensor since my check engine is going on and off since it got out of the shop. Will also replace IAC, injector, and Map sensor on Tuesday.
Hopefully you will get a kick out of my little miss hap. The shop owner cut me a major break in price. he even installed my exhaust and fixed my driver power window with out charging, plus he knocked 20% off over all bill for being a college student.
Good luck!