Refactoring to be more like an API app - WIP