Added collision detection.