Make the script traverse directories recursively.
Remove some dead code.