Security improvements

Refactored security filters to remove unnecessary code and streamline future changes