Fixed some problems with collision detection.