edit: added docstrings and pruned out old code