Made FixRampsEnds more general