Fixing metadata dictionary bug

When converting database row objects into dictionaries, metadata items
with the same keys were being merged into a single key/value pair,
potentially losing many values.
This is now fixed by building lists of values using defaultdict.