Fix worst-case DFS complexity
Reset global state between DFS runs
Merge pull request #70 from eush77/dfs-fixes

Reset global state between DFS calls, minor jsdoc fix