Re: vitamin b6 causing insomnia
Vitamin B6 is necessary for sleep, since it's involved in the serotonin and melatonin cycles. However there are lots of other things that could throw off sleep cycles too. I've found that there are a number of foods that cause me insomnia because they have a negative effect on my vitamin B6 levels. (caffeine, wheat, chocolate, nuts...). Some plant foods that are supposed to have B6 in them according to nutrition lists actually have pyridoxine glucoside, which is poorly utilized. It seem like in my case that form of vitamin B6 actually competes with the active form of B6 and causes a deficiency.
There also seems to be a connection to the gut microbiome, which could possibly be where your issue is coming from. You would probably be better off trying to improve the health of your intestinal bacteria rather than taking an acid. Probiotic supplements, probiotic foods (yogurt, kefir, fermented vegetables) are something to try. You could also try taking a B vitamin supplement with P5P (pyridoxal-5-phosphate) instead of pyridoxine hydrochloride. I suspect that there's a lot of pyridoxine glucoside (or something else with an anti-nutrient effect) in some pyridoxine hydrochloride supplements. If the acid is actually giving you a B6 deficiency, it's possible that might help. But if it doesn't, continuing to take the betaine hydrochloride doesn't seem wise. Sleep deprivation can give you lots of health problems.