Cleaned up code and updated docstrings. Resolves #41