Implemented early cycle detection.