Cleaning up the API and adding a bit of documentation.