Refactored some of the backend code to get it to work with Angular.