Improve statistic gathering, cleanup, fix ADHI-4730