refactor, and renice XML output