The way Jerry Stackhouse's contract was structured, the Dallas Mavericks knew they could parlay him into a key player for next season. As it turned out, a lot of teams benefited.

The Mavericks, Raptors, Grizzlies and Magic combined in a massive swap Thursday that included eight players, a draft pick and stacks of cash. The deal sent Shawn Marion to Dallas, Stackhouse to Memphis and helped seal the transaction that moved Hedo Turkoglu from Orlando to Toronto.

Among the other pieces: Forward Kris Humphries, center Nathan Jawai and cash went from Toronto to Dallas; guard Greg Buckner moves from Memphis to Dallas; and swingmen Antoine Wright and Devean George go from Dallas to Toronto.

Memphis also received a second-round pick and cash from Toronto and cash from Dallas. The Mavericks and Raptors both also sent cash to Orlando.

The Magic were going to lose Turkoglu anyway. After Orlando acquired Vince Carter, Turkoglu opted out of his contract and became a free agent. He'd already decided to go to Toronto, but turning his departure into a sign-and-trade glued together the rest of this complex puzzle.

"So many things were going on that I was like, `Just sit back and wait until it happens,'" Marion said. "I'm just happy to come to Dallas."

The Mavs are no strangers to convoluted, multi-team deals, but this one was still taxing. Team owner Mark Cuban posted on his Twitter feed late Wednesday: "Its been a long day of looking at spreadsheets, reading NBA cap rules and rubbing my eyes."

It was worth the effort: Dallas gets Marion, a four-time All-Star nicknamed "The Matrix" for his do-it-all game, in hopes that he'll be a great complement to a starting lineup featuring Dirk Nowitzki, Jason Kidd and Josh Howard.

Although Howard and Marion have similar skills, Marion said, "I think we can mesh fine. I'm a basketball player. I've played a little bit of every (position) before."

Marion is especially looking forward to playing with Kidd, having done so at the start of his career in Phoenix. The two already had spoken twice as of Thursday afternoon. Marion said he's also talked to sixth man Jason Terry, a friend since college.

"With J-Kidd running the show, he's definitely going to be spreading the wealth," Marion said.

Marion was a matchup nightmare during his heyday with the Suns _ too big for Howard, too quick for Nowitzki. For his career, he's averaged 17.8 points, 9.9 rebounds, 2.0 assists, 1.83 steals and 1.31 blocks per game.

Yet Marion is also 31 and headed to his fourth team since February 2008, having bounced from Phoenix to Miami to Toronto. He's also coming off a season in which he had his fewest points, rebounds, blocks and steals since his rookie season.

But this change is different. He's arriving at the start of the season and on a team with legitimate hopes for a deep playoff run. He also has the security of a new contract, which means he doesn't have to think about whether he might be traded again.

"At the end of the day, everybody wants security," Marion said. "If you can get security and get a great home at the same time, why not?"

Stackhouse was enticing for his numbers _ contract numbers, that is.

Although Stackhouse is due more than $7 million next season, he can be bought out for only $2 million. That's likely the amount of cash Memphis received for the 34-year-old swingman. The former scoring star played only 10 games last season because of injuries, but will soon be able to cut a deal with any team.

Buckner, who has played in Dallas twice before, has a similar contract. So he's likely to be dealt again or bought out.

Humphries' best season was 2007-08, when he averaged 5.7 points and 3.7 rebounds. Last season, he was down to 3.9 points and 2.4 rebounds before breaking his right leg in January. The 6-foot-10, 280-pound Jawai is an Australian who played just six games last season as a rookie.

The Mavs also are close to re-signing Kidd (awaiting paperwork) and likely adding 25-year-old center Marcin Gortat (more paperwork, including an offer sheet that Orlando is not expected to match). They also want to keep their own free agents, Brandon Bass and James Singleton.

All told, Marion believes Dallas will keep pace with the Lakers, Spurs and the rest of the tough Western Conference.

"With our talent and depth, why not?" he said. "It's the ultimate goal. You've got to have that in your aspirations."