Index: src/AST/Convert.cpp
===================================================================
--- src/AST/Convert.cpp	(revision dff645253958b5492b3ea07df67bc6ccd31d9b57)
+++ src/AST/Convert.cpp	(revision ef5ef56042ce2b547da955746d9986e26cf628ca)
@@ -1342,10 +1342,9 @@
 };
 
-std::list< Declaration * > convert( std::list< ast::ptr< ast::Decl > > && translationUnit ) {
+std::list< Declaration * > convert( const std::list< ast::ptr< ast::Decl > > && translationUnit ) {
 	ConverterNewToOld c;
 	std::list< Declaration * > decls;
 	for(auto d : translationUnit) {
 		decls.emplace_back( c.decl( d ) );
-		delete d;
 	}
 	return decls;
@@ -1436,4 +1435,5 @@
 			{ old->get_funcSpec().val }
 		);
+		cache.emplace( old, decl );
 		decl->scopeLevel = old->scopeLevel;
 		decl->mangleName = old->mangleName;
@@ -1441,5 +1441,4 @@
 		decl->uniqueId   = old->uniqueId;
 		decl->extension  = old->extension;
-		cache.emplace( old, decl );
 
 		this->node = decl;
@@ -1458,4 +1457,5 @@
 			{ old->get_funcSpec().val }
 		};
+		cache.emplace( old, decl );
 		decl->scopeLevel = old->scopeLevel;
 		decl->mangleName = old->mangleName;
@@ -1463,5 +1463,4 @@
 		decl->uniqueId   = old->uniqueId;
 		decl->extension  = old->extension;
-		cache.emplace( old, decl );
 
 		this->node = decl;
@@ -1477,4 +1476,5 @@
 			{ old->linkage.val }
 		);
+		cache.emplace( old, decl );
 		decl->parent = GET_ACCEPT_1(parent, AggregateDecl);
 		decl->body   = old->body;
@@ -1484,5 +1484,4 @@
 		decl->uniqueId   = old->uniqueId;
 		decl->storage    = { old->storageClasses.val };
-		cache.emplace( old, decl );
 
 		this->node = decl;
@@ -1497,4 +1496,5 @@
 			{ old->linkage.val }
 		);
+		cache.emplace( old, decl );
 		decl->parent = GET_ACCEPT_1(parent, AggregateDecl);
 		decl->body   = old->body;
@@ -1504,5 +1504,4 @@
 		decl->uniqueId   = old->uniqueId;
 		decl->storage    = { old->storageClasses.val };
-		cache.emplace( old, decl );
 
 		this->node = decl;
@@ -1517,4 +1516,5 @@
 			{ old->linkage.val }
 		);
+		cache.emplace( old, decl );
 		decl->parent = GET_ACCEPT_1(parent, AggregateDecl);
 		decl->body   = old->body;
@@ -1524,5 +1524,4 @@
 		decl->uniqueId   = old->uniqueId;
 		decl->storage    = { old->storageClasses.val };
-		cache.emplace( old, decl );
 
 		this->node = decl;
@@ -1537,4 +1536,5 @@
 			{ old->linkage.val }
 		);
+		cache.emplace( old, decl );
 		decl->parent = GET_ACCEPT_1(parent, AggregateDecl);
 		decl->body   = old->body;
@@ -1544,5 +1544,4 @@
 		decl->uniqueId   = old->uniqueId;
 		decl->storage    = { old->storageClasses.val };
-		cache.emplace( old, decl );
 
 		this->node = decl;
@@ -1560,9 +1559,9 @@
 			GET_ACCEPT_1(init, Type)
 		};
+		cache.emplace( old, decl );
 		decl->assertions = GET_ACCEPT_V(assertions, DeclWithType);
 		decl->params     = GET_ACCEPT_V(parameters, TypeDecl);
 		decl->extension  = old->extension;
 		decl->uniqueId   = old->uniqueId;
-		cache.emplace( old, decl );
 
 		this->node = decl;
@@ -1912,4 +1911,6 @@
 	ast::TypeSubstitution * convertTypeSubstitution(const TypeSubstitution * old) {
 
+		if (!old) return nullptr;
+
 		ast::TypeSubstitution *rslt = new ast::TypeSubstitution();
 
@@ -2703,6 +2704,6 @@
 		d->accept( c );
 		decls.emplace_back( c.decl() );
-		delete d;
-	}
+	}
+	deleteAll(translationUnit);
 	return decls;
 }
Index: src/AST/Expr.cpp
===================================================================
--- src/AST/Expr.cpp	(revision dff645253958b5492b3ea07df67bc6ccd31d9b57)
+++ src/AST/Expr.cpp	(revision ef5ef56042ce2b547da955746d9986e26cf628ca)
@@ -157,5 +157,5 @@
 	assert( aggregate->result );
 
-	assert(!"unimplemented; need TypeSubstitution, genericSubstitution");
+//	assert(!"unimplemented; need TypeSubstitution, genericSubstitution");
 }
 
Index: src/AST/Node.hpp
===================================================================
--- src/AST/Node.hpp	(revision dff645253958b5492b3ea07df67bc6ccd31d9b57)
+++ src/AST/Node.hpp	(revision ef5ef56042ce2b547da955746d9986e26cf628ca)
@@ -115,5 +115,5 @@
 	template<typename o_node_t>
 	ptr_base & operator=( const o_node_t * node ) {
-		assign(strict_dynamic_cast<const node_t *>(node));
+		assign( node ? strict_dynamic_cast<const node_t *>(node) : nullptr );
 		return *this;
 	}
