Ensuring that the state of models is preserved when undoing changes, even with deleted nested models.

Also when undoing changes that have added attributes to an object, it unsets these attributes.