When the Securities and Exchange Commission approached Key Energy Services Inc. (KEGX) about bribery allegations in Mexico, the company went into high gear. It launched a major internal investigation and reformed its compliance efforts, including shaking up its legal department.

As part of the corporate reorganization, general counsel Kimberly Frye left last October, after chief compliance officer Garrett Cornelison left in June 2015. Cornelison is now chief compliance officer at Quantas Services Inc. Both have been replaced at Key Energy by Katherine Hargis, a former associate general counsel who was promoted to chief legal officer and chief compliance officer.

The changes and hard work paid off. Last week the SEC made the Houston-based company disgorge $5 million in profits, but the company escaped any other fines or penalties. The Department of Justice already had declined to criminally prosecute the company in April.

But there’s another major hitch. The company promised an orderly exit from all markets outside North America and an exit from Mexico by the end of this year.

The SEC accused Key Energy’s subsidiary in Mexico of violating the books and records and internal control provisions of the Foreign Corrupt Practices Act (FCPA) from August 2010 through April 2013 by making improper payments through a “consultant” to a contract employee at the Mexican state-owned oil company known as Pemex.

In its cease and desist order, the SEC credited the oilfield services company’s cooperation and remedial efforts, while it also noted Key Energy’s shaky financial condition “and its ability to maintain necessary cash reserves to fund its operations and meet its liabilities.”

In the company’s second quarter earnings report released Aug. 15, the company reported a pretax loss of $ $92.9 million. Its first quarter loss was $81.9 million.

The first quarter results included the $5 million charge accrued for the SEC settlement, as well as costs of $2.4 million “related to the FCPA investigations,” which likely included some legal fees. The second quarter results included another $600,000 in costs associated with the FCPA investigation.

A statement from Key’s president and CEO Robert Drummond said, “We are pleased to have resolved the FCPA investigation with the SEC.”

The SEC said Key Energy’s new chief compliance officer oversaw (1) the suspension of payments to all vendors and third parties in Mexico shortly after the independent investigation/internal review began; (2) the engagement of a manual review of over 600 vendors in Mexico for purposes of clearing legitimate payments and assessing whether to move forward with those vendors in current and future operations; (3) reviewing all vendors in use in Russia and Colombia and instituting an enhanced due diligence procedure for all vendors globally; (4) establishing enhanced financial controls around payment processes in Mexico, Colombia and Russia; and much more.

The SEC’s kicker, though, was Key Energy’s promise of “a coordinated wind-down and exit of all markets outside of North America, and a commitment to exit Mexico by the end of 2016.”

This article originally appeared on our ALM partner site Corporate Counsel.