I think you're on the right track, suspecting the key switch. Due to some capacitors inside the controller, there's a big spark over the contact points inside the key switch each time you turn it on, and that can only leave some residue over time, making poor contact...
It's up to you, but I wouldn't worry about warranty by opening that end cap and either try to clean the key switch contacts with a contact cleaning spray of some sort, or bypass it entirely.
If you have the external controller, you could resolder your wires so that the main power cables from the battery goes directly to the plug inside the end-cap, and add a third, thinner control wire from the positive on the battery, via the key switch, to the thinner red wire (the Control-on/off wire) that are connected together with the thick positive wire to the controller...
This way, the controller will always have main power, and you'll avoid that spark each time you turn on the key switch. (Also, this will also enable the use of the anti-theft function.
)
Edit:
I also had similar problems that I tracked down to my key switch; I measured around 40V, but the fuel gauge showed nothing... Wiggling the key switch on and of, made it work intermittently...