Refactor client library API to fit Precog guidelines.

This is a huge change that renames almost all of the methods, changes
their semantics, etc. It also expands the test coverage substantially
and adds a lot more documentation.