2002 TRX350TM Intermittent Spark

Just acquired a 2002 TRX350TM as a project. It runs good without smoke and has excellent compression. The weird thing is that it might crank like it’s new and run great for as long as I want to ride without faltering but then park and sit for a few hours and not start. The starter spins but there is no fire at the plug. A few hours later it might fire up again without any issues. Once cranked, it has not suddenly shut off. The key switch was broken and the key would come out in the on position. I have replaced it with a new OEM switch without resolution. I have looked for loose grounds. I have looked for shorts while cranking in a pitch dark shop without finding a clue. I have tried a new spark plug. Any known common pinch points on the wiring harness or other common failures? Any ignition components on these known to work intermittently? Any suggestions would be much appreciated.