EXHIBIT 10.4.7

                         AMENDMENT NO. 2 TO THE AMENDED
                        AND RESTATED CUSTODIAL AGREEMENT

            AMENDMENT NO. 2, dated as of October 21, 2004 (this "Amendment"), to
the Amended and Restated Custodial Agreement, dated as of November 26, 2003 (as
amended, restated, supplemented or otherwise modified prior to the date hereof,
the "Existing Custodial Agreement", a as amended, hereby and as further amended,
restated, supplemented or otherwise modified and in effect from time to time,
the "Custodial Agreement"), by and among AMERICAN HOME MORTGAGE CORP., a New
York corporation, AMERICAN HOME MORTGAGE INVESTMENT CORP., a Maryland
corporation, AMERICAN HOME MORTGAGE HOLDINGS, INC., a Delaware corporation,
AMERICAN HOME MORTGAGE ACCEPTANCE, INC., a Maryland corporation, and AMERICAN
HOME MORTGAGE SERVICING, INC., a Maryland corporation (formerly known as
Columbia National, Incorporated) (each a "Borrower", collectively the
"Borrowers"), DEUTSCHE BANK NATIONAL TRUST COMPANY, as custodian (in such
capacity, the "Custodian"), and MORGAN STANLEY BANK (the "Lender Agent").

                                    RECITALS

            The Borrowers, the Lender Agent and the Custodian are parties to the
Existing Custodial Agreement. Capitalized terms used but not otherwise defined
herein shall have the meanings given to them in the Existing Custodial
Agreement.

            The Borrowers, the Lender Agent and the Custodian have agreed,
subject to the terms and conditions of this Amendment, that the Existing
Custodial Agreement be amended to revise Annex I of the Existing Custodial
Agreement.

            Accordingly, the Borrowers, the Lender Agent and the Custodian
hereby agree, in consideration of the mutual premises and mutual obligations set
forth herein, that the Existing Custodial Agreement is hereby amended as
follows:

            SECTION 1. Amendments.

            1.1 The Existing Custodial Agreement is hereby amended by deleting
Annex I to the Existing Custodial Agreement in its entirety and substituting in
lieu thereof the Annex I attached hereto.

            1.2 Annex 4 paragraph 11 of the Existing Loan Agreement is hereby
deleted in its entirety and the following shall be inserted in lieu thereof:

            "11 based upon a review of the Mortgage Note, items (d), (f), (g),
      (h), (m), (p), (bb), (hh), (jj), (fff) and (ppp) of Annex 1 as set forth
      in the Mortgage Loan Schedule delivered by the applicable Borrower to the
      Custodian are correct;"

            SECTION 2. Conditions Precedent. This Amendment and its provisions
shall become effective on the date (the "Amendment Effective Date") on which the
following


<PAGE>

conditions precedent shall have been satisfied, and upon satisfaction of such
conditions precedent the Amendment Effective Date shall be the date of this
Amendment:

            2.1   Delivered  Documents.  On or before the Amendment  Effective
Date,  the Lender Agent shall have received the following  documents,  each of
which shall be satisfactory to the Lender Agent in form and substance:

            (a) Amendment. This Amendment, executed and delivered by a duly
      authorized officer of each of the Borrowers, the Custodian, and the Lender
      Agent; and

            (b) Other Documents. Such other documents as the Lender Agent or
      counsel to the Lender may reasonably request.

            2.2   No Default.  On the Amendment  Effective Date,  after giving
effect to the Sixth Amendment,  (i) each  Borrower shall be in compliance with
all the terms and provisions set forth in the Existing Custodial  Agreement on
its part to be observed or performed,  (ii) the representations and warranties
made and  restated by each  Borrower  pursuant to Section 3 of this  Amendment
shall be true and  complete  on and as of such  date  with the same  force and
effect as if made on and as of such  date,  and  (iii) no  Default  shall have
occurred and be continuing on such date.

            SECTION 3. Representations and Warranties. After giving effect to
