Improve the loop-breaking heuristics