Refactor BaseController.