Fix infinite loops.