Refactor controller code, add some services