(a) Such lien as to the land and buildings or improvements thereon, shall have priority over all other liens, mortgages, or incumbrances created subsequent to the commencement of work on the building or improvement. Except to the extent provided in subsection (b) below, all liens, mortgages, and incumbrances (in this section, "mortgages and other liens") created prior to the commencement of such work shall have priority over all liens for such work. Enforcement of such lien of a mechanic, materialman, or other person created by Section 35-11-210 (in this section, "mechanic or materialman lien") shall not affect any prior mortgage or other lien, and the purchaser in connection with the enforcement of such mechanic or materialman lien shall take the property subject to such prior mortgages and other liens of which the purchaser has actual or constructive notice on the date of the purchase. Foreclosure of any prior mortgage or other lien shall terminate and extinguish such subordinate mechanic or materialman lien or other interest as to the land and the buildings and improvements thereon, whether or not at the time of such foreclosure such lien or interest has been perfected in accordance with the provisions of this division, and the mechanic, materialman, or other person thereafter shall have, to the extent of his lawful claim under this division, the statutory right of redemption afforded under applicable redemption laws to a judgment creditor whose judgment was recorded on the date such work was commenced and such rights in any excess proceeds received by the foreclosing lienholder as provided by law.
(b) As to liens, mortgages, or incumbrances created prior to the commencement of the work, the lien for such work shall have priority only against the building or improvement, the product of such work which is an entirety, separable from the land, building, or improvement subject of the prior lien, mortgage, or incumbrance, and which can be removed therefrom without impairing the value or security of any prior lien, mortgage or incumbrance; and the person entitled to such lien may have it enforced, at any time prior to the foreclosure of such prior lien, mortgage, or incumbrance, by a sale of such buildings or improvement under the provisions of this division and the purchaser may, within a reasonable time thereafter, remove the same. If such mechanic or materialman lien for such work is not enforced prior to such foreclosure, the mechanic or materialman lien shall be terminated and extinguished and after such foreclosure, the mechanic, materialman, or other person who held such mechanic or materialman lien thereafter shall have the statutory right of redemption and such rights in excess proceeds to the extent provided in subsection (a) above.
(c) The provisions of this section clarify and confirm the intent of the Legislature regarding existing law governing the matters contained in this section. The provisions of this section shall apply to all mortgages and other liens and to all liens of a mechanic, materialman, or other person created by Section 35-11-210 existing on February 23, 1990, and those created or arising after February 23, 1990.