Refactor resource controller.