Fix a deadlock or two; rename socket fd variable