diff --git a/Applications/ApplicationsLib/Simulation.cpp b/Applications/ApplicationsLib/Simulation.cpp
index 9cd9b1eb7b16420666a521d522702d0a69269721..ded70561e2e6650a4282df0138a9e2f9cd9eb366 100644
--- a/Applications/ApplicationsLib/Simulation.cpp
+++ b/Applications/ApplicationsLib/Simulation.cpp
@@ -10,18 +10,17 @@
  *
  */
 
-#include <spdlog/spdlog.h>
-
 #include "Simulation.h"
 
+#include <spdlog/spdlog.h>
+
 #include "Applications/ApplicationsLib/LinearSolverLibrarySetup.h"
 #include "Applications/ApplicationsLib/ProjectData.h"
 #include "Applications/ApplicationsLib/TestDefinition.h"
 #include "Applications/InSituLib/Adaptor.h"
 #include "BaseLib/ConfigTreeUtil.h"
-#include "BaseLib/DateTools.h"
 #include "BaseLib/FileTools.h"
-#include "BaseLib/RunTime.h"
+#include "BaseLib/PrjProcessing.h"
 #include "NumLib/NumericsConfig.h"
 #include "ProcessLib/TimeLoop.h"
 
@@ -46,13 +45,15 @@ Simulation::Simulation(int argc, char* argv[])
 
 void Simulation::initializeDataStructures(
     std::string&& project, std::vector<std::string>&& xml_patch_file_names,
-    bool reference_path_is_set, std::string&& reference_path, bool nonfatal,
-    std::string&& outdir)
+    bool const reference_path_is_set, std::string&& reference_path,
+    bool const nonfatal, std::string&& outdir, std::string&& mesh_dir,
+    bool const write_prj)
 {
+    std::stringstream prj_stream;
+    BaseLib::prepareProjectFile(prj_stream, project, xml_patch_file_names,
+                                write_prj, outdir);
     auto project_config = BaseLib::makeConfigTree(
-        project, !nonfatal, "OpenGeoSysProject", xml_patch_file_names);
-
-    BaseLib::setProjectDirectory(BaseLib::extractPath(project));
+        project, !nonfatal, "OpenGeoSysProject", prj_stream);
 
     if (!reference_path_is_set)
     {  // Ignore the test_definition section.
@@ -90,7 +91,7 @@ void Simulation::initializeDataStructures(
 #endif
 
     project_data = std::make_unique<ProjectData>(
-        project_config, BaseLib::getProjectDirectory(), outdir);
+        project_config, BaseLib::getProjectDirectory(), outdir, mesh_dir);
 
     INFO("Initialize processes.");
     for (auto& p : project_data->getProcesses())
diff --git a/Applications/ApplicationsLib/Simulation.h b/Applications/ApplicationsLib/Simulation.h
index cc44306af9bd8b0d65add7d0dd165587e3946a85..d477e401ae71b2d9cd1e647311b017f0259254c5 100644
--- a/Applications/ApplicationsLib/Simulation.h
+++ b/Applications/ApplicationsLib/Simulation.h
@@ -28,7 +28,7 @@ public:
     void initializeDataStructures(
         std::string&& project, std::vector<std::string>&& xml_patch_file_names,
         bool reference_path_is_set, std::string&& reference_path, bool nonfatal,
-        std::string&& outdir);
+        std::string&& outdir, std::string&& mesh_dir, bool write_prj);
 
     bool executeSimulation();