Fixed bugs in block rotation