the Sixth Amendment, each Borrower hereby represents and warrants to the Lender
Agent and the Custodian that it is in compliance with all the terms and
provisions set forth in the Loan Documents on its part to be observed or
performed, and that no Default has occurred or is continuing, and hereby
confirms and reaffirms its representations and warranties contained in Section
10 of the Existing Custodial Agreement.

            SECTION 4. Limited Effect. Except as expressly amended and modified
by this Amendment, the Existing Custodial Agreement shall continue to be, and
shall remain, in full force and effect in accordance with its terms; provided,
however, that reference therein and herein to the "Loan Documents" shall be
deemed to include, in any event, this Amendment. Each reference to the Custodial
Agreement in any of the Loan Documents shall be deemed to be a reference to the
Custodial Agreement as amended hereby. The execution of this Amendment by the
Lender or Custodian shall not operate as a waiver of any of their rights, powers
or privileges under the Custodial Agreement or under any of the other Loan
Documents except as expressly set forth herein.

            SECTION 5. Counterparts. This Amendment may be executed by each of
the parties hereto on any number of separate counterparts, each of which shall
be an original and all of which taken together shall constitute one and the same
instrument. Delivery of an executed counterpart of a signature page to this
Amendment in Portable Document Format (PDF) or by facsimile transmission shall
be effective as delivery of a manually executed original counterpart thereof.

            SECTION 6. GOVERNING LAW. THIS AMENDMENT SHALL BE GOVERNED BY, AND
CONSTRUED AND INTERPRETED IN ACCORDANCE WITH, THE LAWS OF THE STATE OF NEW YORK.


<PAGE>

                            [SIGNATURE PAGE FOLLOWS]




<PAGE>

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

                                    BORROWERS

                                    AMERICAN HOME MORTGAGE CORP.

                                    By:    /s/ Alan B. Horn
                                       -----------------------------------------
                                       Name:   Alan B. Horn
                                       Title:  Executive Vice President, General
                                               Counsel, and Secretary

                                    AMERICAN HOME MORTGAGE INVESTMENT CORP.

                                    By:    /s/ Alan B. Horn
                                       -----------------------------------------
                                       Name:   Alan B. Horn
                                       Title:  Executive Vice President, General
                                               Counsel, and Secretary

                                    AMERICAN HOME MORTGAGE HOLDINGS, INC.

                                    By:    /s/ Alan B. Horn
                                       -----------------------------------------
                                       Name:   Alan B. Horn
                                       Title:  Executive Vice President, General
                                               Counsel, and Secretary

                                    AMERICAN HOME MORTGAGE ACCEPTANCE, INC.

                                    By:    /s/ Alan B. Horn
                                       -----------------------------------------
                                       Name:   Alan B. Horn
                                       Title:  Executive Vice President, General
                                               Counsel, and Secretary

                                    AMERICAN HOME MORTGAGE SERVICING, INC.
                                       (f/k/a Columbia National,
                                       Incorporated)

                                    By:    /s/ Alan B. Horn
                                       -----------------------------------------
                                       Name:   Alan B. Horn
                                       Title:  Executive Vice President, General
                                               Counsel, and Secretary

                                    LENDER AGENT

                                    MORGAN STANLEY BANK

                                    By:    /s/ Paul Najarian
                                        ----------------------------------------
                                        Name:  Paul Najarian
                                        Title: Vice President
<PAGE>

                                    CUSTODIAN

                                    DEUTSCHE BANK NATIONAL TRUST COMPANY

                                    By:    /s/ Christopher Corcoran
                                        ----------------------------------------
                                        Name:  Christopher Corcoran
                                        Title: Assistant Vice President



                                    By:    /s/ Carlos Falconi
                                        ----------------------------------------
                                        Name:  Carlos Falconi
                                        Title: Associate
<PAGE>

                                                                         Annex 1
                                                          to Custodial Agreement

                   INFORMATION TO BE PROVIDED WITH RESPECT TO

                             ELIGIBLE MORTGAGE LOANS

