Data structures and algorithms underlying the Key Variable Mapping System