finished 统计函数 and small fixes