socket handling fixes, more cosmetics