edit/crop: Refactor a lot of the inner working to make code simpler and more robust.
