Index: src/ResolvExpr/Resolver.cc
===================================================================
--- src/ResolvExpr/Resolver.cc	(revision 228099e32b231901671e3825bc79f7423f019a50)
+++ src/ResolvExpr/Resolver.cc	(revision c366ec68d73cd23ab1a4b37dd84d4eb9ac2206be)
@@ -115,13 +115,15 @@
 	} // namespace
 
-	Expression *findVoidExpression( Expression *untyped, const SymTab::Indexer &indexer ) {
+	void findVoidExpression( Expression *& untyped, const SymTab::Indexer &indexer ) {
 		global_renamer.reset();
 		TypeEnvironment env;
 		Expression *newExpr = resolveInVoidContext( untyped, indexer, env );
 		finishExpr( newExpr, env, untyped->env );
-		return newExpr;
-	}
-
-	Expression * findSingleExpression( Expression *untyped, const SymTab::Indexer &indexer ) {
+		delete untyped;
+		untyped = newExpr;
+	}
+
+	void findSingleExpression( Expression *&untyped, const SymTab::Indexer &indexer ) {
+		if ( ! untyped ) return;
 		TypeEnvironment env;
 		AlternativeFinder finder( indexer, env );
@@ -141,5 +143,20 @@
 		Expression *newExpr = choice.expr->clone();
 		finishExpr( newExpr, choice.env, untyped->env );
-		return newExpr;
+		delete untyped;
+		untyped = newExpr;
+	}
+
+	void findSingleExpression( Expression *& untyped, Type * type, const SymTab::Indexer & indexer ) {
+		assert( untyped && type );
+		untyped = new CastExpr( untyped, type );
+		findSingleExpression( untyped, indexer );
+		if ( CastExpr * castExpr = dynamic_cast< CastExpr * >( untyped ) ) {
+			if ( ResolvExpr::typesCompatible( castExpr->arg->result, castExpr->result, indexer ) ) {
+				// cast is to the same type as its argument, so it's unnecessary -- remove it
+				untyped = castExpr->arg;
+				castExpr->arg = nullptr;
+				delete castExpr;
+			}
+		}
 	}
 
@@ -157,5 +174,5 @@
 		}
 
-		Expression *findIntegralExpression( Expression *untyped, const SymTab::Indexer &indexer ) {
+		void findIntegralExpression( Expression *& untyped, const SymTab::Indexer &indexer ) {
 			TypeEnvironment env;
 			AlternativeFinder finder( indexer, env );
@@ -187,5 +204,6 @@
 			} // if
 			finishExpr( newExpr, *newEnv, untyped->env );
-			return newExpr;
+			delete untyped;
+			untyped = newExpr;
 		}
 
@@ -212,8 +230,5 @@
 	void Resolver::handlePtrType( PtrType * type ) {
 		if ( type->get_dimension() ) {
-			CastExpr *castExpr = new CastExpr( type->get_dimension(), SymTab::SizeType->clone() );
-			Expression *newExpr = findSingleExpression( castExpr, indexer );
-			delete type->get_dimension();
-			type->set_dimension( newExpr );
+			findSingleExpression( type->dimension, SymTab::SizeType->clone(), indexer );
 		}
 	}
@@ -268,19 +283,13 @@
 	void Resolver::previsit( ExprStmt *exprStmt ) {
 		visit_children = false;
-		assertf( exprStmt->get_expr(), "ExprStmt has null Expression in resolver" );
-		Expression *newExpr = findVoidExpression( exprStmt->get_expr(), indexer );
-		delete exprStmt->get_expr();
-		exprStmt->set_expr( newExpr );
+		assertf( exprStmt->expr, "ExprStmt has null Expression in resolver" );
+		findVoidExpression( exprStmt->expr, indexer );
 	}
 
 	void Resolver::previsit( AsmExpr *asmExpr ) {
 		visit_children = false;
-		Expression *newExpr = findVoidExpression( asmExpr->get_operand(), indexer );
-		delete asmExpr->get_operand();
-		asmExpr->set_operand( newExpr );
+		findVoidExpression( asmExpr->operand, indexer );
 		if ( asmExpr->get_inout() ) {
-			newExpr = findVoidExpression( asmExpr->get_inout(), indexer );
-			delete asmExpr->get_inout();
-			asmExpr->set_inout( newExpr );
+			findVoidExpression( asmExpr->inout, indexer );
 		} // if
 	}
