Fix up some doctests and fix another few small bugs.