Ok, here's a possible problem: afsd.c:1143 int maxDir = (cacheFiles + nFilesPerDir - 1) / nFilesPerDir; Won't maxDir be too small if we're shrinking the cache and we're going to remove some directories? Won't this make us scribble past the end of cache_dir_filelist and cache_dir_list?