Improved GeneralizedBeam beam-count logic.