Move global counters outside eadh function
Add documentation