diff -ru pdns-4.0.5.orig/modules/bindbackend/binddnssec.cc pdns-4.0.5/modules/bindbackend/binddnssec.cc
--- pdns-4.0.5.orig/modules/bindbackend/binddnssec.cc	2017-11-27 12:38:48.000000000 +0100
+++ pdns-4.0.5/modules/bindbackend/binddnssec.cc	2018-10-10 11:30:03.159903279 +0200
@@ -164,9 +164,8 @@
 
   static int maxNSEC3Iterations=::arg().asNum("max-nsec3-iterations");
   if(ns3p) {
-    NSEC3PARAMRecordContent* tmp=dynamic_cast<NSEC3PARAMRecordContent*>(DNSRecordContent::mastermake(QType::NSEC3PARAM, 1, value));
+    auto tmp=std::dynamic_pointer_cast<NSEC3PARAMRecordContent>(DNSRecordContent::mastermake(QType::NSEC3PARAM, 1, value));
     *ns3p = *tmp;
-    delete tmp;
 
     if (ns3p->d_iterations > maxNSEC3Iterations) {
       ns3p->d_iterations = maxNSEC3Iterations;
diff -ru pdns-4.0.5.orig/modules/tinydnsbackend/tinydnsbackend.cc pdns-4.0.5/modules/tinydnsbackend/tinydnsbackend.cc
--- pdns-4.0.5.orig/modules/tinydnsbackend/tinydnsbackend.cc	2017-11-27 12:38:48.000000000 +0100
+++ pdns-4.0.5/modules/tinydnsbackend/tinydnsbackend.cc	2018-10-10 11:30:03.159903279 +0200
@@ -300,10 +300,9 @@
         dr.d_type = rr.qtype.getCode();
         dr.d_clen = val.size()-pr.d_pos;
 
-        DNSRecordContent *drc = DNSRecordContent::mastermake(dr, pr);
+        auto drc = DNSRecordContent::mastermake(dr, pr);
         rr.content = drc->getZoneRepresentation();
         DLOG(cerr<<"CONTENT: "<<rr.content<<endl);
-        delete drc;
       }
       catch (...) {
         if (d_ignorebogus) {
diff -ru pdns-4.0.5.orig/pdns/dnsparser.cc pdns-4.0.5/pdns/dnsparser.cc
--- pdns-4.0.5.orig/pdns/dnsparser.cc	2017-11-27 12:38:48.000000000 +0100
+++ pdns-4.0.5/pdns/dnsparser.cc	2018-10-10 11:30:03.159903279 +0200
@@ -121,54 +121,42 @@
   return ret;
 }
 
-DNSRecordContent* DNSRecordContent::mastermake(const DNSRecord &dr, 
-                                               PacketReader& pr)
+std::shared_ptr<DNSRecordContent> DNSRecordContent::mastermake(const DNSRecord &dr, 
+                                                               PacketReader& pr)
 {
   uint16_t searchclass = (dr.d_type == QType::OPT) ? 1 : dr.d_class; // class is invalid for OPT
 
   typemap_t::const_iterator i=getTypemap().find(make_pair(searchclass, dr.d_type));
   if(i==getTypemap().end() || !i->second) {
-    return new UnknownRecordContent(dr, pr);
+    return std::make_shared<UnknownRecordContent>(dr, pr);
   }
 
   return i->second(dr, pr);
 }
 
-DNSRecordContent* DNSRecordContent::mastermake(uint16_t qtype, uint16_t qclass,
-                                               const string& content)
+std::shared_ptr<DNSRecordContent> DNSRecordContent::mastermake(uint16_t qtype, uint16_t qclass,
+                                                               const string& content)
 {
   zmakermap_t::const_iterator i=getZmakermap().find(make_pair(qclass, qtype));
   if(i==getZmakermap().end()) {
-    return new UnknownRecordContent(content);
+    return std::make_shared<UnknownRecordContent>(content);
   }
 
   return i->second(content);
 }
 
-std::unique_ptr<DNSRecordContent> DNSRecordContent::makeunique(uint16_t qtype, uint16_t qclass,
-                                               const string& content)
-{
-  zmakermap_t::const_iterator i=getZmakermap().find(make_pair(qclass, qtype));
-  if(i==getZmakermap().end()) {
-    return std::unique_ptr<DNSRecordContent>(new UnknownRecordContent(content));
-  }
-
-  return std::unique_ptr<DNSRecordContent>(i->second(content));
-}
-
-
-DNSRecordContent* DNSRecordContent::mastermake(const DNSRecord &dr, PacketReader& pr, uint16_t oc) {
+std::shared_ptr<DNSRecordContent> DNSRecordContent::mastermake(const DNSRecord &dr, PacketReader& pr, uint16_t oc) {
   // For opcode UPDATE and where the DNSRecord is an answer record, we don't care about content, because this is
   // not used within the prerequisite section of RFC2136, so - we can simply use unknownrecordcontent.
   // For section 3.2.3, we do need content so we need to get it properly. But only for the correct Qclasses.
   if (oc == Opcode::Update && dr.d_place == DNSResourceRecord::ANSWER && dr.d_class != 1)
-    return new UnknownRecordContent(dr, pr);
+    return std::make_shared<UnknownRecordContent>(dr, pr);
 
   uint16_t searchclass = (dr.d_type == QType::OPT) ? 1 : dr.d_class; // class is invalid for OPT
 
   typemap_t::const_iterator i=getTypemap().find(make_pair(searchclass, dr.d_type));
   if(i==getTypemap().end() || !i->second) {
-    return new UnknownRecordContent(dr, pr);
+    return std::make_shared<UnknownRecordContent>(dr, pr);
   }
 
   return i->second(dr, pr);
diff -ru pdns-4.0.5.orig/pdns/dnsparser.hh pdns-4.0.5/pdns/dnsparser.hh
--- pdns-4.0.5.orig/pdns/dnsparser.hh	2017-11-27 12:38:48.000000000 +0100
+++ pdns-4.0.5/pdns/dnsparser.hh	2018-10-10 11:30:03.159903279 +0200
@@ -166,10 +166,9 @@
 class DNSRecordContent
 {
 public:
-  static DNSRecordContent* mastermake(const DNSRecord &dr, PacketReader& pr);
-  static DNSRecordContent* mastermake(const DNSRecord &dr, PacketReader& pr, uint16_t opcode);
-  static DNSRecordContent* mastermake(uint16_t qtype, uint16_t qclass, const string& zone);
-  static std::unique_ptr<DNSRecordContent> makeunique(uint16_t qtype, uint16_t qclass, const string& content);
+  static std::shared_ptr<DNSRecordContent> mastermake(const DNSRecord &dr, PacketReader& pr);
+  static std::shared_ptr<DNSRecordContent> mastermake(const DNSRecord &dr, PacketReader& pr, uint16_t opcode);
+  static std::shared_ptr<DNSRecordContent> mastermake(uint16_t qtype, uint16_t qclass, const string& zone);
 
   virtual std::string getZoneRepresentation(bool noDot=false) const = 0;
   virtual ~DNSRecordContent() {}
@@ -198,8 +197,8 @@
 
   void doRecordCheck(const struct DNSRecord&){}
 
-  typedef DNSRecordContent* makerfunc_t(const struct DNSRecord& dr, PacketReader& pr);  
-  typedef DNSRecordContent* zmakerfunc_t(const string& str);  
+  typedef std::shared_ptr<DNSRecordContent> makerfunc_t(const struct DNSRecord& dr, PacketReader& pr);
+  typedef std::shared_ptr<DNSRecordContent> zmakerfunc_t(const string& str);
 
   static void regist(uint16_t cl, uint16_t ty, makerfunc_t* f, zmakerfunc_t* z, const char* name)
   {
diff -ru pdns-4.0.5.orig/pdns/dnsrecords.cc pdns-4.0.5/pdns/dnsrecords.cc
--- pdns-4.0.5.orig/pdns/dnsrecords.cc	2017-11-27 12:38:48.000000000 +0100
+++ pdns-4.0.5/pdns/dnsrecords.cc	2018-10-10 11:30:03.159903279 +0200
@@ -386,19 +386,19 @@
 {
   regist(1, QType::EUI48, &make, &make, "EUI48");
 }
-DNSRecordContent* EUI48RecordContent::make(const DNSRecord &dr, PacketReader& pr)
+std::shared_ptr<DNSRecordContent> EUI48RecordContent::make(const DNSRecord &dr, PacketReader& pr)
 {
     if(dr.d_clen!=6)
       throw MOADNSException("Wrong size for EUI48 record");
 
-    EUI48RecordContent* ret=new EUI48RecordContent();
+    auto ret=std::make_shared<EUI48RecordContent>();
     pr.copyRecord((uint8_t*) &ret->d_eui48, 6);
     return ret;
 }
-DNSRecordContent* EUI48RecordContent::make(const string& zone)
+std::shared_ptr<DNSRecordContent> EUI48RecordContent::make(const string& zone)
 {
     // try to parse
-    EUI48RecordContent *ret=new EUI48RecordContent();
+    auto ret=std::make_shared<EUI48RecordContent>();
     // format is 6 hex bytes and dashes    
     if (sscanf(zone.c_str(), "%2hhx-%2hhx-%2hhx-%2hhx-%2hhx-%2hhx", 
            ret->d_eui48, ret->d_eui48+1, ret->d_eui48+2, 
@@ -429,19 +429,19 @@
 {
   regist(1, QType::EUI64, &make, &make, "EUI64");
 }
-DNSRecordContent* EUI64RecordContent::make(const DNSRecord &dr, PacketReader& pr)
+std::shared_ptr<DNSRecordContent> EUI64RecordContent::make(const DNSRecord &dr, PacketReader& pr)
 {
     if(dr.d_clen!=8)
       throw MOADNSException("Wrong size for EUI64 record");
 
-    EUI64RecordContent* ret=new EUI64RecordContent();
+    auto ret=std::make_shared<EUI64RecordContent>();
     pr.copyRecord((uint8_t*) &ret->d_eui64, 8);
     return ret;
 }
-DNSRecordContent* EUI64RecordContent::make(const string& zone)
+std::shared_ptr<DNSRecordContent> EUI64RecordContent::make(const string& zone)
 {
     // try to parse
-    EUI64RecordContent *ret=new EUI64RecordContent();
+    auto ret=std::make_shared<EUI64RecordContent>();
     // format is 8 hex bytes and dashes
     if (sscanf(zone.c_str(), "%2hhx-%2hhx-%2hhx-%2hhx-%2hhx-%2hhx-%2hhx-%2hhx", 
            ret->d_eui64, ret->d_eui64+1, ret->d_eui64+2,
diff -ru pdns-4.0.5.orig/pdns/dnsrecords.hh pdns-4.0.5/pdns/dnsrecords.hh
--- pdns-4.0.5.orig/pdns/dnsrecords.hh	2017-11-27 12:38:48.000000000 +0100
+++ pdns-4.0.5/pdns/dnsrecords.hh	2018-10-10 11:30:03.159903279 +0200
@@ -33,8 +33,8 @@
   RNAME##RecordContent(const string& zoneData);                                                  \
   static void report(void);                                                                      \
   static void unreport(void);                                                                    \
-  static DNSRecordContent* make(const DNSRecord &dr, PacketReader& pr);                          \
-  static DNSRecordContent* make(const string& zonedata);                                         \
+  static std::shared_ptr<DNSRecordContent> make(const DNSRecord &dr, PacketReader& pr);          \
+  static std::shared_ptr<DNSRecordContent> make(const string& zonedata);                         \
   string getZoneRepresentation(bool noDot=false) const override;                                 \
   void toPacket(DNSPacketWriter& pw) override;                                                   \
   uint16_t getType() const override { return QType::RNAME; }                                   \
@@ -466,8 +466,8 @@
   {}
   NSECRecordContent(const string& content, const string& zone=""); //FIXME400: DNSName& zone?
 
-  static DNSRecordContent* make(const DNSRecord &dr, PacketReader& pr);
-  static DNSRecordContent* make(const string& content);
+  static std::shared_ptr<DNSRecordContent> make(const DNSRecord &dr, PacketReader& pr);
+  static std::shared_ptr<DNSRecordContent> make(const string& content);
   string getZoneRepresentation(bool noDot=false) const override;
   void toPacket(DNSPacketWriter& pw) override;
   uint16_t getType() const override
@@ -487,8 +487,8 @@
   {}
   NSEC3RecordContent(const string& content, const string& zone=""); //FIXME400: DNSName& zone?
 
-  static DNSRecordContent* make(const DNSRecord &dr, PacketReader& pr);
-  static DNSRecordContent* make(const string& content);
+  static std::shared_ptr<DNSRecordContent> make(const DNSRecord &dr, PacketReader& pr);
+  static std::shared_ptr<DNSRecordContent> make(const string& content);
   string getZoneRepresentation(bool noDot=false) const override;
   void toPacket(DNSPacketWriter& pw) override;
 
@@ -516,8 +516,8 @@
   {}
   NSEC3PARAMRecordContent(const string& content, const string& zone=""); // FIXME400: DNSName& zone?
 
-  static DNSRecordContent* make(const DNSRecord &dr, PacketReader& pr);
-  static DNSRecordContent* make(const string& content);
+  static std::shared_ptr<DNSRecordContent> make(const DNSRecord &dr, PacketReader& pr);
+  static std::shared_ptr<DNSRecordContent> make(const string& content);
   string getZoneRepresentation(bool noDot=false) const override;
   void toPacket(DNSPacketWriter& pw) override;
 
@@ -541,8 +541,8 @@
   {}
   LOCRecordContent(const string& content, const string& zone="");
 
-  static DNSRecordContent* make(const DNSRecord &dr, PacketReader& pr);
-  static DNSRecordContent* make(const string& content);
+  static std::shared_ptr<DNSRecordContent> make(const DNSRecord &dr, PacketReader& pr);
+  static std::shared_ptr<DNSRecordContent> make(const string& content);
   string getZoneRepresentation(bool noDot=false) const override;
   void toPacket(DNSPacketWriter& pw) override;
 
@@ -565,8 +565,8 @@
   {}
   WKSRecordContent(const string& content, const string& zone=""); // FIXME400: DNSName& zone?
 
-  static DNSRecordContent* make(const DNSRecord &dr, PacketReader& pr);
-  static DNSRecordContent* make(const string& content);
+  static std::shared_ptr<DNSRecordContent> make(const DNSRecord &dr, PacketReader& pr);
+  static std::shared_ptr<DNSRecordContent> make(const string& content);
   string getZoneRepresentation(bool noDot=false) const override;
   void toPacket(DNSPacketWriter& pw) override;
 
@@ -580,8 +580,8 @@
 public:
   EUI48RecordContent() {};
   static void report(void);
-  static DNSRecordContent* make(const DNSRecord &dr, PacketReader& pr);
-  static DNSRecordContent* make(const string& zone); // FIXME400: DNSName& zone?
+  static std::shared_ptr<DNSRecordContent> make(const DNSRecord &dr, PacketReader& pr);
+  static std::shared_ptr<DNSRecordContent> make(const string& zone); // FIXME400: DNSName& zone?
   string getZoneRepresentation(bool noDot=false) const override;
   void toPacket(DNSPacketWriter& pw) override;
   uint16_t getType() const override { return QType::EUI48; }
@@ -595,8 +595,8 @@
 public:
   EUI64RecordContent() {};
   static void report(void);
-  static DNSRecordContent* make(const DNSRecord &dr, PacketReader& pr);
-  static DNSRecordContent* make(const string& zone); // FIXME400: DNSName& zone?
+  static std::shared_ptr<DNSRecordContent> make(const DNSRecord &dr, PacketReader& pr);
+  static std::shared_ptr<DNSRecordContent> make(const string& zone); // FIXME400: DNSName& zone?
   string getZoneRepresentation(bool noDot=false) const override;
   void toPacket(DNSPacketWriter& pw) override;
   uint16_t getType() const override { return QType::EUI64; }
@@ -643,9 +643,9 @@
 };
 
 #define boilerplate(RNAME, RTYPE)                                                                         \
-RNAME##RecordContent::DNSRecordContent* RNAME##RecordContent::make(const DNSRecord& dr, PacketReader& pr) \
+std::shared_ptr<RNAME##RecordContent::DNSRecordContent> RNAME##RecordContent::make(const DNSRecord& dr, PacketReader& pr) \
 {                                                                                                  \
-  return new RNAME##RecordContent(dr, pr);                                                         \
+  return std::make_shared<RNAME##RecordContent>(dr, pr);                                           \
 }                                                                                                  \
                                                                                                    \
 RNAME##RecordContent::RNAME##RecordContent(const DNSRecord& dr, PacketReader& pr)                  \
@@ -654,9 +654,9 @@
   xfrPacket(pr);                                                                                   \
 }                                                                                                  \
                                                                                                    \
-RNAME##RecordContent::DNSRecordContent* RNAME##RecordContent::make(const string& zonedata)         \
+std::shared_ptr<RNAME##RecordContent::DNSRecordContent> RNAME##RecordContent::make(const string& zonedata)         \
 {                                                                                                  \
-  return new RNAME##RecordContent(zonedata);                                                       \
+  return std::make_shared<RNAME##RecordContent>(zonedata);                                         \
 }                                                                                                  \
                                                                                                    \
 void RNAME##RecordContent::toPacket(DNSPacketWriter& pw)                                           \
diff -ru pdns-4.0.5.orig/pdns/nsecrecords.cc pdns-4.0.5/pdns/nsecrecords.cc
--- pdns-4.0.5.orig/pdns/nsecrecords.cc	2017-11-27 12:38:48.000000000 +0100
+++ pdns-4.0.5/pdns/nsecrecords.cc	2018-10-10 11:30:03.159903279 +0200
@@ -29,9 +29,9 @@
   regist(1, 47, &make, &make, "NSEC");
 }
 
-DNSRecordContent* NSECRecordContent::make(const string& content)
+std::shared_ptr<DNSRecordContent> NSECRecordContent::make(const string& content)
 {
-  return new NSECRecordContent(content);
+  return std::make_shared<NSECRecordContent>(content);
 }
 
 NSECRecordContent::NSECRecordContent(const string& content, const string& zone) 
@@ -81,9 +81,9 @@
   pw.xfrBlob(tmp);
 }
 
-NSECRecordContent::DNSRecordContent* NSECRecordContent::make(const DNSRecord &dr, PacketReader& pr) 
+std::shared_ptr<NSECRecordContent::DNSRecordContent> NSECRecordContent::make(const DNSRecord &dr, PacketReader& pr)
 {
-  NSECRecordContent* ret=new NSECRecordContent();
+  auto ret=std::make_shared<NSECRecordContent>();
   pr.xfrName(ret->d_next);
   string bitmap;
   pr.xfrBlob(bitmap);
@@ -136,9 +136,9 @@
   regist(1, 50, &make, &make, "NSEC3");
 }
 
-DNSRecordContent* NSEC3RecordContent::make(const string& content)
+std::shared_ptr<DNSRecordContent> NSEC3RecordContent::make(const string& content)
 {
-  return new NSEC3RecordContent(content);
+  return std::make_shared<NSEC3RecordContent>(content);
 }
 
 NSEC3RecordContent::NSEC3RecordContent(const string& content, const string& zone)
@@ -203,9 +203,9 @@
   }
 }
 
-NSEC3RecordContent::DNSRecordContent* NSEC3RecordContent::make(const DNSRecord &dr, PacketReader& pr) 
+std::shared_ptr<NSEC3RecordContent::DNSRecordContent> NSEC3RecordContent::make(const DNSRecord &dr, PacketReader& pr)
 {
-  NSEC3RecordContent* ret=new NSEC3RecordContent();
+  auto ret=std::make_shared<NSEC3RecordContent>();
   pr.xfr8BitInt(ret->d_algorithm);
   pr.xfr8BitInt(ret->d_flags);
   pr.xfr16BitInt(ret->d_iterations);
@@ -273,9 +273,9 @@
   regist(254, 51, &make, &make, "NSEC3PARAM");
 }
 
-DNSRecordContent* NSEC3PARAMRecordContent::make(const string& content)
+std::shared_ptr<DNSRecordContent> NSEC3PARAMRecordContent::make(const string& content)
 {
-  return new NSEC3PARAMRecordContent(content);
+  return std::make_shared<NSEC3PARAMRecordContent>(content);
 }
 
 NSEC3PARAMRecordContent::NSEC3PARAMRecordContent(const string& content, const string& zone) 
@@ -297,9 +297,9 @@
   pw.xfrBlob(d_salt);
 }
 
-NSEC3PARAMRecordContent::DNSRecordContent* NSEC3PARAMRecordContent::make(const DNSRecord &dr, PacketReader& pr) 
+std::shared_ptr<NSEC3PARAMRecordContent::DNSRecordContent> NSEC3PARAMRecordContent::make(const DNSRecord &dr, PacketReader& pr)
 {
-  NSEC3PARAMRecordContent* ret=new NSEC3PARAMRecordContent();
+  auto ret=std::make_shared<NSEC3PARAMRecordContent>();
   pr.xfr8BitInt(ret->d_algorithm); 
         pr.xfr8BitInt(ret->d_flags); 
         pr.xfr16BitInt(ret->d_iterations); 
diff -ru pdns-4.0.5.orig/pdns/pdnsutil.cc pdns-4.0.5/pdns/pdnsutil.cc
--- pdns-4.0.5.orig/pdns/pdnsutil.cc	2017-11-27 12:38:48.000000000 +0100
+++ pdns-4.0.5/pdns/pdnsutil.cc	2018-10-10 11:30:03.159903279 +0200
@@ -1414,15 +1414,15 @@
     if(rr.qtype.getCode() == QType::DNSKEY) {
       cerr<<"got DNSKEY!"<<endl;
       apex=rr.qname;
-      drc = *dynamic_cast<DNSKEYRecordContent*>(DNSRecordContent::mastermake(QType::DNSKEY, 1, rr.content));
+      drc = *std::dynamic_pointer_cast<DNSKEYRecordContent>(DNSRecordContent::mastermake(QType::DNSKEY, 1, rr.content));
     }
     else if(rr.qtype.getCode() == QType::RRSIG) {
       cerr<<"got RRSIG"<<endl;
-      rrc = *dynamic_cast<RRSIGRecordContent*>(DNSRecordContent::mastermake(QType::RRSIG, 1, rr.content));
+      rrc = *std::dynamic_pointer_cast<RRSIGRecordContent>(DNSRecordContent::mastermake(QType::RRSIG, 1, rr.content));
     }
     else if(rr.qtype.getCode() == QType::DS) {
       cerr<<"got DS"<<endl;
-      dsrc = *dynamic_cast<DSRecordContent*>(DNSRecordContent::mastermake(QType::DS, 1, rr.content));
+      dsrc = *std::dynamic_pointer_cast<DSRecordContent>(DNSRecordContent::mastermake(QType::DS, 1, rr.content));
     }
     else {
       qname = rr.qname;
diff -ru pdns-4.0.5.orig/pdns/sillyrecords.cc pdns-4.0.5/pdns/sillyrecords.cc
--- pdns-4.0.5.orig/pdns/sillyrecords.cc	2017-11-27 12:38:48.000000000 +0100
+++ pdns-4.0.5/pdns/sillyrecords.cc	2018-10-10 11:30:08.046519093 +0200
@@ -159,9 +159,9 @@
   regist(254, QType::LOC, &make, &make, "LOC");
 }
 
-DNSRecordContent* LOCRecordContent::make(const string& content)
+std::shared_ptr<DNSRecordContent> LOCRecordContent::make(const string& content)
 {
-  return new LOCRecordContent(content);
+  return std::make_shared<LOCRecordContent>(content);
 }
 
 
@@ -177,9 +177,9 @@
   pw.xfr32BitInt(d_altitude);
 }
 
-LOCRecordContent::DNSRecordContent* LOCRecordContent::make(const DNSRecord &dr, PacketReader& pr) 
+std::shared_ptr<LOCRecordContent::DNSRecordContent> LOCRecordContent::make(const DNSRecord &dr, PacketReader& pr) 
 {
-  LOCRecordContent* ret=new LOCRecordContent();
+  auto ret=std::make_shared<LOCRecordContent>();
   pr.xfr8BitInt(ret->d_version);
   pr.xfr8BitInt(ret->d_size);
   pr.xfr8BitInt(ret->d_horizpre);
diff -ru pdns-4.0.5.orig/pdns/speedtest.cc pdns-4.0.5/pdns/speedtest.cc
--- pdns-4.0.5.orig/pdns/speedtest.cc	2017-11-27 12:38:48.000000000 +0100
+++ pdns-4.0.5/pdns/speedtest.cc	2018-10-10 11:30:08.046519093 +0200
@@ -207,9 +207,8 @@
 
   void operator()() const
   {
-      DNSRecordContent*drc = DNSRecordContent::mastermake(QType::A, 1, 
-                                                          "1.2.3.4");
-      delete drc;
+      auto drc = DNSRecordContent::mastermake(QType::A, 1,
+                                              "1.2.3.4");
   }
 };
 
@@ -281,8 +280,8 @@
     DNSPacketWriter pw(packet, DNSName("outpost.ds9a.nl"), d_type);
     for(int records = 0; records < d_records; records++) {
       pw.startRecord(DNSName("outpost.ds9a.nl"), d_type);
-      DNSRecordContent*drc = DNSRecordContent::mastermake(d_type, 1, 
-                                                          d_content);
+      auto drc = DNSRecordContent::mastermake(d_type, 1,
+                                              d_content);
       drc->toPacket(pw);
       delete drc;
     }
@@ -309,7 +308,7 @@
     DNSPacketWriter pw(packet, DNSName("outpost.ds9a.nl"), QType::AAAA);
     for(int records = 0; records < d_records; records++) {
       pw.startRecord(DNSName("outpost.ds9a.nl"), QType::AAAA);
-      DNSRecordContent*drc = DNSRecordContent::mastermake(QType::AAAA, 1, "fe80::21d:92ff:fe6d:8441");
+      auto drc = DNSRecordContent::mastermake(QType::AAAA, 1, "fe80::21d:92ff:fe6d:8441");
       drc->toPacket(pw);
       delete drc;
     }
@@ -334,7 +333,7 @@
 
     for(int records = 0; records < d_records; records++) {
       pw.startRecord(DNSName("outpost.ds9a.nl"), QType::SOA);
-      DNSRecordContent*drc = DNSRecordContent::mastermake(QType::SOA, 1, "a0.org.afilias-nst.info. noc.afilias-nst.info. 2008758137 1800 900 604800 86400");
+      auto drc = DNSRecordContent::mastermake(QType::SOA, 1, "a0.org.afilias-nst.info. noc.afilias-nst.info. 2008758137 1800 900 604800 86400");
       drc->toPacket(pw);
       delete drc;
     }
@@ -356,7 +355,7 @@
   DNSPacketWriter pw(packet, DNSName("outpost.ds9a.nl"), QType::A);
 
   pw.startRecord(DNSName("ds9a.nl"), QType::NS, 3600, 1, DNSResourceRecord::AUTHORITY);
-  DNSRecordContent* drc = DNSRecordContent::mastermake(QType::NS, 1, "ns1.ds9a.nl");
+  auto drc = DNSRecordContent::mastermake(QType::NS, 1, "ns1.ds9a.nl");
   drc->toPacket(pw);
   delete drc;
 
diff -ru pdns-4.0.5.orig/pdns/test-dnsrecords_cc.cc pdns-4.0.5/pdns/test-dnsrecords_cc.cc
--- pdns-4.0.5.orig/pdns/test-dnsrecords_cc.cc	2017-11-27 12:38:48.000000000 +0100
+++ pdns-4.0.5/pdns/test-dnsrecords_cc.cc	2018-10-10 11:30:08.046519093 +0200
@@ -183,7 +183,7 @@
    try {
       std::string recData;
       if (q.getCode() != QType::TSIG) {
-        boost::scoped_ptr<DNSRecordContent> rec(DNSRecordContent::mastermake(q.getCode(), 1, val.get<1>()));
+        auto rec = DNSRecordContent::mastermake(q.getCode(), 1, val.get<1>());
         BOOST_CHECK_MESSAGE(rec != NULL, "mastermake( " << q.getCode() << ", 1, " << val.get<1>() << ") returned NULL");
         if (rec == NULL) continue;
         // now verify the record (note that this will be same as *zone* value (except for certain QTypes)
@@ -268,10 +268,10 @@
 
     if (val.get<2>()) {
       bool success=true;
-      BOOST_WARN_EXCEPTION( { boost::scoped_ptr<DNSRecordContent> drc(DNSRecordContent::mastermake(q.getCode(), 1, val.get<1>())); pw.startRecord(DNSName("unit.test"), q.getCode()); drc->toPacket(pw); success=false; }, std::exception, test_dnsrecords_cc_predicate );
+      BOOST_WARN_EXCEPTION( { std::shared_ptr<DNSRecordContent> drc(DNSRecordContent::mastermake(q.getCode(), 1, val.get<1>())); pw.startRecord(DNSName("unit.test"), q.getCode()); drc->toPacket(pw); success=false; }, std::exception, test_dnsrecords_cc_predicate );
       if (success==false) REC_FAIL_XSUCCESS2(q.getName() << " test #" << n << " has unexpectedly passed"); // a bad record was detected when it was supposed not to be detected
     } else {
-      BOOST_CHECK_EXCEPTION( { boost::scoped_ptr<DNSRecordContent> drc(DNSRecordContent::mastermake(q.getCode(), 1, val.get<1>())); pw.startRecord(DNSName("unit.test"), q.getCode()); drc->toPacket(pw); }, std::exception, test_dnsrecords_cc_predicate );
+      BOOST_CHECK_EXCEPTION( { std::shared_ptr<DNSRecordContent> drc(DNSRecordContent::mastermake(q.getCode(), 1, val.get<1>())); pw.startRecord(DNSName("unit.test"), q.getCode()); drc->toPacket(pw); }, std::exception, test_dnsrecords_cc_predicate );
     }
   };
 }
diff -ru pdns-4.0.5.orig/pdns/test-signers.cc pdns-4.0.5/pdns/test-signers.cc
--- pdns-4.0.5.orig/pdns/test-signers.cc	2017-11-27 12:38:48.000000000 +0100
+++ pdns-4.0.5/pdns/test-signers.cc	2018-10-10 11:30:08.046519093 +0200
@@ -33,7 +33,7 @@
 
     reportBasicTypes();
 
-    rrs.push_back(DNSRecordContent::makeunique(QType::MX, 1, "10 mail.example.com."));
+    rrs.push_back(DNSRecordContent::mastermake(QType::MX, 1, "10 mail.example.com."));
 
     RRSIGRecordContent rrc;
     rrc.d_originalttl = 3600;
@@ -76,7 +76,7 @@
 
     reportBasicTypes();
 
-    rrs.push_back(DNSRecordContent::makeunique(QType::MX, 1, "10 mail.example.com."));
+    rrs.push_back(DNSRecordContent::mastermake(QType::MX, 1, "10 mail.example.com."));
 
     RRSIGRecordContent rrc;
     rrc.d_originalttl = 3600;
diff -ru pdns-4.0.5.orig/pdns/toysdig.cc pdns-4.0.5/pdns/toysdig.cc
--- pdns-4.0.5.orig/pdns/toysdig.cc	2017-11-27 12:38:48.000000000 +0100
+++ pdns-4.0.5/pdns/toysdig.cc	2018-10-10 11:30:08.046519093 +0200
@@ -102,7 +102,7 @@
 LuaConfigItems::LuaConfigItems()
 {
   for (const auto &dsRecord : rootDSs) {
-    auto ds=unique_ptr<DSRecordContent>(dynamic_cast<DSRecordContent*>(DSRecordContent::make(dsRecord)));
+    auto ds=std::dynamic_pointer_cast<DSRecordContent>(DSRecordContent::make(dsRecord));
     dsAnchors[DNSName(".")].insert(*ds);
   }
 }
diff -ru pdns-4.0.5.orig/pdns/ws-auth.cc pdns-4.0.5/pdns/ws-auth.cc
--- pdns-4.0.5.orig/pdns/ws-auth.cc	2017-11-27 12:38:48.000000000 +0100
+++ pdns-4.0.5/pdns/ws-auth.cc	2018-10-10 11:30:08.049852391 +0200
@@ -291,7 +291,7 @@
 /** Helper to build a record content as needed. */
 static inline string makeRecordContent(const QType& qtype, const string& content, bool noDot) {
   // noDot: for backend storage, pass true. for API users, pass false.
-  std::unique_ptr<DNSRecordContent> drc(DNSRecordContent::mastermake(qtype.getCode(), 1, content));
+  auto drc = DNSRecordContent::mastermake(qtype.getCode(), QClass::IN, content);
   return drc->getZoneRepresentation(noDot);
 }
 
