Fix cycle detection (bad path reference)

Fixes #5.