Andreas Moritz says in his book that magnesium deficiency can be caused by poor bowel health. I also believe that it's important to improve gut health before liver-flushing. This always leads to the question, what should one eat? This is the big question, and apart from not eating junk and refined food, the diet is determined by your genetic make-up, dietary history, past medications, etc. You have to experiment and treat all advice as guidance, not rules.
There are primary and secondary enteroliths (AKA stones). Primary ones come from the biliary system and secondary ones from the bowel where the bile precipitates, especially in the ilium. If you see round enteroliths rather than faceted enteroliths; they are secondary. This means you should concentrate on your bowel health and lifestyle issues, and carry out a Liver Flush less often, say twice a year.