Made changes to writing and reading of counters