stats: move code that loops over all stats into python
15 files changed