Some cleanups to the bad-filename handling