Fixed rotation on boundaries

I hope at least.