Allies of beleaguered Brazilian President Michel Temer are waiting for a crucial electoral court ruling in early June rather than withdrawing support now, but they are already preparing a grand bargain to pick an interim successor, party leaders said this week.

At dinner parties in plush Brasilia residences and in backroom meetings in Congress, Temer’s coalition partners and members of his party are seeking agreement on a caretaker to replace the scandal-plagued president, who they see as too damaged to govern.

Amid the political turmoil that comes just a year after his predecessor was impeached and removed from office, preserving Temer’s agenda of austerity reforms and pulling Brazil’s economy out of recession is more important than saving the leader himself, sources in three parties that are his main allies said.

Those measures range from reducing a gaping budget deficit through opening doors to foreign investors to weakening labor laws and tightening pensions.

“We have to wait until we can agree on a way forward the day after, to maintain stability and preserve our Constitution and democracy,” said Sen. Tasso Jereissati, leader of the center-right Brazilian Social Democracy Party (PSDB) that is the largest ally in Temer’s ruling coalition. Jereissati, a wealthy entrepreneur, is among likely candidates to become temporary president.

An electoral court is expected to rule June 8 or 9 on whether to annul the 2014 reelection of President Dilma Rousseff and her running mate Temer on accusations that the ticket was funded by illegal campaign donations.

It had been expected that the court would spare Temer by “splitting” the ticket and ruling that Rousseff, as president, should bear full responsibility. That changed last week when Brazil’s Supreme Court approved a corruption investigation into Temer himself.

If the electoral court nixes the 2014 ticket as a whole, Temer could still appeal to the Supreme Court, dragging out the process.

Young lawmakers in the PSDB wanted to abandon his government immediately last week when the top court approved the corruption probe into Temer. That came on the back of plea-bargain testimony indicating that Temer condoned bribing a witness in the sprawling “Car Wash” graft probe and that he had received $4.6 million in bribes.

But party elders convinced them to wait so a less turbulent transition could be arranged. Other main coalition allies, the Democrats and the Social Democrat Party (PSD), are similarly waiting for the electoral court decision on Temer’s fate.