diff --git a/src/ComputingTasks.cc b/src/ComputingTasks.cc
index aabcb5fbb1ba22e587a6aea1e81805b20650a978..1c958ed3daa55f04a318836c1e14bab0cac212e5 100644
--- a/src/ComputingTasks.cc
+++ b/src/ComputingTasks.cc
@@ -2400,8 +2400,8 @@ ModelComparisonStatement::writeJsonOutput(ostream& output) const
   output << "}";
 }
 
-PlannerObjectiveStatement::PlannerObjectiveStatement(const PlannerObjective& model_tree_arg) :
-    model_tree {model_tree_arg}
+PlannerObjectiveStatement::PlannerObjectiveStatement(unique_ptr<PlannerObjective> model_tree_arg) :
+    model_tree {move(model_tree_arg)}
 {
 }
 
@@ -2409,8 +2409,8 @@ void
 PlannerObjectiveStatement::checkPass(ModFileStructure& mod_file_struct,
                                      [[maybe_unused]] WarningConsolidation& warnings)
 {
-  assert(model_tree.equation_number() == 1);
-  if (model_tree.exoPresentInEqs())
+  assert(model_tree->equation_number() == 1);
+  if (model_tree->exoPresentInEqs())
     {
       cerr << "ERROR: You cannot include exogenous variables (or variables of undeclared type) in "
               "the planner objective. Please "
@@ -2424,13 +2424,13 @@ PlannerObjectiveStatement::checkPass(ModFileStructure& mod_file_struct,
 const PlannerObjective&
 PlannerObjectiveStatement::getPlannerObjective() const
 {
-  return model_tree;
+  return *model_tree;
 }
 
 void
 PlannerObjectiveStatement::computingPass(const ModFileStructure& mod_file_struct)
 {
-  model_tree.computingPass(max(3, mod_file_struct.order_option), 0, {}, false, false, false);
+  model_tree->computingPass(max(3, mod_file_struct.order_option), 0, {}, false, false, false);
   computing_pass_called = true;
 }
 
@@ -2439,14 +2439,14 @@ PlannerObjectiveStatement::writeOutput(ostream& output, const string& basename,
                                        [[maybe_unused]] bool minimal_workspace) const
 {
   output << "M_.NNZDerivatives_objective = [";
-  for (int i = 1; i < static_cast<int>(model_tree.getNNZDerivatives().size()); i++)
-    output << (i > model_tree.getComputedDerivsOrder() ? -1 : model_tree.getNNZDerivatives()[i])
+  for (int i = 1; i < static_cast<int>(model_tree->getNNZDerivatives().size()); i++)
+    output << (i > model_tree->getComputedDerivsOrder() ? -1 : model_tree->getNNZDerivatives()[i])
            << ";";
   output << "];" << endl << "M_.objective_tmp_nbr = [";
-  for (const auto& temporary_terms_derivative : model_tree.getTemporaryTermsDerivatives())
+  for (const auto& temporary_terms_derivative : model_tree->getTemporaryTermsDerivatives())
     output << temporary_terms_derivative.size() << "; ";
   output << "];" << endl;
-  model_tree.writeStaticFile(basename + ".objective", false, "", {}, false);
+  model_tree->writeStaticFile(basename + ".objective", false, "", {}, false);
 }
 
 void
@@ -2455,9 +2455,9 @@ PlannerObjectiveStatement::writeJsonOutput(ostream& output) const
   output << R"({"statementName": "planner_objective")"
          << ", ";
   if (computing_pass_called)
-    model_tree.writeJsonComputingPassOutput(output, false);
+    model_tree->writeJsonComputingPassOutput(output, false);
   else
-    model_tree.writeJsonOutput(output);
+    model_tree->writeJsonOutput(output);
 
   output << "}";
 }
diff --git a/src/ComputingTasks.hh b/src/ComputingTasks.hh
index 1537811098a76305766e87b60dd4c6943cf2de0d..73b9cf7efdaff65e366914309c2fc7526970c982 100644
--- a/src/ComputingTasks.hh
+++ b/src/ComputingTasks.hh
@@ -20,6 +20,7 @@
 #ifndef _COMPUTINGTASKS_HH
 #define _COMPUTINGTASKS_HH
 
+#include <memory>
 #include <optional>
 #include <ostream>
 
@@ -618,11 +619,11 @@ public:
 class PlannerObjectiveStatement : public Statement
 {
 private:
-  PlannerObjective model_tree;
+  unique_ptr<PlannerObjective> model_tree;
   bool computing_pass_called {false};
 
 public:
-  explicit PlannerObjectiveStatement(const PlannerObjective& model_tree_arg);
+  explicit PlannerObjectiveStatement(unique_ptr<PlannerObjective> model_tree_arg);
   /*! \todo check there are only endogenous variables at the current period in the objective
     (no exogenous, no lead/lag) */
   void checkPass(ModFileStructure& mod_file_struct, WarningConsolidation& warnings) override;
@@ -631,7 +632,7 @@ public:
   void writeOutput(ostream& output, const string& basename, bool minimal_workspace) const override;
   void writeJsonOutput(ostream& output) const override;
   //! Return a reference the Planner Objective model tree
-  const PlannerObjective& getPlannerObjective() const;
+  [[nodiscard]] const PlannerObjective& getPlannerObjective() const;
 };
 
 class BVARDensityStatement : public Statement
diff --git a/src/ParsingDriver.cc b/src/ParsingDriver.cc
index bf40c2ea394c2622f2dd983510764873e6828e98..ae2c74cfe74e62f04e1602e71faa73c74106eb66 100644
--- a/src/ParsingDriver.cc
+++ b/src/ParsingDriver.cc
@@ -2235,7 +2235,7 @@ ParsingDriver::end_planner_objective(expr_t expr)
   expr_t eq = model_tree->AddEqual(expr, model_tree->Zero);
   model_tree->addEquation(eq, location.begin.line);
 
-  mod_file->addStatement(make_unique<PlannerObjectiveStatement>(*planner_objective));
+  mod_file->addStatement(make_unique<PlannerObjectiveStatement>(move(planner_objective)));
 
   // Handle undeclared variables (see #81)
   bool exit_after_write = false;