TYRUS-348: Better handling of close and other states.

- Filter class refactoring, moving more logic into that and removing from implementations.