fix comments and add docstrings