Added utility to count frequencies of values.