cleanup DFS code