Improvements to model serialization