Big refactor. Moved the api calls into an encapsulated gateway service.