Fairly major refactor of the api.