Refactor stats controller.