Fixed a bug realted to atomic counters