Refactor task filtering. Fixes #6.