The MapVector type stores key-value pairs in a vector, which, when
resized, copies the entries and destroys the old ones. This causes the
underlying operations to be deleted, subsequently causing segfaults.
This patch makes the mappings map type refer to a shared pointer
instead, so that resizing the vector doesn't call the operations'
destructors.
You can return *it->second.get() and return a Mappings & from this function (and all the other functions), then this change will be really small.