SAFE_SWITCH_ON_TYPECODE() macro saves the day