EXHIBIT 5.1 OPINION REGARDING LEGALITY June 4, 1999 To the parties listed on Annex A attached hereto Re: Mortgage Lenders Network Home Equity Loan Trust 1999-1, Asset Backed Notes, Series 1999-1, Class A-1 and Class A-2 Ladies and Gentlemen: We have acted as special counsel to Residential Asset Funding Corporation (the "Depositor") and Mortgage Lenders Network Home Equity Loan Trust 1999-1, a Delaware business trust (the "Issuer") in connection with the execution and delivery of the following documents: (i) the Mortgage Loan Sale Agreement dated as of June 1, 1999 (the "Sale Agreement") between the Depositor and Mortgage Lenders Network USA, Inc., as Seller (the "Seller"); (ii) the Deposit Trust Agreement dated as of June 1, 1999 (the "Trust Agreement") among the Depositor, the Seller, Norwest Bank Minnesota, National Association, as Trust Paying Agent and Wilmington Trust Company, as Owner Trustee; (iii) the Management Agreement dated as of June 1, 1999 (the "Management Agreement") between the Issuer and Norwest Bank Minnesota, National Association, as Manager; (iv) the Mortgage Loan Contribution Agreement dated as of June 1, 1999 (the "Contribution Agreement") between the Depositor and the Issuer; (v) the Indenture dated as of June 1, 1999 (the "Indenture") between Norwest Bank Minnesota, National Association, as Indenture Trustee (in such capacity, the "Indenture Trustee") and the Issuer; (vi) the Underwriting Agreement dated as of May 27, 1999 (the "Underwriting Agreement") between the Depositor and First Union Capital Markets Corp., as Representative of the Underwriters (the "Representative"); (vii) the Standard Provisions to Underwriting Agreement dated as of May 27, 1999 between the Depositor and the Representative; (viii) the Custodial Agreement dated as of June 1, 1999 among Mortgage Lenders Network USA, Inc., as Servicer (in such capacity, the "Servicer"), Bank Boston, as Custodian and the Indenture Trustee; (ix) the Servicing Agreement dated as of June 1, 1999 among the Servicer, the Issuer and Norwest Bank Minnesota, as Trust Paying Agent; and (x) the Insurance Agreement dated as of June 1, 1999 (the "Insurance Agreement") among MBIA Insurance Corporation (the "Insurer"), the Issuer, the Seller, the Servicer, the Depositor and the Indenture Trustee. Capitalized terms used herein, but not defined, shall have the meanings assigned to them in the Indenture. We have examined executed copies of the Sale Agreement, the Underwriting Agreement, the Standard Provisions to Underwriting Agreement, the Contribution Agreement, the Trust Agreement, the Servicing Agreement; the Custodial Agreement, the Indenture. the Management Agreement and the Insurance Agreement (collectively, the "Documents"). We have also examined a copy of each of the executed Notes. We have also examined the Registration Statement No. 333-64775, as heretofore amended (the "Registration Statement") and the Prospectus dated November 10, 1998 the Preliminary Prospectus Supplement relating to the Notes and the Prospectus Supplement dated May 27, 1999 relating to the Notes (such Prospectus, Preliminary Prospectus Supplement and Prospectus Supplement being referred to together as the "Prospectus"). We have also examined originals or photostatic or certified copies of all such corporate records of the Depositor and such certificates of public officials, certificates of corporate officers, and other documents, and such questions of law, as we have deemed relevant and necessary as a basis for the opinions hereinafter expressed. As to certain issues of fact material to the opinions expressed herein, we have, with your consent, relied to the extent we deemed appropriate upon certificates and representations of officers of the Depositor. In making our examinations and rendering the opinions herein expressed, we have made the following assumptions: (1) each party to each of the Documents (other than the Depositor) has the corporate power to enter into and perform all of its obligations thereunder; (2) the due authorization, execution and delivery of the Documents by all parties thereto (other than the Depositor) and the validity and binding effect on all parties (other than the Depositor) of each of the Documents, as applicable; (3) the genuineness of all signatures; (4) the authenticity of all documents submitted to us as originals and the conformity to originals of all documents submitted to us as copies; (5) in the case of each purchaser of a Note investing assets of an employee benefit plan covered by ERISA, such plan is a plan to which Prohibited Transaction Exemption 90-32 is fully available. The opinions expressed in paragraphs 3 and 4 with respect to the enforceability of certain agreements are subject to the following additional qualifications: The effect of bankruptcy, insolvency, reorganization, moratorium, receivership, or other similar laws of general applicability relating to or affecting creditors' rights generally or the rights of creditors of national banking associations in the event of bankruptcy, insolvency, reorganization, moratorium or receivership. The application of general principles of equity, including, but not limited to, the right of specific performance (regardless of whether enforceability is considered in a proceeding in equity or at law). In addition, we wish to advise you that the enforceability of certain provisions set forth in the Underwriting Agreement which purport to provide for indemnification for losses due to securities laws violations may be limited by public policy considerations. We are admitted to the Bar of the State of New York, and we express no opinion as to the laws of any other jurisdiction except as to matters that are governed by federal law and with respect to paragraph 1 below, the General Corporation Law of the State of Delaware. All opinions expressed herein are based on laws, regulations and policy guidelines currently in force and may be affected by future regulations. Furthermore, no opinion is expressed herein regarding the applicable state Blue Sky, legal investment or real estate syndication laws. Based upon the foregoing and subject to the last paragraph hereof, we are of the opinion that: 1. The Depositor is a corporation duly organized, validly existing and in good standing under the laws of the State of North Carolina and is duly qualified to do business in each State necessary to enable it to perform its obligations under the Documents to which it is a party. 2. The Depositor has the corporate power and authority to convey the Mortgage Loans and to execute, deliver and perform, and to enter into and consummate transactions contemplated by the Documents to which it is a party and such Documents have been duly authorized, executed and delivered by the Depositor. 3. Each of the Documents to which the Depositor is a party constitutes the valid, legal and binding agreement of the Depositor, and is enforceable against the Depositor in accordance with its terms. 4. Each of the Documents to which the Issuer is a party is enforceable against the Issuer in accordance with its terms. 5. The Notes, assuming the due execution by the Owner Trustee on behalf of the Trust and due authentication by the Indenture Trustee and payment therefor pursuant to the Underwriting Agreement, are validly issued and outstanding and are entitled to the benefits of the Indenture. 6. No consent, approval, authorization or order of, registration or filing with, or notice to, any governmental authority or court is required under federal laws or the laws of the State of New York for the execution, delivery and performance of the Documents to which the Depositor is a party, or the offer, issuance, sale or delivery of the Notes or the consummation of any other transaction contemplated thereby by the Depositor, except such which have been obtained. 7. The Registration Statement and the Prospectus (other than the financial and statistical data included therein, as to which we are not called upon to express any opinion), at the time the Registration Statement became effective, as of the date of execution of the Underwriting Agreement and as of the date hereof comply as to form in all material respects with the requirements of the Securities Act of 1933, as amended, and the rules and regulations thereunder, and the Exchange Act and the rules and regulations thereunder, and we do not know of any amendment to the Registration Statement required to be filed, or of any contracts, indentures or other documents of a character required to be filed as an exhibit to the Registration Statement or required to be described in the Registration Statement or the Prospectus, which has not been filed or described as required. 8. The Registration Statement is effective, and to the best of our knowledge, the Commission has not issued any stop order suspending the effectiveness of the Registration Statement (which for purposes of this opinion shall not be deemed to include any exhibits filed therewith) or any order directed to any prospectus relating to the Notes (including the Prospectus), and has not initiated or threatened any proceeding for that purpose. 9. The Indenture has been duly qualified under the Trust Indenture Act of 1939 (the "TIA"), as amended, the Trust Agreement is not required to be qualified under the TIA and neither the Depositor nor the Issuer is required to be qualified under the Investment Company Act of 1940. 10. The statements in the Prospectus Supplement set forth under the caption "DESCRIPTION OF THE NOTES," to the extent such statements purport to summarize certain provisions of the Notes or of the Indenture, are fair and accurate in all material respects. 11. None of the sale of the Mortgage Loans to the Issuer, the issuance or sale of the Notes, or the execution, delivery or performance by the Depositor of its obligations under the Documents, conflicts with or will conflict with, or results or will result in a breach of, or constitutes or will constitute a default under the charter or bylaws of the Depositor or any law, rule or regulation of the United States federal government or of the State of New York. 12. The Indenture establishes in favor of the Indenture Trustee for the benefit of the Noteholders and the Insurer, a valid and enforceable security interest in all right, title and interest of the Issuer in the Mortgage Loans. Our opinions contained herein are rendered only as of the date hereof, and we undertake no obligation to update this letter or the opinions contained herein after the date hereof. This opinion is furnished by us as counsel in connection with the conveyance of the Mortgage Loans to the Issuer as of the date hereof and is solely for the benefit of the addressees hereto, and is not to be used, circulated, quoted or otherwise referred to for any other purpose without our express written permission. Very truly yours, /s/ Dewey Ballantine LLP ANNEX A MBIA Insurance Corporation First Union Capital Markets Corp. 113 King Street 301 South College Street Armonk, New York 10504 Charlotte, North Carolina 28288 Residential Asset Funding Corporation Norwest Bank Minnesota, National Association c/o First Union Capital Markets Sixth Street and Marquette Avenue 301 South College Street Minneapolis, Minnesota 55479-0070 Charlotte, North Carolina 28288-0610 Standard & Poor's Ratings Services Moody's Investors Service, Inc. 25 Broadway 99 Church Street New York, New York 10004 New York, New York 10007 Mortgage Lenders Network USA, Inc. Middlex Corporate Center, 11th Floor Fitch IBCA 213 Court Street One State Street Plaza Middletown, Connecticut 06457 New York, New York 10004 Mortgage Lenders Home Equity Loan Trust 1999-1 c/o Wilmington Trust Company Wilmington Trust Company Rodney Square North Rodney Square North 1100 North Market Street 1100 North Market Street Wilmington, Delaware 19890-0001 Wilmington, Delaware 19890-0001