Added cycle detection & docs