Support filtering by arbitrary functions.
Fix typo in comment.