Clean up socket code.