Refactor connection procedure of the controller application.