Refactor models and controllers to support server