API cleanup. Added docstrings.