Index: libcfa/src/Makefile.am
===================================================================
--- libcfa/src/Makefile.am	(revision 05b400ababf74bc5b0a2fce25752c9ed890fdcc1)
+++ libcfa/src/Makefile.am	(revision e01d2f619fe1b6a0a10882627380a2c394901d11)
@@ -216,4 +216,5 @@
 nobase_cfa_include_HEADERS = ${stdhdr} ${inst_headers_src} ${inst_headers_nosrc} ${inst_thread_headers_src} ${inst_thread_headers_nosrc}
 EXTRA_DIST = stdhdr
+DISTCLEANFILES = $(libdeps) $(thread_libdeps)
 
 #----------------------------------------------------------------------------------------------------------------
@@ -221,6 +222,6 @@
 	-rm -rf ${CFA_INCDIR} ${CFA_LIBDIR}
 
-distclean-local:
-	find ${builddir} -path '*.Plo' -delete
+#distclean-local:
+#	find ${builddir} -path '*.Plo' -delete
 
 
Index: src/GenPoly/Box.cc
===================================================================
--- src/GenPoly/Box.cc	(revision 05b400ababf74bc5b0a2fce25752c9ed890fdcc1)
+++ src/GenPoly/Box.cc	(revision e01d2f619fe1b6a0a10882627380a2c394901d11)
@@ -189,6 +189,4 @@
 			/// Enters a new scope for type-variables, adding the type variables from ty
 			void beginTypeScope( Type *ty );
-			/// Exits the type-variable scope
-			void endTypeScope();
 			/// Enters a new scope for knowLayouts and knownOffsets and queues exit calls
 			void beginGenericScope();
@@ -198,4 +196,5 @@
 			UniqueName bufNamer;                           ///< Namer for VLA buffers
 			Expression * addrMember = nullptr;             ///< AddressExpr argument is MemberExpr?
+			bool expect_func_type = false;                 ///< used to avoid recursing too deep in type decls
 		};
 
@@ -1419,4 +1418,9 @@
 		void PolyGenericCalculator::beginGenericScope() {
 			GuardScope( *this );
+			// We expect the first function type see to be the type relating to this scope
+			// but any further type is probably some unrelated function pointer
+			// keep track of which is the first
+			GuardValue( expect_func_type );
+			expect_func_type = true;
 		}
 
@@ -1468,4 +1472,21 @@
 		void PolyGenericCalculator::premutate( FunctionType *funcType ) {
 			beginTypeScope( funcType );
+
+			GuardValue( expect_func_type );
+
+			if(!expect_func_type) {
+				GuardAction( [this]() {
+					knownLayouts.endScope();
+					knownOffsets.endScope();
+				});
+				// If this is the first function type we see
+				// Then it's the type of the declaration and we care about it
+				knownLayouts.beginScope();
+				knownOffsets.beginScope();
+			}
+
+			// The other functions type we will see in this scope are probably functions parameters
+			// they don't help us with the layout and offsets so don't mark them as known in this scope
+			expect_func_type = false;
 
 			// make sure that any type information passed into the function is accounted for
@@ -1746,4 +1767,6 @@
 				}
 
+				// std::cout << "TRUE 2" << std::endl;
+
 				return true;
 			} else if ( UnionInstType *unionTy = dynamic_cast< UnionInstType* >( ty ) ) {
