new code
Implement counters.