Add a little refinement to socket handling