improved increment_filename
remove cruft
improved handling of folders with repeated filenames