code and api restructure