Index: src/GenPoly/Lvalue.cc
===================================================================
--- src/GenPoly/Lvalue.cc	(revision da7fe3906c96450ab7bb9652fd41097ef1096f9e)
+++ src/GenPoly/Lvalue.cc	(revision 57acae0dd55a32107fc1c3e35f161b499e5bbf1e)
@@ -17,5 +17,4 @@
 #include <string>                        // for string
 
-#include "Common/Debug.h"
 #include "Common/PassVisitor.h"
 #include "GenPoly.h"                     // for isPolyType
@@ -129,19 +128,11 @@
 		PassVisitor<AddrRef> addrRef;
 		PassVisitor<FixIntrinsicResult> intrinsicResults;
-		Debug::codeGen( translationUnit, "begin" );
 		mutateAll( translationUnit, intrinsicResults );
-		Debug::codeGen( translationUnit, "intrinsicResults" );
 		mutateAll( translationUnit, addrRef );
-		Debug::codeGen( translationUnit, "addrRef" );
 		mutateAll( translationUnit, refCvt );
-		Debug::codeGen( translationUnit, "refCvt" );
 		mutateAll( translationUnit, fixer );
-		Debug::codeGen( translationUnit, "fixer" );
 		mutateAll( translationUnit, collapser );
-		Debug::codeGen( translationUnit, "collapser" );
 		mutateAll( translationUnit, genLval );
-		Debug::codeGen( translationUnit, "genLval" );
 		mutateAll( translationUnit, elim );  // last because other passes need reference types to work
-		Debug::codeGen( translationUnit, "elim" );
 
 		// from this point forward, no other pass should create reference types.
@@ -310,6 +301,12 @@
 				}
 
-				if ( addCast ) {
-					PRINT( std::cerr << "adding cast..." << std::endl; )
+				// if addrExpr depth is 0, then the result is a pointer because the arg was depth 1 and not lvalue.
+				// This means the dereference result is not a reference, is lvalue, and one less pointer depth than
+				// the addrExpr. Thus the cast is meaningless.
+				// TODO: One thing to double check is whether it is possible for the types to differ outside of the single
+				// pointer level (i.e. can the base type of addrExpr differ from the type of addrExpr-arg?).
+				// If so then the cast might need to be added, conditional on a more sophisticated check.
+				if ( addCast && addrExpr->result->referenceDepth() != 0 ) {
+					PRINT( std::cerr << "adding cast to " << addrExpr->result << std::endl; )
 					return new CastExpr( ret, addrExpr->result->clone() );
 				}
Index: src/InitTweak/InitTweak.cc
===================================================================
--- src/InitTweak/InitTweak.cc	(revision da7fe3906c96450ab7bb9652fd41097ef1096f9e)
+++ src/InitTweak/InitTweak.cc	(revision 57acae0dd55a32107fc1c3e35f161b499e5bbf1e)
@@ -520,8 +520,4 @@
 
 	ApplicationExpr * createBitwiseAssignment( Expression * dst, Expression * src ) {
-		std::cerr << "=== createBitwiseAssignment ===" << std::endl;
-		std::cerr << "== dst: " << dst << std::endl;
-		std::cerr << "== src: " << src << std::endl;
-
 		static FunctionDecl * assign = nullptr;
 		if ( ! assign ) {
@@ -544,7 +540,4 @@
 			// src = new CastExpr( src, new ReferenceType( noQualifiers, src->result->stripReferences()->clone() ) );
 		}
-		std::cerr << "============= endl : " << std::endl;
-		std::cerr << "-- dst: " << dst << std::endl;
-		std::cerr << "-- src: " << src << std::endl;
 		return new ApplicationExpr( VariableExpr::functionPointer( assign ), { dst, src } );
 	}
