Reduce calls to state.render in migrations

`state.render` is actually very long, so this commit easily reduce the
number of times it needs to be called by moving some calls only after
`allowed_to_migrate` was called (to avoid calling render states we won't
need)

And in `allowed_to_migrate`, avoid calling `allow_migrate` if not needed.

No new tests because the full test suit still pass and there is nothing new.
As far as I can tell, those changes don't relate to reducing calls on `state.render()`. Can you rebase your branch appropriately, please.