Improved collision detection and handling