Switched to using defaultdict.