Add optimization to avoid revisiting an already visited repo and some small fixes.