Started refactoring serialization