diff --git a/Modules/Python/QmitkPythonSnippets.cpp b/Modules/Python/QmitkPythonSnippets.cpp
index 5803da3614..e4bb50d7af 100644
--- a/Modules/Python/QmitkPythonSnippets.cpp
+++ b/Modules/Python/QmitkPythonSnippets.cpp
@@ -1,452 +1,465 @@
 /*===================================================================
 
 The Medical Imaging Interaction Toolkit (MITK)
 
 Copyright (c) German Cancer Research Center,
 Division of Medical and Biological Informatics.
 All rights reserved.
 
 This software is distributed WITHOUT ANY WARRANTY; without
 even the implied warranty of MERCHANTABILITY or FITNESS FOR
 A PARTICULAR PURPOSE.
 
 See LICENSE.txt or http://www.mitk.org for details.
 
 ===================================================================*/
 
 #include "QmitkPythonSnippets.h"
 #include "QmitkPythonScriptEditorHighlighter.h"
 #include <QtGui>
 #include <mitkCommon.h>
+#include <memory>
 
 struct QmitkPythonSnippetsData
 {
   QString m_AutoSaveFileName;
   QString m_SaveFileName;
 
   QAction* m_PasteSnippet;
   QAction* m_RemoveSnippet;
   QAction* m_RenameSnippet;
   QAction* m_AddSnippet;
   QAction* m_RestoreDefaultSnippets;
   QAction* m_LoadSnippets;
   QAction* m_SaveSnippets;
 
   QToolBar* m_Toolbar;
 
   QComboBox* m_Name;
 
   QTextEdit* m_Content;
 
   QGridLayout* m_Layout;
 
   QmitkPythonSnippets::QStringMap m_Snippets;
 };
 
 const QString QmitkPythonSnippets::DEFAULT_SNIPPET_FILE( ":/mitkPython/PythonSnippets.xml" );
 const QString QmitkPythonSnippets::SNIPPETS_ROOT_XML_ELEMENT_NAME( "PythonSnippets" );
 const QString QmitkPythonSnippets::SNIPPETS_XML_ELEMENT_NAME( "PythonSnippet" );
 
 QmitkPythonSnippets::QmitkPythonSnippets( const QString& _AutoSaveFileName, QWidget* parent )
 : QWidget(parent), d(new QmitkPythonSnippetsData)
 {
   d->m_SaveFileName = QDir::currentPath();
 
   d->m_PasteSnippet = new QAction(this);
   d->m_PasteSnippet->setObjectName(QString::fromUtf8("PasteSnippet"));
   QIcon icon;
   icon.addFile(QString::fromUtf8(":/mitkPython/edit-paste.png"), QSize(), QIcon::Normal, QIcon::Off);
   d->m_PasteSnippet->setIcon(icon);
   d->m_PasteSnippet->setToolTip("Paste snippet!");
   d->m_PasteSnippet->setEnabled(false);
 
   d->m_RemoveSnippet = new QAction(this);
   d->m_RemoveSnippet->setObjectName(QString::fromUtf8("RemoveSnippet"));
   QIcon icon1;
   icon1.addFile(QString::fromUtf8(":/mitkPython/edit-delete.png"), QSize(), QIcon::Normal, QIcon::Off);
   d->m_RemoveSnippet->setIcon(icon1);
   d->m_RemoveSnippet->setToolTip("Remove snippet.");
   d->m_RemoveSnippet->setEnabled(false);
 
   d->m_RenameSnippet = new QAction(this);
   d->m_RenameSnippet->setObjectName(QString::fromUtf8("RenameSnippet"));
   QIcon icon2;
   icon2.addFile(QString::fromUtf8(":/mitkPython/edit-find-replace.png"), QSize(), QIcon::Normal, QIcon::Off);
   d->m_RenameSnippet->setIcon(icon2);
   d->m_RenameSnippet->setToolTip("Rename snippet.");
   d->m_RenameSnippet->setEnabled(false);
 
   d->m_AddSnippet = new QAction(this);
   d->m_AddSnippet->setObjectName(QString::fromUtf8("AddSnippet"));
   QIcon icon3;
   icon3.addFile(QString::fromUtf8(":/mitkPython/document-new.png"), QSize(), QIcon::Normal, QIcon::Off);
   d->m_AddSnippet->setIcon(icon3);
   d->m_AddSnippet->setToolTip("Add snippet.");
 
   d->m_RestoreDefaultSnippets = new QAction(this);
   d->m_RestoreDefaultSnippets->setObjectName(QString::fromUtf8("RestoreDefaultSnippets"));
   QIcon icon4;
   icon4.addFile(QString::fromUtf8(":/mitkPython/edit-clear.png"), QSize(), QIcon::Normal, QIcon::Off);
   d->m_RestoreDefaultSnippets->setIcon(icon4);
   d->m_RestoreDefaultSnippets->setToolTip("Restore default snippets");
 
   d->m_LoadSnippets = new QAction(this);
   d->m_LoadSnippets->setToolTip("Load Snippets from disk.");
   d->m_LoadSnippets->setObjectName(QString::fromUtf8("LoadSnippets"));
   QIcon icon5;
   icon5.addFile(QString::fromUtf8(":/mitkPython/document-open.png"), QSize(), QIcon::Normal, QIcon::Off);
   d->m_LoadSnippets->setIcon(icon5);
 
   d->m_SaveSnippets = new QAction(this);
   d->m_SaveSnippets->setToolTip("Save Snippets to disk.");
   d->m_SaveSnippets->setObjectName(QString::fromUtf8("SaveSnippets"));
   QIcon icon6;
   icon6.addFile(QString::fromUtf8(":/mitkPython/document-save.png"), QSize(), QIcon::Normal, QIcon::Off);
   d->m_SaveSnippets->setIcon(icon6);
   d->m_SaveSnippets->setEnabled(false);
 
   d->m_Toolbar = new QToolBar;
   d->m_Toolbar->addAction( d->m_PasteSnippet );
   d->m_Toolbar->addAction( d->m_AddSnippet );
   d->m_Toolbar->addAction( d->m_RemoveSnippet );
   d->m_Toolbar->addAction( d->m_RenameSnippet );
   d->m_Toolbar->addAction( d->m_RestoreDefaultSnippets );
   d->m_Toolbar->addAction( d->m_SaveSnippets );
   d->m_Toolbar->addAction( d->m_LoadSnippets );
 
   d->m_Name = new QComboBox;
   d->m_Name->setObjectName(QString::fromUtf8("Name"));
 
   d->m_Content = new QTextEdit(this);
   d->m_Content->setObjectName(QString::fromUtf8("Content"));
   d->m_Content->setEnabled(false);
 
   QmitkPythonScriptEditorHighlighter* highlighter =
       new QmitkPythonScriptEditorHighlighter( d->m_Content->document() );
 
   d->m_Layout = new QGridLayout;
   d->m_Layout->addWidget( d->m_Toolbar, 0, 0, 1, 1 );
   d->m_Layout->addWidget( d->m_Name, 1, 0, 1, 1 );
   d->m_Layout->addWidget( d->m_Content, 2, 0, 1, 1 );
   d->m_Layout->setContentsMargins(2,2,2,2);
 
   this->setLayout(d->m_Layout);
   QMetaObject::connectSlotsByName(this);
 
   d->m_AutoSaveFileName = _AutoSaveFileName;
 
-  if( !this->StringMapFromXmlFile( d->m_AutoSaveFileName, d->m_Snippets ) )
+  if( !this->LoadStringMap( d->m_AutoSaveFileName, d->m_Snippets ) )
   {
-    this->StringMapFromXmlFile( DEFAULT_SNIPPET_FILE, d->m_Snippets );
+    this->LoadStringMap( DEFAULT_SNIPPET_FILE, d->m_Snippets );
   }
 
   this->Update();
 }
 
 QmitkPythonSnippets::~QmitkPythonSnippets()
 {
   delete d;
 }
 
 void QmitkPythonSnippets::on_PasteSnippet_triggered( bool )
 {
   emit PasteCommandRequested( d->m_Content->toPlainText() );
 }
 
 void QmitkPythonSnippets::on_RenameSnippet_triggered(bool)
 {
   QString oldname = d->m_Name->currentText();
   QString name = oldname;
   bool ok = false;
   while( true )
   {
     name = QInputDialog::getText(this,
                                  tr("Add new snippet"),
                                  tr("Name of snippet:"),
                                  QLineEdit::Normal,
                                  name,
                                  &ok);
 
     if (ok)
     {
       if ( d->m_Snippets.contains(name) )
       {
         QMessageBox::warning(this,
                              tr("Duplicate name."),
                              tr("The entered name already exists. Enter another one or cancel the operation."),
                              QMessageBox::Ok,
                              QMessageBox::Ok );
       }
       else
       {
         QString tmpSnippet = d->m_Snippets[oldname];
         d->m_Snippets.remove(oldname);
         d->m_Snippets[name] = tmpSnippet;
         this->Update(name);
+        this->SaveStringMap( d->m_AutoSaveFileName, d->m_Snippets );
         break;
       }
     }
     else
     {
       break;
     }
   }
 }
 
 void QmitkPythonSnippets::on_AddSnippet_triggered(bool)
 {
   bool ok;
   QString name = QInputDialog::getText(this,
                                        tr("Add new snippet"),
                                        tr("Name of snippet:"),
                                        QLineEdit::Normal,
                                        "newSnippet",
                                        &ok);
   if (ok && !name.isEmpty())
   {
     MITK_DEBUG("QmitkPythonSnippets") << "creating unique name for " << name.toStdString();
     name = this->CreateUniqueName(name);
 
     MITK_DEBUG("QmitkPythonSnippets") << "creating snippet " << name.toStdString();
     d->m_Snippets[name] = "";
     this->Update(name);
+    this->SaveStringMap( d->m_AutoSaveFileName, d->m_Snippets );
   }
 }
 
 QString QmitkPythonSnippets::CreateUniqueName( const QString& name ) const
 {
   QString newName = name;
   size_t i = 2;
   while( d->m_Snippets.contains(name) )
   {
     newName = name + QString("_%1").arg(i);
     ++i;
   }
 
   return newName;
 }
 
 void QmitkPythonSnippets::on_RemoveSnippet_triggered(bool)
 {
   QString name = d->m_Name->currentText();
   QString question = QString("Really remove Snippet %1?").arg(name);
   int remove = QMessageBox::question( this,
                                       QString("Confirm removal"),
                                       question,
                                       QMessageBox::Yes | QMessageBox::No,
                                       QMessageBox::No );
 
   if( remove == QMessageBox::Yes || remove == QMessageBox::Ok )
   {
     d->m_Snippets.remove(name);
     this->Update();
+    this->SaveStringMap( d->m_AutoSaveFileName, d->m_Snippets );
   }
 }
 
 void QmitkPythonSnippets::on_RestoreDefaultSnippets_triggered(bool)
 {
   QString question = QString("Really restore default Snippets?");
   int remove = QMessageBox::question( this,
                                       QString("Confirm restoring"),
                                       question,
                                       QMessageBox::Yes | QMessageBox::No,
                                       QMessageBox::No );
   if( remove == QMessageBox::Yes || remove == QMessageBox::Ok )
   {
-    this->StringMapFromXmlFile( DEFAULT_SNIPPET_FILE, d->m_Snippets );
+    this->LoadStringMap( DEFAULT_SNIPPET_FILE, d->m_Snippets );
     this->Update();
+    this->SaveStringMap( d->m_AutoSaveFileName, d->m_Snippets );
   }
 }
 
 void QmitkPythonSnippets::on_Name_currentIndexChanged(int i)
 {
   bool validSelection =  i >= 0 ;
 
   d->m_PasteSnippet->setEnabled(validSelection);
   d->m_RemoveSnippet->setEnabled(validSelection);
   d->m_RenameSnippet->setEnabled(validSelection);
   d->m_Content->setEnabled(validSelection);
   d->m_SaveSnippets->setEnabled(validSelection);
 
   if( validSelection )
   {
     QString name = d->m_Name->currentText();
     d->m_Content->setText( d->m_Snippets[name] );
   }
 }
 
