Problem 46 improvements and docstrings