Index: src/CodeGen/FixMain.cc
===================================================================
--- src/CodeGen/FixMain.cc	(revision c6b4432f5c6c6679b981f5a6bded51ad30ac00d9)
+++ src/CodeGen/FixMain.cc	(revision 25f2798eafbbfb4bb8b7940f48998f59c55a7e12)
@@ -5,5 +5,5 @@
 // file "LICENCE" distributed with Cforall.
 //
-// FixMain.cc --
+// FixMain.cc -- Tools to change a Cforall main into a C main.
 //
 // Author           : Thierry Delisle
@@ -33,9 +33,9 @@
 namespace {
 
-struct FindMainCore_new {
+struct FindMainCore final {
 	ast::FunctionDecl const * main_declaration = nullptr;
 
 	void previsit( ast::FunctionDecl const * decl ) {
-		if ( FixMain::isMain( decl ) ) {
+		if ( isMain( decl ) ) {
 			if ( main_declaration ) {
 				SemanticError( decl, "Multiple definition of main routine\n" );
@@ -106,7 +106,17 @@
 }
 
+struct FixLinkageCore final {
+	ast::Linkage::Spec const spec;
+	FixLinkageCore( ast::Linkage::Spec spec ) : spec( spec ) {}
+
+	ast::FunctionDecl const * previsit( ast::FunctionDecl const * decl ) {
+		if ( decl->name != "main" ) return decl;
+		return ast::mutate_field( decl, &ast::FunctionDecl::linkage, spec );
+	}
+};
+
 } // namespace
 
-bool FixMain::isMain( const ast::FunctionDecl * decl ) {
+bool isMain( const ast::FunctionDecl * decl ) {
 	if ( std::string("main") != decl->name ) {
 		return false;
@@ -115,8 +125,15 @@
 }
 
-void FixMain::fix( ast::TranslationUnit & translationUnit,
+void fixMainLinkage( ast::TranslationUnit & translationUnit,
+		bool replace_main ) {
+	ast::Linkage::Spec const spec =
+		( replace_main ) ? ast::Linkage::Cforall : ast::Linkage::C;
+	ast::Pass<FixLinkageCore>::run( translationUnit, spec );
+}
+
+void fixMainInvoke( ast::TranslationUnit & translationUnit,
 		std::ostream &os, const char * bootloader_filename ) {
 
-	ast::Pass<FindMainCore_new> main_finder;
+	ast::Pass<FindMainCore> main_finder;
 	ast::accept_all( translationUnit, main_finder );
 	if ( nullptr == main_finder.core.main_declaration ) return;
Index: src/CodeGen/FixMain.h
===================================================================
--- src/CodeGen/FixMain.h	(revision c6b4432f5c6c6679b981f5a6bded51ad30ac00d9)
+++ src/CodeGen/FixMain.h	(revision 25f2798eafbbfb4bb8b7940f48998f59c55a7e12)
@@ -5,5 +5,5 @@
 // file "LICENCE" distributed with Cforall.
 //
-// FixMain.h -- 
+// FixMain.h -- Tools to change a Cforall main into a C main.
 //
 // Author           : Thierry Delisle
@@ -17,8 +17,4 @@
 
 #include <iosfwd>
-#include <memory>
-#include <list>
-
-#include "AST/LinkageSpec.hpp"
 
 namespace ast {
@@ -29,22 +25,13 @@
 namespace CodeGen {
 
-class FixMain {
-public :
-	static inline ast::Linkage::Spec getMainLinkage() {
-		return replace_main ? ast::Linkage::Cforall : ast::Linkage::C;
-	}
+/// Is this function a program main function?
+bool isMain( const ast::FunctionDecl * decl );
 
-	static inline void setReplaceMain(bool val) {
-		replace_main = val;
-	}
+/// Adjust the linkage of main functions.
+void fixMainLinkage( ast::TranslationUnit & transUnit, bool replaceMain );
 
-	static bool isMain(const ast::FunctionDecl * decl);
-
-	static void fix( ast::TranslationUnit & translationUnit,
-			std::ostream &os, const char * bootloader_filename );
-
-private:
-	static bool replace_main;
-};
+/// Add a wrapper around to run the Cforall main.
+void fixMainInvoke( ast::TranslationUnit & transUnit,
+		std::ostream & os, const char * bootloaderFilename );
 
 } // namespace CodeGen
Index: src/CodeGen/FixMain2.cc
===================================================================
--- src/CodeGen/FixMain2.cc	(revision c6b4432f5c6c6679b981f5a6bded51ad30ac00d9)
+++ 	(revision )
@@ -1,28 +1,0 @@
-//
-// Cforall Version 1.0.0 Copyright (C) 2015 University of Waterloo
-//
-// The contents of this file are covered under the licence agreement in the
-// file "LICENCE" distributed with Cforall.
-//
-// FixMain2.cc -- A side file used to seperate the compiler and demangler.
-//
-// Author           : Andrew Beach
-// Created On       : Tue May 17 10:05:00 2022
-// Last Modified By : Andrew Beach
-// Last Modified On : Tue May 17 10:08:00 2022
-// Update Count     : 0
-//
-
-#include "FixMain.h"
-
-namespace CodeGen {
-
-bool FixMain::replace_main = false;
-
-} // namespace CodeGen
-
-// Local Variables: //
-// tab-width: 4 //
-// mode: c++ //
-// compile-command: "make install" //
-// End: //
Index: src/CodeGen/FixNames.cc
===================================================================
--- src/CodeGen/FixNames.cc	(revision c6b4432f5c6c6679b981f5a6bded51ad30ac00d9)
+++ src/CodeGen/FixNames.cc	(revision 25f2798eafbbfb4bb8b7940f48998f59c55a7e12)
@@ -28,6 +28,9 @@
 
 namespace CodeGen {
+
+namespace {
+
 /// Does work with the main function and scopeLevels.
-class FixNames_new final {
+class FixNames final {
 	int scopeLevel = 1;
 
@@ -45,5 +48,5 @@
 
 	const ast::FunctionDecl *postvisit( const ast::FunctionDecl *functionDecl ) {
-		if ( FixMain::isMain( functionDecl ) ) {
+		if ( isMain( functionDecl ) ) {
 			auto mutDecl = ast::mutate( functionDecl );
 
@@ -80,6 +83,8 @@
 };
 
+} // namespace
+
 void fixNames( ast::TranslationUnit & translationUnit ) {
-	ast::Pass<FixNames_new>::run( translationUnit );
+	ast::Pass<FixNames>::run( translationUnit );
 }
 
Index: src/CodeGen/FixNames.h
===================================================================
--- src/CodeGen/FixNames.h	(revision c6b4432f5c6c6679b981f5a6bded51ad30ac00d9)
+++ src/CodeGen/FixNames.h	(revision 25f2798eafbbfb4bb8b7940f48998f59c55a7e12)
@@ -16,7 +16,4 @@
 #pragma once
 
-#include <list>  // for list
-
-class Declaration;
 namespace ast {
 	class TranslationUnit;
@@ -24,8 +21,8 @@
 
 namespace CodeGen {
-	/// mangles object and function names
-	void fixNames( std::list< Declaration* > & translationUnit );
+
 /// Sets scope levels and fills in main's default return.
 void fixNames( ast::TranslationUnit & translationUnit );
+
 } // namespace CodeGen
 
Index: src/CodeGen/module.mk
===================================================================
--- src/CodeGen/module.mk	(revision c6b4432f5c6c6679b981f5a6bded51ad30ac00d9)
+++ src/CodeGen/module.mk	(revision 25f2798eafbbfb4bb8b7940f48998f59c55a7e12)
@@ -18,6 +18,4 @@
 	CodeGen/CodeGeneratorNew.cpp \
 	CodeGen/CodeGeneratorNew.hpp \
-	CodeGen/FixMain2.cc \
-	CodeGen/FixMain.h \
 	CodeGen/GenType.cc \
 	CodeGen/GenType.h \
@@ -29,4 +27,5 @@
 	CodeGen/Generate.h \
 	CodeGen/FixMain.cc \
+	CodeGen/FixMain.h \
 	CodeGen/FixNames.cc \
 	CodeGen/FixNames.h \
