Add filter option.

An alternative implementation for pull request #30.

Still to do: full coverage.