Section 5. (a) If the donor consents in a record, an institution may release or modify, in whole or in part, a restriction contained in a gift instrument on the management, investment, duration or purpose of an institutional fund. A release or modification shall not allow a fund to be used for a purpose other than a charitable purpose of the institution.
(b) The court, upon application of an institution, may modify a restriction contained in a gift instrument regarding the management, investment or duration of an institutional fund if the restriction has become impracticable or wasteful, if it impairs the management or investment of the fund or if, because of circumstances not anticipated by the donor, a modification of a restriction will further the purposes of the fund. The attorney general shall be made a party to any such application and resulting proceeding. To the extent practicable, a modification shall be made in accordance with the donor's probable intention.
(c) If a particular charitable purpose or a restriction contained in a gift instrument on the use of an institutional fund becomes unlawful, impracticable, impossible to achieve or wasteful, the court, upon application of an institution, may modify the purpose of the fund or the restriction on the use of the fund in a manner consistent with the charitable purposes expressed in the gift instrument. The attorney general shall be made a party to any such application and resulting proceeding.
(d) The supreme judicial court may by rule or order provide that an application otherwise subject to court approval pursuant to subsections (b) and (c), may be approved by the attorney general if the value of the fund is not greater than such amount as the court may provide or in such other situations as the court may so provide.