Refactor sanitization to make it more automatic