Loop detection/removal