added some doctests and documentation