Fix tgi counting bug.