Rework socket handling again. Rather than