Pushed updateCategoryCounts() to transaction end to reduce contention.

* This can really be a problem if locks are held during file related operations.

Change-Id: I00107ffc9951915d3af6002b258b3dae2de5fa92