
309 B.R. 577 (2004)
In re Richard M. HAYNES and Victoria A. Haynes, Debtors.
Robert J. Davis, Chapter 7 Trustee, Plaintiff,
v.
Wells Fargo & Company, a Delaware corporation, Defendant.
Bankruptcy No. 2-00-01858-PHX-RJH. Adversary No. 02-00135.
United States Bankruptcy Court, D. Arizona.
April 21, 2004.
*578 Randy Nussbaum, Jaburg & Wilk PC, Scottsdale, AZ, for Debtors.
Edwin P. Lee, Law Office of Edwin Lee PC, Phoenix, AZ, for Trustee, Plaintiff.
Philip G. Mitchell, William F. Begley, Craig J. Bolton, Jennings Haug & Cunningham, Phoenix, AZ, for Defendant.

OPINION
RANDOLPH J. HAINES, Bankruptcy Judge.
The Court must here determine whether a debtor's depository bank may exercise a setoff right to apply a debtor's deposit toward an unsecured obligation owed to the bank, when the debtor deposited the funds with specific direction that they be applied to reduce another, secured debt owed the bank. The Court concludes that *579 the bank's setoff is avoidable by the trustee.

Background Facts
On December 30, 1999, Victoria Haynes deposited $24,775.33 into her checking account at Wells Fargo Bank (the "Bank").[1] She instructed the Bank to apply these funds to satisfy the outstanding balance owed on her "Equity Plus" account, which was apparently a home equity credit line secured by a second lien on the Haynes' home. This payoff amount was $17,151.56. She also instructed the Bank to apply another $4,000 of these funds toward another real estate loan. She understood the funds would be so applied.
The Bank's records indicate that it initially credited the Haynes' home equity line with a payment in the amount of $17,151.56 on December 31, 1999. That payment was then reversed, however, on January 6, 2000. Similarly, the Bank's records on the other real estate loan reflect a payment on December 30, 1999 of approximately $4,000 in principal, reducing the outstanding balance to $12,322, but that transaction was also reversed on January 7, increasing the balance to $16,281.
Instead of applying funds as its customer had requested, Wells Fargo Bank reversed the payments it had originally reflected as being made from the Debtors' checking account,[2] and then exercised a setoff right against that account. On December 30, the Bank made a setoff against the Debtors' checking account in the amount of $4,546.29 and applied that amount to an unsecured business loan the Hayneses had obtained for their dba Victorian Construction & Painting. On December 31, 1999 the Bank setoff the Haynes' checking account in the amount of $18,841.44 and applied that amount to their unsecured business line for their company Easy Travel.[3]
Richard and Victoria Haynes filed a chapter 7 petition[4] on February 25, 2000, and Robert Davis was appointed Trustee on that date.
On February 25, 2002, Trustee Davis filed an adversary complaint against Wells Fargo. After amendments, the complaint asserted three counts against Wells Fargo Bank: a count seeking to avoid the setoff pursuant to § 553(b); a count seeking to avoid the amounts applied to the unsecured debts as preferences pursuant to § 547; and a count seeking to avoid the Bank's enhanced security interest in the funds deposited on December 30, 1999, as a preference avoidable pursuant to § 547.
*580 The Bank moved for summary judgment asserting, among other things, that it was not liable to the Trustee because the Debtors' Business Line Customer Agreements provided that the Bank might exercise its setoff right against any obligation that the Bank owed to the Debtor, "including a setoff against any deposit account[s] Customer [debtor] has with Bank to the extent permitted by law." The Bank argued that this setoff right rendered it a secured creditor, and because it was fully secured the payments could not be preferential. The Bank's motion cited California Civil Code § 3054(a),[5] which grants a bank a general lien on all property in the bank's possession belonging to a customer, and to A.R.S. § 47-4210, Arizona's version of U.C.C. § 4-210, which gives a collecting bank a security interest in items deposited in an account and their proceeds.
At oral argument on the Bank's motion, the Court indicated that it believed it had authority to enter summary judgment against a moving party despite the absence of a cross-motion,[6] requested the filing of supplemental memoranda and set further oral argument. The Court took the matter under advisement at that continued oral argument.

