WIP: Filters working

Filters appear to be working properly. Committing as a work-in-progress
because I still need to do quite a bit of testing... but initial tests
seem to show the correct behavior everywhere. (I also need to remove a
lot of the console.log calls I was using for debugging.)