Revert "pull request #1610 from AdrianGaudebert/929197-refactor-connection"

This reverts commit ee2a5111c687a0a305e2cd680ac5dc4f82ff9785, reversing
changes made to 4b83ca1293d8af13be313d64ec9061b5bc804a68.