Fixed a bug in collision detection.