Index: src/AST/Decl.cpp
===================================================================
--- src/AST/Decl.cpp	(revision 51b858208ac4ba1dd63af02aa6f808536839b22a)
+++ src/AST/Decl.cpp	(revision 7d7ef6f328b11b3e98b9104c162a3207b075562f)
@@ -39,8 +39,10 @@
 	if ( uniqueId ) return;  // ensure only set once
 	uniqueId = ++lastUniqueId;
-	//idMap[ uniqueId ] = this;
+	// The extra readonly pointer is causing some reference counting issues.
+	// idMap[ uniqueId ] = this;
 }
 
 readonly<Decl> Decl::fromId( UniqueId id ) {
+	// Right now this map is always empty, so don't use it.
 	assert( false );
 	IdMapType::const_iterator i = idMap.find( id );
Index: src/SynTree/TypeSubstitution.cc
===================================================================
--- src/SynTree/TypeSubstitution.cc	(revision 51b858208ac4ba1dd63af02aa6f808536839b22a)
+++ src/SynTree/TypeSubstitution.cc	(revision 7d7ef6f328b11b3e98b9104c162a3207b075562f)
@@ -146,12 +146,4 @@
 }
 
-static bool are_same( TypeInstType * left, TypeInstType * right ) {
-	if ( left->baseType && right->baseType ) {
-		return left->baseType == right->baseType;
-	} else {
-		return left->name == right->name;
-	}
-}
-
 Type * TypeSubstitution::Substituter::postmutate( TypeInstType *inst ) {
 	BoundVarsType::const_iterator bound = boundVars.find( inst->name );
@@ -166,5 +158,5 @@
 		// TODO: investigate preventing type variables from being bound to themselves in the first place.
 		if ( TypeInstType * replacement = dynamic_cast< TypeInstType * >( i->second ) ) {
-			if ( are_same( inst, replacement ) ) {
+			if ( inst->name == replacement->name ) {
 				return inst;
 			}
