[WIP] Add connection manager

This is my [WIP] proposal for the connection manager. I'd like to have a first review on this.

Targets #542.
You would add this to the scope of this PR? I would consider this as stuff for a second PR, as it is mostly refactoring work...