Fixed recovery order

A model would recover its dependents and then itself but that broke a lot of validations. If a dependent had a validation for the model to exist it would fail to be recovered. This patch proposes a more intelligent recovery, where models first recover models that they are dependent on, then they recover themselves, and then they recover their dependents.