Clean up hit detection code.