Clean up code for building state counts collection.