diff --git a/Modules/SegmentationUI/Qmitk/QmitkMultiLabelInspector.cpp b/Modules/SegmentationUI/Qmitk/QmitkMultiLabelInspector.cpp
index 6311220ef5..2b2002ec07 100644
--- a/Modules/SegmentationUI/Qmitk/QmitkMultiLabelInspector.cpp
+++ b/Modules/SegmentationUI/Qmitk/QmitkMultiLabelInspector.cpp
@@ -1,1131 +1,1139 @@
 /*============================================================================
 
 The Medical Imaging Interaction Toolkit (MITK)
 
 Copyright (c) German Cancer Research Center (DKFZ)
 All rights reserved.
 
 Use of this source code is governed by a 3-clause BSD license that can be
 found in the LICENSE file.
 
 ============================================================================*/
 
 #include <QmitkMultiLabelInspector.h>
 
 // mitk
 #include <mitkRenderingManager.h>
 #include <mitkLabelSetImageHelper.h>
 #include <mitkDICOMSegmentationPropertyHelper.h>
 
 // Qmitk
 #include <QmitkMultiLabelTreeModel.h>
 #include <QmitkLabelColorItemDelegate.h>
 #include <QmitkLabelToggleItemDelegate.h>
 #include <QmitkStyleManager.h>
 
 // Qt
 #include <QMenu>
 #include <QLabel>
 #include <QWidgetAction>
 #include <QMessageBox>
 
 #include <ui_QmitkMultiLabelInspectorControls.h>
 
 QmitkMultiLabelInspector::QmitkMultiLabelInspector(QWidget* parent/* = nullptr*/)
   : QWidget(parent), m_Controls(new Ui::QmitkMultiLabelInspector)
 {
   m_Controls->setupUi(this);
 
   m_Model = new QmitkMultiLabelTreeModel(this);
 
   m_Controls->view->setModel(m_Model);
 
   m_ColorItemDelegate = new QmitkLabelColorItemDelegate(this);
 
   auto visibleIcon = QmitkStyleManager::ThemeIcon(QLatin1String(":/Qmitk/visible.svg"));
   auto invisibleIcon = QmitkStyleManager::ThemeIcon(QLatin1String(":/Qmitk/invisible.svg"));
   m_VisibilityItemDelegate = new QmitkLabelToggleItemDelegate(visibleIcon, invisibleIcon, this);
 
   auto lockIcon = QmitkStyleManager::ThemeIcon(QLatin1String(":/Qmitk/lock.svg"));
   auto unlockIcon = QmitkStyleManager::ThemeIcon(QLatin1String(":/Qmitk/unlock.svg"));
   m_LockItemDelegate = new QmitkLabelToggleItemDelegate(lockIcon, unlockIcon, this);
 
   auto* view = this->m_Controls->view;
   view->setItemDelegateForColumn(1, m_LockItemDelegate);
   view->setItemDelegateForColumn(2, m_ColorItemDelegate);
   view->setItemDelegateForColumn(3, m_VisibilityItemDelegate);
 
   auto* header = view->header();
   header->setSectionResizeMode(0,QHeaderView::Stretch);
   header->setSectionResizeMode(1, QHeaderView::ResizeToContents);
   header->setSectionResizeMode(2, QHeaderView::ResizeToContents);
   header->setSectionResizeMode(3, QHeaderView::ResizeToContents);
   view->setContextMenuPolicy(Qt::CustomContextMenu);
 
   connect(m_Model, &QAbstractItemModel::modelReset, this, &QmitkMultiLabelInspector::OnModelReset);
   connect(view->selectionModel(), SIGNAL(selectionChanged(const QItemSelection&, const QItemSelection&)), SLOT(OnChangeModelSelection(const QItemSelection&, const QItemSelection&)));
   connect(view, &QAbstractItemView::customContextMenuRequested, this, &QmitkMultiLabelInspector::OnContextMenuRequested);
   connect(view, &QAbstractItemView::doubleClicked, this, &QmitkMultiLabelInspector::OnItemDoubleClicked);
 }
 
 QmitkMultiLabelInspector::~QmitkMultiLabelInspector()
 {
   delete m_Controls;
 }
 
 void QmitkMultiLabelInspector::Initialize()
 {
   m_LastValidSelectedLabels = {};
   m_ModelManipulationOngoing = false;
   m_Model->SetSegmentation(m_Segmentation);
   m_Controls->view->expandAll();
 
   m_LastValidSelectedLabels = {};
 
   //in singel selection mode, if at least one label exist select the first label of the mode.
   if (m_Segmentation.IsNotNull() && !this->GetMultiSelectionMode() && m_Segmentation->GetTotalNumberOfLabels() > 0)
   {
     auto firstIndex = m_Model->FirstLabelInstanceIndex(QModelIndex());
     auto labelVariant = firstIndex.data(QmitkMultiLabelTreeModel::ItemModelRole::LabelInstanceValueRole);
 
     if (labelVariant.isValid())
     {
       this->SetSelectedLabel(labelVariant.value<LabelValueType>());
       m_Controls->view->selectionModel()->setCurrentIndex(firstIndex, QItemSelectionModel::NoUpdate);
     }
   }
 }
 
 void QmitkMultiLabelInspector::SetMultiSelectionMode(bool multiMode)
 {
   m_Controls->view->setSelectionMode(multiMode
      ? QAbstractItemView::SelectionMode::MultiSelection
      : QAbstractItemView::SelectionMode::SingleSelection);
 }
 
 bool QmitkMultiLabelInspector::GetMultiSelectionMode() const
 {
   return QAbstractItemView::SelectionMode::MultiSelection == m_Controls->view->selectionMode();
 }
 
 void QmitkMultiLabelInspector::SetAllowVisibilityModification(bool visibilityMod)
 {
   m_AllowVisibilityModification = visibilityMod;
   this->m_Model->SetAllowVisibilityModification(visibilityMod);
 }
 
 void QmitkMultiLabelInspector::SetAllowLabelModification(bool labelMod)
 {
   m_AllowLabelModification = labelMod;
 }
 
 bool QmitkMultiLabelInspector::GetAllowVisibilityModification() const
 {
   return m_AllowVisibilityModification;
 }
 
 void QmitkMultiLabelInspector::SetAllowLockModification(bool lockMod)
 {
   m_AllowLockModification = lockMod;
   this->m_Model->SetAllowLockModification(lockMod);
 }
 
 bool QmitkMultiLabelInspector::GetAllowLockModification() const
 {
   return m_AllowLockModification;
 }
 
 bool QmitkMultiLabelInspector::GetAllowLabelModification() const
 {
   return m_AllowLabelModification;
 }
 
 void QmitkMultiLabelInspector::SetDefaultLabelNaming(bool defaultLabelNaming)
 {
   m_DefaultLabelNaming = defaultLabelNaming;
 }
 
 void QmitkMultiLabelInspector::SetMultiLabelSegmentation(mitk::LabelSetImage* segmentation)
 {
   if (segmentation != m_Segmentation)
   {
     m_Segmentation = segmentation;
     this->Initialize();
   }
 }
 
 bool QmitkMultiLabelInspector::GetModelManipulationOngoing() const
 {
   return m_ModelManipulationOngoing;
 }
 
 void QmitkMultiLabelInspector::OnModelReset()
 {
   m_LastValidSelectedLabels = {};
   m_ModelManipulationOngoing = false;
 }
 
 bool EqualLabelSelections(const QmitkMultiLabelInspector::LabelValueVectorType& selection1, const QmitkMultiLabelInspector::LabelValueVectorType& selection2)
 {
   if (selection1.size() == selection2.size())
   {
     // lambda to compare node pointer inside both lists
     return std::is_permutation(selection1.begin(), selection1.end(), selection2.begin());
   }
 
   return false;
 }
 
 void QmitkMultiLabelInspector::SetSelectedLabels(const LabelValueVectorType& selectedLabels)
 {
   if (EqualLabelSelections(this->GetSelectedLabels(), selectedLabels))
   {
     return;
   }
 
   this->UpdateSelectionModel(selectedLabels);
   m_LastValidSelectedLabels = selectedLabels;
 }
 
 void QmitkMultiLabelInspector::UpdateSelectionModel(const LabelValueVectorType& selectedLabels)
 {
   // create new selection by retrieving the corresponding indices of the labels
   QItemSelection newCurrentSelection;
   for (const auto& labelID : selectedLabels)
   {
     QModelIndexList matched = m_Model->match(m_Model->index(0, 0), QmitkMultiLabelTreeModel::ItemModelRole::LabelInstanceValueRole, QVariant(labelID), 1, Qt::MatchRecursive);
     if (!matched.empty())
     {
       newCurrentSelection.select(matched.front(), matched.front());
     }
   }
 
   m_Controls->view->selectionModel()->select(newCurrentSelection, QItemSelectionModel::ClearAndSelect|QItemSelectionModel::Current);
 }
 
 void QmitkMultiLabelInspector::SetSelectedLabel(mitk::LabelSetImage::LabelValueType selectedLabel)
 {
   this->SetSelectedLabels({ selectedLabel });
 }
 
 QmitkMultiLabelInspector::LabelValueVectorType QmitkMultiLabelInspector::GetSelectedLabelsFromSelectionModel() const
 {
   LabelValueVectorType result;
   QModelIndexList selectedIndexes = m_Controls->view->selectionModel()->selectedIndexes();
   for (const auto& index : qAsConst(selectedIndexes))
   {
     QVariant qvariantDataNode = m_Model->data(index, QmitkMultiLabelTreeModel::ItemModelRole::LabelInstanceValueRole);
     if (qvariantDataNode.canConvert<mitk::LabelSetImage::LabelValueType>())
     {
       result.push_back(qvariantDataNode.value<mitk::LabelSetImage::LabelValueType>());
     }
   }
   return result;
 }
 
 QmitkMultiLabelInspector::LabelValueVectorType QmitkMultiLabelInspector::GetSelectedLabels() const
 {
   return m_LastValidSelectedLabels;
 }
 
 mitk::Label* QmitkMultiLabelInspector::GetFirstSelectedLabelObject() const
 {
   if (m_LastValidSelectedLabels.empty() || m_Segmentation.IsNull())
     return nullptr;
 
   return m_Segmentation->GetLabel(m_LastValidSelectedLabels.front());
 }
 
 void QmitkMultiLabelInspector::OnChangeModelSelection(const QItemSelection& /*selected*/, const QItemSelection& /*deselected*/)
 {
   if (!m_ModelManipulationOngoing)
   {
     auto internalSelection = GetSelectedLabelsFromSelectionModel();
     if (internalSelection.empty())
     {
       //empty selections are not allowed by UI interactions, there should always be at least on label selected.
       //but selections are e.g. also cleared if the model is updated (e.g. due to addition of labels)
       UpdateSelectionModel(m_LastValidSelectedLabels);
     }
     else
     {
       m_LastValidSelectedLabels = internalSelection;
       emit CurrentSelectionChanged(GetSelectedLabels());
     }
   }
 }
 
 void QmitkMultiLabelInspector::WaitCursorOn() const
 {
   QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
 }
 
 void QmitkMultiLabelInspector::WaitCursorOff() const
 {
   this->RestoreOverrideCursor();
 }
 
 void QmitkMultiLabelInspector::RestoreOverrideCursor() const
 {
   QApplication::restoreOverrideCursor();
 }
 
 mitk::Label* QmitkMultiLabelInspector::GetCurrentLabel() const
 {
   auto currentIndex = this->m_Controls->view->currentIndex();
   auto labelVariant = currentIndex.data(QmitkMultiLabelTreeModel::ItemModelRole::LabelDataRole);
   mitk::Label::Pointer currentIndexLabel = nullptr;
 
   if (labelVariant.isValid())
   {
     auto uncastedLabel = labelVariant.value<void*>();
     currentIndexLabel = static_cast<mitk::Label*>(uncastedLabel);
   }
   return currentIndexLabel;
 }
 
 QmitkMultiLabelInspector::IndexLevelType QmitkMultiLabelInspector::GetCurrentLevelType() const
 {
   auto currentIndex = this->m_Controls->view->currentIndex();
   auto labelInstanceVariant = currentIndex.data(QmitkMultiLabelTreeModel::ItemModelRole::LabelInstanceDataRole);
   auto labelVariant = currentIndex.data(QmitkMultiLabelTreeModel::ItemModelRole::LabelDataRole);
 
   if (labelInstanceVariant.isValid() )
   {
     return IndexLevelType::LabelInstance;
   }
   else if (labelVariant.isValid())
   {
     return IndexLevelType::LabelClass;
   }
 
   return IndexLevelType::Group;
 }
 
 QmitkMultiLabelInspector::LabelValueVectorType QmitkMultiLabelInspector::GetCurrentlyAffactedLabelInstances() const
 {
   auto currentIndex = m_Controls->view->currentIndex();
   return m_Model->GetLabelsInSubTree(currentIndex);
 }
 
 QmitkMultiLabelInspector::LabelValueVectorType QmitkMultiLabelInspector::GetLabelInstancesOfSelectedFirstLabel() const
 {
   if (m_Segmentation.IsNull())
     return {};
 
   if (this->GetSelectedLabels().empty())
     return {};
 
   const auto index = m_Model->indexOfLabel(this->GetSelectedLabels().front());
   return m_Model->GetLabelInstancesOfSameLabelClass(index);
 }
 
 mitk::Label* QmitkMultiLabelInspector::AddNewLabelInstanceInternal(mitk::Label* templateLabel)
 {
   if (!m_AllowLabelModification)
     mitkThrow() << "QmitkMultiLabelInspector is configured incorrectly. Set AllowLabelModification to true to allow the usage of AddNewLabelInstance.";
 
   if (nullptr == templateLabel)
     mitkThrow() << "QmitkMultiLabelInspector is in an invalid state. AddNewLabelInstanceInternal was called with a non existing label as template";
 
   auto groupID = m_Segmentation->GetGroupIndexOfLabel(templateLabel->GetValue());
   auto group = m_Segmentation->GetLabelSet(groupID);
   m_ModelManipulationOngoing = true;
   auto newLabel = group->AddLabel(templateLabel, true);
   m_ModelManipulationOngoing = false;
   this->SetSelectedLabel(newLabel->GetValue());
 
   auto index = m_Model->indexOfLabel(newLabel->GetValue());
   if (index.isValid())
   {
     m_Controls->view->expand(index.parent());
   }
   else
   {
     mitkThrow() << "Segmentation or QmitkMultiLabelTreeModel is in an invalid state. Label is not present in the model after adding it to the segmentation. Label value: " << newLabel->GetValue();
   }
 
   emit ModelUpdated();
   return newLabel;
 }
 
 mitk::Label* QmitkMultiLabelInspector::AddNewLabelInstance()
 {
   auto currentLabel = this->GetFirstSelectedLabelObject();
   if (nullptr == currentLabel)
     return nullptr;
 
   return this->AddNewLabelInstanceInternal(currentLabel);
 }
 
 mitk::Label* QmitkMultiLabelInspector::AddNewLabelInternal(const mitk::LabelSetImage::GroupIndexType& containingGroup)
 {
   auto newLabel = mitk::LabelSetImageHelper::CreateNewLabel(m_Segmentation);
 
   if (!m_DefaultLabelNaming)
     emit LabelRenameRequested(newLabel, false);
 
   auto group = m_Segmentation->GetLabelSet(containingGroup);
 
   m_ModelManipulationOngoing = true;
   group->AddLabel(newLabel, false);
   m_ModelManipulationOngoing = false;
 
   this->SetSelectedLabel(newLabel->GetValue());
 
   auto index = m_Model->indexOfLabel(newLabel->GetValue());
 
   if (!index.isValid())
     mitkThrow() << "Segmentation or QmitkMultiLabelTreeModel is in an invalid state. Label is not present in the "
                    "model after adding it to the segmentation. Label value: " << newLabel->GetValue();
 
   m_Controls->view->expand(index.parent());
 
   emit ModelUpdated();
 
   return newLabel;
 }
 
 mitk::Label* QmitkMultiLabelInspector::AddNewLabel()
 {
   if (!m_AllowLabelModification)
     mitkThrow() << "QmitkMultiLabelInspector is configured incorrectly. Set AllowLabelModification to true to allow the usage of AddNewLabel.";
 
   if (m_Segmentation.IsNull())
   {
     return nullptr;
   }
 
   auto currentLabel = this->GetFirstSelectedLabelObject();
   mitk::LabelSetImage::GroupIndexType groupID = nullptr != currentLabel
     ? m_Segmentation->GetGroupIndexOfLabel(currentLabel->GetValue())
     : 0;
 
   return AddNewLabelInternal(groupID);
 }
 
 void QmitkMultiLabelInspector::DeleteLabelInstance()
 {
   if (!m_AllowLabelModification)
     mitkThrow() << "QmitkMultiLabelInspector is configured incorrectly. Set AllowLabelModification to true to allow the usage of DeleteLabelInstance.";
 
   if (m_Segmentation.IsNull())
     return;
 
   auto label = this->GetFirstSelectedLabelObject();
 
   if (nullptr == label)
     return;
 
   auto index = m_Model->indexOfLabel(label->GetValue());
   auto instanceName = index.data(Qt::DisplayRole);
 
   auto question = "Do you really want to delete label instance \"" + instanceName.toString() + "\"?";
   auto answer = QMessageBox::question(this, QString("Delete label instances"), question, QMessageBox::Yes | QMessageBox::Cancel, QMessageBox::Yes);
 
   if (answer == QMessageBox::Yes)
     this->DeleteLabelInternal({ label->GetValue() });
 }
 
 void QmitkMultiLabelInspector::DeleteLabel()
 {
   if (!m_AllowLabelModification)
     mitkThrow() << "QmitkMultiLabelInspector is configured incorrectly. Set AllowLabelModification to true to allow the usage of DeleteLabel.";
 
   if (m_Segmentation.IsNull())
     return;
 
   const auto label = this->GetFirstSelectedLabelObject();
 
   if (nullptr == label)
     return;
 
   const auto relevantLabels = this->GetLabelInstancesOfSelectedFirstLabel();
 
   if (relevantLabels.empty())
     return;
 
   auto question = "Do you really want to delete label \"" + QString::fromStdString(label->GetName());
   question = relevantLabels.size()==1 ? question + "\"?" : question + "\" with all "+QString::number(relevantLabels.size()) +" instances?";
 
   auto answer = QMessageBox::question(this, QString("Delete label"), question, QMessageBox::Yes | QMessageBox::Cancel, QMessageBox::Yes);
 
   if (answer == QMessageBox::Yes)
     this->DeleteLabelInternal(relevantLabels);
 }
 
 void QmitkMultiLabelInspector::DeleteLabelInternal(const LabelValueVectorType& labelValues)
 {
   if (!m_AllowLabelModification)
     mitkThrow() << "QmitkMultiLabelInspector is configured incorrectly. Set AllowLabelModification to true to allow the usage of DeleteLabelInternal.";
 
   if (m_Segmentation.IsNull())
   {
     return;
   }
 
   QVariant nextLabelVariant;
 
   this->WaitCursorOn();
   m_ModelManipulationOngoing = true;
   for (auto labelValue : labelValues)
   {
     if (labelValue == labelValues.back())
     {
       auto currentIndex = m_Model->indexOfLabel(labelValue);
       auto nextIndex = m_Model->ClosestLabelInstanceIndex(currentIndex);
       nextLabelVariant = nextIndex.data(QmitkMultiLabelTreeModel::ItemModelRole::LabelInstanceValueRole);
     }
 
     m_Segmentation->RemoveLabel(labelValue);
   }
   m_ModelManipulationOngoing = false;
   this->WaitCursorOff();
 
   if (nextLabelVariant.isValid())
   {
     auto newLabelValue = nextLabelVariant.value<LabelValueType>();
     this->SetSelectedLabel(newLabelValue);
 
     auto index = m_Model->indexOfLabel(newLabelValue); //we have to get index again, because it could have changed due to remove operation.
     if (index.isValid())
     {
       m_Controls->view->expand(index.parent());
     }
     else
     {
       mitkThrow() << "Segmentation or QmitkMultiLabelTreeModel is in an invalid state. Label is not present in the model after adding it to the segmentation. Label value: " << newLabelValue;
     }
   }
   else
   {
     this->SetSelectedLabels({});
   }
 
   emit ModelUpdated();
   mitk::RenderingManager::GetInstance()->RequestUpdateAll();
 }
 
 mitk::Label* QmitkMultiLabelInspector::AddNewGroup()
 {
   if (!m_AllowLabelModification)
     mitkThrow() << "QmitkMultiLabelInspector is configured incorrectly. Set AllowLabelModification to true to allow the usage of AddNewLabel.";
 
   if (m_Segmentation.IsNull())
   {
     return nullptr;
   }
 
   mitk::LabelSetImage::GroupIndexType groupID = 0;
   mitk::Label* newLabel = nullptr;
   m_ModelManipulationOngoing = true;
   try
   {
     this->WaitCursorOn();
     groupID = m_Segmentation->AddLayer();
     this->WaitCursorOff();
     newLabel =  this->AddNewLabelInternal(groupID);
   }
   catch (mitk::Exception& e)
   {
     this->WaitCursorOff();
     m_ModelManipulationOngoing = false;
     MITK_ERROR << "Exception caught: " << e.GetDescription();
     QMessageBox::information(this, "Add group", "Could not add a new group. See error log for details.");
   }
   m_ModelManipulationOngoing = false;
 
   emit ModelUpdated();
   return newLabel;
 }
 
 void QmitkMultiLabelInspector::RemoveGroupInternal(const mitk::LabelSetImage::GroupIndexType& groupID)
 {
   if (!m_AllowLabelModification)
     mitkThrow() << "QmitkMultiLabelInspector is configured incorrectly. Set AllowLabelModification to true to allow the usage of RemoveLabel.";
 
   if (m_Segmentation.IsNull())
     return;
 
   if (m_Segmentation->GetNumberOfLayers() < 2)
     return;
 
   auto currentIndex = m_Model->indexOfGroup(groupID);
   auto nextIndex = m_Model->ClosestLabelInstanceIndex(currentIndex);
   auto labelVariant = nextIndex.data(QmitkMultiLabelTreeModel::ItemModelRole::LabelInstanceValueRole);
 
   try
   {
     this->WaitCursorOn();
     m_ModelManipulationOngoing = true;
     m_Segmentation->RemoveGroup(groupID);
     m_ModelManipulationOngoing = false;
     this->WaitCursorOff();
   }
   catch (mitk::Exception& e)
   {
     m_ModelManipulationOngoing = false;
     this->WaitCursorOff();
     MITK_ERROR << "Exception caught: " << e.GetDescription();
     QMessageBox::information(this, "Delete group", "Could not delete the currently active group. See error log for details.");
     return;
   }
 
   if (labelVariant.isValid())
   {
     auto newLabelValue = labelVariant.value<LabelValueType>();
     this->SetSelectedLabel(newLabelValue);
 
     auto index = m_Model->indexOfLabel(newLabelValue); //we have to get index again, because it could have changed due to remove operation.
     if (index.isValid())
     {
       m_Controls->view->expand(index.parent());
     }
     else
     {
       mitkThrow() << "Segmentation or QmitkMultiLabelTreeModel is in an invalid state. Label is not present in the model after adding it to the segmentation. Label value: " << newLabelValue;
     }
   }
+  else
+  {
+    this->SetSelectedLabels({});
+  }
 
   emit ModelUpdated();
   mitk::RenderingManager::GetInstance()->RequestUpdateAll();
 }
 
 void QmitkMultiLabelInspector::RemoveGroup()
 {
   if (!m_AllowLabelModification)
     mitkThrow() << "QmitkMultiLabelInspector is configured incorrectly. Set AllowLabelModification to true to allow the usage of RemoveLabel.";
 
   if (m_Segmentation.IsNull())
     return;
 
   if (m_Segmentation->GetNumberOfLayers() < 2)
   {
     QMessageBox::information(this, "Delete group", "Cannot delete last remaining group. A segmentation must contain at least a single group.");
     return;
   }
 
-  auto question = QStringLiteral("Do you really want to delete the group of the selected label with all labels?");
-  auto answer = QMessageBox::question(this, "Delete group", question, QMessageBox::Yes | QMessageBox::Cancel, QMessageBox::Yes);
+  const auto* selectedLabel = this->GetFirstSelectedLabelObject();
 
-  if (answer != QMessageBox::Yes)
+  if (selectedLabel == nullptr)
     return;
 
-  auto selectedLabel = this->GetFirstSelectedLabelObject();
   const auto group = m_Segmentation->GetGroupIndexOfLabel(selectedLabel->GetValue());
 
+  auto question = QStringLiteral("Do you really want to delete group %1 including all of its labels?").arg(group);
+  auto answer = QMessageBox::question(this, QStringLiteral("Delete group %1").arg(group), question, QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes);
+
+  if (answer != QMessageBox::Yes)
+    return;
+
   this->RemoveGroupInternal(group);
 }
 
 void QmitkMultiLabelInspector::OnDeleteGroup()
 {
   if (!m_AllowLabelModification)
     mitkThrow() << "QmitkMultiLabelInspector is configured incorrectly. Set AllowLabelModification to true to allow the usage of RemoveLabel.";
 
   if (m_Segmentation.IsNull())
     return;
 
   auto currentIndex = this->m_Controls->view->currentIndex();
   auto groupIDVariant = currentIndex.data(QmitkMultiLabelTreeModel::ItemModelRole::GroupIDRole);
 
   if (groupIDVariant.isValid())
   {
     auto groupID = groupIDVariant.value<mitk::LabelSetImage::GroupIndexType>();
 
-    auto question = QStringLiteral("Do you really want to delete the current group with all labels?");
-    auto answer = QMessageBox::question(this, QString("Delete group %1").arg(groupID), question, QMessageBox::Yes | QMessageBox::Cancel, QMessageBox::Yes);
+    auto question = QStringLiteral("Do you really want to delete group %1 including all of its labels?").arg(groupID);
+    auto answer = QMessageBox::question(this, QString("Delete group %1").arg(groupID), question, QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes);
 
     if (answer != QMessageBox::Yes)
       return;
 
     this->RemoveGroupInternal(groupID);
   }
 };
 
 
 void QmitkMultiLabelInspector::OnContextMenuRequested(const QPoint& /*pos*/)
 {
   if (m_Segmentation.IsNull() || !this->isEnabled())
     return;
 
   const auto indexLevel = this->GetCurrentLevelType();
 
   if (IndexLevelType::Group == indexLevel)
   {
     QMenu* menu = new QMenu(this);
 
     if (m_AllowLabelModification)
     {
       QAction* addInstanceAction = new QAction(QmitkStyleManager::ThemeIcon(QStringLiteral(":/Qmitk/icon_label_add.svg")), "&Add label", this);
       QObject::connect(addInstanceAction, &QAction::triggered, this, &QmitkMultiLabelInspector::OnAddLabel);
       menu->addAction(addInstanceAction);
 
       if (m_Segmentation->GetNumberOfLayers() > 1)
       {
         QAction* removeAction = new QAction(QmitkStyleManager::ThemeIcon(QStringLiteral(":/Qmitk/icon_group_delete.svg")), "Delete group", this);
         QObject::connect(removeAction, &QAction::triggered, this, &QmitkMultiLabelInspector::OnDeleteGroup);
         menu->addAction(removeAction);
       }
     }
 
     if (m_AllowLockModification)
     {
       menu->addSeparator();
       QAction* lockAllAction = new QAction(QmitkStyleManager::ThemeIcon(QLatin1String(":/Qmitk/lock.svg")), "Lock group", this);
       QObject::connect(lockAllAction, &QAction::triggered, this, &QmitkMultiLabelInspector::OnLockAffectedLabels);
       menu->addAction(lockAllAction);
 
       QAction* unlockAllAction = new QAction(QmitkStyleManager::ThemeIcon(QLatin1String(":/Qmitk/unlock.svg")), "Unlock group", this);
       QObject::connect(unlockAllAction, &QAction::triggered, this, &QmitkMultiLabelInspector::OnUnlockAffectedLabels);
       menu->addAction(unlockAllAction);
     }
 
     if (m_AllowVisibilityModification)
     {
       menu->addSeparator();
 
       QAction* viewAllAction = new QAction(QmitkStyleManager::ThemeIcon(QLatin1String(":/Qmitk/visible.svg")), "Show group", this);
       QObject::connect(viewAllAction, &QAction::triggered, this, &QmitkMultiLabelInspector::OnSetAffectedLabelsVisible);
       menu->addAction(viewAllAction);
 
       QAction* hideAllAction = new QAction(QmitkStyleManager::ThemeIcon(QLatin1String(":/Qmitk/invisible.svg")), "Hide group", this);
       QObject::connect(hideAllAction, &QAction::triggered, this, &QmitkMultiLabelInspector::OnSetAffectedLabelsInvisible);
       menu->addAction(hideAllAction);
 
       menu->addSeparator();
 
       auto opacityAction = this->CreateOpacityAction();
       if (nullptr != opacityAction)
         menu->addAction(opacityAction);
     }
     menu->popup(QCursor::pos());
   }
   else if (IndexLevelType::LabelClass == indexLevel)
   {
     QMenu* menu = new QMenu(this);
 
     if (m_AllowLabelModification)
     {
       QAction* addInstanceAction = new QAction(QmitkStyleManager::ThemeIcon(QStringLiteral(":/Qmitk/icon_label_add_instance.svg")), "Add label instance", this);
       QObject::connect(addInstanceAction, &QAction::triggered, this, &QmitkMultiLabelInspector::OnAddLabelInstance);
       menu->addAction(addInstanceAction);
 
       QAction* renameAction = new QAction(QIcon(":/Qmitk/RenameLabel.png"), "&Rename label", this);
       QObject::connect(renameAction, SIGNAL(triggered(bool)), this, SLOT(OnRenameLabel(bool)));
       menu->addAction(renameAction);
 
       QAction* removeAction = new QAction(QmitkStyleManager::ThemeIcon(QStringLiteral(":/Qmitk/icon_label_delete.svg")), "&Delete label", this);
       QObject::connect(removeAction, &QAction::triggered, this, &QmitkMultiLabelInspector::OnDeleteAffectedLabel);
       menu->addAction(removeAction);
     }
 
     if (m_AllowLockModification)
     {
       menu->addSeparator();
       QAction* lockAllAction = new QAction(QmitkStyleManager::ThemeIcon(QLatin1String(":/Qmitk/lock.svg")), "Lock label instances", this);
       QObject::connect(lockAllAction, &QAction::triggered, this, &QmitkMultiLabelInspector::OnLockAffectedLabels);
       menu->addAction(lockAllAction);
 
       QAction* unlockAllAction = new QAction(QmitkStyleManager::ThemeIcon(QLatin1String(":/Qmitk/unlock.svg")), "Unlock label instances", this);
       QObject::connect(unlockAllAction, &QAction::triggered, this, &QmitkMultiLabelInspector::OnUnlockAffectedLabels);
       menu->addAction(unlockAllAction);
     }
 
     if (m_AllowVisibilityModification)
     {
       menu->addSeparator();
 
       QAction* viewAllAction = new QAction(QmitkStyleManager::ThemeIcon(QLatin1String(":/Qmitk/visible.svg")), "Show label instances", this);
       QObject::connect(viewAllAction, &QAction::triggered, this, &QmitkMultiLabelInspector::OnSetAffectedLabelsVisible);
       menu->addAction(viewAllAction);
 
       QAction* hideAllAction = new QAction(QmitkStyleManager::ThemeIcon(QLatin1String(":/Qmitk/invisible.svg")), "Hide label instances", this);
       QObject::connect(hideAllAction, &QAction::triggered, this, &QmitkMultiLabelInspector::OnSetAffectedLabelsInvisible);
       menu->addAction(hideAllAction);
 
       menu->addSeparator();
 
       auto opacityAction = this->CreateOpacityAction();
       if (nullptr!=opacityAction)
         menu->addAction(opacityAction);
     }
     menu->popup(QCursor::pos());
   }
   else
   {
     auto selectedLabelValues = this->GetSelectedLabels();
     if (selectedLabelValues.empty())
       return;
 
     QMenu* menu = new QMenu(this);
 
     if (this->GetMultiSelectionMode() && selectedLabelValues.size() > 1)
     {
       QAction* mergeAction = new QAction(QIcon(":/Qmitk/MergeLabels.png"), "Merge selection on current label", this);
       QObject::connect(mergeAction, SIGNAL(triggered(bool)), this, SLOT(OnMergeLabels(bool)));
       menu->addAction(mergeAction);
 
       QAction* removeLabelsAction = new QAction(QmitkStyleManager::ThemeIcon(QStringLiteral(":/Qmitk/icon_label_delete_instance.svg")), "&Delete selected labels", this);
       QObject::connect(removeLabelsAction, SIGNAL(triggered(bool)), this, SLOT(OnDeleteLabels(bool)));
       menu->addAction(removeLabelsAction);
 
       QAction* clearLabelsAction = new QAction(QIcon(":/Qmitk/EraseLabel.png"), "&Clear selected labels", this);
       QObject::connect(clearLabelsAction, SIGNAL(triggered(bool)), this, SLOT(OnClearLabels(bool)));
       menu->addAction(clearLabelsAction);
     }
     else
     {
       if (m_AllowLabelModification)
       {
         QAction* addInstanceAction = new QAction(QmitkStyleManager::ThemeIcon(QStringLiteral(":/Qmitk/icon_label_add_instance.svg")), "&Add label instance", this);
         QObject::connect(addInstanceAction, &QAction::triggered, this, &QmitkMultiLabelInspector::OnAddLabelInstance);
         menu->addAction(addInstanceAction);
 
         const auto selectedLabelIndex = m_Model->indexOfLabel(selectedLabelValues.front());
 
         if (m_Model->GetLabelInstancesOfSameLabelClass(selectedLabelIndex).size() > 1) // Only labels that actually appear as instance (having additional instances)
         {
           QAction* renameAction = new QAction(QIcon(":/Qmitk/RenameLabel.png"), "&Rename label instance", this);
           QObject::connect(renameAction, SIGNAL(triggered(bool)), this, SLOT(OnRenameLabel(bool)));
           menu->addAction(renameAction);
 
           QAction* removeInstanceAction = new QAction(QmitkStyleManager::ThemeIcon(QStringLiteral(":/Qmitk/icon_label_delete_instance.svg")), "&Delete label instance", this);
           QObject::connect(removeInstanceAction, &QAction::triggered, this, &QmitkMultiLabelInspector::DeleteLabelInstance);
           menu->addAction(removeInstanceAction);
         }
         else
         {
           QAction* renameAction = new QAction(QIcon(":/Qmitk/RenameLabel.png"), "&Rename label", this);
           QObject::connect(renameAction, SIGNAL(triggered(bool)), this, SLOT(OnRenameLabel(bool)));
           menu->addAction(renameAction);
         }
 
         QAction* removeLabelAction = new QAction(QmitkStyleManager::ThemeIcon(QStringLiteral(":/Qmitk/icon_label_delete.svg")), "Delete &label", this);
         QObject::connect(removeLabelAction, &QAction::triggered, this, &QmitkMultiLabelInspector::DeleteLabel);
         menu->addAction(removeLabelAction);
 
         QAction* clearAction = new QAction(QIcon(":/Qmitk/EraseLabel.png"), "&Clear content", this);
         QObject::connect(clearAction, SIGNAL(triggered(bool)), this, SLOT(OnClearLabel(bool)));
         menu->addAction(clearAction);
       }
 
       if (m_AllowVisibilityModification)
       {
         menu->addSeparator();
         QAction* viewOnlyAction = new QAction(QmitkStyleManager::ThemeIcon(QLatin1String(":/Qmitk/visible.svg")), "Hide everything in group but this", this);
         QObject::connect(viewOnlyAction, SIGNAL(triggered(bool)), this, SLOT(OnSetOnlyActiveLabelVisible(bool)));
         menu->addAction(viewOnlyAction);
 
         menu->addSeparator();
 
         auto opacityAction = this->CreateOpacityAction();
         if (nullptr != opacityAction)
           menu->addAction(opacityAction);
       }
     }
     menu->popup(QCursor::pos());
   }
 }
 
 QWidgetAction* QmitkMultiLabelInspector::CreateOpacityAction()
 {
   auto relevantLabelValues = this->GetCurrentlyAffactedLabelInstances();
   std::vector<mitk::Label*> relevantLabels;
 
   if (!relevantLabelValues.empty())
   {
     //we assume here that all affacted label belong to one group.
     auto groupID = m_Segmentation->GetGroupIndexOfLabel(relevantLabelValues.front());
     auto group = m_Segmentation->GetLabelSet(groupID);
 
     for (auto value : relevantLabelValues)
     {
       auto label = this->m_Segmentation->GetLabel(value);
       if (nullptr == label)
         mitkThrow() << "Invalid state. Internal model returned a label value that does not exist in segmentation. Invalid value:" << value;
       relevantLabels.emplace_back(label);
     }
 
     auto* opacitySlider = new QSlider;
     opacitySlider->setMinimum(0);
     opacitySlider->setMaximum(100);
     opacitySlider->setOrientation(Qt::Horizontal);
 
     auto opacity = relevantLabels.front()->GetOpacity();
     opacitySlider->setValue(static_cast<int>(opacity * 100));
     auto segmentation = m_Segmentation;
 
     QObject::connect(opacitySlider, &QSlider::valueChanged, this, [segmentation, relevantLabels, group](const int value)
     {
       auto opacity = static_cast<float>(value) / 100.0f;
       for (auto label : relevantLabels)
       {
         label->SetOpacity(opacity);
         group->UpdateLookupTable(label->GetValue());
       }
       mitk::RenderingManager::GetInstance()->RequestUpdateAll();
     }
     );
 
     QLabel* opacityLabel = new QLabel("Opacity: ");
     QVBoxLayout* opacityWidgetLayout = new QVBoxLayout;
     opacityWidgetLayout->setContentsMargins(4, 4, 4, 4);
     opacityWidgetLayout->addWidget(opacityLabel);
     opacityWidgetLayout->addWidget(opacitySlider);
     QWidget* opacityWidget = new QWidget;
     opacityWidget->setLayout(opacityWidgetLayout);
     QWidgetAction* opacityAction = new QWidgetAction(this);
     opacityAction->setDefaultWidget(opacityWidget);
 
     return opacityAction;
   }
 
   return nullptr;
 }
 
 void QmitkMultiLabelInspector::OnClearLabels(bool /*value*/)
 {
   QString question = "Do you really want to clear the selected labels?";
 
   QMessageBox::StandardButton answerButton = QMessageBox::question(
     this, "Clear selected labels", question, QMessageBox::Yes | QMessageBox::Cancel, QMessageBox::Yes);
 
   if (answerButton == QMessageBox::Yes)
   {
     this->WaitCursorOn();
     m_Segmentation->EraseLabels(this->GetSelectedLabels());
     this->WaitCursorOff();
     mitk::RenderingManager::GetInstance()->RequestUpdateAll();
   }
 }
 
 void QmitkMultiLabelInspector::OnDeleteAffectedLabel()
 {
   if (!m_AllowLabelModification)
     mitkThrow() << "QmitkMultiLabelInspector is configured incorrectly. Set AllowLabelModification to true to allow the usage of RemoveLabel.";
 
   if (m_Segmentation.IsNull())
   {
     return;
   }
 
   auto affectedLabels = GetCurrentlyAffactedLabelInstances();
   auto currentLabel = m_Segmentation->GetLabel(affectedLabels.front());
   QString question = "Do you really want to delete all instances of label \"" + QString::fromStdString(currentLabel->GetName()) + "\"?";
 
   QMessageBox::StandardButton answerButton =
     QMessageBox::question(this, "Delete label", question, QMessageBox::Yes | QMessageBox::Cancel, QMessageBox::Yes);
 
   if (answerButton == QMessageBox::Yes)
   {
     this->DeleteLabelInternal(affectedLabels);
   }
 }
 
 void QmitkMultiLabelInspector::OnDeleteLabels(bool /*value*/)
 {
   QString question = "Do you really want to remove the selected labels?";
   QMessageBox::StandardButton answerButton = QMessageBox::question(
     this, "Remove selected labels", question, QMessageBox::Yes | QMessageBox::Cancel, QMessageBox::Yes);
 
   if (answerButton == QMessageBox::Yes)
   {
     this->WaitCursorOn();
     m_Segmentation->RemoveLabels(this->GetSelectedLabels());
     this->WaitCursorOff();
   }
 }
 
 void QmitkMultiLabelInspector::OnMergeLabels(bool /*value*/)
 {
   auto currentLabel = GetCurrentLabel();
   QString question = "Do you really want to merge selected labels into \"" + QString::fromStdString(currentLabel->GetName())+"\"?";
 
   QMessageBox::StandardButton answerButton = QMessageBox::question(
     this, "Merge selected label", question, QMessageBox::Yes | QMessageBox::Cancel, QMessageBox::Yes);
 
   if (answerButton == QMessageBox::Yes)
   {
     this->WaitCursorOn();
     m_Segmentation->MergeLabels(currentLabel->GetValue(), this->GetSelectedLabels(), m_Segmentation->GetActiveLayer());
     this->WaitCursorOff();
 
     mitk::RenderingManager::GetInstance()->RequestUpdateAll();
   }
 }
 
 void QmitkMultiLabelInspector::OnAddLabel()
 {
   auto currentIndex = this->m_Controls->view->currentIndex();
   auto groupIDVariant = currentIndex.data(QmitkMultiLabelTreeModel::ItemModelRole::GroupIDRole);
 
   if (groupIDVariant.isValid())
   {
     auto groupID = groupIDVariant.value<mitk::LabelSetImage::GroupIndexType>();
     this->AddNewLabelInternal(groupID);
   }
 }
 
 void QmitkMultiLabelInspector::OnAddLabelInstance()
 {
   auto currentLabel = this->GetCurrentLabel();
   if (nullptr == currentLabel)
     return;
 
   this->AddNewLabelInstanceInternal(currentLabel);
 }
 
 void QmitkMultiLabelInspector::OnClearLabel(bool /*value*/)
 {
   auto currentLabel = GetFirstSelectedLabelObject();
   QString question = "Do you really want to clear the contents of label \"" + QString::fromStdString(currentLabel->GetName())+"\"?";
 
   QMessageBox::StandardButton answerButton =
     QMessageBox::question(this, "Clear label", question, QMessageBox::Yes | QMessageBox::Cancel, QMessageBox::Yes);
 
   if (answerButton == QMessageBox::Yes)
   {
     this->WaitCursorOn();
     m_Segmentation->EraseLabel(currentLabel->GetValue());
     this->WaitCursorOff();
     mitk::RenderingManager::GetInstance()->RequestUpdateAll();
   }
 }
 
 void QmitkMultiLabelInspector::OnRenameLabel(bool /*value*/)
 {
   auto relevantLabelValues = this->GetCurrentlyAffactedLabelInstances();
   auto currentLabel = this->GetCurrentLabel();
 
   emit LabelRenameRequested(currentLabel, true);
 
   //we assume here that all affacted label belong to one group.
   auto groupID = m_Segmentation->GetGroupIndexOfLabel(currentLabel->GetValue());
   auto group = m_Segmentation->GetLabelSet(groupID);
 
   for (auto value : relevantLabelValues)
   {
     if (value != currentLabel->GetValue())
     {
       auto label = this->m_Segmentation->GetLabel(value);
       if (nullptr == label)
         mitkThrow() << "Invalid state. Internal model returned a label value that does not exist in segmentation. Invalid value:" << value;
 
       label->SetName(currentLabel->GetName());
       label->SetColor(currentLabel->GetColor());
       group->UpdateLookupTable(label->GetValue());
       mitk::DICOMSegmentationPropertyHelper::SetDICOMSegmentProperties(label);
     }
   }
   emit ModelUpdated();
 }
 
 
 void QmitkMultiLabelInspector::SetLockOfAffectedLabels(bool locked) const
 {
   auto relevantLabelValues = this->GetCurrentlyAffactedLabelInstances();
 
   if (!relevantLabelValues.empty())
   {
     for (auto value : relevantLabelValues)
     {
       auto label = this->m_Segmentation->GetLabel(value);
       if (nullptr == label)
         mitkThrow() << "Invalid state. Internal model returned a label value that does not exist in segmentation. Invalid value:" << value;
       label->SetLocked(locked);
     }
     mitk::RenderingManager::GetInstance()->RequestUpdateAll();
   }
 }
 
 void QmitkMultiLabelInspector::OnUnlockAffectedLabels()
 {
   this->SetLockOfAffectedLabels(false);
 }
 
 void QmitkMultiLabelInspector::OnLockAffectedLabels()
 {
   this->SetLockOfAffectedLabels(true);
 }
 
 void QmitkMultiLabelInspector::SetVisibilityOfAffectedLabels(bool visible) const
 {
   auto relevantLabelValues = this->GetCurrentlyAffactedLabelInstances();
 
   if (!relevantLabelValues.empty())
   {
     //we assume here that all affacted label belong to one group.
     auto groupID = m_Segmentation->GetGroupIndexOfLabel(relevantLabelValues.front());
     auto group = m_Segmentation->GetLabelSet(groupID);
 
     for (auto value : relevantLabelValues)
     {
       auto label = this->m_Segmentation->GetLabel(value);
       if (nullptr == label)
         mitkThrow() << "Invalid state. Internal model returned a label value that does not exist in segmentation. Invalid value:" << value;
       label->SetVisible(visible);
       group->UpdateLookupTable(label->GetValue());
     }
     mitk::RenderingManager::GetInstance()->RequestUpdateAll();
   }
 }
 
 void QmitkMultiLabelInspector::OnSetAffectedLabelsVisible()
 {
   this->SetVisibilityOfAffectedLabels(true);
 }
 
 void QmitkMultiLabelInspector::OnSetAffectedLabelsInvisible()
 {
   this->SetVisibilityOfAffectedLabels(false);
 }
 
 void QmitkMultiLabelInspector::OnSetOnlyActiveLabelVisible(bool /*value*/)
 {
   auto currentLabel = GetFirstSelectedLabelObject();
   const auto labelID = currentLabel->GetValue();
   auto groupID = m_Segmentation->GetGroupIndexOfLabel(currentLabel->GetValue());
   auto group = m_Segmentation->GetLabelSet(groupID);
   group->SetAllLabelsVisible(false);
 
   currentLabel->SetVisible(true);
   group->UpdateLookupTable(labelID);
   mitk::RenderingManager::GetInstance()->RequestUpdateAll();
 
   this->PrepareGoToLabel(labelID);
 }
 
 void QmitkMultiLabelInspector::OnItemDoubleClicked(const QModelIndex& index)
 {
   if (!index.isValid()) return;
   if (index.column() > 0) return;
 
   auto labelVariant = index.data(QmitkMultiLabelTreeModel::ItemModelRole::LabelInstanceValueRole);
 
   if (!labelVariant.isValid()) return;
 
   const auto labelID = labelVariant.value<mitk::Label::PixelType>();
 
   if (QApplication::queryKeyboardModifiers().testFlag(Qt::AltModifier))
   {
     this->OnRenameLabel(false);
     return;
   }
 
   this->PrepareGoToLabel(labelID);
 }
 
 void QmitkMultiLabelInspector::PrepareGoToLabel(mitk::Label::PixelType labelID) const
 {
   this->WaitCursorOn();
   m_Segmentation->UpdateCenterOfMass(labelID);
   const auto currentLabel = m_Segmentation->GetLabel(labelID);
   const mitk::Point3D& pos = currentLabel->GetCenterOfMassCoordinates();
   this->WaitCursorOff();
 
   if (pos.GetVnlVector().max_value() > 0.0)
   {
     emit GoToLabel(currentLabel->GetValue(), pos);
   }
 }
 
