cleanup and doctests