Fix crash on connection change