Refactored serialization.
Improved memory usage of mapping class.