doctests, and some fixes