fixed terminals hierarchy.