SANTA CLARA, Calif. (AP) – John Lynch turned out to be an aggressive dealer in his first draft as San Francisco 49ers general manager.

The front-office novice moved down one spot in the NFL draft on Thursday night before taking Stanford defensive lineman Solomon Thomas to upgrade a porous defense. He then used one of the three extra picks he got in that deal to move up from the second round to No. 31 overall to take Alabama linebacker Reuben Foster.

San Francisco also added the 67th overall pick from Chicago and the Bears’ third-rounder next year in the first deal. Chicago used the No. 2 pick to take North Carolina quarterback Mitchell Trubisky.

Lynch ended up with two of the top defensive players on many boards heading into the draft along with some extra loot to fill additional holes. Thomas is the third straight defensive lineman taken with San Francisco’s top pick, following Arik Armstead in 2015 and DeForest Buckner last year.

“I was kind of curious what was going on,” Thomas said. “I was excited to see what happens. I was the one blessed to get that phone call. It was a dream come true.”

Thomas has the versatility to play outside on the base defense where he is an elite run stopper and inside as a pass rusher in nickel situations. He had eight sacks and 15 tackles for loss last season at Stanford when he was named the top defensive lineman in the Pac-12.

Thomas has been compared to Seattle defensive end Michael Bennett and is expected to play a similar role in San Francisco under coordinator Robert Saleh, a former assistant for the Seahawks.

“We’re both very versatile,” Thomas said. “We’re quick. But I have to earn my stripes before I even get compared to him. I have to play my first down, earn my stripes from my teammates and earn their respect. That’s what I’m trying to do right now.”

Lynch, as a Stanford graduate, is quite familiar with Thomas. He has spent time around the program in recent years and even took a class on decision-making with Thomas where they collaborated on a project.

“I was star struck the first day of class,” Thomas said. “I tried to cling on to him, learn from him. It was a really cool experience to be in class with him.”

Thomas said the two kept in touch since then and now he wants to make Lynch proud as his first draft pick ever as a general manager.

Now they will try to fix a defense that set franchise worsts for points, yards and yards rushing allowed in a single season in 2016. That contributed to a 2-14 record that matched the worst in team history and led to the firing of coach Chip Kelly and general manager Trent Baalke.

Lynch and new coach Kyle Shanahan are setting out to rebuild the talent-bereft team and coveted the extra draft picks acquired in this deal to fill significant remaining holes at quarterback, the secondary and receiver.

Foster won the Butkus Award as the nation’s top linebacker last year but faced questions about the health of his shoulder. He said he is 90 percent healthy and expects to be ready for training camp.

Foster also was kicked out of the combine over a confrontation with a hospital worker and had a diluted drug test sample, turning him from a projected top 10 pick to one that almost didn’t make it in the first round.

The Niners now have two picks in each of the fourth, fifth and sixth rounds, along with one in the second, third and seventh round.