Allow connection to be overriden by subclasses, and clean up @lleirborras @amedeo