The hash lookups associated with finding a variable in the variable are relatively expensive, especially when looking up a variable many times. Additionally, the purely function data structure is nice, but is slow when setting variables because a new map must be created.
So, we should chang the VariableMap data structure to just be an array of stacks, where each index in the array represents a single variable qname, and the stack represents the current instance. When a new variable instance is created we push onto the stack. When that instance goes out of scope, we pop it off. Additionally, DPath should be modified so that variable references are just an offset into this array. This should make variable access much faster with minimal allocations.