-void QmitkPythonSnippets::StringMapToXmlFile(const QString &filename, const QmitkPythonSnippets::QStringMap &map) const
+void QmitkPythonSnippets::SaveStringMap(const QString &filename, const QmitkPythonSnippets::QStringMap &map) const
 {
   MITK_DEBUG("QmitkPythonSnippets") << "saving to xml file " << filename.toStdString();
 
-  QXmlStreamWriter* xmlWriter;
-  QFile file;
-  QByteArray data;
-  if( filename.startsWith(":") )
+  if( filename.isEmpty() )
   {
-    QResource res( filename );
-    data = QByteArray( reinterpret_cast< const char* >( res.data() ), res.size() );
-    xmlWriter = new QXmlStreamWriter(&data);
-  }
-  else
-  {
-    QFile file(filename);
-    file.open(QIODevice::WriteOnly);
-    xmlWriter = new QXmlStreamWriter(&file);
+    MITK_WARN("QmitkPythonSnippets") << "empty auto save file path given. quit.";
+    return;
   }
 
-  xmlWriter->setAutoFormatting(true);
-  xmlWriter->writeStartDocument();
-  xmlWriter->writeStartElement(SNIPPETS_ROOT_XML_ELEMENT_NAME);
+  QFile file(filename);
+  file.open(QIODevice::WriteOnly);
+  QXmlStreamWriter xmlWriter(&file);
+
+  xmlWriter.setAutoFormatting(true);
+  xmlWriter.writeStartDocument();
+  xmlWriter.writeStartElement(SNIPPETS_ROOT_XML_ELEMENT_NAME);
 
   QStringMap::const_iterator it = d->m_Snippets.begin();
   while( it != d->m_Snippets.end() )
   {
     MITK_DEBUG("QmitkPythonSnippets") << "writing item " << it.key().toStdString();
-    xmlWriter->writeStartElement(SNIPPETS_XML_ELEMENT_NAME);
+    xmlWriter.writeStartElement(SNIPPETS_XML_ELEMENT_NAME);
 
-    xmlWriter->writeAttribute( "key", it.key() );
-    xmlWriter->writeAttribute( "value", it.value() );
+    xmlWriter.writeAttribute( "key", it.key() );
+    xmlWriter.writeAttribute( "value", it.value() );
 
     ++it;
   }
 
-  xmlWriter->writeEndElement();
-  xmlWriter->writeEndDocument();
+  xmlWriter.writeEndElement();
+  xmlWriter.writeEndDocument();
   if( file.isOpen() )
     file.close();
 
-  delete xmlWriter;
 }
 
