Improve handling of duplicate file names