Index: src/SynTree/ApplicationExpr.cc
===================================================================
--- src/SynTree/ApplicationExpr.cc	(revision 546e712c18fe907ee1619132a875d9ba32994efc)
+++ src/SynTree/ApplicationExpr.cc	(revision 21300d75a007db91aebde37600bdcb7eeb14a5d5)
@@ -29,13 +29,14 @@
 
 ParamEntry::ParamEntry( const ParamEntry &other ) :
-		decl( other.decl ), actualType( maybeClone( other.actualType ) ), formalType( maybeClone( other.formalType ) ), expr( maybeClone( other.expr ) )/*, inferParams( new InferredParams( *other.inferParams ) )*/ {
+		decl( other.decl ), declptr( maybeClone( other.declptr ) ), actualType( maybeClone( other.actualType ) ), formalType( maybeClone( other.formalType ) ), expr( maybeClone( other.expr ) )/*, inferParams( new InferredParams( *other.inferParams ) )*/ {
 }
 
 ParamEntry &ParamEntry::operator=( const ParamEntry &other ) {
 	if ( &other == this ) return *this;
-	decl = other.decl;
+	const_cast<UniqueId &>(decl) = other.decl;
+	const_cast<Declaration * &>(declptr) = maybeClone( other.declptr );
 	// xxx - this looks like a memory leak
-	actualType = maybeClone( other.actualType );
-	formalType = maybeClone( other.formalType );
+	const_cast<Type * &>(actualType) = maybeClone( other.actualType );
+	const_cast<Type * &>(formalType) = maybeClone( other.formalType );
 	expr = maybeClone( other.expr );
 	// *inferParams = *other.inferParams;
@@ -44,4 +45,5 @@
 
 ParamEntry::~ParamEntry() {
+	delete declptr;
 	delete actualType;
 	delete formalType;
@@ -50,7 +52,8 @@
 
 ParamEntry::ParamEntry( ParamEntry && other ) :
-		decl( other.decl ), actualType( other.actualType ), formalType( other.formalType ), expr( other.expr )/*, inferParams( std::move( other.inferParams ) )*/ {
-	other.actualType = nullptr;
-	other.formalType = nullptr;
+		decl( other.decl ), declptr( other.declptr ), actualType( other.actualType ), formalType( other.formalType ), expr( other.expr )/*, inferParams( std::move( other.inferParams ) )*/ {
+	const_cast<Declaration * &>(other.declptr) = nullptr;
+	const_cast<Type * &>(other.actualType) = nullptr;
+	const_cast<Type * &>(other.formalType) = nullptr;
 	other.expr = nullptr;
 }
@@ -58,13 +61,16 @@
 ParamEntry & ParamEntry::operator=( ParamEntry && other ) {
 	if ( &other == this ) return *this;
+	delete declptr;
 	delete actualType;
 	delete formalType;
 	delete expr;
-	decl = other.decl;
-	actualType = other.actualType;
-	formalType = other.formalType;
+	const_cast<UniqueId &>(decl) = other.decl;
+	const_cast<Declaration * &>(declptr) = other.declptr;
+	const_cast<Type * &>(actualType) = other.actualType;
+	const_cast<Type * &>(formalType) = other.formalType;
 	expr = other.expr;
-	other.actualType = nullptr;
-	other.formalType = nullptr;
+	const_cast<Declaration * &>(other.declptr) = nullptr;
+	const_cast<Type * &>(other.actualType) = nullptr;
+	const_cast<Type * &>(other.formalType) = nullptr;
 	other.expr = nullptr;
 	// inferParams = std::move( other.inferParams );
Index: src/SynTree/Declaration.cc
===================================================================
--- src/SynTree/Declaration.cc	(revision 546e712c18fe907ee1619132a875d9ba32994efc)
+++ src/SynTree/Declaration.cc	(revision 21300d75a007db91aebde37600bdcb7eeb14a5d5)
@@ -27,6 +27,4 @@
 
 static UniqueId lastUniqueId = 0;
-typedef std::map< UniqueId, Declaration* > IdMapType;
-static IdMapType idMap;
 
 Declaration::Declaration( const std::string &name, Type::StorageClasses scs, LinkageSpec::Spec linkage )
@@ -45,20 +43,5 @@
 	if ( uniqueId ) return;
 	uniqueId = ++lastUniqueId;
-	idMap[ uniqueId ] = this;
 }
-
-Declaration *Declaration::declFromId( UniqueId id ) {
-	IdMapType::const_iterator i = idMap.find( id );
-	return i != idMap.end() ? i->second : 0;
-}
-
-void Declaration::dumpIds( std::ostream &os ) {
-	for ( IdMapType::const_iterator i = idMap.begin(); i != idMap.end(); ++i ) {
-		os << i->first << " -> ";
-		i->second->printShort( os );
-		os << std::endl;
-	} // for
-}
-
 
 AsmDecl::AsmDecl( AsmStmt *stmt ) : Declaration( "", Type::StorageClasses(), LinkageSpec::C ), stmt( stmt ) {
Index: src/SynTree/Declaration.h
===================================================================
--- src/SynTree/Declaration.h	(revision 546e712c18fe907ee1619132a875d9ba32994efc)
+++ src/SynTree/Declaration.h	(revision 21300d75a007db91aebde37600bdcb7eeb14a5d5)
@@ -68,7 +68,4 @@
 	virtual void printShort( std::ostream &os, Indenter indent = {} ) const = 0;
 
-	static void dumpIds( std::ostream &os );
-	static Declaration *declFromId( UniqueId id );
-
 	UniqueId uniqueId;
 	Type::StorageClasses storageClasses;
Index: src/SynTree/Expression.cc
===================================================================
--- src/SynTree/Expression.cc	(revision 546e712c18fe907ee1619132a875d9ba32994efc)
+++ src/SynTree/Expression.cc	(revision 21300d75a007db91aebde37600bdcb7eeb14a5d5)
@@ -38,5 +38,6 @@
 		for ( InferredParams::const_iterator i = inferParams.begin(); i != inferParams.end(); ++i ) {
 			os << indent+1;
-			Declaration::declFromId( i->second.decl )->printShort( os, indent+1 );
+			assert(i->second.declptr);
+			i->second.declptr->printShort( os, indent+1 );
 			os << std::endl;
 			printInferParams( i->second.expr->inferParams, os, indent+1, level+1 );
Index: src/SynTree/Expression.h
===================================================================
--- src/SynTree/Expression.h	(revision 546e712c18fe907ee1619132a875d9ba32994efc)
+++ src/SynTree/Expression.h	(revision 21300d75a007db91aebde37600bdcb7eeb14a5d5)
@@ -39,6 +39,8 @@
 /// but subject to decay-to-pointer and type parameter renaming
 struct ParamEntry {
-	ParamEntry(): decl( 0 ), actualType( 0 ), formalType( 0 ), expr( 0 )/*, inferParams( new InferredParams )*/ {}
-	ParamEntry( UniqueId decl, Type * actualType, Type * formalType, Expression* expr ): decl( decl ), actualType( actualType ), formalType( formalType ), expr( expr )/*, inferParams( new InferredParams )*/ {}
+	ParamEntry(): decl( 0 ), declptr(nullptr), actualType( 0 ), formalType( 0 ), expr( 0 )/*, inferParams( new InferredParams )*/ {}
+	ParamEntry( UniqueId decl, Declaration * declptr, Type * actualType, Type * formalType, Expression* expr )
+		: decl( decl ), declptr( declptr ), actualType( actualType ), formalType( formalType ), expr( expr )/*, inferParams( new InferredParams )*/ {
+	}
 	ParamEntry( const ParamEntry & other );
 	ParamEntry( ParamEntry && other );
@@ -47,7 +49,8 @@
 	ParamEntry & operator=( ParamEntry && other );
 
-	UniqueId decl;
-	Type * actualType;
-	Type * formalType;
+	UniqueId const decl;
+	Declaration * const declptr;
+	Type * const actualType;
+	Type * const formalType;
 	Expression * expr;
 	// std::unique_ptr< InferredParams > inferParams;
