Do you have any modifications to the intake tract? My old roommate put an ebay CAI in his 2004 when he got it and this happened to him. Every now and then it would backfire like crazy and black smoke on start. Putting the stock MAF/CAI back on fixed it.
Yes. The battery, battery cables, and alternator. A weak charging system can cause all sorts of strange problems on these cars.
And, it could possibly be the CAI like Scotty suggested.
Start with the simple things first.