I had the same problem with my 2002 F150 (5.4L) the last two months. I replaced the IAC valve before Xmas and have never had a problem since. My starting problems were identical to yours. So, I first replaced the battery with no success. Then, the dealer wanted to clean the fuel system. That helped for a week but the starting problems continued. After searching some of the Ford forums, everything pointed to the IAC. I'm 99% sure that's your problem. Also, I've have switched to a higher grade and/or brand of gasoline to prevent this in the future.