diff --git a/App/main.cpp b/App/main.cpp
index fa2d0aedbc6635fbb00a46ef6357fe1f6073bfb5..b01c73340ca7f9b02cdaecbe7cc81f2a9a2d0817 100644
--- a/App/main.cpp
+++ b/App/main.cpp
@@ -16,7 +16,6 @@
 #include "App/MessageHandler.h"
 #include "GUI/Application/ApplicationSettings.h"
 #include "GUI/Model/Data/SessionData.h"
-#include "GUI/Model/Device/InstrumentLibrary.h"
 #include "GUI/Util/Path.h"
 #include "GUI/View/Global/Globals.h"
 #include "GUI/View/Loaders/DataLoaderUtil.h"
@@ -47,7 +46,6 @@ int main(int argc, char* argv[])
 
     ApplicationSettings applicationSettings;
     SessionData GSession; // used globally
-    InstrumentLibrary instrumentLibrary;
 
     qInstallMessageHandler(MessageHandler);
 
@@ -60,9 +58,7 @@ int main(int argc, char* argv[])
     if (!QDir().exists(dir))
         QDir().mkpath(dir);
 
-    instrumentLibrary.load();
-
-    MainWindow win(&instrumentLibrary);
+    MainWindow win;
     GUI::Global::mainWindow = &win;
     if (options.find("geometry"))
         win.resize(options.mainWindowSize());
@@ -70,9 +66,5 @@ int main(int argc, char* argv[])
         win.loadProject(options.projectFile());
     win.show();
 
-    int result = QApplication::exec();
-
-    instrumentLibrary.saveIfModified();
-
-    return result;
+    return QApplication::exec();
 }
diff --git a/GUI/View/Instrument/InstrumentListView.cpp b/GUI/View/Instrument/InstrumentListView.cpp
index d625a3ae5b1d6d24de7b437a5b248446f805627f..f8d7aaa142e8b932856ede5be2a8a50d2f506b51 100644
--- a/GUI/View/Instrument/InstrumentListView.cpp
+++ b/GUI/View/Instrument/InstrumentListView.cpp
@@ -15,23 +15,21 @@
 #include "GUI/View/Instrument/InstrumentListView.h"
 #include "GUI/Model/Data/SessionData.h"
 #include "GUI/Model/Device/InstrumentItems.h"
-#include "GUI/Model/Device/InstrumentLibrary.h"
 #include "GUI/Model/Project/ProjectDocument.h"
 #include "GUI/View/Global/Globals.h"
 #include "GUI/View/Instrument/InstrumentLibraryEditor.h"
 #include "GUI/View/Instrument/InstrumentListModel.h"
-#include <QAction>
-#include <QListView>
 #include <QMessageBox>
 #include <QVBoxLayout>
+#include <QAction>
 
