Bugfixes for statistics