Clean up loop detection.