EXHIBIT 10-4 FIFTH AMENDMENT TO AMENDED AND RESTATED MORTGAGE LOAN WAREHOUSING AGREEMENT The Fifth Amendment to Amended and Restated Mortgage Loan Warehousing Agreement (the "Amendment") is dated as of August 29, 1997, by and among BANK OF AMERICA NATIONAL TRUST AND SAVINGS ASSOCIATION, a national banking association ("BOA"), and the other banks signatory hereto from time to time (each a "Lender" and, collectively, the "Lenders"), BOA as agent for the Lenders (in such capacity, the "Agent") and FIRST MORTGAGE CORPORATION, a California corporation (the "Company"). RECITALS A. Pursuant to that certain Amended and Restated Mortgage Loan Warehousing Agreement dated as of September 1, 1995 by and among BOA, the Agent and the Company (as amended from time to time, the "Agreement"), BOA agreed to extend credit to the Company on the terms and subject to the conditions set forth therein. All capitalized terms not otherwise defined herein shall have the meanings given to such terms in the Agreement. B. The Company and the Lenders desire to amend the Agreement in certain respects, all as set forth more particularly herein. NOW, THEREFORE, in consideration of the foregoing Recitals and for other good and valuable consideration, the receipt and adequacy of which are hereby acknowledged, the parties hereto hereby agree as follows: AGREEMENT 1. Change in Definition of Maturity Date. To reflect the agreement of the parties to extend the Maturity Date, the definition of "Maturity Date" in Section 11 of the Agreement is amended by replacing "September 1, 1997" with "September 1, 1998." 2. Elimination of Prohibition on Purchasing or Retiring Stock. To reflect the agreement of the parties to eliminate the Company's covenant not to acquire, purchase, redeem or retire any shares of its capital stock, Section 7(g) is deleted from the Agreement. 3. Inclusion of High Loan-to-Value Loans in Borrowing Base. To reflect the agreement of the parties to include in the Borrowing Base an allocation, not to exceed Two Million Dollars ($2,000,000.00) in Collateral Value for certain Eligible Committed Mortgage Loans having Loan-to-Value Ratios less than or equal to 125%, the Agreement is amended as set forth below. (a) Addition of Definition of Eligible Committed HLTV Loan. The following new defined term is hereby added to Section 11 of the Agreement in appropriate alphabetical position: "'Eligible Committed HLTV Loan' shall mean a Mortgage Loan with respect to which the following statement shall be accurate and complete (and the Company by including such Mortgage Loan in any computation of the Collateral Value of the Borrowing Base shall be deemed to so represent and warrant to the Agent, the Collateral Agent and the Lenders at and as of the date of such computation): Said Mortgage Loan meets all of the requirements in the definition of Eligible Committed Mortgage Loan except that said Mortgage Loan: (a) has an original principal balance not exceeding $300,000.00; (b) has a Loan-to-Value Ratio (including any related first mortgage) not greater than 125%; (c) is not required to be covered by a policy of private mortgage insurance; and (d) has not been included in the Borrowing Base for more than thirty (30) days or such longer period as may be approved by the Agent in writing (not to exceed an additional thirty (30) days)." (b) Change in Definition of "Type" The definition of the term "Type," set forth in Section 11 of the Agreement, is hereby amended to read in its entirety as follows: "'Type' for any Mortgage Loan shall mean an Eligible Committed Conforming Mortgage Loan including but not limited to an Eligible Committed HLTV Loan), an Eligible Committed Non-Conforming Mortgage Loan, an Eligible Foreclosure Mortgage Loan, an Eligible Uncommitted Conforming Mortgage Loan or an Eligible Gestation Mortgage Loan," (c) Change in Definition of "Eligible Mortgage Loan." Clause (u) of the definition of the term "Eligible Mortgage Loan," set forth in Section 11 of the Agreement, is amended to read in its entirety as follows: "(u) Unless said Mortgage Loan is an Eligible Committed HLTV Loan, if said Mortgage Loan has a Loan-to-Value Ratio greater than eighty percent (80%), said Mortgage Loan is covered by a policy of private mortgage insurance acceptable to FNMA, FHLMC or has been pre-approved by the Agent." (d) Changes in Definition of "Eligible Committed Conforming Mortgage Loan." Clauses (b) and (e) of the definition of the term "Eligible Committed Conforming Mortgage Loan," set forth in Section 11 of the Agreement, are hereby amended to read in their entirety as follows: "(b) Said Mortgage Loan is secured by a first or second priority deed of trust (or mortgage) on the Property in favor of the Company; provided. however, that unless said Mortgage Loan is an Eligible Committed HLTV Loan, if said Mortgage Loan is secured by a second priority deed of trust (or mortgage), the Collateral Value of said Mortgage Loan when added to the Collateral Value of all other Mortgage Loans included in the Borrowing Base which are secured by second priority deeds of trust (or mortgages) and are not Eligible Committed HLTV Loans does not exceed $1,000,000.00 and provided further, that if said Mortgage Loan is an Eligible Committed HLTV Loan secured by a first or second priority deed of trust (or mortgage), the Collateral Value of said Mortgage Loan when added to the Collateral Value of all other Eligible Committed HLTV Loans included in the Borrowing Base does not exceed $2,000,000.00." "(e) Said Mortgage Loan has not been included in the Borrowing Base for more than ninety (90) days or such longer period as may be approved by the Agent in writing (not to exceed an additional sixty (60) days in the case of Mortgage Loans secured by first priority deeds of trust and thirty (30) days in the case of Mortgage Loans other than Eligible Committed HLTV Loans secured by second priority deeds of trust); provided, however, that notwithstanding the foregoing, if said Mortgage Loan is an Eligible Committed HLTV Loan, said Mortgage Loan has not been included in the Borrowing Base for more than thirty (30) days or such longer period as may be approved by the Agent in writing (not to exceed an additional thirty (30) days); and" (e) Change in Definition of "Collateral Value." Clause (a) of the definition of the term "Collateral Value," set forth in Section 11 of the Agreement, is hereby amended to read in its entirety as follows: "(a) If such Eligible Mortgage Loan is an Eligible Committed Conforming Mortgage Loan (other than an Eligible Committed HLTV Loan), an Eligible Committed Non-Conforming Mortgage Loan or an Eligible Gestation Mortgage Loan, ninety-eight percent (98%), and if such Eligible Mortgage Loan is an Eligible Committed HLTV Loan, ninety-five percent (95%) of the lesser of: (1) the unpaid principal balance thereof, (2) the Applicable Take-Out Price multiplied by the unpaid principal balance thereof, (3) the acquisition price thereof (net of discount and fees associated with yield), and (4) but only if said Mortgage Loan is an Eligible Committed HLTV Loan or is secured by a second priority deed of trust (or mortgage), the Fair Market Value of said Mortgage Loan;" 4. Reaffirmation of Security- Agreement The Company hereby affirms and agrees that (a) the execution, delivery and performance by the Company of its obligations under this Amendment shall not in any way amend, impair, invalidate or otherwise affect any of the obligations of the Company or the rights of the Secured Parties under the Security Agreement or any other document or instrument made or given by the Company in connection therewith, (b) the term "Obligations" as used in the Security Agreement includes, without limitation, the Obligations of the Company under the Agreement as amended hereby, and (c) the Security Agreement remains in full force and effect in that such agreement constitutes a continuing first priority security interest in and lien upon the Collateral. 5. Effective Date. This Amendment shall be effective as of the date (the "Effective Date") upon which: (a) All parties signatory hereto have executed and delivered this Amendment to the Agent; and (b) The Agent has received such board resolutions, incumbency certificates and other additional documentation as it may request in connection herewith. 6. No Other Amendment. Except as expressly amended herein, the Agreement and the other Loan Documents (as amended from time to time) shall remain in full force and effect as currently written. 7. Counterparts. This Amendment may be executed in any number of counterparts, each of which when so executed shall be deemed to be an original and all of which when taken together shall constitute one and the same agreement. 8. Representations and Warranties. The Company hereby represents and warrants to the Agent, the Lenders and the Collateral Agent as follows: (a) The Company has the corporate power and authority and the legal right to execute, deliver and perform this Amendment and all documents, instruments and agreements executed and delivered by the Company in connection therewith (collectively, the "Amendment Documents") and has taken all necessary corporate action to authorize the execution, delivery and performance of the Amendment Documents. The Amendment Documents have been duly executed and delivered on behalf of the Company and constitute legal, valid and binding obligations of the Company, enforceable against the Company in accordance with their respective terms. (b) At and as of the date of execution hereof and at and as of the Effective Date of this Amendment and both prior to and after giving effect to the Amendment Documents: (1) the representations and warranties of the Company contained in the Agreement are accurate and complete in all respects, and (2) there has not occurred art Event of Default or Potential Default under the Agreement. IN WITNESS WHEREOF, the parties hereto have caused this Amendment to be executed as of the day and year first above written. FIRST MORTGAGE CORPORATION A California Corporation By: Name: Clement Ziroli Title: President Percentage Shares: 100% BANK OF AMERICA NATIONAL TRUST AND SAVINGS ASSOCIATION, A national banking association as Agent and Lender By: Name: Thomas A. Pizurie Title: Vice President