FBI director James Comey’s election-eve decision to publicly revive his investigation into Hillary Clinton’s use of a personal email server and treatment of classified materials when she was secretary of state has unleashed a torrent of criticism. Here are a series of questions and answers to help understand a complicated legal situation:

Did Comey mess up?

Oh, yes.

In general, prosecutors don’t comment on criminal inquiries unless and until a charge is brought, and there is a separate, long-held policy that, during the last 60 days before an election, the department exercises heightened restraint in an effort to avoid doing anything that might be perceived as political interference with the vote.

In this instance, Comey violated both of those sacrosanct principles. He publicly announced in a letter to Congress that he was rekindling a seemingly completed criminal investigation into whether candidate Hillary Clinton and her staff mishandled classified emails. Worse, he did so without even yet knowing whether a newly discovered trove of emails might simply be duplicates of the thousands he had already pored over and found not worth pursuing. Worst of all, he did it just 11 days before one of the most bitter presidential elections our nation has ever known. So yes, that was a mistake.

More than a 100 former federal prosecutors or Justice Department officials have now criticized Comey, either in a signed statement or in assorted media appearances or op-ed pieces, for having violated these guidelines. They have included former Attorney General Eric Holder (who served under President Barack Obama), former Attorney General Alberto Gonzales (George W. Bush), deputy AG George H.W. Terwilliger III (George H.W. Bush), former deputy AG Jamie Gorelick (Bill Clinton), and so on.

The only credible person unassociated with the Donald Trump campaign that I know of who has defended Comey is Dan Richman of Columbia Law School, a former prosecutor who is currently an adviser to Comey.

Did he act out of political bias?

No. None of the 100 or so critics cited above have made such a suggestion and, on the contrary, nearly all have saluted Comey’s integrity. (““Many of us have worked with Director Comey; all of us respect him,” the letter says.) There’s also no evidence Comey supports Trump.

(Some critics have speculated that the savage criticism Comey endured from some Republicans after he decided not to prosecute Hillary Clinton last July could have unconsciously influenced his action this time around, but, obviously, that’s impossible to prove.)

What prompted the inquiry?

The answer is weird and still puzzling at multiple levels.

In pursuing an investigation into whether the disgraced former Congressman Anthony Weiner was knowingly sexting a minor, prosecutors obtained a search warrant to search several of his electronic devices. On one of those, they found thousands of emails belonging to the email accounts of wife Huma Abedin—from whom he is now estranged. Abedin was, from 2009 to 2013, Clinton’s deputy chief of staff at the State Department.

During the original inquiry into Hillary Clinton’s emails, Abedin provided investigators with access to her email accounts and to emails stored on three of her electronic devices.

But she had evidently not mentioned then the existence of the device belonging to her husband, which, it turns out, had hundreds of thousands of her emails on it. After Comey publicly announced the revival of the inquiry last Friday, Abedin reportedly told law enforcement and others that she was surprised to learn that her emails were on Weiner’s machine, and that she does not know how they got there. Her attorney told the New York Times, “From the beginning, Ms. Abedin has complied fully and voluntarily with State Department and law enforcement requests, including sitting for hourslong interviews and providing her work-related and potentially work-related documents. . . . While the F.B.I. has not contacted us about this, Ms. Abedin will continue to be, as she always has been, forthcoming and cooperative.”

The fact that this machine’s existence hadn’t previously been disclosed justifies resuscitating the inquiry—but not making the development public.

So why did Comey make his revival of the inquiry public?

He has explained in a letter to FBI employees that he was simply correcting the record and honoring a pledge he had previously made to Congress.

When Comey testified before Congress last July he had told that body that his inquiry into Clinton’s emails had been “completed.” For a lawyer, if you make a statement to a court or other tribunal, and you later discover that the statement is false, or has become false, there’s often a duty to come forward and correct or supplement the record. In Comey’s case, he had not only left Congress with the impression that his inquiry was over, he had also pledged to be transparent with them and to keep them updated (which was, in retrospect, an unwise and unnecessary commitment). That left him in a damned-if-you-do, damned-if-you-don’t spot.

Why is he making all these decisions, instead of Attorney General Loretta Lynch?

Evidently, it all goes back to late June when Bill Clinton—evincing the unerringly poor judgment that we have come to expect of him—decided to pay an impromptu social visit to Attorney General Lynch as their respective planes happened to be parked nearby on the tarmac at Phoenix Sky Harbor airport. Lynch didn’t have the presence of mind to rebuff the former president, notwithstanding that his wife was then under criminal investigation.

Under a firestorm of criticism, she then overreacted. Most AGs would have recused themselves, letting the deputy AG—in this instance, Sally Yates—oversee the probe from that point forward. Strangely, Lynch went further. She not only recused herself, but delegated the decision of whether to prosecute Hillary Clinton to FBI director Comey.

Comey then ran with the discretion Lynch gave him, unexpectedly delivering an unprecedented press conference in July to announce his decision not to pursue charges against Hillary. While doing that, he did something even more unheard of: he took a parting shot at the people he had just elected not to prosecute, characterizing Clinton and her staffers as having been “extremely careless in their handling of very sensitive, highly classified information.”

This time around, Comey gave Lynch notice of what he planned to do—notifying Congress of the revival of the investigation just 11 days before the election—giving Lynch and Yates time to beg him not to do it. But they didn’t order him not to do it, and he disregarded their urgings.

Why didn’t Lynch or Yates give him an order?

According to the Washington Post, they balked due to the “institutional power of the FBI director, Comey’s personality and the political realities they were facing.” Basically, they feared the appearances and political consequences of ordering him not to inform Congress.

Did Comey break the law?

I doubt it.

Richard Painter, a professor at the University of Minnesota Law School who was chief White House ethics lawyer under George W. Bush’s, has argued in the New York Times that Comey has also violated the Hatch Act. That law forbids federal officials from, among other things, using their official positions to influence elections. Painter has actually filed a complaint against Comey with the U.S. Office of Special Counsel, which enforces that law. (Violations of the Hatch Act carry potential administrative sanctions, including dismissal.) Painter says you can violate the Hatch Act if your actions influence an election, even if that’s not the intent or goal of your action.

Painter’s more qualified than I’ll ever be. Still, I don’t buy it. I can’t believe that by trying to keep his promise to Congress—even if it was a dumb promise and one he never should have made—Comey inadvertently violated the law.

Can Comey be fired?

Yes. FBI directors are appointed by the president to serve 10-year terms, but the president can fire them. (FBI director William Sessions was fired in 1983.)

So far, President Barack Obama has refused even to criticize Comey, however. Perhaps he has not wanted to enter this political mine field, but perhaps he simply still regards Comey as, when all is said and done, a man of integrity who, at worst, made a bad decision in a difficult spot.

After the election, on the other hand, he or a different president might have a different perspective.