XML Validation and begining of refactoring