Work towards making a sane public API

This is part of the work for #17 but it doesn't finish it.