Change API and add docstrings