Restructure and redesign the api