tests passing

clean up, add comments and docstrings