Huge refactoring, improve statistic collection and optimize run script