--- a/cmajor++/Llvm/Llvm.Ir/Constant.cpp
+++ b/cmajor++/Llvm/Llvm.Ir/Constant.cpp
@@ -90,9 +90,17 @@
     return hex;
 }
 
-std::string MakeStringConstantName(const std::string& s)
-{
-    std::string name("c\"");
+std::string MakeStringConstantName(const std::string& s, bool metadataSyntax)
+{
+    std::string name;
+    if (metadataSyntax)
+    {
+        name.append("\"");
+    }
+    else
+    {
+        name.append("c\"");
+    }
     for (char c : s)
     {
         if (c != '"' && c != '\\' && c >= 32 && c <= 126)
@@ -104,8 +112,20 @@
             name.append("\\" + Hex(byte(c)));
         }
     }
-    name.append("\\00\"");
+    if (metadataSyntax)
+    {
+        name.append("\"");
+    }
+    else
+    {
+        name.append("\\00\"");
+    }
     return name;
+}
+
+std::string MakeStringConstantName(const std::string& s)
+{
+    return MakeStringConstantName(s, false);
 }
 
 class ConstantCache;
@@ -169,6 +189,8 @@
 
 ConstantCache::ConstantCache(): trueConstant(true), falseConstant(false)
 {
+    trueConstant.SetOwned();
+    falseConstant.SetOwned();
 }
 
 ConstantCachePtr ConstantCache::instance;
@@ -206,6 +228,7 @@
         return i->second;
     }
     ObjectPtr constant = new Constant(name, type);
+    constant->SetOwned();
     constantMap[p] = constant;
     constants.push_back(UniqueObjectPtr(constant));
     return constant;
@@ -224,6 +247,7 @@
         return i->second;
     }
     ObjectPtr constant = new I8Constant(value);
+    constant->SetOwned();
     i8ConstantMap[value] = constant;
     constants.push_back(UniqueObjectPtr(constant));
     return constant;
@@ -237,6 +261,7 @@
         return i->second;
     }
     ObjectPtr constant = new I16Constant(value);
+    constant->SetOwned();
     i16ConstantMap[value] = constant;
     constants.push_back(UniqueObjectPtr(constant));
     return constant;
@@ -250,6 +275,7 @@
         return i->second;
     }
     ObjectPtr constant = new I32Constant(value);
+    constant->SetOwned();
     i32ConstantMap[value] = constant;
     constants.push_back(UniqueObjectPtr(constant));
     return constant;
@@ -263,6 +289,7 @@
         return i->second;
     }
     ObjectPtr constant = new UI32Constant(value);
+    constant->SetOwned();
     ui32ConstantMap[value] = constant;
     constants.push_back(UniqueObjectPtr(constant));
     return constant;
@@ -276,6 +303,7 @@
         return i->second;
     }
     ObjectPtr constant = new I64Constant(value);
+    constant->SetOwned();
     i64ConstantMap[value] = constant;
     constants.push_back(UniqueObjectPtr(constant));
     return constant;
@@ -289,6 +317,7 @@
         return i->second;
     }
     ObjectPtr constant = new UI64Constant(value);
+    constant->SetOwned();
     ui64ConstantMap[value] = constant;
     constants.push_back(UniqueObjectPtr(constant));
     return constant;
@@ -302,6 +331,7 @@
         return i->second;
     }
     ObjectPtr constant = new FloatConstant(value);
+    constant->SetOwned();
     floatConstantMap[value] = constant;
     constants.push_back(UniqueObjectPtr(constant));
     return constant;
@@ -315,6 +345,7 @@
         return i->second;
     }
     ObjectPtr constant = new DoubleConstant(value);
+    constant->SetOwned();
     doubleConstantMap[value] = constant;
     constants.push_back(UniqueObjectPtr(constant));
     return constant;
@@ -328,6 +359,7 @@
         return i->second;
     }
     ObjectPtr constant = new CharConstant(value);
+    constant->SetOwned();
     charConstantMap[value] = constant;
     constants.push_back(UniqueObjectPtr(constant));
     return constant;
@@ -341,6 +373,7 @@
         return i->second;
     }
     ObjectPtr constant = new StringConstant(value);
+    constant->SetOwned();
     stringConstantMap[value] = constant;
     constants.push_back(UniqueObjectPtr(constant));
     return constant;