Efficiency improvements involving rotation; code cleanup