IMA: clean up the IMA counts updating code