refactor to do sanitization more cleverly and solve a LOT of bugs