Clean up and some work on the API