-bool QmitkPythonSnippets::StringMapFromXmlFile( const QString& filename, QmitkPythonSnippets::QStringMap& oldMap ) const
+bool QmitkPythonSnippets::LoadStringMap( const QString& filename, QmitkPythonSnippets::QStringMap& oldMap ) const
 {
   MITK_DEBUG("QmitkPythonSnippets") << "loading from xml file " << filename.toStdString();
-
-  bool errorOccured = false;
   QStringMap map;
-  QFile file(filename);
-  if (!file.open(QFile::ReadOnly | QFile::Text))
+
+  QXmlStreamReader xmlReader;
+  QFile file;
+  QByteArray data;
+  // resource file
+  if( filename.startsWith(":") )
   {
-      MITK_ERROR << "Error: Cannot read file " << qPrintable(filename)
-       << ": " << qPrintable(file.errorString());
-      errorOccured = true;
+    QResource res( filename );
+    data = QByteArray( reinterpret_cast< const char* >( res.data() ), res.size() );
+    xmlReader.addData( data );
+  }
+  else
+  {
+    file.setFileName( filename );
+    if (!file.open(QFile::ReadOnly | QFile::Text))
+    {
+        MITK_ERROR << "Error: Cannot read file " << qPrintable(filename)
+         << ": " << qPrintable(file.errorString());
+        return false;
+    }
+    xmlReader.setDevice(&file);
   }
 
-  QXmlStreamReader Rxml;
-  Rxml.setDevice(&file);
-  Rxml.readNext();
+  xmlReader.readNext();
 
-  while(!Rxml.atEnd())
+  while(!xmlReader.atEnd())
   {
-    Rxml.readNext();
+    xmlReader.readNext();
 
-    if(Rxml.name() == SNIPPETS_XML_ELEMENT_NAME)
+    if(xmlReader.name() == SNIPPETS_XML_ELEMENT_NAME)
     {
-      QXmlStreamAttributes attributes = Rxml.attributes();
+      QXmlStreamAttributes attributes = xmlReader.attributes();
       QString key;
       QString value;
       if(attributes.hasAttribute("key"))
       {
         key = attributes.value("key").toString();
       }
 
       if(attributes.hasAttribute("value"))
       {
         value = attributes.value("value").toString();
       }
 
       if( !key.isEmpty() )
       {
         MITK_DEBUG("QmitkPythonSnippets") << "loaded snippet " << key.toStdString();
         MITK_DEBUG("QmitkPythonSnippets") << "value " << value.toStdString();
         map[key] = value;
       }
     }
   }
-  file.close();
 
-  if (Rxml.hasError())
+  if (xmlReader.hasError())
   {
     MITK_ERROR << "Error: Failed to parse file "
       << qPrintable(filename) << ": "
-      << qPrintable(Rxml.errorString());
-    errorOccured = true;
+      << qPrintable(xmlReader.errorString());
+    return false;
   }
   else if (file.error() != QFile::NoError)
   {
     MITK_ERROR << "Error: Cannot read file " << qPrintable(filename)
       << ": " << qPrintable(file.errorString());
-    errorOccured = true;
+    return false;
   }
 
+  if( file.isOpen() )
+    file.close();
+
   oldMap = map;
-  return errorOccured;
+  return true;
 }
 
 void QmitkPythonSnippets::Update(const QString &name)
 {
   d->m_Name->clear();
   d->m_Content->clear();
 
   MITK_DEBUG("QmitkPythonSnippets") << "size of snippets " << d->m_Snippets.size();
   QStringMap::const_iterator it = d->m_Snippets.begin();
 
   while( it != d->m_Snippets.end() )
   {
     MITK_DEBUG("QmitkPythonSnippets") << "adding item " << it.key().toStdString();
     d->m_Name->addItem( it.key() );
     ++it;
   }
 
   int index = d->m_Name->findText( name );
   if( index >= 0 )
   {
     MITK_DEBUG("QmitkPythonSnippets") << "selecting index " << index;
     d->m_Name->setCurrentIndex(index);
   }
 
 }
 
 void QmitkPythonSnippets::on_Content_textChanged()
 {
   if( d->m_Content->isEnabled() )
   {
     QString name = d->m_Name->currentText();
     QString snippet = d->m_Content->toPlainText();
     d->m_Snippets[name] = snippet;
+    this->SaveStringMap( d->m_AutoSaveFileName, d->m_Snippets );
   }
 }
 
 void QmitkPythonSnippets::on_SaveSnippets_triggered(bool)
 {
   QString fileName = QFileDialog::getSaveFileName(this, "Save snippets", d->m_SaveFileName, "XML files (*.xml)");
   if( !fileName.isEmpty() )
   {
     d->m_SaveFileName = fileName;
-    this->StringMapToXmlFile( d->m_SaveFileName, d->m_Snippets );
+    this->SaveStringMap( d->m_SaveFileName, d->m_Snippets );
   }
 }
 
 void QmitkPythonSnippets::on_LoadSnippets_triggered(bool)
 {
   QString fileName = QFileDialog::getOpenFileName(this, "Load snippets", d->m_SaveFileName, "XML files (*.xml)");
 
   if( !fileName.isEmpty() )
   {
     d->m_SaveFileName = fileName;
     QString question = QString("Your current snippets will be overwritten. Proceed?");
     int overwrite = QMessageBox::warning(this,
                                         QString("Confirm overwrite"),
                                         question,
                                         QMessageBox::Yes | QMessageBox::No,
                                         QMessageBox::No );
 
     if( overwrite == QMessageBox::Yes )
     {
-      this->StringMapFromXmlFile( d->m_SaveFileName, d->m_Snippets );
+      this->LoadStringMap( d->m_SaveFileName, d->m_Snippets );
       this->Update( d->m_Name->currentText() );
+      this->SaveStringMap( d->m_AutoSaveFileName, d->m_Snippets );
     }
   }
 
 }
