diff --git a/python/dune/codegen/sumfact/autotune.py b/python/dune/codegen/sumfact/autotune.py
index c77d8f0e94a5ddbc1354711c3d6fb6358d01a575..addeabcc92e9a59bb10fac2e825764f058d24bda 100644
--- a/python/dune/codegen/sumfact/autotune.py
+++ b/python/dune/codegen/sumfact/autotune.py
@@ -311,6 +311,13 @@ def generate_standalone_kernel_code(kernel, signature, filename, transformations
     opcounting = get_option("opcounter")
     set_option("opcounter", False)
 
+    # Remove opcounter from signature
+    p = re.compile('OpCounter::OpCounter<([^>]*)>')
+    assert len(signature) == 1
+    sig = signature[0]
+    sig = p.sub(r'\1', sig)
+    assert 'OpCounter' not in signature
+
     with open(filename, 'w') as f:
         if transformations:
             f.write('// Transformations:\n')
@@ -330,8 +337,6 @@ def generate_standalone_kernel_code(kernel, signature, filename, transformations
         f.write("\n".join(headers))
 
         # Get a list of the function argument names
-        assert len(signature) == 1
-        sig = signature[0]
         arguments = sig[sig.find('(') + 1:sig.find(')')].split(',')
         arguments = [a.split(' ')[-1] for a in arguments]
 
@@ -425,7 +430,6 @@ def generate_standalone_kernel_code(kernel, signature, filename, transformations
     set_option("opcounter", opcounting)
 
 
-
 def autotune_realization(sf=None, kernel=None, signature=None, transformations=None):
     """Generate an microbenchmark, compile run and return time