Change algorithms to be class-based

This makes algorithm configuration a bit more sensible, instead of
having to pass in a bunch of parameters (possibly with defaults) to a
single function.

Fixes #5.