Improve handling of nr_files != open_files