Add locking missing from the conversion from main-thread-only, and fix A->B->A problem.