Fixing up connection state handling.