Internal package; implements optimizations on the internal hierachical model.