This caps a dramatic rebound for the firm that months ago was among the S&P 500 Index’s worst performers