(1-a) Parties having assignments of moneys due or to become due under a contract for the improvement of real property, unless such assignments be set aside as diversions of trust assets as provided in article three-a of this chapter, shall have priority as follows: An assignee of moneys or any part thereof, due or to become due under a contract for the improvement of real property, whose assignment is duly filed prior to the filing of a notice of lien or assignment of every other party to the action, shall have priority over those parties to the extent of moneys advanced upon such assignment before the filing of the notice of lien or assignment next subsequent to his assignment, but as to moneys advanced subsequent to a notice of lien or assignment filed and unsatisfied or not discharged such assignee for the purpose of determining his proportionate share of moneys available for distribution as provided in subdivision one of this section shall be treated as a lienor having a lien to the extent of moneys so advanced. An assignee of moneys or any part thereof, due or to become due under a contract for an improvement of real property whose assignment is duly filed subsequent to the filing of the notice of lien or assignment of any other party shall for the purpose of determining his proportionate share of moneys available for distribution, as provided in subdivision one of this section be treated as a lienor having a lien to the extent of moneys actually advanced upon such assignment prior to the filing thereof.
(2) When a building loan mortgage is delivered and recorded a lien shall have priority over advances made on the building loan mortgage after the filing of the notice of lien; but such building loan mortgage, whenever recorded, to the extent of advances made before the filing of such notice of lien, shall have priority over the lien, provided it or the building loan contract contains the covenant required by subdivision three hereof, and provided the building loan contract is filed as required by section twenty-two of this chapter. Every mortgage recorded subsequent to the commencement of the improvement and before the expiration of the period specified in section ten of this chapter for filing of notice of lien after the completion of the improvement shall, to the extent of advances made before the filing of a notice of lien, have priority over liens thereafter filed if it contains the covenant required by subdivision three hereof. The lien of a vendee under an executory contract for the sale of land and the improvement thereof by the construction of a building thereon shall, to the extent of amounts paid thereunder to the vendor before the filing of a notice of lien, have priority over liens filed after the contract or memorandum thereof is recorded as provided in section two hundred ninety-four of the real property law if the recorded contract or memorandum specifies the total amount of payments made by the vendee or required by the contract to be made by the vendee before conveyance of title.
(3) Every such building loan mortgage and every mortgage recorded subsequent to the commencement of the improvement and before the expiration of the period specified in section ten of this chapter for filing of notice of lien after the completion of the improvement shall contain a covenant by the mortgagor that he will receive the advances secured thereby and will hold the right to receive such advances as a trust fund to be applied first for the purpose of paying the cost of improvement, and that he will apply the same first to the payment of the cost of improvement before using any part of the total of the same for any other purpose, provided, however, that if the party executing the building loan contract is not the owner of the fee but is the party to whom such advances are to be made, a building loan contract executed and filed pursuant to section twenty-two of this chapter shall contain the said covenant by such party executing such building loan contract, in place of the covenant by the mortgagor in the building loan mortgage as hereinbefore provided. Nothing in this subdivision shall be considered as imposing upon the lender any obligation to see to the proper application of such advances by the owner; and nothing in this section, nor in that portion of section two of this chapter, defining "cost of improvement" shall be deemed to impair or subordinate the lien of any mortgage containing the covenant required by this subdivision. To the extent that the trust res consists of the right to receive advances as distinct from advances actually received, breach of the trust shall give rise to a civil action only. The covenant provided for herein shall be deemed to have been made and to be in full force and effect if, in lieu of the foregoing provisions, a statement in substantially the following form is contained in the mortgage or contract, "subject to the trust fund provisions of section thirteen of the lien law."
(4) Nothing in subdivision two or three of this section shall apply to any mortgage given by a purchaser for value from an owner making the improvement and recorded prior to the filing of a lien pursuant to this chapter, provided the instrument of conveyance contains the provisions mentioned in subdivision five herein.
(5) No instrument of conveyance recorded subsequent to the commencement of the improvement, and before the expiration of the period specified in section ten of this chapter for filing of notice of lien after the completion of the improvement, shall be valid as against liens filed within a corresponding period of time measured from the recording of such conveyance, unless the instrument contains a covenant by the grantor that he will receive the consideration for such conveyance and will hold the right to receive such consideration as a trust fund to be applied first for the purpose of paying the cost of the improvement and that he will apply the same first to the payment of the cost of the improvement before using any part of the total of the same for any other purpose. Nothing in this subdivision shall be construed as imposing upon the grantee any obligation to see to the proper application of such consideration by the grantor. Nothing in this subdivision shall apply to a deed given by a referee or other person appointed by the court for the sole purpose of selling real property. Nothing in this subdivision shall apply to the consideration received by a grantor who, pursuant to a written agreement entered into and duly recorded prior to the commencement of the improvement, conveys to the person making such improvement, the land upon which such improvement is made. However, such a conveyance shall be subject to liens filed prior thereto, as provided by this chapter. To the extent that the trust res consists of the right to receive the consideration for such conveyance as distinct from the consideration actually received, breach of the trust shall give rise to a civil action only. The covenant provided for herein shall be deemed to have been made and to be in full force and effect if, in lieu of the foregoing provisions, a statement in substantially the following form is contained in the instrument of conveyance, "subject to the trust fund provisions of section thirteen of the lien law." Except that this section shall not apply to any mortgage taken by the home owners' loan corporation, a corporation created under an act of congress, known as the "home owners' loan act of nineteen hundred thirty-three," and the "home owners' loan act of nineteen hundred thirty-three as amended," and said mortgage shall have priority over any and all liens filed subsequent to the date of the recording of said mortgage whether or not the cash and/or bonds for which said mortgage has been taken as security, shall have been advanced at the time of the execution of such mortgage or subsequent thereto, and it shall not be necessary to execute and file any building loan contract or any other contract, in compliance with this section or any part thereof.
(6) Every assignment of moneys, or any part thereof, due or to become due under a contract for the improvement of real property shall contain a covenant by the assignor that he will receive any moneys advanced thereunder by the assignee and will hold the right to receive such moneys as trust funds to be first applied to the payment of trust claims as defined in section seventy-one of the lien law, and that he will apply the same to such payments only, before using any part of the moneys for any other purpose.