Refactoring file sanitization to be a little cleaner