Cleanup API

Changes as discussed in issue #364 and a couple of other cleanups that I made along the way.

There are rather a lot of commits in this PR, they're all fairly small concise changes, so hopefully reviewing will be quite trivial. I'm publishing this now in the hopes of gather feedback, all comments welcome!