This is an appeal in a diversity action by Energy Oils, Inc., et al. (“Energy” or “appellants”) from a judgment in favor of the defendant, The Montana Power Company (“Montana”) entered in the United States District Court for the District of Montana (Battin, J.) after a trial without a jury. At issue for review are the construction and interpretation of two agreements with virtually identical provisions (“Energy-Bond agreements”), pursuant to which Energy assigned certain oil and gas leases to Roland Bond and Lone Star Exploration, Inc. (“Bond-Lone Star group”),1 who in turn subsequently assigned their interests in the leases to Montana (“Bond-Montana agreement”).
*733In the two agreements with the Bond-Lone Star group, Energy reserved overriding royalty interests (“ORRs”)2 aggregating 6.25% which were convertible at Energy’s option, upon recovery by Bond-Lone Star group of certain costs and expenses, into working interests3 aggregating 25%. The questions presented by this appeal are whether (1) under the terms of the Energy-Bond agreements appellants’ option for 25% working interests was triggered by the sale of the leases by the Bond-Lone Star group to Montana for a sum which exceeded the costs and expenses incurred by Bond-Lone Star with respect to the properties; and (2) the receipt by the Bond-Lone Star group, pursuant to its agreement with Montana, of payments of a portion of the purchase price predicated upon the actual production of oil and gas from the properties, constituted “proceeds from the sale of production” within the meaning of the Energy-Bond agreements. Energy claims that under the terms of the agreements with the Bond-Lone Star group, the sale to Montana entitled appellants to exercise the option of obtaining a 25% working interest. Montana denies that the agreements so provide.
Facts
Beginning in 1967, appellants had assembled two blocks of oil and gas leases in northern Montana, one block in what is known as the “Bullwacker” area, and one in the so-called “Rocky Boy” area. After an exploration program Energy decided not to develop the properties but to interest third parties in the exploitation of the leases. Energy’s efforts were successful and led in November 1970 to the consummation of two agreements assigning the Bullwacker and Rocky Boy oil and gas leases, wells and well equipment to the Bond-Lone Star group. One agreement, dated November 3, 1970, pertains to leases in the Bullwacker area, and the other, dated November 11, 1970, relates to the Rocky Boy area. Both agreements reserved ORRs of 6.25% which under certain conditions could be converted at appellants’ option into working interests aggregating 25%. The key provision of the agreements, about which this controversy revolves, reads as follows:
If, as and when Bond and Lone Star, and their respective heirs, successors and assigns, have recovered from the ownership, operation and development of the properties and interests herein assigned and conveyed to them (including by way of illustration, proceeds from the sale of production, contributions to drilling, or advance payments made by a purchaser of production) all of the costs and expenses of whatsoever nature theretofore incurred by them in [acquiring], drilling, developing, completing, operating and maintaining such properties and interest.4 (Emphasis supplied.)
Between the time of its acquisition of the properties in 1970 and September 1975, the Bond-Lone Star group made substantial expenditures in drilling and developing the properties, incurring recoupable costs of $4,387,714 with respect to the Bullwacker area and $1,498,641 with respect to the Rocky Boy area, for a total of $5,886,355. On September 8, 1975, Bond-Lone Star sold the properties to Montana for a purchase price substantially in excess of these costs and expenses. The sales agreement provided for delivery to the Bond-Lone Star group *734of a purchase price5 consisting of three types of payment: (i) a fixed sum in cash; (ii) a fixed sum in unconditional promissory notes maturing and payable at various dates, with interest at 7% per annum; and (iii) a contingent balance which could amount to almost two and one-half times the prior cash and note payments, together with interest at 4% per annum. The third type of payment was contingent upon the amount of oil and gas produced from the properties, or the amount of gas “deemed to be produced” therefrom, and payable only out of the proceeds thereof.
On January 20,1976, Energy brought this suit, seeking a declaration that it became entitled to exercise its option to obtain a 25% working interest in the Bullwacker and Rocky Boy properties when the Bond-Lone Star group sold the leases to Montana. The district court found for Montana on the alternative grounds that (1) the agreement was unambiguous and precluded the interpretation asserted by appellants (Finding XXIX; Conclusion II); or (2) assuming the agreements were ambiguous, the facts indicated no intention by the parties that proceeds of outright sale of the leases would be considered as option-triggering recoupment within the meaning of the agreements, so that any ambiguity must be resolved against appellants. (Conclusion III). At the same time the district court concluded that “there was no evidence to indicate that any portion of the consideration paid by Montana Power was to be allocated to, or was allocated to, any part of the gas reserves or estimated gas reserves in the gas fields.” (Conclusion IV).
Standard of Review
As a general rule, the interpretation of written contracts is a matter of law and reviewable as such on appeal. C. Wright and A. Miller, Federal Practice and Procedure, Civil § 2588 n.47 (1971); Republic Pictures v. Rogers, 213 F.2d 662 (9th Cir.), cert, denied, 348 U.S. 858, 75 S.Ct. 83, 99 L.Ed. 676 (1954). In construing both these agreements we are bound by the fundamental principles of contract construction as set forth in the Revised Code of Montana (“RCM”) 1947 and applied by Montana courts.6 Sections 13-714 and 13-713 read respectively as follows:
Section 13-714:
Contract restricted to its evident object. However broad may be the terms of a contract, it extends only to those things concerning which it appears that the parties intended to contract.
Section 13-713:
A contract may be explained by reference to the circumstances under which it was made and the matter to which it relates.
In Kintner v. Harr, 146 Mont. 461, 408 P.2d 487, 494 (1965), the Montana Supreme Court stated:
It is a fundamental rule that in the construction of contracts the courts may look not only to the language employed, but to the subject-matter and the surrounding circumstances, and may avail themselves of the same light which the parties possessed when the contract was made. (Citation omitted.) To ascertain the intention, regard must be had to the nature of the instrument itself, the condition of the *735parties executing it, and the objects which they had in view.
See also Custer v. Missoula Public Service Co., 91 Mont. 136, 143, 6 P.2d 131 (1931). In interpreting and construing the wording of a contract the purpose of and circumstances leading up to its execution must be seriously weighed. As stated in Liberty National Bank & Trust Co. v. Bank of America National Trust & Savings Association, 218 F.2d 831 (10th Cir. 1955), cited with approval in 4 Williston Contracts § 607 at 379 (3d ed. 1961):
The primary function of judicial interpretation is to ascertain and give effect to the intention of the parties as expressed in their writing [taking] into consideration the writing itself, its purpose and the circumstances leading up to and attending its execution, endeavorpng] to ascertain what the parties purposed and intended by their agreement.
218 F.2d at 840.
The Energy-Bond Agreements
After carefully reading the key provisions of these agreements, we believe that any ambiguity in their meaning is resolved when the purpose and circumstances of their execution are considered, and in view of the extrinsic evidence introduced in aid of their interpretation. Since the district court has held in the first instance that the agreements were unambiguous, we need refer to the extrinsic evidence only if we disagree with or doubt the district court’s construction.
The objective of the assignment of the leases to the Bond-Lone Star group was the exploration and development of the Bullwacker and Rocky Boy properties. This is acknowledged by all the parties. Upon the assignment of the leases the Bond-Lone Star group agreed to bear the entire risks and expenses of exploration and development. The small interest retained by appellants through the reservation of the 6.25% overriding royalty interests was free of these risks and expenses. The agreements also afforded appellants an opportunity to enlarge their interest to a working interest of 25% at such time as the Bond-Lone Star group recovered all of its “costs and expenses.”
The district court interpreted this language to mean that Energy would have a right to convert its ORRs into working interests only when Bond-Lone Star, or their “heirs, successors [or] assigns” recouped their outlays from sources like those enumerated “by way of illustration,” i. e., from revenues derived from the production of oil and gas. It also appeared from the agreement that upon the sale of the leases Montana became a “successor” and an “assign” of Bond and Lone Star, so that appellants would continue to have an option to convert their ORRs into a 25% working interest when Montana recovered both its own and Bond-Lone Star’s development costs from oil and gas revenues.7
Appellants’ main contention is that the agreements unambiguously provide that they have a right to convert when the Bond-Lone Star group recoups its costs and expenses from virtually any source, including the outright sale of the leases. In making this argument they do not differentiate between the fixed sum paid by Montana upon the transfer of title to the leases and the additional contingent installment payment tied to future production of oil and gas from the properties. They argue that the clause “recovered from the ownership, operation and development” has a broad meaning, pointing out that the right to sell is an incident of ownership. They assert that the district court took an unduly restrictive view of the permissible sources of recoupment by ignoring the phrase “by way of illustration” which preceded the enumerated examples of recovery.
Appellants focus upon the word “ownership” which they assert must be construed with and in the light of the provision referring to “operation and development” *736as the basis for recovery of costs and expenses of drilling and maintaining the property. This approach is not very helpful to appellants’ cause. It is true that “ownership” is a collection of rights to use and enjoy property, Henneford v. Silas Mason Co., 300 U.S. 577, 582, 57 S.Ct. 524, 527, 81 L.Ed. 814 (1937); In re Hunter’s Estate, 125 Mont. 315, 236 P.2d 94, 99 (1951), including the right to sell and transmit the same. State v. Gleason, 128 Mont. 485, 277 P.2d 530 (1954). It is also true that from this fundamental principle it follows that without ownership the Bond-Lone Star group could not operate or develop the properties, much less sell them to appellee. But this fact is not decisive of the issue here presented.
The real issue in construing these agreements is not what are the consequences of the transfer of title but what are the sources from which a “payout”8 of costs and expenses is recoverable. The word “ownership” in the agreements takes its color from the words “operation and development” with which it is juxtaposed, as well as from the enumerated examples of sources of recovery. The fact that operation and development are predicated upon ownership in this case is immaterial. The decisive fact is that the recovery of “costs and expenses” is limited to the proceeds of oil and gas produced as a result of operation and development. It should be added that there is neither any express indication in the wording of the agreements nor any extrinsic evidence that a payout is available upon a sale of the properties.
Appellants claim that the three types of payments expressed in the agreements as examples of the source from which recovery of costs may be obtained are in reality monies “recovered from the ownership, operation and development of the properties.” They contend that these specifics do not exclude recovery of costs and expenses from the proceeds of the sale of the ownership. The illustrated categories establish the opposite conclusion. The expanded construction of the agreements suggested by appellants would completely ignore the fundamental purpose of the agreements to exploit, develop and operate the properties without any risk to appellants. Their construction would place a “successor” or “assign” in the position of succeeding to only 75% of the working interest in the properties before he recovered his costs and expenses of development and, to that extent, would deprive him of the right to be a true “successor” and “assign.” As stated in RCM § 13-707:
The whole of a contract is to be taken together, so as to give effect to every part, if reasonably practicable, each clause helping to interpret the other.
See also United States v. Hathaway, 242 F.2d 897 (9th Cir. 1957); Steen v. Rustad, 132 Mont. 96, 313 P.2d 1014, 1018 (1957).
Applying the above principle to the agreements in the light of the objectives to be accomplished, we find no ambiguity which bars a conclusion that the recovery of costs and expenses should be limited to the proceeds of production.9
Extrinsic Evidence
If there were any doubt about the district court’s conclusion in denying that proceeds from transfer of title to the leases constituted a “payout,” such doubt was dispelled by the admission of certain extrinsic evidence. Extrinsic evidence is admissible to enable the court “to put itself as nearly *737as possible in the position of the parties with their knowledge and their ignorance, with their language and their usage.” 3 Corbin Contracts § 555 at 229 (1960); 4 Williston Contracts § 616 (3d ed. 1961).
Expert witnesses called by Montana testified that the Energy-Bond agreements were so-called “farmout” agreements. They confirmed that such arrangements, common in the oil and gas industry, enable the owner of an oil or gas lease to transfer the risks of development to another party while retaining some value in the form of an ORR. While the developer is recouping his costs (and deriving certain tax benefits from the arrangement), the owner has time to determine whether to convert his royalty into a working interest. According to Montana’s witnesses, in a farmout situation the proceeds of the outright sale of the oil and gas-producing property are never deemed to be a cost recoupment triggering conversion rights. To treat them as such would thwart the purposes of the farmout for the reasons outlined.10 Energy conceded that drilling arrangements such as the ones in issue here do generally relegate the drilling party to recovery of costs from the proceeds of production. That the instant agreements also authorized cost recoupment from “advance payments” and “contributions to drilling” in no way indicates that the proceeds from the outright sale of the leases should be included among the possible sources of “payout.”
To the extent that the district court relied upon the above extrinsic evidence as to custom and usage in the oil industry in eliminating any hypothetical ambiguity in the agreements, we find no error. Cf. Martin v. Vector Company, Inc., 498 F.2d 16, 22 (1st Cir. 1974). The court went further, however, by admitting testimony of expert witnesses concerning their opinions as to the legal effect of the agreements and also by permitting a witness to express the subjective intent of the parties in entering into the agreements. The admission of such evidence was erroneous;11 but since the custom and usage evidence justified the court’s finding, the error was harmless. See In re Ginn’s Estate, 136 Mont. 338, 347 P.2d 467 (1959).
The Bond-Montana Agreement
To complete our task we must carefully examine the Bond-Montana agreement. Although we agree with the district court’s construction that the entire purchase price as such is not available under the Energy-Bond agreements for recovery of costs and expenses in triggering the option, we do not subscribe to its conclusion that no part of that purchase price as payable under the Bond-Montana agreement is available for that purpose. Nor can we accept in toto appellants’ alternative argument that the entire purchase price received by the Bond-Lone Star group from Montana is available for that purpose upon the theory that the entire purchase price constitutes “proceeds from the sale of production” within the meaning of the Energy-Bond agreements. We do find merit, however, in appellants’ contention to the extent that it refers to the last installments of the purchase price. This balance was conditional and in addition to the unconditional payments. Referring *738to said balance, section 5 of the Bond-Montana agreement provides:
In addition to the payments to be made under Section 4 hereof, and only if, as, and when, such Oil, Gas, Casinghead Gas, Condensate or Distillate is actually produced or Gas is deemed to have been produced pursuant to Section 7 hereof, the Buyer will pay to the Sellers the Value, as herein defined, of twenty percent (20%) of such Oil, Gas, Casinghead Gas, Condensate or Distillate actually produced, as produced, or of the Gas deemed to have been produced pursuant to Section 7 hereof if not actually produced . . (Emphasis added.)
The last contingent installment is payable at a fixed or determinable price per MCF (one thousand cubic feet) of gas produced in the future which is attributable to specified percentages of the net interests in the properties which were purchased from the Bond-Lone Star group. “Production,” as used in the contract and in the oil and gas industry, refers to oil and gas actually severed from the ground. Christian v. A. A. Oil Corporation, 161 Mont. 420, 506 P.2d 1369, 1373 (1973); Monsanto Co. v. Tyrrell, 537 S.W.2d 135 (Tex.Civ.App.1976); Simmons v. Great Western Drilling Company, 294 S.W.2d 230 (Tex.Civ.App.1956). Thus we have a situation where, according to the literal language of the Energy-Bond lease assignment, Montana as successor of Bond and Lone Star is employing “proceeds from the sale of production” to pay off the last installment of the purchase price of the assignment. Clearly, these proceeds are a source for the recovery of costs and expenses and the fact that they are used for the last installment of the purchase price of the lease assignment is immaterial in triggering appellants’ conversion option into a working interest. It is the source of the proceeds and not the purpose of their use that is decisive of the issue. Such proceeds are not from the sale of ownership but from the sale of production. In fact, the last installment is in the nature of a boot-strap transaction where a portion of the purchase price is paid out of the gas production of the property purchased.
CONCLUSION
Our conclusion, then, is as follows:
(1) The fixed and unconditional portion of the purchase price paid by Montana for transfer of title to the leases and equipment cannot be considered as triggering Energy’s option to convert its 6.25% interest into a 25% working interest.
(2) The balance of the purchase price paid by Montana, which could amount to almost two and one-half times the fixed and unconditional portion of the purchase price, payable in installments predicated upon the value of oil and gas actually produced by Montana from the properties as set forth in section 5 of the Bond-Montana agreement, must be considered as proceeds from the sale of oil production. As such, these proceeds are the source of recovery of costs and expenses of operating the properties and triggered Energy’s option to convert. The record does not disclose the date when the option was triggered under the above conditions, nor the amount of costs and expenses which must be contributed by Energy, nor the net amount of recovery to which Energy is entitled.
The judgment of the district court is affirmed in part and reversed in part and the case is therefore remanded for further proceedings between the parties in accordance with this opinion.
. Subsequent to the assignments Bond Oil Corp. acquired a portion of Roland Bond’s interest in the properties before it was dissolved in June 1975. Bond’s assets were transferred to Bond and four other persons. (Finding VII). Lone Star Exploration, Inc., was also dissolved in June 1975 and its interest in the properties was acquired by E. E. Fogelson, Lone Star’s sole shareholder. (Finding VI). For the sake of brevity, these persons are referred to as “the Bond-Lone Star group” throughout this opinion.
. An ‘overriding royalty” is a share of the production from the lease which is retained by the assignor, but bears none of the risks or costs of development. See 7 Williams and Meyers, Oil and Gas Law, Manual of Oil and Gas Terms at 410; deposition of John Roach at 10.
. A "working interest” confers greater control over the operation of the lease than does an ORR, but is also charged with the risks and expehses of development and exploration.
. The word “acquiring” appears in the Bullwacker but not in the Rocky Boy agreement. According to the unchallenged finding of the district court (XVI), its inclusion in the Bullwacker agreement was intended by the parties to express the intention that certain monies paid by the Boni-Lone Star group to Energy in the initial transaction be included in the total costs that could be recouped. Montana does not claim that its succession to the interests of the Bond-Lone Star group entitles it to recoup its costs of “acquiring” the Bullwacker property. See note 9, infra.
. The actual amount of the purchase price was contained in an exhibit which the lower court sealed from public disclosure.
. Sitting in diversity, we apply the law of the forum state, including its rules on choice of law, to this case. Erie Railroad Company v. Tompkins, 304 U.S. 64, 58 S.Ct. 817, 82 L.Ed. 1188 (1938); Klaxon Co. v. Stentor Electric Mfg. Co., 313 U.S. 487, 61 S.Ct. 1020, 85 L.Ed. 1477 (1941). In the absence of an effective choice of law by the parties, the law to be applied is that of the state with “the most significant relationship to the transaction and the parties.” Restatement (Second) of Conflict of Laws, §§ 188, 189; cf. In re Dauenhauer’s Estate, 167 Mont. 83, 535 P.2d 1005 (1975). By this criterion, the Energy-Bond agreement, concerning interests in land located in Montana, should be governed by the law of that state. Restatement (Second) of Conflict of Laws, supra, § 189. The above principles would also mandate the application of Montana law to the Bond-Montana agreement which, in any event, explicitly so provides. Cf. Restatement (Second) of Conflict of Laws, § 187(1). See, generally, R. Leflar, American Conflicts of Law, § 165 (3d ed. 1977).
. As of March 31, 1977, costs to be recouped amounted to $8,210,570 from the Bullwacker area and $2,868,751 from the Rocky Boy area.
. In the parlance of the oil and gas industry, “payout” refers to the recoupment of costs of production by a driller or developer pursuant to an agreement like the ones in issue here.
. Energy contends that the word “acquiring” in the Bullwacker agreement cannot be reconciled with the interpretation of the lease assignments according to which Montana became a “successor” of the Bond-Lone Star group. Energy points out that if Montana truly became a successor, it should be entitled to recoup its costs of “acquiring” the Bullwacker lease, a right which Montana does not claim. We do not agree. As indicated in note 4, supra, the district court found that the word “acquiring” was included with the specific purpose of allowing a limited recovery of the costs of acquisition in the “initial transaction.” Thus, the word refers to the amount that can be recovered, but not the source from which recovery can occur.
. Energy points out that John Roach, a defense witness who had a role in drafting the agreements, stated that they were “not farm-outs at all.” However, study of his testimony in context reveals that his statement was based on a distinction between the Energy-Bond agreements and a “typical” farmout that is not material to recovery of costs. Moreover, the district court was entitled to rely on the testimony of other witnesses on this point.
. The construction of written agreements belongs to the court (9 Wigmore on Evidence § 2556 at 522 (3d ed. 1940); Lynes v. Northern Pacific R. Co., 43 Mont. 317, 117 P. 81 (1911)); and witnesses should not have been permitted to testify as to the legal effect of the agreements. Marx & Co., Inc. v. Diners’ Club, Inc., 550 F.2d 505, 509-510 (2d Cir. 1977). In addition, at least one defense witness was permitted to testify as to the unexpressed subjective intent of the parties, and this, too, was improper. 3 Corbin Contracts § 543 at 139 (1960); Restatement (Second) of Contracts § 238, comment c. (Tentative Draft No. 7, 1973).