Fix retain crash on connection in some cases