cleanup socket code