Better handling of filenames longer than maximum allowed

 #354