Don't rely on StringRefs for the prototype mapping

Reworked the setup of the prototype mapping. We stop to rely on
StringRefs. Furthermore, we stop using the array operator for inserting
into the map. Using insert and checking for duplicates is safer.