relocated debug printing and fixed an XML output formatting bug