cleaning up the API and internal code