Needs to use max_dirs, not MAX_DIRS, since the array may have been realloc'ed