Added a huge upper bound to the number of iterations, but something is broken.