Making model classes serializable