Move some code to a nicer function.
Handle filtering dates. Closes #20.