Further improving the collision detection code.