code cleanups

The tests don't pass, but the same tests fail on my fork as on your fork.

Review of code I didn't change:
I'm unhappy with the data types, as it's hard to intuit what's going on especially with the generators and filters
Perhaps it would be better to split up some code into different files to clarify organization.

_apply_time() needs some work. I really don't like how f() is defined four times (three of which are the same).

more docstrings please, and better variable names.

cool program though!