Add protection against malicious data in sandbox filters

- general clean up
- improved error messages