refactored xml validator with some speed optimizations