Solved but in parseToDom in XML class. Some memory leaks also cleaned up. Probably more memory leaks in the XML lib.
Still need to resolve those. But first need test code for the functions in the XML class to find the mem leaks.