Add cycle detection using the problem detector, plus test.