diff --git a/examples/advection/var-velocity.py b/examples/advection/var-velocity.py
index e19d6aeb6c22737dd4a5b023e44ace4ce764149e..366fd1e438ea957431377b750511b5fb2759d29f 100644
--- a/examples/advection/var-velocity.py
+++ b/examples/advection/var-velocity.py
@@ -76,7 +76,10 @@ def main(write_output=True, order=4):
         u_analytic(sym.nodes(dim, sym.BTAG_ALL)), quad_tag="product",
         flux_type=flux_type)
 
-    bound_op = bind(discr, op.sym_operator())
+    bound_op = bind(
+            discr, op.sym_operator(),
+            #debug_flags=["dump_sym_operator_stages"]
+            )
 
     u = bind(discr, f(sym.nodes(dim)))(queue, t=0)
 
diff --git a/grudge/execution.py b/grudge/execution.py
index 2915ee85f8f62a586e73559311dc9973040db0f3..04482c86edd289fb8c1e085467fbbe1e690d280a 100644
--- a/grudge/execution.py
+++ b/grudge/execution.py
@@ -559,19 +559,20 @@ def bind(discr, sym_operator, post_bind_mapper=lambda x: x,
 
     stage = [0]
 
-    def dump_optemplate(name, sym_operator):
-        if "dump_optemplate_stages" in debug_flags:
-            from grudge.tools import open_unique_debug_file
-            from grudge.optemplate import pretty
-            open_unique_debug_file("%02d-%s" % (stage[0], name), ".txt").write(
-                    pretty(sym_operator))
+    def dump_sym_operator(name, sym_operator):
+        if "dump_sym_operator_stages" in debug_flags:
+            from pytools.debug import open_unique_debug_file
+            outf, name = open_unique_debug_file("%02d-%s" % (stage[0], name), ".txt")
+            with outf:
+                outf.write(sym.pretty(sym_operator))
+
             stage[0] += 1
 
     sym_operator = process_sym_operator(
             discr,
             sym_operator,
             post_bind_mapper=post_bind_mapper,
-            dumper=dump_optemplate)
+            dumper=dump_sym_operator)
 
     from grudge.symbolic.compiler import OperatorCompiler
     discr_code, eval_code = OperatorCompiler(discr)(sym_operator)