@@ -293,26 +302,18 @@
 
 	void Resolver::previsit( IfStmt *ifStmt ) {
-		Expression *newExpr = findSingleExpression( ifStmt->get_condition(), indexer );
-		delete ifStmt->get_condition();
-		ifStmt->set_condition( newExpr );
+		findSingleExpression( ifStmt->condition, indexer );
 	}
 
 	void Resolver::previsit( WhileStmt *whileStmt ) {
-		Expression *newExpr = findSingleExpression( whileStmt->get_condition(), indexer );
-		delete whileStmt->get_condition();
-		whileStmt->set_condition( newExpr );
+		findSingleExpression( whileStmt->condition, indexer );
 	}
 
 	void Resolver::previsit( ForStmt *forStmt ) {
-		if ( forStmt->get_condition() ) {
-			Expression * newExpr = findSingleExpression( forStmt->get_condition(), indexer );
-			delete forStmt->get_condition();
-			forStmt->set_condition( newExpr );
+		if ( forStmt->condition ) {
+			findSingleExpression( forStmt->condition, indexer );
 		} // if
 
-		if ( forStmt->get_increment() ) {
-			Expression * newExpr = findVoidExpression( forStmt->get_increment(), indexer );
-			delete forStmt->get_increment();
-			forStmt->set_increment( newExpr );
+		if ( forStmt->increment ) {
+			findVoidExpression( forStmt->increment, indexer );
 		} // if
 	}
@@ -320,10 +321,7 @@
 	void Resolver::previsit( SwitchStmt *switchStmt ) {
 		GuardValue( currentObject );
-		Expression *newExpr;
-		newExpr = findIntegralExpression( switchStmt->get_condition(), indexer );
-		delete switchStmt->get_condition();
-		switchStmt->set_condition( newExpr );
-
-		currentObject = CurrentObject( newExpr->get_result() );
+		findIntegralExpression( switchStmt->condition, indexer );
+
+		currentObject = CurrentObject( switchStmt->condition->result );
 	}
 
@@ -332,9 +330,10 @@
 			std::list< InitAlternative > initAlts = currentObject.getOptions();
 			assertf( initAlts.size() == 1, "SwitchStmt did not correctly resolve an integral expression." );
-			CastExpr * castExpr = new CastExpr( caseStmt->get_condition(), initAlts.front().type->clone() );
-			Expression * newExpr = findSingleExpression( castExpr, indexer );
-			castExpr = strict_dynamic_cast< CastExpr * >( newExpr );
-			caseStmt->set_condition( castExpr->get_arg() );
-			castExpr->set_arg( nullptr );
+			// must remove cast from case statement because RangeExpr cannot be cast.
+			Expression * newExpr = new CastExpr( caseStmt->condition, initAlts.front().type->clone() );
+			findSingleExpression( newExpr, indexer );
+			CastExpr * castExpr = strict_dynamic_cast< CastExpr * >( newExpr );
+			caseStmt->condition = castExpr->arg;
+			castExpr->arg = nullptr;
 			delete castExpr;
 		}
@@ -345,10 +344,7 @@
 		// must resolve the argument for a computed goto
 		if ( branchStmt->get_type() == BranchStmt::Goto ) { // check for computed goto statement
-			if ( Expression * arg = branchStmt->get_computedTarget() ) {
-				VoidType v = Type::Qualifiers();		// cast to void * for the alternative finder
-				PointerType pt( Type::Qualifiers(), v.clone() );
-				CastExpr * castExpr = new CastExpr( arg, pt.clone() );
-				Expression * newExpr = findSingleExpression( castExpr, indexer ); // find best expression
-				branchStmt->set_target( newExpr );
+			if ( branchStmt->computedTarget ) {
+				// computed goto argument is void *
+				findSingleExpression( branchStmt->computedTarget, new PointerType( Type::Qualifiers(), new VoidType( Type::Qualifiers() ) ), indexer );
 			} // if
 		} // if
@@ -357,9 +353,6 @@
 	void Resolver::previsit( ReturnStmt *returnStmt ) {
 		visit_children = false;
-		if ( returnStmt->get_expr() ) {
-			CastExpr *castExpr = new CastExpr( returnStmt->get_expr(), functionReturn->clone() );
-			Expression *newExpr = findSingleExpression( castExpr, indexer );
-			delete castExpr;
-			returnStmt->set_expr( newExpr );
+		if ( returnStmt->expr ) {
+			findSingleExpression( returnStmt->expr, functionReturn->clone(), indexer );
 		} // if
 	}
@@ -372,41 +365,13 @@
 				indexer.lookupStruct( "__cfaehm__base_exception_t" );
 			assert( exception_decl );
-			Expression * wrapped = new CastExpr(
-				throwStmt->get_expr(),
-				new PointerType(
-					noQualifiers,
-					new StructInstType(
-						noQualifiers,
-						exception_decl
-						)
-					)
-				);
-			Expression * newExpr = findSingleExpression( wrapped, indexer );
-			throwStmt->set_expr( newExpr );
+			Type * exceptType = new PointerType( noQualifiers, new StructInstType( noQualifiers, exception_decl ) );
+			findSingleExpression( throwStmt->expr, exceptType, indexer );
 		}
 	}
 
 	void Resolver::previsit( CatchStmt *catchStmt ) {
-		if ( catchStmt->get_cond() ) {
-			Expression * wrapped = new CastExpr(
-				catchStmt->get_cond(),
-				new BasicType( noQualifiers, BasicType::Bool )
-				);
-			catchStmt->set_cond( findSingleExpression( wrapped, indexer ) );
-		}
-	}
-
-	inline void resolveAsIf( Expression *& expr, SymTab::Indexer & indexer ) {
-		if( !expr ) return;
-		Expression * newExpr = findSingleExpression( expr, indexer );
-		delete expr;
-		expr = newExpr;
-	}
-
-	inline void resolveAsType( Expression *& expr, Type * type, SymTab::Indexer & indexer ) {
-		if( !expr ) return;
-		Expression * newExpr = findSingleExpression( new CastExpr( expr, type ), indexer );
-		delete expr;
-		expr = newExpr;
+		if ( catchStmt->cond ) {
+			findSingleExpression( catchStmt->cond, new BasicType( noQualifiers, BasicType::Bool ), indexer );
+		}
 	}
 
@@ -578,5 +543,5 @@
 			// Resolve the conditions as if it were an IfStmt
 			// Resolve the statments normally
-			resolveAsIf( clause.condition, this->indexer );
+			findSingleExpression( clause.condition, this->indexer );
 			clause.statement->accept( *visitor );
 		}
