Some improvements to the file-name cleaning code: