Adding a mutex around counters

@ranjib keeping me honest