replace nested switches with TYPEPAIR hack.