Some fixes in stats tracking