Fix statistics

Few beautifications of statistics code, that was missing in initial pull request

The patch is submited under MIT license