Pretty print XML
Minor renaming and comments