add docstrings, remove unused code