Cleanup and improve XMLData error handling