Yes you were right on both counts.
The wire insulation was chaffed through just where it exits the front sprocket cover. I repaired that first but it did not cure the problem.
I then removed the switch and soaked it in a small tub of brake cleaner.
Even though I recently changed the oil and filter the switch was still full of gunge.
Managed to get it cleaned out by pressing the plunger ball in and out while it was submerged in brake cleaner. Followed by a blast of compressed air.
Just back from a 30 mile run and it's still working OK