Fixed problem writing models.