cleaned up socket code