fixed memory leaks in Xml