Analysis
Viewed solely from the perspective of the unsecured business line accounts for which the Bank exercised its setoff rights, the setoffs are avoidable pursuant to § 553(b). The setoffs occurred within 90 days before the petition, and § 553(b) clearly provides that "the trustee may recover from such creditor the amount so offset." Section 553(b) imposes a cap on the trustee's recovery based upon the amount by which the bank's position had improved on the date of the exercise of the setoff as compared to the date 90 days before the filing of the petition, with such "improvement" being measured by the reduction in the bank's deficiency.[7] Here, the Trustee's affidavit establishes that the Bank's position improved to the extent of $19,730.44 between these two dates and the Bank does not challenge that analysis. Because there are no contemporaneous exchange for new value, ordinary course of business or subsequent new value defenses to § 553(b) recoveries as there are to preferences, no more analysis is required to determine that the Trustee is entitled to judgment in the amount of $19,730.44.
What has given this Court pause, however, and necessitated the supplemental *581 briefing and oral argument, was the Court's concern that instead of giving the Trustee recovery for the amount setoff, the proper result might simply be to apply the funds where the Debtors had directed them to be applied. This could be accomplished by application of the equitable maxim that a court of equity should regard as done that which should have been done. It would also be consistent with the Debtors' rights under § 522(h) to recover an avoidable transfer to the extent the property transferred could have been exempted under § 522(g)(1), which requires that the transfer not have been voluntary by the debtor. Those provisions might arguably apply here, because if the funds had been applied as the Debtors directed them to be applied, they would have satisfied a second lien against the Debtors' homestead and thereby increased the amount of equity in that property protected by the homestead. Such prebankruptcy exemption planning is permissible in this Circuit. Gill v. Stern (In re Stem), 345 F.3d 1036, 1044-45 (9th Cir.2003), cert, denied, ___ U.S. ___, 124 S.Ct. 1657, 158 L.Ed.2d 356 (2004).
Not surprisingly, in the supplemental memoranda the Bank takes the position that the funds should be applied as the Debtors had directed. The Bank argues that if it had the right to reverse the credit initially made on the home equity loans, when it did so it was dealing with the Bank's property rather than the Debtors' and therefore its application could not have been a preference. Alternatively, the Bank argues that if it was not within its legal rights to reverse the credits on the home equity lines, then the funds should simply be applied there rather than the Trustee obtaining judgment in that amount. The Trustee, on the other hand, argues that the Court should take the transaction as it actually occurred rather than attempting to recharacterize it, and straightforwardly apply § 553(b) and give the Trustee judgment for the amount offset, subject to the cap measured by improvement in position.
Based primarily on pre-Code Ninth Circuit precedent, the Court concludes it should apply § 553(b) straightforwardly and as written, even though (or perhaps because) the Bank may have violated its customers' rights and directions in applying the funds.
In both England and America, the codification of setoff rights predated the codification of preference laws. In England, the setoff right was first statutorily recognized in a bankruptcy act in 1705, in the Statute of Anne,[8] whereas the English preference law originated in judicial decisions dating from 1758 and was not codified until 1869.[9] In America, the first bankruptcy act of 1800 statutorily recognized the setoff but not the preference, which was not codified until the Act of 1841.[10]
The laws of setoffs and preferences enjoyed an uneasy co-existence under the Bankruptcy Act of 1898. Both were significantly different than they are today. Under the Act, the preference period was four months but the trustee had to establish that the transferee had reasonable cause to believe that the debtor was insolvent at the time of the transfer. The Code reduced the preference period to three months for non-insider transactions, and eliminated the requirement of reasonable *582 cause to believe the debtor insolvent. As to setoffs, case law under the Act generally protected banks' right of setoff as to deposits made to checking accounts in the ordinary course of business, which effectively created a case-law irrebuttable presumption that banks lack reasonable cause to believe their depositors to be insolvent, regardless of the facts of the actual case. No such presumption existed for other preference defendants, and no statutory provision of the Act supported this precedence accorded to banks' setoff rights over the trustees' right to recover preferences.[11]
The Code adopted the recommendation of the Bankruptcy Commission and eliminated this special protection of banks' setoff rights, making banks with setoff rights as subject to preference actions as all other creditors. But a compromise provided all creditors with setoff rights a defense if there was no net improvement in position over the position as compared to 90 days prepetition.[12] The net result of these changes is that banks are more subject to preference attack under the Code than they were under the Act. Ordinary deposits that augment the bank's setoff rights can be avoided, and the trustee need not prove the bank had reasonable cause to believe the depositor was insolvent.
And yet even under the Act, the law was clear that if the debtor made a deposit to his bank account and either restricted his *583 own ability subsequently to withdraw the funds or advised the bank that the funds were intended for a specified purpose, the bank would lose its case law defenses to the avoidance of the preferential setoff right. Indeed, the bank's knowledge of a special purpose for the funds was itself a sufficient basis to deny the bank's right of setoff even if it were not preferential. In United States v. Butterworth-Judson Corp., 267 U.S. 387, 394-95, 45 S.Ct. 338, 69 L.Ed. 672 (1925), the Supreme Court held:
Ordinarily, the relation existing between banks and their depositors is that of debtor and creditor, out of which the right of set-off arises. As a general rule, in the absence of an agreement to the contrary, a deposit, not made specifically applicable to some other purpose, may be applied by the bank in payment of the indebtedness of the depositor. [Citation omitted] But a bank having notice that a deposit is held by one for the use of or as security for another has only such right of set-off as is not inconsistent with the rights of the latter.
And where there was such a special purpose for the deposit, the bank could be held liable in preference for exercising a setoff, even though the bank would have had no such liability as to a general deposit account not designated for a special purpose. For example, in Union Bank & Trust Co. v. Loble (In re Gans & Klein Co.), 20 F.2d 124 (9th Cir.1927), the bank was aware that the debtor's bank account contained special sale proceeds that were intended to satisfy certain Eastern merchants. The bank exercised a setoff and also filed a proof of claim for the balance due on the debtor's note to the bank. The trustee moved to disallow the bank's claim unless the bank should account for and pay to the trustee the amounts applied from the setoff. The District Court and the Ninth Circuit upheld the trustee's preference claim. The Ninth Circuit held:
While the money realized on the special sale and deposited to the bankrupt's current account and subject to its check for general purposes may not be said to come within the accepted definition of a special deposit so as to be exempt from the bank's claim to the right of set-off, we are inclined to the view that the circumstances under which the fund was created, and the co-operation of the bank and the bankrupt in its creation, were sufficient to so far impress upon it the character of a trust fund that the bank should be held estopped to assert a lien thereon or the right of set-off.

