Fix revert() function so it works after cropping and move size functions into core library