Check you electrical connections. Loose or corroded connections create all sorts of gremlins like this.
Especially check the grounding bolt ontop of the gearbox (under the airbox)
Also check the battery connections.
Make sure the connectors are clean and bright - not dusty with white crust. clean with some hot water and scotchbrite.
One other thing to check is the main electrical cable. It can fray from wear and vibration.
Remove the airbox and look at the right side top frame rail just in front of the seat. the cable can rub against the frame here.
- air filter for dirtiness
- throttle bodies for dirt, clean as needed (noted above)
- electrical ground(s)
- bad gas, drain or try some gas drier - you could have water in the tank(!)
- wires frayed or rubbed through