Refactor the api component and some of the widgets