Fixes concurrency bug in counter.