Fix connected state change handling