diff --git a/Modules/Python/QmitkPythonSnippets.h b/Modules/Python/QmitkPythonSnippets.h
index 9729099f61..6a0b2b97a2 100644
--- a/Modules/Python/QmitkPythonSnippets.h
+++ b/Modules/Python/QmitkPythonSnippets.h
@@ -1,104 +1,104 @@
 /*===================================================================
 
 The Medical Imaging Interaction Toolkit (MITK)
 
 Copyright (c) German Cancer Research Center,
 Division of Medical and Biological Informatics.
 All rights reserved.
 
 This software is distributed WITHOUT ANY WARRANTY; without
 even the implied warranty of MERCHANTABILITY or FITNESS FOR
 A PARTICULAR PURPOSE.
 
 See LICENSE.txt or http://www.mitk.org for details.
 
 ===================================================================*/
 
 #ifndef _QmitkPythonSnippets_H
 #define _QmitkPythonSnippets_H
 
 #include <QWidget>
 #include <QMap>
 #include "mitkPythonExports.h"
 struct QmitkPythonSnippetsData;
 
 ///
 /// a widget that holds snippets and serializes the snippets to a certain places
 class MITK_PYTHON_EXPORT QmitkPythonSnippets: public QWidget
 {
   Q_OBJECT
 
   public:
     static const QString DEFAULT_SNIPPET_FILE;
     static const QString SNIPPETS_ROOT_XML_ELEMENT_NAME;
     static const QString SNIPPETS_XML_ELEMENT_NAME;
     ///
     /// typedef for string map
     typedef QMap<QString, QString> QStringMap;
     ///
     /// build ui here
     /// the snippets will be loaded from _AutoSaveFileName if not empty and readable
     /// otherwise the default snippets will be loaded
     QmitkPythonSnippets( const QString& _AutoSaveFileName="", QWidget* parent=0 );
     ///
     /// delete d pointer
     virtual ~QmitkPythonSnippets();
 signals:
     ///
     /// this class whishes to paste sth command
     void PasteCommandRequested(const QString& command);
 
   protected slots:
     ///
     /// emits PasteCommandRequested signal
     void on_PasteSnippet_triggered( bool checked = false );
     ///
     /// ask for name as long as it exists, call update()
     void on_RenameSnippet_triggered( bool checked = false );
     ///
     /// ask for name, create snippet, call update()
     void on_AddSnippet_triggered( bool checked = false );
     ///
     /// remove the current snippet, call update()
     void on_RemoveSnippet_triggered( bool checked = false );
     ///
-    /// call StringMapFromXmlFile with d->m_DefaultSnippetsAutoSaveFileName
+    /// call LoadStringMap with d->m_DefaultSnippetsAutoSaveFileName
     void on_RestoreDefaultSnippets_triggered( bool checked = false );
     ///
     /// update action state (enable/disable), update text box
     void on_Name_currentIndexChanged( int i );
     ///
     /// save changed snippet
     void on_Content_textChanged();
     ///
     /// ask for file, save snippets
     void on_SaveSnippets_triggered( bool checked = false );
     ///
     /// ask for file, load snippets (do not replace)
     void on_LoadSnippets_triggered( bool checked = false );
 
   protected:
     ///
     /// write string map to xml file
-    void StringMapToXmlFile( const QString& filename, const QStringMap& map ) const;
+    void SaveStringMap( const QString& filename, const QStringMap& map ) const;
     ///
     /// read string map from xml file
-    bool StringMapFromXmlFile( const QString& filename, QStringMap& oldMap ) const;
+    bool LoadStringMap( const QString& filename, QStringMap& oldMap ) const;
     ///
     /// creates a name which does not exist in the list
     QString CreateUniqueName(const QString &name) const;
     ///
     /// update combo box
     /// if name is passed, the according element will be selected
     void Update(const QString &name = "");
   private:
     ///
     /// d pointer declaration (holds members)
     QmitkPythonSnippetsData* d;
 };
 
 
 
 
 #endif // _QmitkPythonSnippets_H_INCLUDED
 
