The main reason is often to overdose magnesium. Try to take less and see what happens. Good counter combinations to avoid grogginess are Vitamin B complex, Ferrum, Coenzyme Q10 (CoQ10), Ginseng, Coffein, Rhodiola roses or Acetyl-L-Carnitin (ALCAR). I hope I've written everything cause I'm not native speaker.