Move connection and disconnection code into Transmitter and Connection classes.