Bug fix for rotate algorithm
Merge commit