Index: src/CodeGen/CodeGenerator.cc
===================================================================
--- src/CodeGen/CodeGenerator.cc	(revision d104b0259d2af56d64a4f024802ad2afa0236505)
+++ src/CodeGen/CodeGenerator.cc	(revision ec55ed511aef2cea8def162fb5808c263ad1f7e5)
@@ -10,6 +10,6 @@
 // Created On       : Mon May 18 07:44:20 2015
 // Last Modified By : Andrew Beach
-// Last Modified On : Tus Jul 25 15:29:00 2017
-// Update Count     : 486
+// Last Modified On : Fri Aug 18 15:34:00 2017
+// Update Count     : 488
 //
 #include "CodeGenerator.h"
@@ -79,23 +79,33 @@
 	}
 
-	CodeGenerator::LineMarker::LineMarker(
-			CodeLocation const & loc, bool toPrint) :
-		loc(loc), toPrint(toPrint)
-	{}
-
-	CodeGenerator::LineMarker CodeGenerator::lineDirective(
-			BaseSyntaxNode const * node) {
-		return LineMarker(node->location, lineMarks);
-	}
-
-	std::ostream & operator<<(std::ostream & out,
-			CodeGenerator::LineMarker const & marker) {
-		if (marker.toPrint && marker.loc.isSet()) {
-			return out << "\n# " << marker.loc.linenumber << " \""
-				<< marker.loc.filename << "\"\n";
-		} else if (marker.toPrint) {
-			return out << "\n/* Missing CodeLocation */\n";
-		} else {
-        	return out;
+	/* Using updateLocation at the beginning of a node and nextLine
+	 * within a node should become the method of formating.
+	 */
+	void CodeGenerator::updateLocation( CodeLocation const & to ) {
+		if ( !lineMarks ) {
+			return;
+		} else if ( currentLocation.followedBy( to, 0 ) ) {
+			return;
+		} else if ( currentLocation.followedBy( to, 1 ) ) {
+			output << "\n" << indent;
+			currentLocation.linenumber += 1;
+		} else if ( currentLocation.followedBy( to, 2 ) ) {
+			output << "\n\n" << indent;
+			currentLocation.linenumber += 2;
+		} else {
+			output << "\n# " << to.linenumber << " \"" << to.filename
+			       << "\"\n" << indent;
+			currentLocation = to;
+		}
+		output << std::flush;
+	}
+
+	void CodeGenerator::updateLocation( BaseSyntaxNode const * to ) {
+		updateLocation( to->location );
+	}
+
+	void CodeGenerator::nextLine() {
+		if ( !lineMarks ) {
+			output << "\n" << indent << std::flush;
 		}
 	}
@@ -195,5 +205,5 @@
 			++indent;
 			for ( std::list< Declaration* >::iterator i = memb.begin(); i != memb.end(); i++ ) {
-				output << lineDirective( *i ) << indent;
+				updateLocation( *i );
 				(*i)->accept( *this );
 				output << ";" << endl;
@@ -218,5 +228,5 @@
 	void CodeGenerator::visit( EnumDecl * enumDecl ) {
 		extension( enumDecl );
-		output << lineDirective ( enumDecl );
+		updateLocation( enumDecl );
 		output << "enum ";
 		genAttributes( enumDecl->get_attributes() );
@@ -234,5 +244,6 @@
 				ObjectDecl * obj = dynamic_cast< ObjectDecl* >( *i );
 				assert( obj );
-				output << lineDirective( obj ) << indent << mangleName( obj );
+				updateLocation( obj );
+				output << mangleName( obj );
 				if ( obj->get_init() ) {
 					output << " = ";
@@ -252,5 +263,5 @@
 	void CodeGenerator::visit( TypedefDecl * typeDecl ) {
 		assertf( ! genC, "Typedefs are removed and substituted in earlier passes." );
-		output << lineDirective( typeDecl );
+		updateLocation( typeDecl );
 		output << "typedef ";
 		output << genType( typeDecl->get_base(), typeDecl->get_name(), pretty, genC ) << endl;
@@ -741,10 +752,11 @@
 	void CodeGenerator::visit( StmtExpr * stmtExpr ) {
 		std::list< Statement * > & stmts = stmtExpr->get_statements()->get_kids();
-		output << lineDirective( stmtExpr) << "({" << std::endl;
+		updateLocation( stmtExpr );
+		output << "({" << std::endl;
 		++indent;
 		unsigned int numStmts = stmts.size();
 		unsigned int i = 0;
 		for ( Statement * stmt : stmts ) {
-			output << lineDirective( stmt ) << indent;
+			updateLocation( stmt );
 			output << printLabels( stmt->get_labels() );
 			if ( i+1 == numStmts ) {
@@ -832,5 +844,5 @@
 
 	void CodeGenerator::visit( IfStmt * ifStmt ) {
-		output << lineDirective( ifStmt );
+		updateLocation( ifStmt );
 		output << "if ( ";
 		ifStmt->get_condition()->accept( *this );
@@ -846,5 +858,5 @@
 
 	void CodeGenerator::visit( SwitchStmt * switchStmt ) {
-		output << lineDirective( switchStmt );
+		updateLocation( switchStmt );
 		output << "switch ( " ;
 		switchStmt->get_condition()->accept( *this );
@@ -859,6 +871,5 @@
 
 	void CodeGenerator::visit( CaseStmt * caseStmt ) {
-		output << lineDirective( caseStmt );
-		output << indent;
+		updateLocation( caseStmt );
 		if ( caseStmt->isDefault()) {
 			output << "default";
Index: src/CodeGen/CodeGenerator.h
===================================================================
--- src/CodeGen/CodeGenerator.h	(revision d104b0259d2af56d64a4f024802ad2afa0236505)
+++ src/CodeGen/CodeGenerator.h	(revision ec55ed511aef2cea8def162fb5808c263ad1f7e5)
@@ -10,6 +10,6 @@
 // Created On       : Mon May 18 07:44:20 2015
 // Last Modified By : Andrew Beach
-// Last Modified On : Tus Jul 25 25:30:00 2017
-// Update Count     : 54
+// Last Modified On : Fri Aug 18 15:40:00 2017
+// Update Count     : 56
 //
 
@@ -21,10 +21,7 @@
 
 #include "Common/Indenter.h"      // for Indenter
-
 #include "SynTree/Declaration.h"  // for DeclarationWithType (ptr only), Fun...
 #include "SynTree/Visitor.h"      // for Visitor
 #include "SynTree/SynTree.h"      // for Visitor Nodes
-
-#include "Common/Indenter.h"      // for Indenter
 
 namespace CodeGen {
@@ -113,17 +110,10 @@
 		};
 
-		struct LineMarker {
-			CodeLocation const & loc;
-			bool toPrint;
-
-			LineMarker(CodeLocation const & loc, bool toPrint);
-		};
-
-		LineMarker lineDirective(BaseSyntaxNode const * node);
-
 		void asmName( DeclarationWithType *decl );
 
 		void extension( Expression *expr );
 		void extension( Declaration *decl );
+
+		void updateLocation( BaseSyntaxNode const * to );
 	  private:
 		Indenter indent;
@@ -134,4 +124,8 @@
 		bool genC = false;    // true if output has to be C code
 		bool lineMarks = false;
+
+		CodeLocation currentLocation;
+		void updateLocation( CodeLocation const & to );
+		void nextLine();
 
 		void handleStorageClass( DeclarationWithType *decl );
@@ -160,7 +154,4 @@
 	/// returns C-compatible name of declaration
 	std::string genName( DeclarationWithType * decl );
-
-	std::ostream & operator<<(std::ostream &,
-		CodeGenerator::LineMarker const &);
 } // namespace CodeGen
 
Index: src/CodeGen/Generate.cc
===================================================================
--- src/CodeGen/Generate.cc	(revision d104b0259d2af56d64a4f024802ad2afa0236505)
+++ src/CodeGen/Generate.cc	(revision ec55ed511aef2cea8def162fb5808c263ad1f7e5)
@@ -10,6 +10,6 @@
 // Created On       : Mon May 18 07:44:20 2015
 // Last Modified By : Andrew Beach
-// Last Modified On : Wed May 19 13:05:00 2017
-// Update Count     : 6
+// Last Modified On : Fri Aug 18 15:39:00 2017
+// Update Count     : 7
 //
 #include "Generate.h"
@@ -33,5 +33,5 @@
 		for ( auto & dcl : translationUnit ) {
 			if ( LinkageSpec::isGeneratable( dcl->get_linkage() ) && (doIntrinsics || ! LinkageSpec::isBuiltin( dcl->get_linkage() ) ) ) {
-				os << cgv.lineDirective(dcl);
+				cgv.updateLocation( dcl );
 				dcl->accept(cgv);
 				if ( doSemicolon( dcl ) ) {
