Fixed dead lock that occurs on connection sometimes.