Id. at 126.
The Ninth Circuit also relied on a Fourth Circuit opinion that upheld a trustee's preference recovery when the bank deposit was not made in the ordinary course: "Under such circumstances the deposit by the bankrupt of large sums in the bank, which both it and the bankrupt intended should be used for the reduction of the former's debt, were obviously not made in ordinary course, in any fair sense of that phrase."[13]
Similarly, in Continental Nat'l Bank v. Moore, 299 F. 270 (9th Cir.1924), the purchaser of the debtor's property deposited money in the debtor's bank account with an instruction that it be returned to the purchaser in the event of bankruptcy proceedings. The Ninth Circuit held that such moneys were not in the nature of mutual credits and debts and the relationship of the parties was not that of banker and depositor, but that of bailee and bailor. *584 "As to the funds so placed in the control of the bank it is well settled that there was no right of set-off." Id. at 272. Consequently the court went on to hold that because the deposit was made within four months of the bankruptcy when the bank had "positive knowledge" that the debtor was insolvent, "all the elements of avoidable preference are found here." Id.
To similar effect, on similar facts, is the Ninth Circuit's holding in First Nat'l Bank of Portland v. Dudley, 231 F.2d 396 (9th Cir.1956). Again, the court characterized the bank account as a trust fund for creditors which estopped the bank from asserting a setoff right, but the remedy was to sustain the trustee's preference action against the bank for the amount setoff.
In short, under the Act it was clear that where moneys were deposited in a bank along with the depositor's intention, made known to the bank, that they be applied in a specific fashion, not only was the right of setoff lost but the bank was liable for a preference if it exercised it. It is significant for present purposes that although these cases used language and analyses suggesting that the fund should be regarded as a trust account, they neither concluded that the property was not property of the estate nor that the property should be distributed to the beneficiaries of the trust. In Gans & Klein, for example, the District Court upheld the trustee's preference action, rather than directing that the funds should be paid to the Eastern merchants for whose benefit they had been collected, and the Ninth Circuit affirmed.
Thus under the Act, Wells Fargo Bank would have been denied its setoff right and subject to a preference attack due to the Debtors' specific intention, made known to the Bank, that the funds should be applied to a particular Bank debt. This was not an ordinary deposit to a checking account, but rather an attempt to pay specified debts. The Hayneses certainly did not intend the funds to remain in the checking account subject to their right to withdraw them, which is essential to the deposit creating a debtor-creditor relationship. As the Ninth Circuit held in Moore, such a deposit with instructions made the relationship of the parties not that of banker and depositor, but that of bailee and bailor.
There is nothing in the Code that indicates an intent to change this case law under the Act. To the contrary, the general direction of the Code's changes in this area has been to expand banks' liability for preferences to include those arising from increases in general deposit accounts that are unrestricted to any special purpose, even those made in the ordinary course.
Moreover, Gans & Klein indicates that the trustee may recover the preference from the Bank notwithstanding the potential claims of the intended beneficiaries of funds deposited in trust. Here, this means that the Trustee's preference recovery is not precluded by the Debtors' potential right to have the funds applied as they had directed, to their home equity line. Nothing in the prior case law or in this opinion implies the result, one way or the other, if the Debtors also should sue the Bank for its failure to apply the funds as they directed.[14]
For the foregoing reasons, the Trustee is granted summary judgment on Count Two of his First Amended Complaint in the amount of $19,730.44. Judgment is denied to the Trustee on all other Counts, *585 as they are rendered moot by this decision. The Trustee is requested to lodge an appropriate form of judgment, which when entered shall be the appealable final judgment.
NOTES
[1]  The facts are unclear as to whether she actually intended to deposit the funds into her checking account, or whether she was instructed to do so by the Bank as its chosen means to accomplish the transaction she intended. She arrived at the Bank with two cashiers checks drawn on other banks in the total amount recited above, with the intent that the funds be applied to satisfy one real estate loan she had with Wells Fargo Bank and apply $4,000 to another real estate loan with the Bank. In any event, the records reflect that the funds were in fact deposited in the checking account before being applied elsewhere, and she was given a receipt for that deposit before she left the Bank.
[2]  The statement the Bank provided on the checking account does not reflect any withdrawals or transfers corresponding to the payments on the real estate loans.
[3]  The amount of these two setoffs, totaling $23,387.73, is slightly less than the $24,775.33 deposited on December 30, but is exactly equal to what the bank reflects as the balance in the checking account on that date.
[4]  Unless otherwise indicated, all chapter, section, and rule references are to the United States Bankruptcy Code, 11 U.S.C. §§ 101-1330, and to the Federal Rules of Bankruptcy Procedure, Rules XXXX-XXXX.
[5]  Although all the relevant transactions took place solely in Arizona, the bank's Business Line Customer Agreement referred to California law.
[6]  Kassbaum v. Steppenwolf Prods., Inc., 236 F.3d 487, 494-95 (9th Cir.2000), cert, denied, 534 U.S. 815, 122 S.Ct. 41, 151 L.Ed.2d 13 (2001); Sohappy v. Hodel, 911 F.2d 1312, 1320 (9th Cir.1990); 10A CHARLES ALAN WRIGHT, ARTHUR R. MILLER & MARY KAY KANE, FEDERAL PRACTICE AND PROCEDURE: CIVIL 3D § 2720, at 345-54 (1998). These authorities concur that while such authority exists, "great care must be exercised to assure that the original movant has had an adequate opportunity to show that there is a genuine issue and that his [or her] opponent is not entitled to judgment as a matter of law." Kassbaum, 236 F.3d at 494 (citations omitted). Here the supplemental memoranda and further oral argument provided that opportunity.
[7]  Because this requires a reduction in the deficiency, there must have initially been a deficiency on the 90th day prepetition. This means that setoffs are never avoidable if the bank was fully or oversecured on the 90th day prepetition, because then there would have been no deficiency that could be reduced. In effect, setoffs are only avoidable as against creditors who were undersecured as of the 90th day prepetition. Code § 506(a) essentially equates creditors with setoff rights to secured creditors.
[8]  4 Anne, c. 17 Sec. 11. See 4 COLLIER ON BANKRUPTCY ¶ 68.01[1], at 843 (14th ed.1978).
[9]  II GARRARD GLENN, FRAUDULENT CONVEYANCES AND PREFERENCES § 378, at 654-55 (rev. ed.1940).
[10]  COLLIER, supra note 8, at 843; GLENN, supra note 9, § 380, at 658.
[11]  Harvard Professor McLaughlin proposed an amendment in the Chandler Act that would have limited the protection of banks' setoff rights to unmatured debts owed to the bank, provided the deposit was made in the ordinary course of business and was subject to withdrawal upon the demand of the bankrupt. James Angell McLaughlin, Amendment of the Bankruptcy Act, 40 HARV. L.REV. 583, 600-04 (1927); James Angell McLaughlin, Aspects of the Chandler Bill to Amend the Bankruptcy Act, 4 U. OF CHI. L.REV. 369, 398-401 (1937); COLLIER, supra note 8, at 845. The banks and banking associations objected, arguing that if banks were to lose their setoff right upon learning of the depositor's insolvency, they would refuse to deal with customers in financial difficulty and hesitate to honor their checks given to third persons, which would precipitate bankruptcies that might otherwise be avoided. COLLIER, supra note 8, at 846. The banks prevailed and Professor McLaughlin's amendments to the Chandler Act were not adopted. The expansion of the preference recovery of bank setoffs under the Code is far more expansive than Professor McLaughlin proposed, but it has not "produce[d] evils of serious and far reaching consequence" that the banks had predicted of Prof. McLaughlin's proposed amendment. Id. at 848.
[12]  REPORT OF THE COMMISSION ON THE BANKRUPTCY LAWS OF THE UNITED STATES, PART I, at 211, 93rd Cong., 1st Sess., H.R. Doc No. 93-137 (July 1973). While the limitation of the preference recovery to the improvement in position over 90 days prepetition might seem at first blush to be a straightforward and logical application of preference law, in fact it is not. The issue arose primarily with respect to inventory and accounts receivable financing, and the fact that the recently adopted Uniform Commercial Code permitted "floating liens." Preference law would ordinarily mean either that any improvement in position over the preceding day might be avoided as a preference, even though the net position was worse than 90 days prepetition, or it should mean that because the lien existed 90 days prepetition, and there was merely an increase in the value of the collateral during the preference period, there was no transfer at all within the preference period notwithstanding the improvement. Professors Grant Gilmore, Homer Kripke, Charles Seligson, Larry King, Frank Kennedy and other leading scholars debated these positions in numerous law review articles, and the latter extreme position was adopted by the Ninth Circuit in DuBay v. Williams, 417 F.2d 1277 (9th Cir.1969). BANKRUPTCY COMMISSION REPORT, at 206-210. The Commission recommended legislative overruling of DuBay but proposed a compromise represented by the "improvement in position" test, which Congress ultimately adopted and is presently found in Code § 547(c)(5). Essentially the same compromise is found in the setoff provision in § 553(b).
[13]  Gans & Klein, 20 F.2d at 126-27, citing Union Trust Co. v. Peck (In re Almond-Jones Co.), 16 F.2d 986, 987 (4th Cir.1927)
[14]  The Court also expresses no opinion whether there is such a cause of action, whether the Bank's boilerplate language in its deposit account agreement provides a defense, whether the claim belongs to the Debtors or to the Trustee, or whether it arises under § 522(h).
