fix XML output and speed up writer initialization