fix update_statistic, mem leaks fix