President Obama in a taped appearance with the Daily's Shows Jon Stewart Tuesday denied that IRS targeted conservatives, an assertion that Stewart then appeared to ridicule him for making.

During a more serious exchange during an appearance that alternated between jokes and straighter policy discussions, Stewart roughed Obama up a bit by stating that the president had come to office promising reform but "couldn't do it after five years."

Obama defended himself, arguing that "government works better now than it ever has given what we ask it do."

He then held up an odd example, noting that Stewart and others had jumped on a story that employees had been targeting conservatives.

"It turns out," Obama said, that wasn't true. He said Congress "passed a crummy law" that provided vague guidance to the people who worked at the IRS. And he said that employees implemented the law "poorly and stupidly."

"Boy, you really do have only a year left," Stewart interjected.

But Obama jumped back in, blaming Congress for not providing enough funds for both the IRS and the Department of Veterans Affairs to work properly.

The real scandal around the IRS, he said, "is that they have been so poorly funded that they cannot go after these folks who are deliberately avoiding tax payments."

"Should people blame the president? You can't use that as an excuse for the big structural problems that we are facing," he said.

Just moments before, Stewart dug into Obama's record on reform the VA where many veterans have waited scandalously long times for treatment. Stewart said that VA waiting times were back up even after the scandal and Obama's pledges to fix the problems, telling the president "you'll find almost unanimous agreement that you've failed."

Obama then interrupted saying that a lot of people were coming home from the wars, to which Stewart replied: "When you got a lot of wars" that's not a big surprise.

The president also took a swipe at the media, acknowledging that some "get on his nerves more than others," and accusing reporters and the outlets they represent of being distracted by "shiny objects."

Stewart started the conversation by poking fun at liberal media bias: "You love 'em. They love you," he stated.

But then asked how the president views his own coverage.

"Are we focused on the wrong things? Are we demanding too much of you, too much of government? Are we inflammatory?" he asked.

Obama tried to explain that he saw news outlets today as a "bunch of different medias."

"Some get on my nerves more than others," he said, noting that "what I'm most concerned about is not that it's unfair or too tough on government …but that it gets distracted by shiny objects and doesn't always focus on the big tough choices and decisions."

"It's tough for folks to do an hour-long special on urban America. …tough to get everyone focused the same way," he said, adding that the whole country now "operates in sound bites."

Earlier, Obama made a playful swipe at critics of the Iran deal by marveling that they seem to believe that "if you just brought Dick Cheney to the negotiations, everything would be fine."

Stewart quickly jumped in with his own rejoinder, joking that the United States has tried so many different approaches in the Middle East, including sending 100,000 troops and arming militant groups.

"This new thing, you called it earlier, diplomacy," he said. "That sounds interesting."

Obama then turned a bit serious, noting that Iran remained a problem in the region, but arguing that the U.S. and other world powers had "taken off the table what would be a catastrophic problem if [Iran] got a weapon."

It was the president's third appearance as a guest on the show during his presidency and his seventh overall, and by now the two have an easy free-flowing banter.

But it is likely the last for Obama before the late-night political funnyman calls it quits and retires Aug. 6 from the show after 16 years.

Stewart made sure not to overshadow the president's appearance at the onset of the show.

"I'm not going to screw around tonight. As someone reminded me from audience … no one's interested in my bulls--- tonight," he said. "Let's get right to it, I'm sure there's a fundraiser he has to be at."

The president entered to loud applause and teased Stewart about leaving the show before Obama leaves office, joking that he might issue an executive order to stop his departure.

"I can't believe you're leaving before me. I'm going to issue an executive order. Jon Stewart cannot leave the show. It's being challenged in the courts," he said to laughter.

"To me, this is a state's rights issue," Stewart quickly retorted.

Obama also took a victory lap of sorts on a string of Supreme Court victories, inking the Iran deal and pushing through two key trade measures in Congress.

He said he's readying the home stretch of his presidency — 18 months left – and finally enjoying some of the fruits of his labor with accomplishments on Iran, healthcare and trade.

"A lot of the work that we did early starts bearing fruit, late," Obama told Stewart.

Obama joked that you get better as "you get experience."

"The way I'm feeling right now is, I've got 18 months," Obama remarked. He says he hopes to tackle climate change next, fuel efficiency standards and to persuade countries like China and India to come aboard.

"That's my goal," Obama said.