Refactoring how xml is handled