Added cleanup logic for sub-directories.