Legal experts continue to crawl through the massive cache of Mitt Romney's Bain fund documents that Gawker published on Thursday.

And one law professor, Victor Fleischer of the University of Colorado, believes he has found a tax-avoidance trick used by the funds that is illegal.

For starters, the Gawker documents confirmed that Bain funds appear to have employed pretty much every sophisticated tax-dodging scheme in the book, including:

Creating "blocker" corporations that allow the funds to avoid business taxes .

. Entering into credit-default swaps that allow the funds to avoid dividend taxes.

And, of course, taking advantage of the ludicrous "carried interest" tax loophole that allows private-equity and hedge-fund managers to treat their performance fees as capital gains instead of ordinary income and thus pay a tiny fraction of the taxes on them that normal professionals would pay.

All of these tricks rely on legal technicalities to avoid taxes. For practical purposes, none of them are available to average taxpayers, because they require considerable sophistication and expense to set up and maintain. But they're common in the fund-management industry. And, for now, they are considered legal.

One of the tax-avoidance tricks that Romney's funds employ, however, is not legal, according to Fleischer.

This trick involves treating not just private-equity "performance-based fees" but management fees as capital gains rather than ordinary income.

This is wonky stuff, but for those interested in the details, here goes:

Private-equity firms, like other fund management firms, generally charge two kinds of fees:

Performance-based fees , which pay the firm ~20% of any gains

, which pay the firm ~20% of any gains Management fees, which assess an annual ~2% fee on all invested capital

Both of these fees are standard professional fees, so they both should be taxed at ordinary income rates.

In one of the most outrageous loopholes in the tax code, however, the fund-management industry has bamboozled (or simply bribed) Congress into treating "performance-based" fees as capital gains rather than income. So, unlike lawyers, doctors, architects, mechanics, and hundreds of other service professionals, fund managers get the privilege of having their fees accrue tax-free in their funds without providing any benefit to the rest of the business. And, if the funds are structured intelligently, the fund managers can avoid ever having to pay ordinary income taxes on their fees. This is likely the primary means by which Mitt Romney has managed to pay such a low tax rate for so long.

But Bain went further than claiming the common "carried interest" treatment on its performance fees, says Fleischer.

In a much more controversial move, Bain also claimed capital gains treatment for its management fees. This allowed the funds (and Romney) to avoid paying ordinary income taxes on all of its fees, not just its performance fees.

How did Bain claim that its management fees were capital gains?

By "waiving" its management fees in some years in exchange for receiving a priority payment of "profit" in future years.

In other words, instead of taking a $20,000 cash payment for each $1 million under management in a particular year, Bain opted to take the $20,000 payment in a later year, as the first portion of any profit distributed from one of the fund's investments.

The theoretical basis for this tax treatment is presumably the same as the one used to justify the regular "carried interest" exemption, which is that by keeping its fees in the funds, the Bain partners are subjecting them to some risk: If the particular investment ends up losing money, the partners won't get paid.

For two reasons, though, this justification is weak.

First, for normal Americans, investment capital is eligible for capital-gains treatment only after it has been assessed with ordinary income taxes. A doctor who makes $1 million for rendering medical services would pay his ~35% tax rate, and then whatever he has left over would be available as investment capital. If the doctor put this capital at risk, he would then be entitled to capital-gains treatment. Thanks to the "carried interest" loophole, however, fund managers can just keep the whole $1 million of fees in their funds. Thus, they can let all of their fee-income compound tax free and never pay ordinary income taxes on it. Over decades, this generates vast wealth above and beyond what they would have earned if they had had to pay ordinary income taxes before they invested like everyone else.

Second, as Fleischer explains, Bain had extraordinary flexibility in choosing which investments to take its guaranteed share of "future profits" out of, in addition to when.

Basically, all Bain had to do to ensure that it would get its management fees was to choose one investment in each fund that would appreciate in value at some point in the future. And given that Bain also had lots of control over the "carrying values" of these investments, it had superior knowledge of which investments would be the most likely to gain value. Thus, Fleischer argues, although there might have technically been some modest risk that Bain would never get paid its fees, this risk was extremely low.

Fleischer says this trick, treating management fees as capital gains, is "not legal." He also believes it would not stand up in court.

To be fair, it appears that, legally, this particular tax-avoidance scheme is still in the "not yet challenged" phase as opposed to the "established law" phase. At some point, if the IRS concludes that this particular capital gains treatment is bogus, it will likely challenge it in court. And Bain and other private-equity firms will defend it. And, years later, a judge or jury will issue a ruling that can be used to set future precedent. Or, alternatively, the IRS and/or Congress could issue a clarification that either explicitly allows this treatment or explicitly disallows it.

But what appears clear is that this aggressive tax-avoidance technique has likely saved Bain and Mitt Romney millions of dollars in taxes over the years.

UPDATE: Dan Primack of Fortune has an excellent overview of these tax schemes here. Apparently many private equity firms use the "fee waiver" technique that the professor pinpoints. So far, the IRS has not challenged it.

Read Fleischer's post here >

SEE ALSO: Many Romney Supporters Appear To Be Delusional About A Key Reason For His 13% Tax Rate