Refactored XML storage out. Fixed encoding issue