And consolidate the connection status checks done during connection and disconnection so that we re-use the same logic.