Some refactoring of the RestController.