Fix serialization of model