ll, in the absence of a contract to the contrary, be held by him in trust to be applied by him, first, in payment of all costs, charges and expenses properly incurred by him as incident to the sale or any attempted sale; and, secondly, in discharge of the mortgage-money and costs and other money, if any, due under the mortgage; and the residue of the money so received shall be paid to the person e