Index: src/CodeGen/FixMain.cc
===================================================================
--- src/CodeGen/FixMain.cc	(revision 0c577f7b3078d0a929f6d13463746d71c745126a)
+++ src/CodeGen/FixMain.cc	(revision e58e423bd2a4a3fc8416ab0f70ad09323cbaebed)
@@ -32,6 +32,23 @@
 
 namespace CodeGen {
+
+namespace {
+
+struct FindMainCore {
+	FunctionDecl * main_signature = nullptr;
+
+	void previsit( FunctionDecl * decl ) {
+		if ( FixMain::isMain( decl ) ) {
+			if ( main_signature ) {
+				SemanticError( decl, "Multiple definition of main routine\n" );
+			}
+			main_signature = decl;
+		}
+	}
+};
+
+}
+
 	bool FixMain::replace_main = false;
-	std::unique_ptr<FunctionDecl> FixMain::main_signature = nullptr;
 
 	template<typename container>
@@ -40,16 +57,13 @@
 	}
 
-	void FixMain::registerMain(FunctionDecl* functionDecl)
-	{
-		if(main_signature) {
-			SemanticError(functionDecl, "Multiple definition of main routine\n");
-		}
-		main_signature.reset( functionDecl->clone() );
-	}
+	void FixMain::fix( std::list< Declaration * > & translationUnit,
+			std::ostream &os, const char* bootloader_filename ) {
+		PassVisitor< FindMainCore > main_finder;
+		acceptAll( translationUnit, main_finder );
+		FunctionDecl * main_signature = main_finder.pass.main_signature;
 
-	void FixMain::fix(std::ostream &os, const char* bootloader_filename) {
 		if( main_signature ) {
 			os << "static inline int invoke_main(int argc, char* argv[], char* envp[]) { (void)argc; (void)argv; (void)envp; return ";
-			main_signature->mangleName = SymTab::Mangler::mangle(main_signature.get());
+			main_signature->mangleName = SymTab::Mangler::mangle(main_signature);
 
 			os << main_signature->get_scopedMangleName() << "(";
@@ -121,12 +135,4 @@
 }
 
-struct FindMainCore {
-	void previsit( FunctionDecl * decl ) {
-		if ( FixMain::isMain( decl ) ) {
-			FixMain::registerMain( decl );
-		}
-	}
-};
-
 } // namespace
 
@@ -145,8 +151,3 @@
 }
 
-void FixMain::findMain( std::list< Declaration * > & translationUnit ) {
-	PassVisitor< FindMainCore > mainFinder;
-	acceptAll( translationUnit, mainFinder );
-}
-
 };
Index: src/CodeGen/FixMain.h
===================================================================
--- src/CodeGen/FixMain.h	(revision 0c577f7b3078d0a929f6d13463746d71c745126a)
+++ src/CodeGen/FixMain.h	(revision e58e423bd2a4a3fc8416ab0f70ad09323cbaebed)
@@ -10,6 +10,6 @@
 // Created On       : Thr Jan 12 14:11:09 2017
 // Last Modified By : Andrew Beach
-// Last Modified On : Fri Oct 29 14:49:00 2021
-// Update Count     : 7
+// Last Modified On : Fri Oct 29 16:20:00 2021
+// Update Count     : 8
 //
 
@@ -29,25 +29,24 @@
 
 namespace CodeGen {
-	class FixMain {
-	  public :
-		static inline LinkageSpec::Spec mainLinkage() {
-			return replace_main ? LinkageSpec::Cforall : LinkageSpec::C;
-		}
 
-		static inline void setReplaceMain(bool val) {
-			replace_main = val;
-		}
+class FixMain {
+public :
+	static inline LinkageSpec::Spec mainLinkage() {
+		return replace_main ? LinkageSpec::Cforall : LinkageSpec::C;
+	}
 
-		static void registerMain(FunctionDecl* val);
-		static bool isMain(FunctionDecl* decl);
-		static bool isMain(const ast::FunctionDecl * decl);
+	static inline void setReplaceMain(bool val) {
+		replace_main = val;
+	}
 
-		static void fix(std::ostream &os, const char* bootloader_filename);
+	static bool isMain(FunctionDecl* decl);
+	static bool isMain(const ast::FunctionDecl * decl);
 
-		static void findMain( std::list< Declaration * > & decls );
+	static void fix( std::list< Declaration * > & decls,
+			std::ostream &os, const char* bootloader_filename );
 
-	  private:
-  		static bool replace_main;
-		static std::unique_ptr<FunctionDecl> main_signature;
-	};
+private:
+	static bool replace_main;
+};
+
 } // namespace CodeGen
Index: src/main.cc
===================================================================
--- src/main.cc	(revision 0c577f7b3078d0a929f6d13463746d71c745126a)
+++ src/main.cc	(revision e58e423bd2a4a3fc8416ab0f70ad09323cbaebed)
@@ -10,6 +10,6 @@
 // Created On       : Fri May 15 23:12:02 2015
 // Last Modified By : Andrew Beach
-// Last Modified On : Fri Oct 29 10:10:00 2021
-// Update Count     : 654
+// Last Modified On : Fri Oct 29 16:34:00 2021
+// Update Count     : 655
 //
 
@@ -472,6 +472,6 @@
 		PASS( "Code Gen", CodeGen::generate( translationUnit, *output, ! genproto, prettycodegenp, true, linemarks ) );
 
-		CodeGen::FixMain::findMain( translationUnit );
-		CodeGen::FixMain::fix( *output, (PreludeDirector + "/bootloader.c").c_str() );
+		CodeGen::FixMain::fix( translationUnit, *output,
+				(PreludeDirector + "/bootloader.c").c_str() );
 		if ( output != &cout ) {
 			delete output;
