Optimize the API and restructure the packages