Refactored XMLTool code.