Fix subtle concurrency bug.