Refactored controller and REST router.