diff --git a/Modules/Python/QmitkPythonVariableStackTableModel.cpp b/Modules/Python/QmitkPythonVariableStackTableModel.cpp
index 55385f6607..68e25862ee 100755
--- a/Modules/Python/QmitkPythonVariableStackTableModel.cpp
+++ b/Modules/Python/QmitkPythonVariableStackTableModel.cpp
@@ -1,217 +1,218 @@
 /*===================================================================
 
 The Medical Imaging Interaction Toolkit (MITK)
 
 Copyright (c) German Cancer Research Center,
 Division of Medical and Biological Informatics.
 All rights reserved.
 
 This software is distributed WITHOUT ANY WARRANTY; without
 even the implied warranty of MERCHANTABILITY or FITNESS FOR
 A PARTICULAR PURPOSE.
 
 See LICENSE.txt or http://www.mitk.org for details.
 
 ===================================================================*/
 
 #include "QmitkPythonVariableStackTableModel.h"
 #include <QMimeData>
 #include <mitkModuleContext.h>
 #include <usServiceReference.h>
 #include <mitkDataNode.h>
 #include <mitkGetModuleContext.h>
 #include <QStringList>
 #include <QMessageBox>
 
 const QString QmitkPythonVariableStackTableModel::MITK_IMAGE_VAR_NAME = "mitkImage";
 const QString QmitkPythonVariableStackTableModel::MITK_SURFACE_VAR_NAME = "mitkSurface";
 
 QmitkPythonVariableStackTableModel::QmitkPythonVariableStackTableModel(QObject *parent)
     :QAbstractTableModel(parent)
 {
     mitk::ModuleContext* context = mitk::GetModuleContext();
     mitk::ServiceReference serviceRef = context->GetServiceReference<mitk::IPythonService>();
     m_PythonService = context->GetService<mitk::IPythonService>(serviceRef);
     m_PythonService->AddPythonCommandObserver( this );
 }
 
 QmitkPythonVariableStackTableModel::~QmitkPythonVariableStackTableModel()
 {
   m_PythonService->RemovePythonCommandObserver( this );
 }
 
 bool QmitkPythonVariableStackTableModel::dropMimeData ( const QMimeData * data, Qt::DropAction action, int row, int column, const QModelIndex & parent )
 {
     // Early exit, returning true, but not actually doing anything (ignoring data).
     if (action == Qt::IgnoreAction)
         return true;
 
     // Note, we are returning true if we handled it, and false otherwise
     bool returnValue = false;
 
     if(data->hasFormat("application/x-mitk-datanodes"))
     {
         MITK_DEBUG("QmitkPythonVariableStackTableModel") << "dropped MITK DataNode";
         returnValue = true;
 
         QString arg = QString(data->data("application/x-mitk-datanodes").data());
         QStringList listOfDataNodeAddressPointers = arg.split(",");
 
         QStringList::iterator slIter;
         int i = 0;
         int j = 0;
         for (slIter = listOfDataNodeAddressPointers.begin();
              slIter != listOfDataNodeAddressPointers.end();
              slIter++)
         {
           long val = (*slIter).toLong();
           mitk::DataNode* node = static_cast<mitk::DataNode *>((void*)val);
           mitk::Image* mitkImage = dynamic_cast<mitk::Image*>(node->GetData());
 
           if( mitkImage )
           {
             QString varName = MITK_IMAGE_VAR_NAME;
             if( i > 0 )
               varName = QString("%1%2").arg(MITK_IMAGE_VAR_NAME).arg(i);
             MITK_DEBUG("varName") << "varName" << varName;
 
             bool exportAsCvImage = m_PythonService->IsOpenCvPythonWrappingAvailable();
 
             if( mitkImage->GetDimension() == 2 && exportAsCvImage )
             {
-              int ret = QMessageBox::question(this, "Export option",
+              int ret = QMessageBox::question(NULL, "Export option",
                 "2D image detected. Export as OpenCV image to Python instead of an ITK image?",
-                QMessageBox::Yes|QMessageBox::No);
+                                              QMessageBox::Yes | QMessageBox::No, QMessageBox::No);
+
               exportAsCvImage = ret == QMessageBox::Yes;
               if(exportAsCvImage)
               {
                 m_PythonService->CopyToPythonAsCvImage( mitkImage, MITK_IMAGE_VAR_NAME );
                 ++i;
               }
             }
             if( !exportAsCvImage )
             {
               if( m_PythonService->IsItkPythonWrappingAvailable() )
               {
                 m_PythonService->CopyToPythonAsItkImage( mitkImage, MITK_IMAGE_VAR_NAME );
                 ++i;
               }
               else
               {
                 MITK_ERROR << "ITK Python wrapping not available. Skipping export for image " << node->GetName();
               }
             }
           }
           else
           {
             mitk::Surface* surface = dynamic_cast<mitk::Surface*>(node->GetData());
 
             if( surface )
             {
               QString varName = MITK_SURFACE_VAR_NAME;
               if( j > 0 )
                 varName = QString("%1%2").arg(MITK_SURFACE_VAR_NAME).arg(j);
               MITK_DEBUG("varName") << "varName" << varName;
 
               if( m_PythonService->IsVtkPythonWrappingAvailable() )
               {
                 m_PythonService->CopyToPythonAsVtkPolyData( surface, MITK_SURFACE_VAR_NAME );
                 ++j;
               }
               else
               {
                 MITK_ERROR << "VTK Python wrapping not available. Skipping export for surface " << node->GetName();
               }
             }
           }
         }
     }
     return returnValue;
 }
 
 QVariant QmitkPythonVariableStackTableModel::headerData(int section, Qt::Orientation orientation,
                                                         int role) const
 {
     QVariant headerData;
 
     // show only horizontal header
     if ( role == Qt::DisplayRole )
     {
         if( orientation == Qt::Horizontal )
         {
             // first column: "Attribute"
             if(section == 0)
                 headerData = "Attribute";
             else if(section == 1)
                 headerData = "Value";
             else if(section == 2)
                 headerData = "Type";
         }
     }
 
     return headerData;
 }
 
 Qt::ItemFlags QmitkPythonVariableStackTableModel::flags(const QModelIndex &index) const
 {
     Qt::ItemFlags flags = QAbstractItemModel::flags(index);
 
     if(index.isValid())
         return Qt::ItemIsDragEnabled | Qt::ItemIsDropEnabled | flags;
     else
         return Qt::ItemIsDropEnabled | flags;
 }
 
 int QmitkPythonVariableStackTableModel::rowCount(const QModelIndex &) const
 {
     return m_VariableStack.size();
 }
 
 int QmitkPythonVariableStackTableModel::columnCount(const QModelIndex &) const
 {
     return 3;
 }
 
 QVariant QmitkPythonVariableStackTableModel::data(const QModelIndex &index, int role) const
 {
     if (index.isValid() && !m_VariableStack.empty())
     {
         if(role == Qt::DisplayRole)
         {
             mitk::PythonVariable item = m_VariableStack.at(index.row());
             if(index.column() == 0)
                 return item.m_Name;
             if(index.column() == 1)
                 return item.m_Value;
             if(index.column() == 2)
                 return item.m_Type;
         }
     }
     return QVariant();
 }
 
 QStringList QmitkPythonVariableStackTableModel::mimeTypes() const
 {
     return QAbstractTableModel::mimeTypes();
     QStringList types;
     types << "application/x-mitk-datanodes";
     types << "application/x-qabstractitemmodeldatalist";
     return types;
 }
 
 Qt::DropActions QmitkPythonVariableStackTableModel::supportedDropActions() const
 {
     return Qt::CopyAction | Qt::MoveAction;
 }
 
 void QmitkPythonVariableStackTableModel::CommandExecuted(const QString &pythonCommand)
 {
   MITK_DEBUG("QmitkPythonVariableStackTableModel") << "command was executed " << pythonCommand.toStdString();
     m_VariableStack = m_PythonService->GetVariableStack();
     QAbstractTableModel::reset();
 }
 
 QList<mitk::PythonVariable> QmitkPythonVariableStackTableModel::GetVariableStack() const
 {
     return m_VariableStack;
 }
