I broke mod_rewrite by modifying strings in place when expanding them, because variable lookups can cause subrequests which cause mod_rewrite to do its stuff again including an expansion on the same string, which is then syntactically invalid. So copy the lookup keys somewhere else before using them in such a way that may cause recursion.
In addition to this, my parser could also be confused by complicated nested rewrite map expansions like ${map1:${map2:key|dflt}|dflt} so fix that too by keeping track of {} when looking for |.
Provide apr_pool_t arg to register_hooks, since anything they do in that step -must- be done with a pool that will not outlive the cmd pool, from which they may have been dynamically loaded.