Fixed the rotation angle and angle calcuation. Bouncing works better now...

..., but still breaks at the endpoints of walls.