diff --git a/Plugins/org.mitk.gui.qt.python/src/internal/QmitkPythonView.cpp b/Plugins/org.mitk.gui.qt.python/src/internal/QmitkPythonView.cpp
index 61cf307900..3e78a732a0 100644
--- a/Plugins/org.mitk.gui.qt.python/src/internal/QmitkPythonView.cpp
+++ b/Plugins/org.mitk.gui.qt.python/src/internal/QmitkPythonView.cpp
@@ -1,90 +1,93 @@
 /*===================================================================
 
 The Medical Imaging Interaction Toolkit (MITK)
 
 Copyright (c) German Cancer Research Center,
 Division of Medical and Biological Informatics.
 All rights reserved.
 
 This software is distributed WITHOUT ANY WARRANTY; without
 even the implied warranty of MERCHANTABILITY or FITNESS FOR
 A PARTICULAR PURPOSE.
 
 See LICENSE.txt or http://www.mitk.org for details.
 
 ===================================================================*/
 
 #include "QmitkPythonView.h"
 #include <QtGui>
 #include <QmitkCtkPythonShell.h>
 #include "mitkPluginActivator.h"
 #include <QmitkPythonVariableStackTableView.h>
 #include <QmitkPythonTextEditor.h>
 #include <QmitkPythonSnippets.h>
 
 const std::string QmitkPythonView::VIEW_ID = "org.mitk.views.python";
 
 struct QmitkPythonViewData
 {
     // widget
     QmitkPythonVariableStackTableView* m_PythonVariableStackTableView;
     QmitkPythonSnippets* m_PythonSnippets;
 
     QmitkCtkPythonShell* m_PythonShell;
     QmitkPythonTextEditor* m_TextEditor;
 };
 
 QmitkPythonView::QmitkPythonView()
     : d( new QmitkPythonViewData )
 {
     d->m_PythonVariableStackTableView = 0;
     d->m_PythonShell = 0;
 }
 
 QmitkPythonView::~QmitkPythonView()
 {
     delete d;
 }
 
 void QmitkPythonView::CreateQtPartControl(QWidget* parent)
 {
     d->m_PythonVariableStackTableView = new QmitkPythonVariableStackTableView;
     d->m_PythonVariableStackTableView->SetDataStorage(this->GetDataStorage());
     d->m_PythonVariableStackTableView->horizontalHeader()->setResizeMode(QHeaderView::Stretch);
 
-    d->m_PythonSnippets = new QmitkPythonSnippets;
+    QString snippetsFilePath = mitk::PluginActivator::m_XmlFilePath;
+    MITK_DEBUG("QmitkPythonView") << "got snippetsFilePath " << snippetsFilePath.toStdString();
+
+    d->m_PythonSnippets = new QmitkPythonSnippets(snippetsFilePath);
 
     QTabWidget* varStackSnippetsTab = new QTabWidget;
     varStackSnippetsTab->addTab( d->m_PythonVariableStackTableView, "Variable Stack" );
     varStackSnippetsTab->addTab( d->m_PythonSnippets, "Snippets" );
     varStackSnippetsTab->setTabPosition( QTabWidget::South );
 
     d->m_PythonShell = new QmitkCtkPythonShell;
 
     d->m_TextEditor = new QmitkPythonTextEditor;
 
     QTabWidget* tabWidgetConsoleEditor = new QTabWidget;
     tabWidgetConsoleEditor->addTab( d->m_PythonShell, "Console" );
     tabWidgetConsoleEditor->addTab( d->m_TextEditor, "Text Editor" );
     tabWidgetConsoleEditor->setTabPosition( QTabWidget::South );
 
     QList<int> sizes;
     sizes << 1 << 3;
     QSplitter* splitter = new QSplitter;
     splitter->addWidget(varStackSnippetsTab);
     splitter->addWidget(tabWidgetConsoleEditor);
     splitter->setStretchFactor ( 0, 1 );
     splitter->setStretchFactor ( 1, 3 );
 
     QGridLayout* layout = new QGridLayout;
     layout->addWidget( splitter, 0, 0 );
     parent->setLayout(layout);
 
     connect( d->m_PythonSnippets, SIGNAL(PasteCommandRequested(QString)), d->m_PythonShell, SLOT(Paste(QString)) );
     connect( d->m_PythonSnippets, SIGNAL(PasteCommandRequested(QString)), d->m_TextEditor, SLOT(Paste(QString)) );
 }
 
 void QmitkPythonView::SetFocus()
 {
     d->m_PythonShell->setFocus();
 }
