Altered the connection callback mechanism. and the doConnection method.