Added docstrings, minor cleanup