Handle errors, read diffs from the DB, etc.

Lots of error handling, diff reading, and other bits to implement some
of the API server logic.