first refactoring step, replaced Maps of sets with multimaps.