Fix wait-free algorithm.