Minor optimizations and bugfixings.
Fixed new generic DFS.