I had a somewhat similar issue that I chased my tail on for a few days that ended up being a bad ground at the handlebars.
My kill switch was also broken internally and was cutting power unless it was in the perfect position. I didn’t realize until I took it all apart. I changed my bars to...