/**
  * Walks through all directories and removes the ones for this device.
  *
  * @param dirsToRefresh list of the directory to refresh, null if all of them
  * @return true if there was any directory removed
  */
 private boolean cleanDirectories(List<Directory> dirsToRefresh) {
   boolean bChanges = false;
   List<Directory> dirs = null;
   if (dirsToRefresh == null) {
     dirs = DirectoryManager.getInstance().getDirectories();
   } else {
     // If one or more named directories are provided, not only clean them up but also their sub
     // directories
     dirs = new ArrayList<Directory>(dirsToRefresh);
     for (Directory dir : dirsToRefresh) {
       dirs.addAll(dir.getDirectoriesRecursively());
     }
   }
   for (final Directory dir : dirs) {
     if (!ExitService.isExiting()
         && dir.getDevice().equals(this)
         && dir.getDevice().isMounted()
         && !dir.getFio().exists()) {
       // note that associated files are removed too
       DirectoryManager.getInstance().removeDirectory(dir.getID());
       Log.debug("Removed: " + dir);
       bChanges = true;
     }
   }
   return bChanges;
 }