Implemented proper disconnects and reconnects