A lot of what is in here, namely the connection manager stuff, should be in a separate module.