Added docstrings, code formatting