1st thing to look at is the ignition switch (the actual switch, not the key cylinder). the switch lives under the key cylinder, and is black in color, circular, a little smaller than a hockey puck. search the forums here for instructions on how to disassemble and clean it.
after that, look up the 2 wire mod.. it bypasses the clutch switch and neutral switch to improve functioning of many things, including intermittant cranking that your describing. Again, this bypasses 2 safety switches, which will allow the bike to be cranked in gear, with the clutch release (which will cause the bike to jump forward). my bike had intermittant crank issue just like yours, and performing that mod cured it.. totally... for good.