diff --git a/Plugins/org.mitk.gui.qt.python/src/internal/mitkPluginActivator.cpp b/Plugins/org.mitk.gui.qt.python/src/internal/mitkPluginActivator.cpp
index c9ce4149a5..e59a8e8108 100644
--- a/Plugins/org.mitk.gui.qt.python/src/internal/mitkPluginActivator.cpp
+++ b/Plugins/org.mitk.gui.qt.python/src/internal/mitkPluginActivator.cpp
@@ -1,35 +1,38 @@
 /*===================================================================
 
 The Medical Imaging Interaction Toolkit (MITK)
 
 Copyright (c) German Cancer Research Center,
 Division of Medical and Biological Informatics.
 All rights reserved.
 
 This software is distributed WITHOUT ANY WARRANTY; without
 even the implied warranty of MERCHANTABILITY or FITNESS FOR
 A PARTICULAR PURPOSE.
 
 See LICENSE.txt or http://www.mitk.org for details.
 
 ===================================================================*/
 #include "mitkPluginActivator.h"
 #include <QtPlugin>
 #include "QmitkPythonView.h"
 
 namespace mitk
 {
+    QString PluginActivator::m_XmlFilePath;
 
     void PluginActivator::start(ctkPluginContext* context)
     {
+      m_XmlFilePath = context->getDataFile("PythonSnippets.xml").absoluteFilePath();
+
       BERRY_REGISTER_EXTENSION_CLASS(QmitkPythonView, context)
     }
 
     void PluginActivator::stop(ctkPluginContext* context)
     {
         Q_UNUSED(context)
     }
 
 }
 
 Q_EXPORT_PLUGIN2(org_mitk_gui_qt_python, mitk::PluginActivator)
