Clojure code adapted from map-invert
Well, the most obvious fix is indeed map-invert-preserving-dups - the whole thing could be more easily written as:

(defn map-invert-preserving-dups [m]
  (apply merge-with into
         (for [[k v] m]
           {v [k]})))


The for expression yields a sequence of maps like [{a [1]} {b [2]} {a [5]}]. Apply calls merge-with into on all of those maps. If you look up the definition of merge-with, you can see that this means basically: "Merge all of these maps together, and if the same key exists twice, with values x and y, then make its value (into x y)".