fix bugs in the local dir cleaning