Socket code fixes, style updates