Former President Barack Obama spoke at a conference held Wednesday by Qualtrics, a tech company in Salt Lake City.

While he never mentioned the Trump administration by name, he couldn't help throwing a few barbs out such as talking about the importance of having competent people in important government posts.

He said his presidency wasn't clouded by "scandals and indictments" because he didn't hire mercenaries — described as people who enter government looking to enrich themselves — for government posts.

And he said that, like a garden, democracy would not thrive without care.

Former US President Barack Obama considers himself a die-hard optimist, but he couldn't help venting some frustrations over the political climate when he spoke with a crowd of 11,000 on Wednesday at a tech conference put on by Qualtrics, a software company in Salt Lake City.

Obama never mentioned the Trump administration by name but occasionally expressed his disapproval through quips and jokes.

"I like the rule of law, democracy, competency, and facts. Those things aren't partisan, but they also don't happen automatically," Obama warned in a rare moment of seriousness. "Democracy is a garden that has to be tended."

When asked by his interviewer, Qualtrics CEO Ryan Smith, about leadership during difficult times, Obama threw another gentle jab that got a big cheer from the crowd: "I'm old-fashioned and believe in values like facts and reason and logic."

He said there were several keys to good leadership and, doubling down on his theme of competency, he said one of the big ones was hiring.

When running a large and complicated organization, leaders need to surround themselves with people who are more knowledgeable than themselves, he said.

On top of that, he said, good leaders must listen to those experts. "Have confidence that you can understand what they are saying and, if not, you'll keep on asking questions until you do," he said.

Sometimes the people who rise to become the big boss "start feeling, 'I have every answer,'" he said, warning that "in fact, most of the time you have not."

Obama with Qualtrics CEO Ryan Smith. Qualtrics He told the story of what it was like for him during the Deepwater Horizon oil-spill crisis in the spring of 2010.

An oil rig owned by British Petroleum and built by Halliburton exploded in such a way, and in such deep water, that engineers from those companies could not easily fix it. Oil flowed for 87 days, dumping massive amounts of oil into the Gulf of Mexico.

Obama on Wednesday described it as "the largest environmental crisis to happen in our lifetimes, in terms of an oil spill."

"Fortunately I had recruited as my secretary of energy Steven Chu, who was a Nobel Prize-winning physicist," he said.

As the weeks went by, he said, his daughters started asking him about it, concerned about the people and wildlife being harmed. They asked him, "Daddy when are you going to shut down the hole?" he said and then laughed. "Now I'm feeling bad because my daughters think I'm not handling this well."

About three weeks into the crisis, he said, Chu came in with a sketch on a napkin. "It looked like a little hat," he said. "There were some numbers next to it." They sent it off to BP, which fleshed out the idea, and it worked. The engineers capped the oil spill with a literal cap.

"My role as the leader in the organization was not to come up with the little hat because I wouldn't have thought of that — I would have thought, 'That doesn't look complicated enough to stop this hole in the ground,'" he joked.

"My job was to have Steven Chu there, who has a Nobel Prize in physics, and that's who should be in charge of the Department of Energy."

The audience gave Obama another big round of applause in response. (The current secretary of energy is former Gov. Rick Perry of Texas.)

Obama said the upside for him in hiring such experts was that it "gave me a lot of confidence."

"I had confidence in the talent I had around me," he said.

He said it's not just about someone's résumé either. Motivations also play a role.

"I was good at making sure the people working with me were there for the right reasons, that there was a core integrity to what they were doing," he said. He said he wanted people who believed in the mission of using government to support citizens and solve problems.

Those working for and with him, whether volunteers, staff members, or campaign donors, were clear on that, he said. "This is not about us, you, or me — it's not about you getting an appointment or a contract or a position — it's about the mission," he said. "So by the time we got to the White House, we had weeded out the mercenaries."

That set up the culture and "also means you don't have big scandals and indictments, that's a bonus," he joked to another round of applause. Though it was only a passing reference, he was clearing referring to the growing list of people involved in President Donald Trump's campaign to be indicted or charged or to have pleaded guilty of crimes.