Stats recalculation

Recalculate stats when the data state changes.