Add more thread safe counters. Tighten thread synchronization.