96 forman 400 shutting off

I have a 96 forman 400 that began dying just like you would turn the key off. then it quit entirely upon looking at it found the only time it had spark was immediately after releasing starter button. no spark with pull rope or shorting of starter solenoid. Replaced cdi box. Now the first time no spark after that it will spark like normal still nothing on pull rope or shorting of solenoid. Now it really gets weird with running revving slowly gets to a rpm shuts off like hitting kill switch but if you lightly hit starter button comes right back to life. I have cleaned ground wires. completely confused!