Rewrite control flow graph implementation