Years ago I got my D3 levels up looking for a treatment for another affliction. I eventually developed severe insomnia, so I quit taking D3, but my insomnia remained. My insomnia was caused by a bad work situation plus "sinus pain" waking me up through the night.
I've been on the D3 regimin for 5 months now. Try taking your magnesium about 1 1/2 hours before bedtime. It helps with sleep.