Reimplement 'groupby' and 'frequencies' using 'collections.defaultdict'

`collections.defaultdict` to replace explicit `if` and `try` in `groupby` and `frequencies` respectively, yielding more concise code and encouraging more use of the standard library.

P.S. `collections.Counter` could've been used in `frequencies` instead of `collections.defaultdict`, but is not supported in Python 2.6.