Depth first search fixes