Updated flatten_dict to use a dictionary instead of a list. Thanks to @bworrell