large scale serialization refactor