Overhaul the internal data structure for more uniformity and greater code re-use