debug
more small changes, comments, and docstrings :)