Reworked the collision detection.