Edited some functions to work with other mathmagic files.