Prototype k rewrite machine

I call it K rewrite machine but it's really just a simple interpreter so far. Eventually, this would become a a fast abstract rewrite machine and the starting point of native code generation.
so, we're hoping to eventually break this piece off into a new and separate component. What you do here interferes with that. In order for that to happen, it's necessary that the code for the efficient rewriter be able to live in a separate place (i.e. no ifs on a global state variable inside code shared between the two engines). Can you restructure this so it has only one code path which calls out to some function implemented separately for the two engines?