Have you checked the harness connector under the tank? Seem t o rember s ome folks having similar troubles when this gets corroded.
+1 ON THIS!
Even thou the bike is now fixed, you may want to consider doing the below preventive maintainance:
On my old 2004, my bike (still under warranty) experianced the same issues. Yamaha couldn't figure out the issue.
I found a thread here on the forum. There's a main connector (white, I believe), under the tank, that likes to collect moisture. I pulled mine apart, and just like in the forum, had several pins nice and green. Cleaned them off and put some di-lectric grease in the connector(to prevent future issues).
Immediatly upon start up, I knew it was fixed. I could literally get the bike rolling, clutch only, no spitting/misfiring, ran like a top again!!!
If its never been cleaned/cheaked, di-lectric grease applied, thats the first thing I would check. Its not burried either (probably why it collects water)