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