Wherever the court sees fit, and in particular where the encroaching owner is not an owner beneficially entitled to the fee simple free from encumbrances, the court may determine—
(a) by whom and in what proportions the compensation is to be paid in the first instance, and is to be borne ultimately; and
(b) to whom, for whose benefit and upon what limitations the conveyance, transfer, or lease of the subject land or grant in respect of the land is to be made.