For each Mortgage Loan, the applicable Borrower shall provide the following
information:

            (a)   Number of Times Delinquent 30 days in last 12 months;

            (b)   Number of Times Delinquent 60 days in last 12 months;

            (c)   Number of Times Delinquent 90+ days in last 12 months;

            (d)   Address City;

            (e)   Address County;

            (f)   Address State;

            (g)   Address Street;

            (h)   Address Zipcode;

            (i)   Amort Type (Fixed or ARM);

            (j)   Backend Debt Ratio (all debt/income);1

            (k)   Balance Appraisal;

            (l)   Balance Current;

            (m)   Balance Original;

            (n)   Balance Senior;

            (o)   Balloon;

            (p)   Borrower Name;

            (q)   CLTV Original;

            (r)   Co-Borrower's Credit Score (if applicable);

            (s)   Co-Borrower's Name (if applicable);


--------
1 Not required on No Doc and Stated Income Doc Loans


                                   Annex 1-1

<PAGE>

            (t)   Commitment Expiration;

            (u)   Convertible;

            (v)   Coupon Current;

            (w)   Coupon Init Per Cap;

            (x)   Coupon IO;

            (y)   Coupon Life Cap;

            (z)   Coupon Max;

            (aa)  Coupon Min;

            (bb)  Coupon Original;

            (cc)  Coupon Periodic Cap;

            (dd)  Coupon Periodic Floor;

            (ee)  Credit Score (FICO);

            (ff)  Credit Score Type (Beacon, Equifax, TransUnion or Merge);

            (gg)  Date First Cpn Change;

            (hh)  Date First Payment;

            (ii)  Date First Pmt Change;

            (jj)  Date Maturity;

            (kk)  Date Next Coupon Change;

            (ll)  Date Next Due;

            (mm)  Date Next Pay Change;

            (nn)  Date Orig;

            (oo)  Date Paid Thru;

            (pp)  Day Count;

            (qq)  Delinq Status;

            (rr)  Documentation Type;



                                   Annex 1-2
<PAGE>

            (ss)  Eligible Group

            (tt)  Escrow Flag (Yes or No);

            (uu)  Forclosure/REO/Bankruptcy Status;

            (vv)  Freq Coupon Adj;

            (ww)  Freq Payment Adj;

            (xx)  Frequency Pmt;

            (yy)  Frontend Debt Ratio (mortgage debt/income);2

            (zz)  Fund Date;

            (aaa) Index (for ARMs);

            (bbb) IO Flag (Yes or No);

            (ccc) Lien Status;

            (ddd) Loan Purpose;

            (eee) Loan Type (residential, etc..);

            (fff) Loan Id Number;

            (ggg) LTV Current;

            (hhh) LTV Original;

            (iii) Margin;

            (jjj) MERS Loan Flag

            (kkk) MERS Loan Number

            (lll) Number of Units;

            (mmm) Occupancy;

            (nnn) Ownership Type (Leasehold, Fee Simple, etc...);

            (ooo) P&I Current;


--------
2 Not required on No Doc and Stated Income Doc Loans

                                   Annex 1-3

<PAGE>

            (ppp)  P&I Original;

            (qqq)  PMI (Yes or No);

            (rrr)  PMI Percentage (if applicable);

            (sss)  PMI Provider (if applicable);

            (ttt)  Prepayment Penalty (Yes or No);

            (uuu)  Prepayment Penalty Description;

            (vvv)  Prepayment Penalty Term (Months Freely Prepayable);

            (www)  Product Type;

            (xxx)  Property Purchase Amount/Sales Price;

            (yyy)  Property Type;

            (zzz)  Rating;

            (aaaa) Rounding Factor;

            (bbbb) S&P Appraisal Type;

            (cccc) S&P Document Type;

            (dddd) Section 32 Flag;

            (eeee) Service Fee Amount;

            (ffff) Social Security Number;

            (gggg) Takeout Investor;

            (hhhh) Takeout Price;

            (iiii) Term Amort Original;

            (jjjj) Term Coupon Teaser;

            (kkkk) Term IO Original;

            (llll) Term Original;

            (mmmm) Term PNI Teaser;

            (nnnn) Warehouse Amount; and


                                    Annex 1-4

<PAGE>

            (oooo) Warehouse Bank.



                                    Annex 1-5