Added calculation of level statistics.