Refactored filter algorithm

- A lot more short cuts and nulls should be saver now.
- A lot easier to read, less redundant checks.