move serialization functionality to the models package