@@ -587,6 +552,6 @@
 			// Resolve the conditions as if it were an IfStmt
 			// Resolve the statments normally
-			resolveAsType( stmt->timeout.time, new BasicType( noQualifiers, BasicType::LongLongUnsignedInt ), this->indexer );
-			resolveAsIf  ( stmt->timeout.condition, this->indexer );
+			findSingleExpression( stmt->timeout.time, new BasicType( noQualifiers, BasicType::LongLongUnsignedInt ), this->indexer );
+			findSingleExpression( stmt->timeout.condition, this->indexer );
 			stmt->timeout.statement->accept( *visitor );
 		}
@@ -595,5 +560,5 @@
 			// Resolve the conditions as if it were an IfStmt
 			// Resolve the statments normally
-			resolveAsIf( stmt->orelse.condition, this->indexer );
+			findSingleExpression( stmt->orelse.condition, this->indexer );
 			stmt->orelse.statement->accept( *visitor );
 		}
@@ -612,6 +577,6 @@
 		visit_children = false;
 		// resolve initialization using the possibilities as determined by the currentObject cursor
-		UntypedInitExpr * untyped = new UntypedInitExpr( singleInit->get_value(), currentObject.getOptions() );
-		Expression * newExpr = findSingleExpression( untyped, indexer );
+		Expression * newExpr = new UntypedInitExpr( singleInit->get_value(), currentObject.getOptions() );
+		findSingleExpression( newExpr, indexer );
 		InitExpr * initExpr = strict_dynamic_cast< InitExpr * >( newExpr );
 
@@ -620,8 +585,7 @@
 
 		// discard InitExpr wrapper and retain relevant pieces
-		newExpr = initExpr->get_expr();
-		newExpr->set_env( initExpr->get_env() );
-		initExpr->set_expr( nullptr );
-		initExpr->set_env( nullptr );
+		newExpr = initExpr->expr;
+		initExpr->expr = nullptr;
+		std::swap( initExpr->env, newExpr->env );
 		delete initExpr;
 
Index: src/ResolvExpr/Resolver.h
===================================================================
--- src/ResolvExpr/Resolver.h	(revision 228099e32b231901671e3825bc79f7423f019a50)
+++ src/ResolvExpr/Resolver.h	(revision c366ec68d73cd23ab1a4b37dd84d4eb9ac2206be)
@@ -30,7 +30,7 @@
 	void resolve( std::list< Declaration * > translationUnit );
 	void resolveDecl( Declaration *, const SymTab::Indexer &indexer );
-	Expression *resolveInVoidContext( Expression *expr, const SymTab::Indexer &indexer );
-	Expression *findVoidExpression( Expression *untyped, const SymTab::Indexer &indexer );
-	Expression * findSingleExpression( Expression *untyped, const SymTab::Indexer &indexer );
+	Expression *resolveInVoidContext( Expression * expr, const SymTab::Indexer &indexer );
+	void findVoidExpression( Expression *& untyped, const SymTab::Indexer &indexer );
+	void findSingleExpression( Expression *& untyped, const SymTab::Indexer &indexer );
 	void resolveCtorInit( ConstructorInit * ctorInit, const SymTab::Indexer & indexer );
 	void resolveStmtExpr( StmtExpr * stmtExpr, const SymTab::Indexer & indexer );
