simplified cropping, much more robust now

My last change introduced some bugs. I simplified cropping, it's much more robust now.