Race condition fixes.