Reading a little online, there was some confirmation of the value of taking magnesium separately. One benefit of taking magnesium right before bedtime is that it can have a calming effect.
Magnesium can be absorbed through the skin and is available in sprays, oils, and bath salts. A nice alternative to pills! I have not yet found a good review article about transdermal forms of magnesium but will keep looking.