improvements and doctests