Adding docstrings, tightening messiness