Refactor connection code to be simpler.