diff --git a/Modules/SegmentationUI/Qmitk/QmitkMultiLabelTreeModel.cpp b/Modules/SegmentationUI/Qmitk/QmitkMultiLabelTreeModel.cpp
index 315e7952fb..bbf9702b83 100644
--- a/Modules/SegmentationUI/Qmitk/QmitkMultiLabelTreeModel.cpp
+++ b/Modules/SegmentationUI/Qmitk/QmitkMultiLabelTreeModel.cpp
@@ -1,999 +1,1021 @@
 /*============================================================================
 
 The Medical Imaging Interaction Toolkit (MITK)
 
 Copyright (c) German Cancer Research Center (DKFZ)
 All rights reserved.
 
 Use of this source code is governed by a 3-clause BSD license that can be
 found in the LICENSE file.
 
 ============================================================================*/
 
 #include "QmitkMultiLabelTreeModel.h"
 
 #include "mitkRenderingManager.h"
 
 #include "QmitkStyleManager.h"
 
 
 class QmitkMultiLabelSegTreeItem
 {
 public:
   enum class ItemType
   {
     Group,
     Label,
     Instance
   };
 
   QmitkMultiLabelSegTreeItem()
   {
   };
 
   explicit QmitkMultiLabelSegTreeItem(ItemType type, QmitkMultiLabelSegTreeItem* parentItem,
     mitk::Label* label = nullptr, std::string className = ""): m_parentItem(parentItem), m_ItemType(type), m_Label(label), m_ClassName(className)
   {
   };
 
   ~QmitkMultiLabelSegTreeItem()
   {
     for (auto item : m_childItems)
     {
       delete item;
     }
   };
 
   void AppendChild(QmitkMultiLabelSegTreeItem* child)
   {
       m_childItems.push_back(child);
   };
 
   void RemoveChild(std::size_t row)
   {
     if (row < m_childItems.size())
     {
       delete m_childItems[row];
       m_childItems.erase(m_childItems.begin() + row);
     }
   };
 
   int Row() const
   {
     if (m_parentItem)
     {
       auto finding = std::find(m_parentItem->m_childItems.begin(), m_parentItem->m_childItems.end(), this);
       if (finding != m_parentItem->m_childItems.end())
       {
         return std::distance(m_parentItem->m_childItems.begin(), finding);
       }
     }
 
     return 0;
   };
 
   QmitkMultiLabelSegTreeItem* ParentItem()
   {
     return m_parentItem;
   };
 
   const QmitkMultiLabelSegTreeItem* ParentItem() const
   {
     return m_parentItem;
   };
 
   const QmitkMultiLabelSegTreeItem* NextSibblingItem() const
   {
     if (m_parentItem)
     {
       const std::vector<QmitkMultiLabelSegTreeItem*>::size_type row = this->Row();
       if (row + 1 < m_parentItem->m_childItems.size())
         return m_parentItem->m_childItems[row+1];
     }
 
     return nullptr;
   };
 
   const QmitkMultiLabelSegTreeItem* PrevSibblingItem() const
   {
     if (m_parentItem)
     {
       const std::vector<QmitkMultiLabelSegTreeItem*>::size_type row = this->Row();
       if (row > 0)
         return m_parentItem->m_childItems[row-1];
     }
 
     return nullptr;
   };
 
   const QmitkMultiLabelSegTreeItem* RootItem() const
   {
     auto item = this;
     while (item->m_parentItem != nullptr)
     {
       item = item->m_parentItem;
     }
     return item;
   };
 
   std::size_t GetGroupID() const
   {
     auto root = this->RootItem();
     auto item = this;
     if (root == this) return 0;
 
     while (root != item->m_parentItem)
     {
       item = item->m_parentItem;
     }
 
     auto iter = std::find(root->m_childItems.begin(), root->m_childItems.end(), item);
 
     if (root->m_childItems.end() == iter) mitkThrow() << "Invalid internal state of QmitkMultiLabelTreeModel. Root does not have an currentItem as child that has root as parent.";
 
     return std::distance(root->m_childItems.begin(), iter);
   }
 
   bool HandleAsInstance() const
   {
     return (ItemType::Instance == m_ItemType) || ((ItemType::Label == m_ItemType) && (m_childItems.size() == 1));
   }
 
   mitk::Label* GetLabel() const
   {
     if (ItemType::Instance == m_ItemType)
     {
       return m_Label;
     }
     if (ItemType::Label == m_ItemType)
     {
       if (m_childItems.empty()) mitkThrow() << "Invalid internal state of QmitkMultiLabelTreeModel. Internal label currentItem has no instance currentItem.";
       return m_childItems[0]->GetLabel();
     }
 
     return nullptr;
   };
 
   mitk::LabelSetImage::LabelValueType GetLabelValue() const
   {
     auto label = this->GetLabel();
 
     if (nullptr == label)
     {
       mitkThrow() << "Invalid internal state of QmitkMultiLabelTreeModel. Called GetLabelValue on an group currentItem.";
     }
 
     return label->GetValue();
   };
 
   /** returns a vector containing all label values of referenced by this item or its child items.*/
   std::vector< mitk::LabelSetImage::LabelValueType> GetLabelsInSubTree() const
   {
     if (this->m_ItemType == ItemType::Instance)
     {
       return { this->GetLabelValue() };
     }
 
     std::vector< mitk::LabelSetImage::LabelValueType> result;
     for (const auto child : this->m_childItems)
     {
       auto childresult = child->GetLabelsInSubTree();
       result.reserve(result.size() + childresult.size());
       result.insert(result.end(), childresult.begin(), childresult.end());
     }
 
     return result;
   }
 
   std::vector<QmitkMultiLabelSegTreeItem*> m_childItems;
   QmitkMultiLabelSegTreeItem* m_parentItem = nullptr;
   ItemType m_ItemType = ItemType::Group;
   mitk::Label::Pointer m_Label;
   std::string m_ClassName;
 };
 
 QModelIndex GetIndexByItem(const QmitkMultiLabelSegTreeItem* start, const QmitkMultiLabelTreeModel* model)
 {
   QModelIndex parentIndex = QModelIndex();
   if (nullptr != start->m_parentItem)
   {
     parentIndex = GetIndexByItem(start->m_parentItem, model);
   }
   else
   {
     return parentIndex;
   }
 
   return model->index(start->Row(), 0, parentIndex);
 }
 
 QmitkMultiLabelSegTreeItem* GetGroupItem(QmitkMultiLabelTreeModel::GroupIndexType groupIndex, QmitkMultiLabelSegTreeItem* root)
 {
   if (nullptr != root && groupIndex < root->m_childItems.size())
   {
     return root->m_childItems[groupIndex];
   }
 
   return nullptr;
 }
 
 QmitkMultiLabelSegTreeItem* GetInstanceItem(QmitkMultiLabelTreeModel::LabelValueType labelValue, QmitkMultiLabelSegTreeItem* root)
 {
   QmitkMultiLabelSegTreeItem* result = nullptr;
 
   for (auto item : root->m_childItems)
   {
     result = GetInstanceItem(labelValue, item);
     if (nullptr != result) return result;
   }
 
   if (root->m_ItemType == QmitkMultiLabelSegTreeItem::ItemType::Instance && root->GetLabelValue() == labelValue)
   {
     return root;
   }
 
   return nullptr;
 }
 
 const QmitkMultiLabelSegTreeItem* GetFirstInstanceLikeItem(const QmitkMultiLabelSegTreeItem* startItem)
 {
   const QmitkMultiLabelSegTreeItem* result = nullptr;
 
   if (nullptr != startItem)
   {
     if (startItem->HandleAsInstance())
     {
       result = startItem;
     }
     else if (!startItem->m_childItems.empty())
     {
       result = GetFirstInstanceLikeItem(startItem->m_childItems.front());
     }
   }
 
   return result;
 }
 
 QmitkMultiLabelSegTreeItem* GetLabelItemInGroup(const std::string& labelName, QmitkMultiLabelSegTreeItem* group)
 {
   if (nullptr != group)
   {
     auto predicate = [labelName](const QmitkMultiLabelSegTreeItem* item) { return labelName == item->m_ClassName; };
     auto finding = std::find_if(group->m_childItems.begin(), group->m_childItems.end(), predicate);
     if (group->m_childItems.end() != finding)
     {
       return *finding;
     }
   }
 
   return nullptr;
 }
 
 QmitkMultiLabelTreeModel::QmitkMultiLabelTreeModel(QObject *parent) : QAbstractItemModel(parent)
 , m_Observed(false)
 {
   m_RootItem = std::make_unique<QmitkMultiLabelSegTreeItem>();
 }
 
 QmitkMultiLabelTreeModel ::~QmitkMultiLabelTreeModel()
 {
   this->SetSegmentation(nullptr);
 };
 
 int QmitkMultiLabelTreeModel::columnCount(const QModelIndex& /*parent*/) const
 {
   return 4;
 }
 
 int QmitkMultiLabelTreeModel::rowCount(const QModelIndex &parent) const
 {
   if (parent.column() > 0)
     return 0;
 
   if (m_Segmentation.IsNull())
     return 0;
 
   QmitkMultiLabelSegTreeItem* parentItem = m_RootItem.get();
 
   if (parent.isValid())
     parentItem = static_cast<QmitkMultiLabelSegTreeItem *>(parent.internalPointer());
 
   if (parentItem->HandleAsInstance())
   {
     return 0;
   }
 
   return parentItem->m_childItems.size();
 }
 
 QVariant QmitkMultiLabelTreeModel::data(const QModelIndex &index, int role) const
 {
   if (!index.isValid())
     return QVariant();
 
   auto item = static_cast<QmitkMultiLabelSegTreeItem*>(index.internalPointer());
 
   if (!item)
     return QVariant();
 
   if (role == Qt::DisplayRole||role == Qt::EditRole)
   {
     if (TableColumns::NAME_COL == index.column())
     {
       switch (item->m_ItemType)
       {
         case QmitkMultiLabelSegTreeItem::ItemType::Group:
           return QVariant(QString("Group %1").arg(item->GetGroupID()));
 
         case QmitkMultiLabelSegTreeItem::ItemType::Label:
         {
           auto label = item->GetLabel();
 
           if (nullptr == label)
             mitkThrow() << "Invalid internal state. QmitkMultiLabelTreeModel currentItem is refering to a label that does not exist.";
 
           QString name = QString::fromStdString(label->GetName());
 
           if (!item->HandleAsInstance())
             name = name + QString(" (%1 instances)").arg(item->m_childItems.size());
 
           return QVariant(name);
         }
 
         case QmitkMultiLabelSegTreeItem::ItemType::Instance:
         {
           auto label = item->GetLabel();
 
           if (nullptr == label)
             mitkThrow() << "Invalid internal state. QmitkMultiLabelTreeModel currentItem is refering to a label that does not exist.";
 
           return QVariant(QString::fromStdString(label->GetName()) + QString(" [%1]").arg(item->GetLabelValue()));
         }
       }
     }
     else
     {
       if (item->HandleAsInstance())
       {
         auto label = item->GetLabel();
 
         if (TableColumns::LOCKED_COL == index.column())
         {
           return QVariant(label->GetLocked());
         }
         else if (TableColumns::COLOR_COL == index.column())
         {
           return QVariant(QColor(label->GetColor().GetRed() * 255, label->GetColor().GetGreen() * 255, label->GetColor().GetBlue() * 255));
         }
         else if (TableColumns::VISIBLE_COL == index.column())
         {
           return QVariant(label->GetVisible());
         }
       }
     }
   }
   else if (role == ItemModelRole::LabelDataRole)
   {
     auto label = item->GetLabel();
     if (nullptr!=label)  return QVariant::fromValue<void*>(label);
   }
   else if (role == ItemModelRole::LabelValueRole)
   {
     auto label = item->GetLabel();
     if (nullptr != label)  return QVariant(label->GetValue());
   }
   else if (role == ItemModelRole::LabelInstanceDataRole)
   {
     if (item->HandleAsInstance())
     {
       auto label = item->GetLabel();
       return QVariant::fromValue<void*>(label);
     }
   }
   else if (role == ItemModelRole::LabelInstanceValueRole)
   {
     if (item->HandleAsInstance())
     {
       auto label = item->GetLabel();
       return QVariant(label->GetValue());
     }
   }
   else if (role == ItemModelRole::GroupIDRole)
   {
     QVariant v;
     v.setValue(item->GetGroupID());
     return v;
   }
 
   return QVariant();
 }
 
 mitk::Color QtToMitk(const QColor& color)
 {
   mitk::Color mitkColor;
 
   mitkColor.SetRed(color.red() / 255.0f);
   mitkColor.SetGreen(color.green() / 255.0f);
   mitkColor.SetBlue(color.blue() / 255.0f);
 
   return mitkColor;
 }
 
 bool QmitkMultiLabelTreeModel::setData(const QModelIndex& index, const QVariant& value, int role)
 {
   if (!index.isValid())
     return false;
 
   auto item = static_cast<QmitkMultiLabelSegTreeItem*>(index.internalPointer());
 
   if (!item)
     return false;
 
   if (role == Qt::EditRole)
   {
     if (TableColumns::NAME_COL != index.column())
     {
       if (item->HandleAsInstance())
       {
         auto label = item->GetLabel();
 
         if (TableColumns::LOCKED_COL == index.column())
         {
           label->SetLocked(value.toBool());
         }
         else if (TableColumns::COLOR_COL == index.column())
         {
           label->SetColor(QtToMitk(value.value<QColor>()));
         }
         else if (TableColumns::VISIBLE_COL == index.column())
         {
           label->SetVisible(value.toBool());
         }
         auto groupID = m_Segmentation->GetGroupIndexOfLabel(label->GetValue());
         m_Segmentation->GetLabelSet(groupID)->UpdateLookupTable(label->GetValue());
         m_Segmentation->Modified();
         mitk::RenderingManager::GetInstance()->RequestUpdateAll();
       }
       else
       {
 
       }
       return true;
     }
   }
   return false;
 }
 
 QModelIndex QmitkMultiLabelTreeModel::index(int row, int column, const QModelIndex &parent) const
 {
   if (!hasIndex(row, column, parent))
     return QModelIndex();
 
   auto parentItem = m_RootItem.get();
 
   if (parent.isValid())
     parentItem = static_cast<QmitkMultiLabelSegTreeItem *>(parent.internalPointer());
 
   QmitkMultiLabelSegTreeItem *childItem = parentItem->m_childItems[row];
   if (childItem)
     return createIndex(row, column, childItem);
   else
     return QModelIndex();
 }
 
 QModelIndex QmitkMultiLabelTreeModel::indexOfLabel(mitk::Label::PixelType labelValue) const
 {
   if (labelValue == mitk::LabelSetImage::UnlabeledValue) return QModelIndex();
   auto relevantItem = GetInstanceItem(labelValue, this->m_RootItem.get());
 
   if (nullptr == relevantItem)
     return QModelIndex();
 
   auto labelItem = relevantItem->ParentItem();
 
   if (labelItem->m_childItems.size() == 1)
   { //was the only instance of the label, therefor return the label item instat.
     relevantItem = labelItem;
   }
 
   return GetIndexByItem(relevantItem, this);
 }
 
 QModelIndex QmitkMultiLabelTreeModel::indexOfGroup(mitk::LabelSetImage::GroupIndexType groupIndex) const
 {
   auto relevantItem = GetGroupItem(groupIndex, this->m_RootItem.get());
 
   if (nullptr == relevantItem) QModelIndex();
 
   return GetIndexByItem(relevantItem, this);
 }
 
 QModelIndex QmitkMultiLabelTreeModel::parent(const QModelIndex &child) const
 {
   if (!child.isValid())
     return QModelIndex();
 
   QmitkMultiLabelSegTreeItem *childItem = static_cast<QmitkMultiLabelSegTreeItem *>(child.internalPointer());
   QmitkMultiLabelSegTreeItem *parentItem = childItem->ParentItem();
 
   if (parentItem == m_RootItem.get())
     return QModelIndex();
 
   return createIndex(parentItem->Row(), 0, parentItem);
 }
 
 QModelIndex QmitkMultiLabelTreeModel::ClosestLabelInstanceIndex(const QModelIndex& currentIndex) const
 {
   if (!currentIndex.isValid()) return QModelIndex();
 
   auto currentItem = static_cast<const QmitkMultiLabelSegTreeItem*>(currentIndex.internalPointer());
   if (!currentItem) return QModelIndex();
 
   if (currentItem->RootItem() != this->m_RootItem.get()) mitkThrow() << "Invalid call. Passed currentIndex does not seem to be a valid index of this model. It is either outdated or from another model.";
 
   const QmitkMultiLabelSegTreeItem* resultItem = nullptr;
   auto searchItem = currentItem;
   const auto rootItem = currentItem->RootItem();
 
   while (searchItem != rootItem)
   {
-    resultItem = GetFirstInstanceLikeItem(searchItem->NextSibblingItem());
-    if (nullptr != resultItem) break;
+    const auto* sibling = searchItem;
 
-    //no next closest label instance on this level -> check for closest before
-    resultItem = GetFirstInstanceLikeItem(searchItem->PrevSibblingItem());
-    if (nullptr != resultItem) break;
+    while (sibling != nullptr)
+    {
+      sibling = sibling->NextSibblingItem();
+      resultItem = GetFirstInstanceLikeItem(sibling);
+
+      if (nullptr != resultItem)
+        break;
+    }
+
+    if (nullptr != resultItem)
+      break;
+
+    // No next closest label instance on this level -> check for closest before
+    sibling = searchItem;
+
+    while (sibling != nullptr)
+    {
+      sibling = sibling->PrevSibblingItem();
+      resultItem = GetFirstInstanceLikeItem(sibling);
+
+      if (nullptr != resultItem)
+        break;
+    }
+
+    if (nullptr != resultItem)
+      break;
 
-    //no closest label instance before current on this level -> moeve one level up
+    // No closest label instance before current on this level -> moeve one level up
     searchItem = searchItem->ParentItem();
   }
 
   if (nullptr == resultItem)
     return QModelIndex();
 
   return GetIndexByItem(resultItem, this);
 }
 
 QModelIndex QmitkMultiLabelTreeModel::FirstLabelInstanceIndex(const QModelIndex& currentIndex) const
 {
   const QmitkMultiLabelSegTreeItem* currentItem = nullptr;
 
   if (!currentIndex.isValid())
   {
     currentItem = this->m_RootItem.get();
   }
   else
   {
     currentItem = static_cast<const QmitkMultiLabelSegTreeItem*>(currentIndex.internalPointer());
   }
 
   if (!currentItem) return QModelIndex();
 
   if (currentItem->RootItem() != this->m_RootItem.get()) mitkThrow() << "Invalid call. Passed currentIndex does not seem to be a valid index of this model. It is either outdated or from another model.";
 
   const QmitkMultiLabelSegTreeItem* resultItem = nullptr;
   resultItem = GetFirstInstanceLikeItem(currentItem);
 
   if (nullptr == resultItem)
     return QModelIndex();
 
   return GetIndexByItem(resultItem, this);
 }
 
 ///** Returns the index to the next node in the tree that behaves like an instance (label node with only one instance
 //or instance node). If current index is at the end, an invalid index is returned.*/
 //QModelIndex QmitkMultiLabelTreeModel::PrevLabelInstanceIndex(const QModelIndex& currentIndex) const;
 
 std::vector <QmitkMultiLabelTreeModel::LabelValueType> QmitkMultiLabelTreeModel::GetLabelsInSubTree(const QModelIndex& currentIndex) const
 {
   const QmitkMultiLabelSegTreeItem* currentItem = nullptr;
 
   if (!currentIndex.isValid())
   {
     currentItem = this->m_RootItem.get();
   }
   else
   {
     currentItem = static_cast<const QmitkMultiLabelSegTreeItem*>(currentIndex.internalPointer());
   }
 
   if (!currentItem) return {};
 
   return currentItem->GetLabelsInSubTree();
 }
 
 std::vector <QmitkMultiLabelTreeModel::LabelValueType> QmitkMultiLabelTreeModel::GetLabelInstancesOfSameLabelClass(const QModelIndex& currentIndex) const
 {
   const QmitkMultiLabelSegTreeItem* currentItem = nullptr;
 
   if (currentIndex.isValid())
   {
     currentItem = static_cast<const QmitkMultiLabelSegTreeItem*>(currentIndex.internalPointer());
   }
 
   if (!currentItem)
     return {};
 
   if (QmitkMultiLabelSegTreeItem::ItemType::Group == currentItem->m_ItemType)
     return {};
 
   if (QmitkMultiLabelSegTreeItem::ItemType::Instance == currentItem->m_ItemType)
     currentItem = currentItem->ParentItem();
 
   return currentItem->GetLabelsInSubTree();
 }
 
 Qt::ItemFlags QmitkMultiLabelTreeModel::flags(const QModelIndex &index) const
 {
   if (!index.isValid())
     return Qt::NoItemFlags;
 
   if (!index.isValid())
     return Qt::NoItemFlags;
 
   auto item = static_cast<QmitkMultiLabelSegTreeItem*>(index.internalPointer());
 
   if (!item)
     return Qt::NoItemFlags;
 
   if (TableColumns::NAME_COL != index.column())
   {
     if (item->HandleAsInstance() &&
       ((TableColumns::VISIBLE_COL == index.column() && m_AllowVisibilityModification) ||
        (TableColumns::COLOR_COL == index.column() && m_AllowVisibilityModification) || //m_AllowVisibilityModification controls visibility and color
        (TableColumns::LOCKED_COL == index.column() && m_AllowLockModification)))
     {
       return Qt::ItemIsEnabled | Qt::ItemIsEditable;
     }
     else
     {
       return Qt::ItemIsEnabled;
     }
   }
   else
   {
     if (item->HandleAsInstance())
     {
       return Qt::ItemIsEnabled | Qt::ItemIsSelectable;
     }
     else
     {
       return Qt::ItemIsEnabled;
     }
   }
 
   return Qt::NoItemFlags;
 }
 
 QVariant QmitkMultiLabelTreeModel::headerData(int section, Qt::Orientation orientation, int role) const
 {
   if ((Qt::DisplayRole == role) && (Qt::Horizontal == orientation))
   {
     if (TableColumns::NAME_COL == section)
     {
       return "Name";
     }
     else if (TableColumns::LOCKED_COL == section)
     {
       return "Locked";
     }
     else if (TableColumns::COLOR_COL == section)
     {
       return "Color";
     }
     else if (TableColumns::VISIBLE_COL == section)
     {
       return "Visibility";
     }
   }
   return QVariant();
 }
 
 const mitk::LabelSetImage* QmitkMultiLabelTreeModel::GetSegmentation() const
 {
   return m_Segmentation;
 }
 
 
 void QmitkMultiLabelTreeModel::SetSegmentation(mitk::LabelSetImage* segmentation)
 {
   if (m_Segmentation != segmentation)
   {
     this->RemoveObserver();
     this->m_Segmentation = segmentation;
     this->AddObserver();
 
     this->UpdateInternalTree();
   }
 }
 
 
 /**Helper function that adds a labek into the item tree. Passes back the new created instance iten*/
 QmitkMultiLabelSegTreeItem* AddLabelToGroupTree(mitk::Label* label, QmitkMultiLabelSegTreeItem* groupItem, bool& newLabelItemCreated)
 {
   if (nullptr == groupItem) return nullptr;
   if (nullptr == label) return nullptr;
 
   newLabelItemCreated = false;
 
   std::set<std::string> labelNames;
   for (auto labelItem : groupItem->m_childItems)
   {
     labelNames.emplace(labelItem->GetLabel()->GetName());
   }
 
   QmitkMultiLabelSegTreeItem* labelItem = nullptr;
   auto finding = labelNames.find(label->GetName());
   if (finding != labelNames.end())
   { //other label with same name exists
     labelItem = groupItem->m_childItems[std::distance(labelNames.begin(), finding)];
   }
   else
   {
     newLabelItemCreated = true;
     labelItem = new QmitkMultiLabelSegTreeItem(QmitkMultiLabelSegTreeItem::ItemType::Label, groupItem, nullptr, label->GetName());
 
     auto predicate = [label](const std::string& name) { return name > label->GetName(); };
     auto insertFinding = std::find_if(labelNames.begin(), labelNames.end(), predicate);
 
     groupItem->m_childItems.insert(groupItem->m_childItems.begin() + std::distance(labelNames.begin(), insertFinding), labelItem);
   }
 
   auto instanceItem = new QmitkMultiLabelSegTreeItem(QmitkMultiLabelSegTreeItem::ItemType::Instance, labelItem, label);
 
   auto predicate = [label](const QmitkMultiLabelSegTreeItem* item) { return item->GetLabelValue() > label->GetValue(); };
   auto insertFinding = std::find_if(labelItem->m_childItems.begin(), labelItem->m_childItems.end(), predicate);
   labelItem->m_childItems.insert(labelItem->m_childItems.begin() + std::distance(labelItem->m_childItems.begin(), insertFinding), instanceItem);
 
   return instanceItem;
 }
 
 void QmitkMultiLabelTreeModel::GenerateInternalGroupTree(unsigned int groupID, QmitkMultiLabelSegTreeItem* groupItem)
 {
   auto labelSet = m_Segmentation->GetLabelSet(groupID);
 
   for (auto lIter = labelSet->IteratorConstBegin(); lIter != labelSet->IteratorConstEnd(); lIter++)
   {
     if (lIter->first== mitk::LabelSetImage::UnlabeledValue) continue;
 
     bool newItemCreated = false;
     AddLabelToGroupTree(lIter->second, groupItem, newItemCreated);
   }
 }
 
 QmitkMultiLabelSegTreeItem* QmitkMultiLabelTreeModel::GenerateInternalTree()
 {
   auto rootItem = new QmitkMultiLabelSegTreeItem();
 
   if (m_Segmentation.IsNotNull())
   {
     for (unsigned int groupID = 0; groupID < m_Segmentation->GetNumberOfLayers(); ++groupID)
     {
       auto groupItem = new QmitkMultiLabelSegTreeItem(QmitkMultiLabelSegTreeItem::ItemType::Group, rootItem);
       rootItem->AppendChild(groupItem);
 
       GenerateInternalGroupTree(groupID, groupItem);
     }
   }
 
   return rootItem;
 }
 
 void QmitkMultiLabelTreeModel::UpdateInternalTree()
 {
   emit beginResetModel();
   auto newTree = this->GenerateInternalTree();
   this->m_RootItem.reset(newTree);
   emit endResetModel();
   emit modelChanged();
 }
 
 void QmitkMultiLabelTreeModel::AddObserver()
 {
   if (this->m_Segmentation.IsNotNull())
   {
     if (m_Observed)
     {
       MITK_DEBUG << "Invalid observer state in QmitkMultiLabelTreeModel. There is already a registered observer. Internal logic is not correct. May be an old observer was not removed.";
     }
 
     this->m_Segmentation->AddLabelAddedListener(mitk::MessageDelegate1<QmitkMultiLabelTreeModel, LabelValueType>(
       this, &QmitkMultiLabelTreeModel::OnLabelAdded));
     this->m_Segmentation->AddLabelModifiedListener(mitk::MessageDelegate1<QmitkMultiLabelTreeModel, LabelValueType>(
       this, &QmitkMultiLabelTreeModel::OnLabelModified));
     this->m_Segmentation->AddLabelRemovedListener(mitk::MessageDelegate1<QmitkMultiLabelTreeModel, LabelValueType>(
       this, &QmitkMultiLabelTreeModel::OnLabelRemoved));
     this->m_Segmentation->AddGroupAddedListener(mitk::MessageDelegate1<QmitkMultiLabelTreeModel, GroupIndexType>(
       this, &QmitkMultiLabelTreeModel::OnGroupAdded));
     this->m_Segmentation->AddGroupModifiedListener(mitk::MessageDelegate1<QmitkMultiLabelTreeModel, GroupIndexType>(
       this, &QmitkMultiLabelTreeModel::OnGroupModified));
     this->m_Segmentation->AddGroupRemovedListener(mitk::MessageDelegate1<QmitkMultiLabelTreeModel, GroupIndexType>(
       this, &QmitkMultiLabelTreeModel::OnGroupRemoved));
     m_Observed = true;
   }
 }
 
 void QmitkMultiLabelTreeModel::RemoveObserver()
 {
   if (this->m_Segmentation.IsNotNull())
   {
     this->m_Segmentation->RemoveLabelAddedListener(mitk::MessageDelegate1<QmitkMultiLabelTreeModel, LabelValueType>(
       this, &QmitkMultiLabelTreeModel::OnLabelAdded));
     this->m_Segmentation->RemoveLabelModifiedListener(mitk::MessageDelegate1<QmitkMultiLabelTreeModel, LabelValueType>(
       this, &QmitkMultiLabelTreeModel::OnLabelModified));
     this->m_Segmentation->RemoveLabelRemovedListener(mitk::MessageDelegate1<QmitkMultiLabelTreeModel, LabelValueType>(
       this, &QmitkMultiLabelTreeModel::OnLabelRemoved));
     this->m_Segmentation->RemoveGroupAddedListener(mitk::MessageDelegate1<QmitkMultiLabelTreeModel, GroupIndexType>(
       this, &QmitkMultiLabelTreeModel::OnGroupAdded));
     this->m_Segmentation->RemoveGroupModifiedListener(mitk::MessageDelegate1<QmitkMultiLabelTreeModel, GroupIndexType>(
       this, &QmitkMultiLabelTreeModel::OnGroupModified));
     this->m_Segmentation->RemoveGroupRemovedListener(mitk::MessageDelegate1<QmitkMultiLabelTreeModel, GroupIndexType>(
       this, &QmitkMultiLabelTreeModel::OnGroupRemoved));
   }
   m_Observed = false;
 }
 
 void QmitkMultiLabelTreeModel::OnLabelAdded(LabelValueType labelValue)
 {
   GroupIndexType groupIndex = 0;
   if (m_Segmentation->IsLabelInGroup(labelValue, groupIndex))
   {
     auto label = m_Segmentation->GetLabel(labelValue);
     if (nullptr == label) mitkThrow() << "Invalid internal state. Segmentation signaled the addition of an label that does not exist in the segmentation. Invalid label value:" << labelValue;
     if (labelValue == mitk::LabelSetImage::UnlabeledValue) return;
 
     auto groupItem = GetGroupItem(groupIndex, this->m_RootItem.get());
 
     bool newLabelCreated = false;
     auto instanceItem = AddLabelToGroupTree(label, groupItem, newLabelCreated);
 
     if (newLabelCreated)
     {
       if (groupItem->m_childItems.size() == 1)
       { //first label added
         auto groupIndex = GetIndexByItem(groupItem, this);
         emit dataChanged(groupIndex, groupIndex);
         this->beginInsertRows(groupIndex, instanceItem->ParentItem()->Row(), instanceItem->ParentItem()->Row());
         this->endInsertRows();
       }
       else
       { //whole new label level added to group item
         auto groupIndex = GetIndexByItem(groupItem, this);
         this->beginInsertRows(groupIndex, instanceItem->ParentItem()->Row(), instanceItem->ParentItem()->Row());
         this->endInsertRows();
       }
     }
     else
     {
       if (instanceItem->ParentItem()->m_childItems.size() < 3)
       { //second instance item was added, so label item will now able to colapse
         // -> the whole label node has to be updated.
         auto labelIndex = GetIndexByItem(instanceItem->ParentItem(), this);
         emit dataChanged(labelIndex, labelIndex);
         this->beginInsertRows(labelIndex, 0, instanceItem->ParentItem()->m_childItems.size()-1);
         this->endInsertRows();
       }
       else
       {
         // instance item was added to existing label item with multiple instances
         //-> just notify the row insertion
         auto labelIndex = GetIndexByItem(instanceItem->ParentItem(), this);
         this->beginInsertRows(labelIndex, instanceItem->Row(), instanceItem->Row());
         this->endInsertRows();
       }
     }
   }
   else
   {
     mitkThrow() << "Group less labels are not supported in the current implementation.";
   }
 }
 
 void QmitkMultiLabelTreeModel::OnLabelModified(LabelValueType labelValue)
 {
   if (labelValue == mitk::LabelSetImage::UnlabeledValue) return;
 
   auto instanceItem = GetInstanceItem(labelValue, this->m_RootItem.get());
 
   if (nullptr == instanceItem)
   {
     mitkThrow() << "Internal invalid state. QmitkMultiLabelTreeModel recieved a LabelModified signal for a label that is not represented in the model. Invalid label: " << labelValue;
   }
 
   auto labelItem = instanceItem->ParentItem();
 
   if (labelItem->m_ClassName == instanceItem->GetLabel()->GetName())
   { //only the state of the label changed, but not its position in the model tree.
 
     auto index = GetIndexByItem(labelItem, this);
     emit dataChanged(index, index);
   }
   else
   { //the name of the label changed and thus its place in the model tree, delete the current item and add a new one
     this->OnLabelRemoved(labelValue);
     this->OnLabelAdded(labelValue);
   }
 }
 
 void QmitkMultiLabelTreeModel::OnLabelRemoved(LabelValueType labelValue)
 {
   if (labelValue == mitk::LabelSetImage::UnlabeledValue) return;
   auto instanceItem = GetInstanceItem(labelValue, this->m_RootItem.get());
 
   if (nullptr == instanceItem) mitkThrow() << "Internal invalid state. QmitkMultiLabelTreeModel recieved a LabelRemoved signal for a label that is not represented in the model. Invalid label: " << labelValue;
 
   auto labelItem = instanceItem->ParentItem();
 
   if (labelItem->m_childItems.size() > 2)
   {
     auto labelIndex = GetIndexByItem(labelItem, this);
     this->beginRemoveRows(labelIndex, instanceItem->Row(), instanceItem->Row());
     labelItem->RemoveChild(instanceItem->Row());
     this->endRemoveRows();
   }
   else if (labelItem->m_childItems.size() == 2)
   { //After removal only one label is left -> the whole label node is about to be changed (no instances are shown any more).
     auto labelIndex = GetIndexByItem(labelItem, this);
     this->beginRemoveRows(labelIndex, instanceItem->Row(), instanceItem->Row());
     labelItem->RemoveChild(instanceItem->Row());
     this->endRemoveRows();
     emit dataChanged(labelIndex, labelIndex);
   }
   else
   { //was the only instance of the label, therefor also remove the label node from the tree.
     auto groupItem = labelItem->ParentItem();
     auto groupIndex = GetIndexByItem(groupItem, this);
     this->beginRemoveRows(groupIndex, labelItem->Row(), labelItem->Row());
     groupItem->RemoveChild(labelItem->Row());
     this->endRemoveRows();
   }
 }
 
 void QmitkMultiLabelTreeModel::OnGroupAdded(GroupIndexType groupIndex)
 {
   if (m_ShowGroups)
   {
     this->beginInsertRows(QModelIndex(), groupIndex, groupIndex);
     auto rootItem = m_RootItem.get();
     auto groupItem = new QmitkMultiLabelSegTreeItem(QmitkMultiLabelSegTreeItem::ItemType::Group, rootItem);
     rootItem->AppendChild(groupItem);
     this->GenerateInternalGroupTree(groupIndex, groupItem);
     this->endInsertRows();
   }
 }
 
 void QmitkMultiLabelTreeModel::OnGroupModified(GroupIndexType /*groupIndex*/)
 {
   //currently not needed
 }
 
 void QmitkMultiLabelTreeModel::OnGroupRemoved(GroupIndexType groupIndex)
 {
   if (m_ShowGroups)
   {
     this->beginRemoveRows(QModelIndex(), groupIndex, groupIndex);
     auto root = m_RootItem.get();
     root->RemoveChild(groupIndex);
     this->endRemoveRows();
   }
 }
 
 void QmitkMultiLabelTreeModel::SetAllowVisibilityModification(bool vmod)
 {
   m_AllowVisibilityModification = vmod;
 }
 
 bool QmitkMultiLabelTreeModel::GetAllowVisibilityModification() const
 {
   return m_AllowVisibilityModification;
 }
 
 void QmitkMultiLabelTreeModel::SetAllowLockModification(bool lmod)
 {
   m_AllowLockModification = lmod;
 }
 
 bool QmitkMultiLabelTreeModel::GetAllowLockModification() const
 {
   return m_AllowLockModification;
 }