Refactor connection classes into single class