Changes to code to make it more OO and make a REST API