Refactor rotation, detect cell bottom [ci skip]