added docstrings / doctests; removed unnecessary code