Fixed some issues with the collision detection