Added a lot of dostrings and doctests.