Condensed if statements into a for loop.

The first commit just implements those filtering changes we talked about -- ANDing tags together rather than ORing them. The second is just a minor refactor to keep things DRY. If you think it's too terse (or just don't like it, you can easily cherry-pick the first commit without any conflicts.