Added docstrings, some minor fixes