Some attempts at doing filtering better. Work in progress, does not yet work.
A few minor changes.
Got the filtering to work the way I wanted it to.
Merge branch 'improve-filtering'.