Added disconnect handling code.