Bugfix in stats function.