Added function docstrings and improved whitespace usage