Better flip-edges alg