U.S. President Barack Obama told Kenya on Saturday that the United States was ready to work more closely in the battle against Somalia’s Islamist group Al-Shabab, but criticized Nairobi’s gay-rights record.

In his first visit as president to his father’s homeland, Obama also said Kenya had to tackle corruption by showing it was prosecuting culprits, saying it would spur growth. Graft is cited as a major obstacle to business across Africa.

Obama has been seeking to strengthen business ties with a continent that is home to some of the world’s fastest growing economies. Earlier Saturday he addressed a U.S.-sponsored conference to encourage entrepreneurs.

But security was high on the agenda in talks with his counterpart President Uhuru Kenyatta, whose country has suffered a spate of attacks by al-Shabab militants.

“We have been able to decrease their effective control within Somalia, and have weakened those networks operated within this region of east Africa,” Obama told a joint news conference, adding Washington would give more training and funding to Kenya.

But, when Obama spoke on gay rights, he said discriminating against people for their sexual orientation eroded freedoms.

“As an African-American in the United States I am painfully aware of the what happens when people are treated differently,” he said, adding “bad things happen” when such a path was followed.

Kenya, like many African states, outlaws homosexual relations. Kenyan Deputy President William Ruto, who attended talks with Obama, said in May there was “no room” for gays in Kenya.

Kenyatta, who welcomed the united stance on security, said America and Kenya did not see eye-to-eye on all matters, saying gay rights were not “foremost on the minds” of Kenyans.

“There are some things that we must admit we don’t share,” Kenyatta said.

Criminal charges

The briefing followed talks at State House, which were also attended by Ruto, who faces charges at the International Criminal Court that he fomented ethnic killings after Kenya’s disputed 2007 election. He denies them. Kenyatta faced similar charges, but they have been dropped.

Obama earlier addressed the Global Entrepreneurship Summit to boost U.S. ties with a continent where China overtook the United States as the continent’s biggest trade partner in 2009.

“Africa is on the move. Africa is one of the fastest growing regions in the world,” Obama told the conference, where he was greeted by applause as he began with the word “Jambo,” Swahili for “hello.” “It is wonderful to be back in Kenya.”

He told delegates governments had to establish the rule of law and tackle corruption.

Fighting corruption

At the news conference, Obama commended the government for its efforts against graft efforts and said corruption “may be the biggest impediment to Kenya growing faster.”

Kenya’s economy is expected to grow by about 6 percent this year. The economy of Ethiopia, Obama’s next stop, is forecast to expand by more than 10 percent, although right groups say Addis Ababa’s achievements are at the expense of political freedom.

Obama also said the presidential vote held last week in the central African state of Burundi in the face of criticism by many African and Western states was not “credible.”

Earlier Saturday, Obama laid a wreath to victims of the 1998 bombing by Islamist militants of the U.S. Embassy. The site of the attack in central Nairobi is now a memorial park.

Kenya has been hit by a spate of attacks in the past two years launched by the Al-Qaida-linked al Shabaab. In 2013, the militants assaulted Nairobi’s Westgate shopping mall, leaving at least 67 people dead. In April, gunmen attacked a university in Kenya’s northeast near the Somali border, killing 148 people.

After arriving on Friday evening, Obama had dinner with his Kenyan relatives, saying he had not met some of them. “There were lengthy explanations in some cases of the connections,” he said smiling, adding: “Mostly we were just catching up.”

Some Africans complain that Obama, whose father is buried in western Kenya, has not paid enough attention to the continent in his presidency. Obama has sought to change that perception, in part by hosting African leaders in Washington last year.