Various fixes for the stats code...