Updated  model serialization code.