Clean up some of the sanitization logic.