-InstrumentListView::InstrumentListView(ProjectDocument* document,
-                                       InstrumentLibrary* instrumentLibrary, QWidget* parent,
+InstrumentListView::InstrumentListView(ProjectDocument* document, QWidget* parent,
                                        Qt::WindowFlags f)
     : QWidget(parent, f)
     , m_document(document)
-    , m_instrumentLibrary(instrumentLibrary)
 {
+    m_instrumentLibrary.load();
+
     setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Expanding);
 
     auto* layout = new QVBoxLayout(this);
@@ -130,6 +128,11 @@ InstrumentListView::InstrumentListView(ProjectDocument* document,
     ensureItemSelected();
 }
 
+InstrumentListView::~InstrumentListView()
+{
+    m_instrumentLibrary.saveIfModified();
+}
+
 QSize InstrumentListView::sizeHint() const
 {
     return QSize(170, 400);
@@ -220,7 +223,7 @@ void InstrumentListView::onStoreInLibrary()
     QModelIndex idx = m_listView->selectionModel()->selectedIndexes().front();
     InstrumentItem* instrument = m_model->instrumentItemForIndex(idx);
 
-    InstrumentLibraryEditor dlg(GUI::Global::mainWindow, m_instrumentLibrary);
+    InstrumentLibraryEditor dlg(GUI::Global::mainWindow, &m_instrumentLibrary);
     dlg.setGisasEnabled(m_document->functionalities().testFlag(ProjectDocument::Gisas));
     dlg.setOffspecEnabled(m_document->functionalities().testFlag(ProjectDocument::Offspec));
     dlg.setSpecularEnabled(m_document->functionalities().testFlag(ProjectDocument::Specular));
@@ -230,13 +233,13 @@ void InstrumentListView::onStoreInLibrary()
 
 void InstrumentListView::onLoadFromLibrary()
 {
-    if (m_instrumentLibrary->isEmpty()) {
+    if (m_instrumentLibrary.isEmpty()) {
         QMessageBox::information(GUI::Global::mainWindow, "Select from library",
                                  "The library does not contain instruments so far.");
         return;
     }
 
-    InstrumentLibraryEditor dlg(GUI::Global::mainWindow, m_instrumentLibrary);
+    InstrumentLibraryEditor dlg(GUI::Global::mainWindow, &m_instrumentLibrary);
     dlg.setGisasEnabled(m_document->functionalities().testFlag(ProjectDocument::Gisas));
     dlg.setOffspecEnabled(m_document->functionalities().testFlag(ProjectDocument::Offspec));
     dlg.setSpecularEnabled(m_document->functionalities().testFlag(ProjectDocument::Specular));
diff --git a/GUI/View/Instrument/InstrumentListView.h b/GUI/View/Instrument/InstrumentListView.h
index d05e5c417dfb40d92a3c9f95c723261abab826fb..9484cd3c229d58ec213716e0f441ae72292ff1a1 100644
--- a/GUI/View/Instrument/InstrumentListView.h
+++ b/GUI/View/Instrument/InstrumentListView.h
@@ -15,15 +15,12 @@
 #ifndef BORNAGAIN_GUI_VIEW_INSTRUMENT_INSTRUMENTLISTVIEW_H
 #define BORNAGAIN_GUI_VIEW_INSTRUMENT_INSTRUMENTLISTVIEW_H
 
-#include <QWidget>
+#include "GUI/Model/Device/InstrumentLibrary.h"
+#include <QListView>
 
-class InstrumentModel;
-class QAction;
-class QListView;
 class InstrumentItem;
 class InstrumentListModel;
 class ProjectDocument;
-class InstrumentLibrary;
 
 //! Instrument selector on the left side of InstrumentView.
 
@@ -31,8 +28,9 @@ class InstrumentListView : public QWidget {
     Q_OBJECT
 
 public:
-    InstrumentListView(ProjectDocument* document, InstrumentLibrary* instrumentLibrary,
-                       QWidget* parent = nullptr, Qt::WindowFlags f = Qt::WindowFlags());
+    InstrumentListView(ProjectDocument* document, QWidget* parent = nullptr,
+                       Qt::WindowFlags f = Qt::WindowFlags());
+    ~InstrumentListView();
 
     QSize sizeHint() const override;
     QSize minimumSizeHint() const override;
@@ -65,10 +63,10 @@ private:
     void ensureItemSelected();
 
 private:
+    InstrumentLibrary m_instrumentLibrary;
     ProjectDocument* m_document;
     QListView* m_listView;
     InstrumentListModel* m_model;
-    InstrumentLibrary* m_instrumentLibrary;
     QAction* m_newGisasAction;
     QAction* m_newOffspecAction;
     QAction* m_newSpecularAction;
diff --git a/GUI/View/Instrument/InstrumentView.cpp b/GUI/View/Instrument/InstrumentView.cpp
index 5fe7fe161da8883bd072f0f6666c690a70df4d93..084e49295774ef2616e8bf939a8d8e04ec07e60c 100644
--- a/GUI/View/Instrument/InstrumentView.cpp
+++ b/GUI/View/Instrument/InstrumentView.cpp
@@ -30,8 +30,7 @@
 #include <QScrollArea>
 #include <QTextEdit>
 
-InstrumentView::InstrumentView(QWidget* parent, ProjectDocument* document,
-                               InstrumentLibrary* instrumentLibrary)
+InstrumentView::InstrumentView(QWidget* parent, ProjectDocument* document)
     : QWidget(parent)
     , m_document(document)
 {
@@ -39,7 +38,7 @@ InstrumentView::InstrumentView(QWidget* parent, ProjectDocument* document,
     setProperty("stylable", true); // for stylesheet addressing
 
     auto* horizontalLayout = new QHBoxLayout;
-    m_instrumentListView = new InstrumentListView(document, instrumentLibrary, this);
+    m_instrumentListView = new InstrumentListView(document, this);
     horizontalLayout->addWidget(m_instrumentListView);
 
     m_scrollArea = new QScrollArea(this);
diff --git a/GUI/View/Instrument/InstrumentView.h b/GUI/View/Instrument/InstrumentView.h
index 1ae8ab39a44f570345b7df4af28281a39f51e51d..47b70e1bfca89e05996f8cc9e78476386cdfa277 100644
--- a/GUI/View/Instrument/InstrumentView.h
+++ b/GUI/View/Instrument/InstrumentView.h
@@ -21,14 +21,12 @@
 class InstrumentItem;
 class InstrumentListView;
 class ProjectDocument;
-class InstrumentLibrary;
 
 class InstrumentView : public QWidget {
     Q_OBJECT
 
 public:
-    InstrumentView(QWidget* parent, ProjectDocument* document,
-                   InstrumentLibrary* instrumentLibrary);
+    InstrumentView(QWidget* parent, ProjectDocument* document);
 
 protected:
     void showEvent(QShowEvent*) override;
diff --git a/GUI/View/Main/MainWindow.cpp b/GUI/View/Main/MainWindow.cpp
index c2c13ffd7d8edbd396452e0a44a0f99c06253af5..4dd79cfd949b54b20450390347c841bf2316ae9a 100644
--- a/GUI/View/Main/MainWindow.cpp
+++ b/GUI/View/Main/MainWindow.cpp
@@ -41,7 +41,7 @@
 #include <QStatusBar>
 #include <QToolButton>
 
-MainWindow::MainWindow(InstrumentLibrary* instrumentLibrary)
+MainWindow::MainWindow()
     : QMainWindow(nullptr)
     , m_progressBar(new QProgressBar)
     , m_viewSelectionButtons(new QButtonGroup(this))
@@ -57,7 +57,6 @@ MainWindow::MainWindow(InstrumentLibrary* instrumentLibrary)
     , m_projectSettingsView(nullptr)
     , m_jobView(nullptr)
     , m_sessionModelView(nullptr)
-    , m_instrumentLibrary(instrumentLibrary)
 {
     auto* centralWidget = new QWidget(this);
     auto* mainLayout = new QHBoxLayout(centralWidget);
@@ -233,7 +232,7 @@ void MainWindow::initViews()
 
     if (gSessionData->projectDocument.has_value()) {
         auto* doc = gSessionData->projectDocument.value();
-        m_instrumentView = new InstrumentView(this, doc, m_instrumentLibrary);
+        m_instrumentView = new InstrumentView(this, doc);
         m_sampleView = new SampleView(this, doc);
         m_importDataView = new ImportDataView(this, doc);
         m_simulationView = new SimulationView(this, doc);
diff --git a/GUI/View/Main/MainWindow.h b/GUI/View/Main/MainWindow.h
index f6e5eac8c04e1c03fd48db75b9d2b60134f5ed6f..7adc8b13442818dbbde96b55be7440c05a855222 100644
--- a/GUI/View/Main/MainWindow.h
+++ b/GUI/View/Main/MainWindow.h
@@ -28,7 +28,6 @@ class SessionModelView;
 class SimulationView;
 class UpdateNotifier;
 class WelcomeView;
-class InstrumentLibrary;
 
 class QButtonGroup;
 class QProgressBar;
@@ -43,7 +42,7 @@ class MainWindow : public QMainWindow {
 public:
     enum ViewId { WELCOME, PROJECT, INSTRUMENT, SAMPLE, IMPORT, SIMULATION, JOB, SESSIONMODEL };
 
-    explicit MainWindow(InstrumentLibrary* instrumentLibrary);
+    explicit MainWindow();
     ~MainWindow() override;
 
     QProgressBar* progressBar();
@@ -105,7 +104,6 @@ private:
     ProjectSettingsView* m_projectSettingsView;
     JobView* m_jobView;
     SessionModelView* m_sessionModelView;
-    InstrumentLibrary* m_instrumentLibrary;
 };
 
 #endif // BORNAGAIN_GUI_VIEW_MAIN_MAINWINDOW_H