Xml Cleanup

A couple of bug fixes here and there too