Refactor input controller.