minor, but on the construction of ``map_dict``, worth doing as ``map_dict = defaultdict(dict)``?