Added XML serialization for saving data. Also refactored.