diff --git a/Plugins/org.mitk.gui.qt.python/src/internal/mitkPluginActivator.h b/Plugins/org.mitk.gui.qt.python/src/internal/mitkPluginActivator.h
index eb6cd768f0..9a32e11e62 100644
--- a/Plugins/org.mitk.gui.qt.python/src/internal/mitkPluginActivator.h
+++ b/Plugins/org.mitk.gui.qt.python/src/internal/mitkPluginActivator.h
@@ -1,38 +1,39 @@
 /*===================================================================
 
 The Medical Imaging Interaction Toolkit (MITK)
 
 Copyright (c) German Cancer Research Center,
 Division of Medical and Biological Informatics.
 All rights reserved.
 
 This software is distributed WITHOUT ANY WARRANTY; without
 even the implied warranty of MERCHANTABILITY or FITNESS FOR
 A PARTICULAR PURPOSE.
 
 See LICENSE.txt or http://www.mitk.org for details.
 
 ===================================================================*/
 #ifndef MITKPLUGINACTIVATOR_H
 #define MITKPLUGINACTIVATOR_H
 
 #include <ctkPluginActivator.h>
 #include <mitkExportMacros.h>
 
 namespace mitk {
 
 class MITK_LOCAL PluginActivator :
   public QObject, public ctkPluginActivator
 {
   Q_OBJECT
   Q_INTERFACES(ctkPluginActivator)
 
 public:
   void start(ctkPluginContext* context);
   void stop(ctkPluginContext* context);
 
+  static QString m_XmlFilePath;
 }; // PluginActivator
 
 }
 
 #endif // MITKPLUGINACTIVATOR_H