Even when he was running Fox News, Roger Ailes was advising Donald Trump.

The former Fox News chief started advising Trump at a private lunch just days before the launch of his campaign, and regularly offered him advice over the course of the primaries, sources familiar with the discussions said.

Trump and Ailes met in person several times between June 2015 and June 2016 -- almost always at Fox News headquarters -- and spoke frequently on the phone, the sources said. Even when Ailes and Trump appeared to be at war over Trump's treatment of Megyn Kelly, the two men kept the conversation going.

But since late July, when Ailes left Fox News amid a torrent of sexual harassment allegations, he has taken on a much more active role in Trump's campaign -- specifically in terms of debate preparation.

In recent weeks, Ailes has become one of the most influential voices in the room as Trump prepares for his first head-to-head matchup with Hillary Clinton, on September 26. Ailes has attended at least two of Trump's Sunday debate prep sessions in person, sources said, and talks with Trump by phone multiple times a week.

In these meetings and conversations, Ailes' main objective is to sharpen Trump's message. He is trying to help the candidate get his message out in a smart, cogent way while also maintaining his air of authenticity, one source familiar with the conversations said. He is also trying to help Trump come up with memorable one-liners that will stay in voters' minds, drive headlines, and perhaps even turn the tide in Trump's favor.

The Trump campaign, which did not respond to multiple requests for interviews, has always maintained that Ailes has no role with the campaign, formal or informal. This may be strictly accurate, but as CNNMoney has previously reported, that denial has relied on fine distinctions, including the fact that Ailes has given advice directly to Trump, not to the campaign.

Related: What role is Roger Ailes playing in Donald Trump's campaign?

Asked about the relationship on ABC's "Good Morning America" Wednesday, Trump campaign manager Kellyanne Conway demurred: "I'm at Trump Tower everyday, I'm the campaign manager. I've never seen Mr. Ailes there. I saw him one time for lunch recently, he was at lunch," she said. Asked again if Ailes was giving Trump advice, Conway said, "Well Mr. Trump -- I don't know, because Mr. Trump speaks to many people on the phone during the day when I'm not there. They've known each other probably thirty years."

Debates are Ailes' bailiwick. Before launching Fox News, in 1996, he spent decades as an on-and-off adviser to Republican presidential candidates on media strategy. He helped repackage Richard Nixon for the television era in 1968, and served as a debate coach to both Ronald Reagan in 1984 and George H. W. Bush in 1989.

Given Ailes' experience in this field, the Trump campaign has shown deference to the former Fox News chief despite the sexual harassment allegations, and the $20 million settlement with Gretchen Carlson over Ailes' alleged harassment of her that 21st Century Fox just announced. While reporters and pundits question the wisdom of Trump's decision to align himself with such a controversial figure, the campaign has done no such handwringing. They know Trump is going to talk to Ailes no matter what, and think that it's better for them to know what he's telling their candidate.

Within the Clinton campaign, however, Trump's relationship with Ailes is a source of concern, sources there said.

Last week, the Commission on Presidential Debates, an independent group, announced that "Fox News Sunday" host Chris Wallace would moderate the third and final presidential debate, on October 19. He will be the first Fox News host ever to moderate a presidential debate.

When Ailes resigned from Fox, Wallace described him to The New York Times as "the best boss I've had in almost a half a century in journalism," and said he "admired him tremendously professionally, and loved him personally."

Wallace is a widely respected journalist in Washington and beyond. Publicly, the Clinton campaign has said it is "extremely grateful to the bipartisan commission for its continued work in preparation for the debates," and they selected Wallace as the first person to interview Clinton following the Democratic National Convention.

Nevertheless, the fact that the man moderating the third debate is a self-described friend and admirer of Ailes, who in turn is helping Trump on debate prep, strikes some Clinton insiders as problematic. They worry that Ailes' familiarity with Wallace's style and methods will allow him to give Trump an edge over Clinton in preparation.