Exhibit 10.4.1


                   SECOND AMENDMENT TO AMENDED AND RESTATED
                      MORTGAGE LOAN WAREHOUSING AGREEMENT


     THIS SECOND AMENDMENT TO AMENDED AND RESTATED MORTGAGE LOAN WAREHOUSING
AGREEMENT (the "Amendment") is made and dated as of the 9th day of January,
1998, by and among THE FIRST NATIONAL BANK OF CHICAGO, a national banking
association ("FNBC"), BANK OF AMERICA NATIONAL TRUST AND SAVINGS ASSOCIATION, a
national banking association, THE BANK OF NEW YORK, a banking corporation
organized under the laws of the State of New York, COMERICA BANK - CALIFORNIA, a
California banking corporation, FIRST UNION NATIONAL BANK, a national banking
association, and GUARANTY FEDERAL BANK, a federal savings bank (all of the above
individually a "Lender" and, collectively, the "Lenders"), FNBC, as
administrative agent for the Lenders (in such capacity, the "Administrative
Agent"), FIRST CHICAGO NATIONAL PROCESSING ASSOCIATION, a Delaware corporation,
as collateral agent for the Administrative Agent and the Lenders (in such
capacity, the "Collateral Agent"), and HEADLANDS MORTGAGE COMPANY, a California
corporation (the "Company").

                                   RECITALS

     A. Pursuant to that certain Amended and Restated Mortgage Loan Warehousing
Agreement dated as of August 29, 1997 among the Administrative Agent, the
Collateral Agent, the Lenders and the Company (the "Agreement"), the Lenders
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 filed a Form S-1 with the United States Securities and
Exchange Commission on October 20, 1997 (and subsequently filed an amended Form
S-1 on December 11, 1997) describing its plans to have an initial public
offering of its common stock (the "IPO"), copies of which Form S-1 and amended
Form S-1 have been distributed to the Lenders.

     C. In connection with the IPO, the Company has requested certain amendments
and waivers to the Agreement and the Lenders have agreed thereto on certain
conditions, all as more particularly described below.

     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:

                                       1

 
                                   AGREEMENT

     1.   Payment of Dividends.
          --------------------

          (a) Upon the occurrence of the IPO, the Company will no longer be an S
Corporation under the Code. The Company desires to make a distribution to its
current shareholders, in an aggregate amount not to exceed the amount of the
Company's aggregate taxable income which has not been previously distributed
(the "Shareholder Distribution"), from a portion of the proceeds from the IPO.
The Lenders hereby approve the Shareholder Distribution, such approval to be
effective as of the IPO Effective Date (as defined in Paragraph 13(b) below) if
and when it occurs.

          (b) Effective as of the IPO Effective Date, Paragraph 12(f) of the
Agreement is hereby amended to read in its entirety as follows:

                   "12(f) Payment of Dividends. (1) Declare or pay any dividends
                          --------------------
     upon any shares of the Company's stock now or hereafter outstanding, except
     dividends payable in the capital stock of the Company, or (2) make any
     distribution of assets to its stockholders as such, whether in cash,
     property or securities, or (3) set aside any of its property for the
     purpose of doing any of the foregoing; provided, however, that the Company
     may pay, from time to time during any fiscal year of the Company, dividends
     and distributions in an aggregate amount not to exceed twenty-five percent
     (25%) of the amount equal to the Adjusted Net Income of the Company to date
     for such fiscal year (calculated as of each fiscal quarter end of such
     fiscal year); and provided further, that no dividend payment otherwise
     permitted above shall be made if, immediately before or after giving effect
     thereto, any Event of Default or Potential Default exists or would exist."

          (c) Effective as of the IPO Effective Date, a new definition of the
term "Adjusted Net Income" is hereby added to Paragraph 16 of the Agreement in
correct alphabetical order to replace the definition of the term "Pre-Tax
Income," to read in its entirety as follows:

              "'Adjusted Net Income' shall mean for any period the positive
                -------------------
     consolidated net income of the Company for such period, determined in
     accordance with the methodology described on Schedule V."
                                                  ----------

          (d) Effective as of the IPO Effective Date, Schedule V to the
                                                      ---------- 
Agreement is hereby replaced by Replacement Schedule V attached hereto.
                                ----------------------    

    2.    Prepayment of Subordinated Debt.
          -------------------------------  

          (a)  The Company desires to prepay in full all outstanding principal
and accrued interest (in an aggregate amount not exceeding $11,000,000.00) in
connection with certain unsecured Subordinated Debt of the Company to Peter Paul
and/or Jessica Paul (the "Paul Subordinated Debt") with a portion of the
proceeds from the IPO. The Lenders hereby approve 

                                       2

 
such prepayment of the Paul Subordinated Debt, such approval to be effective as
of the IPO Effective Date if and when it occurs.

          (b)  Effective as of the IPO Effective Date, Exhibit N to the
                                                       ---------
Agreement is hereby replaced by Replacement Exhibit N attached hereto.
                                ---------------------- 

    3.    Purchase or Retirement of Stock. The Company desires the flexibility
          --------------------------------  
to repurchase and retire shares of its common stock once it becomes a public
company and the Lenders have agreed to provide such flexibility as long as no
Event of Default or Potential Default exists. Effective as of the IPO Effective
Date, Paragraph 12(g) of the Agreement is hereby amended by adding the phrase
"if, immediately before or after giving effect to any such acquisition,
purchase, redemption or retirement, any Event of Default or Potential Default
exists or would exist" after the word "outstanding" at the end of the paragraph.

    4.    Minimum Net Worth.
          -----------------

          (a)   To reflect the agreement of the parties hereto to change the
minimum net worth requirements under the Agreement, effective as of the
Effective Date (as defined in Paragraph 13(a) below), Paragraph 12(k) of the
Agreement is hereby amended to read in its entirety as follows:

                    "12(k) Minimum Net Worth. Permit at any date its
                           -----------------
                    consolidated:

                           (1) Effective Net Worth to be less than the greater
          of: (i) the amount equal to $40,000,000.00 plus fifty percent (50%) of
          the Company's consolidated annual net income (if positive) earned each
          calendar year commencing with the year 1998, and (ii) the amount equal
          to eighty percent (80%) of its consolidated Effective Net Worth as of
          the end of the month of occurrence of the initial public offering of
          the Company's common stock, minus such additional reductions
          thereafter that may occur as a result of the final determination of
          the exact amount of the Shareholder Distribution, plus fifty percent
          (50%) of the Company's consolidated annual net income (if positive)
          earned each calendar year (with the first year being a partial year
          commencing the month immediately following the month of occurrence of
          the initial public offering of the Company's common stock); or

                           (2) Adjusted Tangible Net Worth to be less than the
          greater of: (i) the amount equal to $70,000,000.00 plus fifty percent
          (50%) of the Company's consolidated annual net income (if positive)
          earned each calendar year commencing with the year 1998, and (ii) the
          amount equal to eighty percent (80%) of its consolidated Adjusted
          Tangible Net Worth as of the end of the month of occurrence of the
          initial public offering of the Company's common stock, minus such
          additional reductions thereafter that may occur as a result of the
          final determination of the exact amount of the Shareholder
          Distribution, plus fifty percent (50%) of the Company's consolidated
          annual net income (if positive) 

                                       3

 
          earned each calendar year (with the first year being a partial year
          commencing the month immediately following the month of occurrence of
          the initial public offering of the Company's common stock)."

          (b) Effective as of the Effective Date, a new definition of the term
"Shareholder Distribution" is hereby added to Paragraph 16 of the Agreement in
correct alphabetical order to read in its entirety as follows:

              "'Shareholder Distribution' shall mean the distribution by the
                ------------------------
       Company to its shareholders, in an aggregate amount not to exceed the
       amount of the Company's aggregate taxable income which has not been
       previously distributed, from a portion of the proceeds from the initial
       public offering of the Company's common stock, which distribution has
       been expressly approved in writing by one hundred percent (100%) of the
       Lenders."

       5. Current Ratio. To reflect the agreement of the parties hereto to
          -------------             
exclude certain assets of the Company in the determination of its Current Ratio,
effective as of the Effective Date, the definition of the term "Current Ratio"
set forth in Paragraph 16 of the Agreement is hereby amended to read in its
entirety as follows:

              "'Current Ratio' shall mean at any date the ratio of current
                -------------      
       assets to current liabilities of the Company and its Subsidiaries,
       determined on a consolidated basis in accordance with GAAP; provided,
       however, that in determining the Company's current assets for purposes
       hereof, the following assets shall be excluded: (a) the aggregate
       outstanding principal amount of all loans and advances outstanding to
       officers and employees of the Company and its Subsidiaries, and (b) any
       transferor interests retained by the Company in any securitizations of
       HELOCs and interest only strips receivables that will not be realized in
       the immediately following twelve-month period."

       6. Stock Ownership. To reflect the agreement of the parties hereto to
          --------------- 
change the stock ownership requirement in anticipation of the IPO, effective as
of the IPO Effective Date, Paragraph 13(i) of the Agreement is hereby amended to
read in its entirety as follows:

              "13(i) Peter Paul shall cease to own at least twenty-five percent
       (25%) of the outstanding shares of capital stock of the Company; or any
       other Person, or Persons acting in concert, shall hold, directly or
       indirectly, beneficial interests in more shares of capital stock than
       Peter Paul does."

       7. Reduction in Pricing. To reflect the agreement of the Lenders to
          --------------------
reduce the interest rates applicable to certain Loans upon the occurrence of the
IPO, effective as of the IPO Effective Date, the definitions of the terms
"Eurodollar Spread," "Federal Funds Pricing Spread" and "Overnight Transaction
Loan Rate" set forth in Paragraph 16 of the Agreement are hereby amended to read
in their entirety as follows:

              "'Eurodollar Spread' shall mean eleven-twentieths of one percent
                -----------------
       (0.55%).

                                       4

 
              'Federal Funds Pricing Spread' shall mean: (a) for any Tranche A
               ----------------------------
       Loan maintained as a Federal Funds Rate Loan, twenty-seven-fortieths of
       one percent (0.675%), and (b) for any Tranche D Loan, one-half of one
       percent (0.50%).

              'Overnight Transaction Loan Rate' shall mean for any Tranche C
               ------------------------------- 
       Loan on any day such Tranche C Loan is outstanding the rate per annum
       determined by the Administrative Agent for such day to be its overnight
       transaction loan rate plus nine-tenths of one percent (0.90%)."

       8.  Eligible High LTV Mortgage Loan. To reflect the agreement of the
           -------------------------------
parties hereto to permit certain Mortgage Loans the Obligors on which had a FICO
score of less than 680 to be included as Eligible High LTV Mortgage Loans,
effective as of the Effective Date, subparagraphs (e) and (h) of the definition
of the term "Eligible High LTV Mortgage Loan" set forth in Paragraph 16 of the
Agreement are hereby amended to read in their entirety as follows:

              "(e) The Obligor on said Mortgage Loan had a FICO score of not
       less than 640 or, if the Obligor on said Mortgage Loan had a FICO score
       of less than 640, the Unit Collateral Value of said Mortgage Loan, when
       added to the Unit Collateral Values of all other Eligible High LTV
       Mortgage Loans the Obligor on which had a FICO score of less than 640
       included in the computation of the Collateral Value of the Borrowing Base
       does not exceed one-half of one percent (0.50%) of the Aggregate Credit
       Limit;

              (h) Said Mortgage Loan generally conforms to all underwriting and
       other requirements of an Approved High LTV Investor and, in addition, if
       the Obligor on said Mortgage Loan had a FICO score of less than 640, said
       Mortgage Loan generally conforms to all underwriting standards of FNMA or
       FHLMC."

       9.  Addition of Approved High LTV Investor. Effective as of the Effective
           --------------------------------------
Date, the Lenders hereby approve Residential Funding Corporation and FirstPlus
Financial Group, Inc. as additional Approved High LTV Investors for all purposes
of the Agreement.

       10. Eligible Non-Conforming Mortgage Loan. To reflect the agreement of
           -------------------------------------- 
the parties hereto to add certain additional eligibility requirements applicable
to Eligible Non-Conforming Mortgage Loans, effective as of the Effective Date, a
new subparagraph (j) is hereby added to the definition of the term "Eligible 
Non-Conforming Mortgage Loan" set forth in Paragraph 16 of the Agreement to 
read in its entirety as follows:

              "(j) If said Mortgage Loan has a Loan-to-Value Ratio in excess of
       eighty percent (80%) but not in excess of eighty-five percent (85%), and
       is not covered by a policy of private mortgage insurance, said Mortgage
       Loan has an original principal balance of not more than $650,000.00."

                                       5

 
       11.  Reaffirmation of Other Loan Documents. The Company hereby affirms
            -------------------------------------   
and agrees that (a) the execution and delivery by the Company of and the
performance 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 Administrative Agent, the Collateral Agent or the Lenders
under the Agreement, the Security Agreement or any other Loan Document, (b) the
term "Obligations" as defined in Paragraph 16 of the Agreement includes, without
limitation, the Obligations of the Company under the Agreement as amended by
this Amendment, (c) the Security Agreement remains in full force and effect and
such agreement constitutes a continuing first priority security interest in and
lien upon the Collateral, and (d) for any and all purposes, any reference to the
Agreement following the effective date of this Amendment shall constitute a
reference to the Agreement as amended to date, including, without limitation, by
this Amendment.

       12.  Modification of Related Documents. All reports and other forms
            ---------------------------------
utilized in connection with the day-to-day operations of the credit facility
evidenced by the Agreement shall be deemed modified consistent with the
provisions of this Amendment.

       13.  Effective Date and IPO Effective Date.
            -------------------------------------

            (a)  The amendments set forth in Paragraphs 4, 5, 8, 9 and 10 above
shall be effective on the earliest date (the "Effective Date") upon which the
Administrative Agent has received (a) duly executed copies of this Amendment
from each of the Lenders, the Administrative Agent, the Collateral Agent and the
Company, and (b) such board resolutions, incumbency certificates and other
additional documentation as the Administrative Agent may request in connection
herewith.

            (b)  The amendments set forth in Paragraphs 1, 2, 3, 6 and 7 above
shall be effective on the earliest date (the "IPO Effective Date") after the
Effective Date upon which the IPO shall occur and each of the following
statements shall be true: (i) the IPO involves the offering of between 4,500,000
and 5,700,000 shares of capital stock of the Company to the public market, (ii)
there is no violation of any rule, regulation or requirement under the
Securities Act of 1933, as amended, or the Securities Exchange Act of 1934, as
amended, in connection with the IPO, and (iii) the Net Proceeds from the IPO is
not less than $20,000,000.00. For the purposes hereof, "Net Proceeds" shall mean
the gross proceeds from the IPO minus all underwriter fees and expenses, the
aggregate amount of the Shareholder Distribution, and the aggregate amount
required to repay in full all outstanding amounts under the Paul Subordinated
Debt.

       14.  Representations and Warranties. The Company hereby represents and
            ------------------------------
warrants to the Administrative Agent and the Lenders as follows:

            (a)  The Company has the corporate power and authority and the legal
right to execute, deliver and perform this Amendment and has taken all necessary
corporate action to authorize the execution, delivery and performance of this
Amendment. This Amendment has been duly executed and delivered on behalf of the
Company and constitutes the legal, valid and binding obligation of the Company
enforceable against the Company in accordance with its 

                                       6

 
terms. The execution, delivery and performance of this Amendment will not
violate any Requirement of Law or Contractual Obligation or require any consent,
approval or authorization of, or registration, declaration or filing with, any
Governmental Authority.

            (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
hereto: (1) the representations and warranties of the Company contained in the
Loan Documents are accurate and complete in all respects, and (2) there has not
occurred an Event of Default or Potential Default.

       15.  No Other Amendment. Except as expressly amended herein, the Loan
            ------------------
Documents shall remain in full force and effect as currently written.

       16.  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.

                                       7

 
      IN WITNESS WHEREOF, the parties hereto have caused this Amendment to be
executed as of the day and year first above written.

                                          HEADLANDS MORTGAGE COMPANY, 
                                          a California corporation    



                                          By:____________________________
                                          Name:__________________________
                                          Title:_________________________

                             
                                          THE FIRST NATIONAL BANK OF CHICAGO, 
                                          a national banking association, as 
                                          Administrative Agent and a Lender



                                          By:____________________________
                                          Name:__________________________
                                          Title:_________________________


                                          BANK OF AMERICA NATIONAL TRUST AND
                                          SAVINGS ASSOCIATION,              
                                          a national banking association, as a
                                          Lender                    
                                          
                                                               
                                          By:____________________________
                                          Name:__________________________
                                          Title:_________________________


                                          THE BANK OF NEW YORK,     
                                          a banking corporation organized under 
                                          the laws of the State of New York, 
                                          as a Lender                 
                                          

                                          By:____________________________ 
                                          Name:__________________________
                                          Title:_________________________

                                       8

 
                                          COMERICA BANK-CALIFORNIA,   
                                          a California banking corporation, as 
                                          a Lender        


                                          By:____________________________   
                                          Name:__________________________ 
                                          Title:_________________________


                                          FIRST UNION NATIONAL BANK,     
                                          a national banking association, as a 
                                          Lender          


                                          By:____________________________
                                          Name:__________________________
                                          Title:_________________________


                                          GUARANTY FEDERAL BANK,     
                                          a federal savings bank, as a Lender


                                          By:____________________________
                                          Name:__________________________
                                          Title:_________________________


                                          FIRST CHICAGO NATIONAL PROCESSING  
                                          CORPORATION, a Delaware corporation,
                                          as Collateral Agent   


                                          By:____________________________
                                          Name:__________________________
                                          Title:_________________________

                                       9

 
                                                          REPLACEMENT SCHEDULE V
                                                          ----------------------

                                  SCHEDULE V:
              METHODOLOGY FOR COMPUTATION OF ADJUSTED NET INCOME

 
 
Net Income                                                       $ XX
                                                                      
                            LESS                                      
                                                                      
     FAS 122      Gain On Sale of Mortgages                        XX 
                                                                      
     FAS 122      Decrease in Deferred Tax Liability               XX 
                                                                      
                            PLUS                                      
                                                                      
     FAS 122      Loss On Sale of Mortgages                        XX 
                                                                      
     FAS 122      Service Release Premiums                         XX 
                                                                      
     FAS 122      Amortization and Impairment                         
                  of Servicing Rights                              XX 
                                                                      
     FAS 122      Net Book Value of Servicing                         
                  Assets Sold                                      XX 
                                                                      
     FAS 122      Increase in Deferred Tax Liability               XX 
                                                                      
     ADJUSTED NET INCOME                
                                                                 $ XX  


                                       1