improve the stats recording stuff