fix random thread-safety and TBB loop location