Refactored sanitization

To ensure we catch non-theme error pages.