diff --git a/GUI/coregui/Models/GUIObjectBuilder.cpp b/GUI/coregui/Models/GUIObjectBuilder.cpp
index c14457e9d80d9dd5e6833a3c959dce8ef92dbe1e..9afe15334b9e3405b7cc6978adcb82ea08d3ca6e 100644
--- a/GUI/coregui/Models/GUIObjectBuilder.cpp
+++ b/GUI/coregui/Models/GUIObjectBuilder.cpp
@@ -509,23 +509,22 @@ void GUIObjectBuilder::visit(const LayerRoughness *)
 MaterialProperty GUIObjectBuilder::createMaterialFromDomain(
         const IMaterial *material)
 {
-    Q_ASSERT(0);
-//    QString materialName = m_topSampleName + QString("_")
-//            + QString(material->getName().c_str());
+    QString materialName = m_topSampleName + QString("_")
+            + QString(material->getName().c_str());
 
-//    MaterialProperty materialProperty =
-//            MaterialEditor::getMaterialProperty(materialName);
-//    if(materialProperty.isDefined()) return materialProperty;
+    MaterialProperty materialProperty =
+            MaterialEditor::getMaterialProperty(materialName);
+    if(materialProperty.isDefined()) return materialProperty;
 
-//    MaterialModel *model = MaterialEditor::getMaterialModel();
+    MaterialModel *model = MaterialEditor::getMaterialModel();
 
-//    if(material->isScalarMaterial()) {
-//      MaterialItem *materialItem  = model->addMaterial(materialName,
-//                                       MaterialItem::HomogeneousMaterial);
-//      complex_t rindex = material->getRefractiveIndex();
-//      materialItem->setRefractiveIndex(1-rindex.real(),rindex.imag());
-//      return MaterialUtils::getMaterialProperty(materialItem);
-//    }
+    if(material->isScalarMaterial()) {
+      complex_t rindex = material->getRefractiveIndex();
+      MaterialItem *materialItem  = model->addMaterial(materialName, 1-rindex.real(),rindex.imag());
+      return MaterialProperty(materialItem->getIdentifier());
+    } else {
+        throw GUIHelpers::Error("GUIObjectBuilder::createMaterialFromDomain() -> Not implemented.");
+    }
 
-//    return MaterialProperty();
+    return MaterialProperty();
 }
diff --git a/GUI/coregui/Models/MaterialItem.cpp b/GUI/coregui/Models/MaterialItem.cpp
index fc5c78d1e75056ad29eb09f3d74bdd4521dda1f1..c556f131c850be216ce3944dcce22b1d4969fefa 100644
--- a/GUI/coregui/Models/MaterialItem.cpp
+++ b/GUI/coregui/Models/MaterialItem.cpp
@@ -64,6 +64,18 @@ QColor MaterialItem::getColor() const
     return color_property.getColor();
 }
 
+bool MaterialItem::isHomogeneousMaterial() const
+{
+    ComboProperty combo_property = getRegisteredProperty(MaterialItem::P_MATERIAL_TYPE).value<ComboProperty>();
+    return (combo_property.getValue() == Constants::HomogeneousMaterialType);
+}
+
+bool MaterialItem::isHomogeneousMagneticMaterial() const
+{
+    ComboProperty combo_property = getRegisteredProperty(MaterialItem::P_MATERIAL_TYPE).value<ComboProperty>();
+    return (combo_property.getValue() == Constants::HomogeneousMagneticMaterialType);
+}
+
 
 //bool MaterialItem::setMaterialProperty(QString name, const QVariant &value)
 //{
diff --git a/GUI/coregui/Models/MaterialItem.h b/GUI/coregui/Models/MaterialItem.h
index 41d62820cffe0d1d20cc2e53c936b1eee4a2b0a0..057695a7ebf4a14e9d49079aa79728f5bc67e511 100644
--- a/GUI/coregui/Models/MaterialItem.h
+++ b/GUI/coregui/Models/MaterialItem.h
@@ -19,6 +19,10 @@ public:
     QString getIdentifier() const;
 
     QColor getColor() const;
+
+    bool isHomogeneousMaterial() const;
+
+    bool isHomogeneousMagneticMaterial() const;
 };
 
 
diff --git a/GUI/coregui/Models/MaterialModel.cpp b/GUI/coregui/Models/MaterialModel.cpp
index 33fc94c03194f98eee14bb482357e8b24dd69528..a1daf370aaf743e978c395079cf91e64be6482a3 100644
--- a/GUI/coregui/Models/MaterialModel.cpp
+++ b/GUI/coregui/Models/MaterialModel.cpp
@@ -30,21 +30,6 @@ void MaterialModel::removeMaterial(MaterialItem *item)
 {
     QModelIndex materialIndex = indexOfItem(item);
     removeRows(materialIndex.row(), 1, materialIndex.parent());
-
-    //bool MaterialModel::removeMaterial(MaterialItem *material)
-    //{
-    //    if(m_materials.contains(material)) {
-    //        int row = m_materials.indexOf(material);
-    //        beginRemoveRows(QModelIndex(), row, row);
-    //        m_materials.removeOne(material);
-    //        delete material;
-    //        endRemoveRows();
-    //        return true;
-    //    }
-    //    Q_ASSERT(0);
-    //    return false;
-    //}
-
 }
 
 MaterialItem *MaterialModel::getMaterial(const MaterialProperty &property)
@@ -61,6 +46,20 @@ MaterialItem *MaterialModel::getMaterial(const MaterialProperty &property)
     return 0;
 }
 
+MaterialItem *MaterialModel::getMaterial(const QString &material_name)
+{
+    qDebug() << "MaterialModel::getMaterial()";
+    QModelIndex parentIndex;
+    for( int i_row = 0; i_row < rowCount( parentIndex ); ++i_row) {
+         QModelIndex itemIndex = index( i_row, 0, parentIndex );
+
+         if (MaterialItem *material = dynamic_cast<MaterialItem *>(itemForIndex(itemIndex))){
+             if(material->itemName() == material_name) return material;
+         }
+    }
+    return 0;
+}
+
 
 
 
diff --git a/GUI/coregui/Models/MaterialModel.h b/GUI/coregui/Models/MaterialModel.h
index 31678be2eca3c888c116f436107f30f6aa37cb5c..b3ce200cddf0bc8687b571295330566b23f9ca35 100644
--- a/GUI/coregui/Models/MaterialModel.h
+++ b/GUI/coregui/Models/MaterialModel.h
@@ -16,6 +16,8 @@ public:
     void removeMaterial(MaterialItem *);
 
     MaterialItem *getMaterial(const MaterialProperty &property);
+    MaterialItem *getMaterial(const QString &material_name);
+
 };
 
 
diff --git a/GUI/coregui/Models/RefractiveIndexItem.cpp b/GUI/coregui/Models/RefractiveIndexItem.cpp
index d6a04330d1c5a57423ef2245e4ad48bec909e63c..61ff6a410265d960f0bba556db9445c6b6ecae46 100644
--- a/GUI/coregui/Models/RefractiveIndexItem.cpp
+++ b/GUI/coregui/Models/RefractiveIndexItem.cpp
@@ -16,5 +16,16 @@ RefractiveIndexItem::RefractiveIndexItem(ParameterizedItem *parent)
 QString RefractiveIndexItem::getItemLabel() const
 {
     return QString("(1 - %1, %2)").arg(getRegisteredProperty(P_DELTA).toDouble())
-                                  .arg(getRegisteredProperty(P_BETA).toDouble());
+            .arg(getRegisteredProperty(P_BETA).toDouble());
+}
+
+double RefractiveIndexItem::getDelta() const
+{
+    return getRegisteredProperty(P_DELTA).toDouble();
+
+}
+
+double RefractiveIndexItem::getBeta() const
+{
+    return getRegisteredProperty(P_BETA).toDouble();
 }
diff --git a/GUI/coregui/Models/RefractiveIndexItem.h b/GUI/coregui/Models/RefractiveIndexItem.h
index c64b4dd3318b8cfdaf5c707acc22ebbb1834c2b7..afb802f47650a4f248ea4dcd70762373159259f2 100644
--- a/GUI/coregui/Models/RefractiveIndexItem.h
+++ b/GUI/coregui/Models/RefractiveIndexItem.h
@@ -12,6 +12,8 @@ public:
     explicit RefractiveIndexItem(ParameterizedItem *parent=0);
     ~RefractiveIndexItem(){}
     QString getItemLabel() const;
+    double getDelta() const;
+    double getBeta() const;
 };
 
 
diff --git a/GUI/coregui/Models/TransformToDomain.cpp b/GUI/coregui/Models/TransformToDomain.cpp
index e2af0d063832b74d1e5eca96e478e31db006b064..07527ac3f04843ccc88a484459203dc9ed8f4c06 100644
--- a/GUI/coregui/Models/TransformToDomain.cpp
+++ b/GUI/coregui/Models/TransformToDomain.cpp
@@ -40,13 +40,17 @@
 
 IMaterial *TransformToDomain::createDomainMaterial(const ParameterizedItem &item)
 {
-    QVariant v = item.property("Material");
-    if( !v.isValid() )
-        throw GUIHelpers::Error("TransformToDomain::createDomainMaterial() -> "
-                                "No material property");
+    MaterialProperty material_property;
+    if(item.modelType() == Constants::ParticleType) {
+        material_property = item.getRegisteredProperty(ParticleItem::P_MATERIAL).value<MaterialProperty>();
+    }
+    else if(item.modelType() == Constants::LayerType) {
+        material_property = item.getRegisteredProperty(LayerItem::P_MATERIAL).value<MaterialProperty>();
+    }
+    if(!material_property.isDefined())
+        throw GUIHelpers::Error("TransformToDomain::createDomainMaterial() -> Error. Unknown item to create material");
 
-    MaterialProperty materialProperty = v.value<MaterialProperty>();
-    return MaterialUtils::createDomainMaterial(materialProperty.getName());
+    return MaterialUtils::createDomainMaterial(material_property);
 }
 
 MultiLayer *TransformToDomain::createMultiLayer(const ParameterizedItem &item)
diff --git a/GUI/coregui/Views/Components/MaterialEditor/MaterialEditor.cpp b/GUI/coregui/Views/Components/MaterialEditor/MaterialEditor.cpp
index a331a8fd6dcc2cc01e8eda8250c54d2af9c9dcaf..66bd68d58173def0e8a860e66481002349732162 100644
--- a/GUI/coregui/Views/Components/MaterialEditor/MaterialEditor.cpp
+++ b/GUI/coregui/Views/Components/MaterialEditor/MaterialEditor.cpp
@@ -55,10 +55,9 @@ MaterialProperty MaterialEditor::getMaterialProperty(const QString &name)
 
 MaterialProperty MaterialEditor::this_getMaterialProperty(const QString &name)
 {
-    Q_ASSERT(0);
-//    MaterialItem *material = m_materialModel->getMaterial(name);
-//    if(material)
-//        return MaterialUtils::getMaterialProperty(material);
+    MaterialItem *material = m_materialModel->getMaterial(name);
+    if(material)
+        return MaterialProperty(material->getIdentifier());
 
     return MaterialProperty();
 }
@@ -75,10 +74,13 @@ MaterialProperty MaterialEditor::getDefaultMaterialProperty()
 MaterialProperty MaterialEditor::this_getDefaultMaterialProperty()
 {
     Q_ASSERT(m_materialModel);
-    Q_ASSERT(m_materialModel->rowCount( QModelIndex() ));
-    QModelIndex firstIndex = m_materialModel->index(0, 0, QModelIndex());
-    MaterialItem *material = dynamic_cast<MaterialItem *>(m_materialModel->itemForIndex(firstIndex));
-    return MaterialProperty(material->getIdentifier());
+    if((m_materialModel->rowCount( QModelIndex() ) ) ) {
+        QModelIndex firstIndex = m_materialModel->index(0, 0, QModelIndex());
+        MaterialItem *material = dynamic_cast<MaterialItem *>(m_materialModel->itemForIndex(firstIndex));
+        return MaterialProperty(material->getIdentifier());
+    } else {
+        return MaterialProperty();
+    }
 }
 
 
diff --git a/GUI/coregui/Views/Components/MaterialEditor/MaterialProperty.h b/GUI/coregui/Views/Components/MaterialEditor/MaterialProperty.h
index 03db4bc31a87d56eaf3770286fd261434ccd86cf..580bd310bef546f83d86398f1916aae34a9cfe51 100644
--- a/GUI/coregui/Views/Components/MaterialEditor/MaterialProperty.h
+++ b/GUI/coregui/Views/Components/MaterialEditor/MaterialProperty.h
@@ -13,7 +13,7 @@
 class MaterialProperty
 {
 public:
-    MaterialProperty(const QString &identifier=QString())
+    explicit MaterialProperty(const QString &identifier=QString())
         : m_identifier(identifier){}
 
     QString getIdentifier() const {
diff --git a/GUI/coregui/Views/Components/MaterialEditor/MaterialUtils.cpp b/GUI/coregui/Views/Components/MaterialEditor/MaterialUtils.cpp
index 9dcba419ce5ca25645815cc1ae7256e4fd33d29a..da4070fe399be80ccf62aa9d93e71b1b977846e8 100644
--- a/GUI/coregui/Views/Components/MaterialEditor/MaterialUtils.cpp
+++ b/GUI/coregui/Views/Components/MaterialEditor/MaterialUtils.cpp
@@ -5,6 +5,9 @@
 #include "HomogeneousMagneticMaterial.h"
 #include "MaterialEditor.h"
 #include "MaterialModel.h"
+#include "RefractiveIndexItem.h"
+#include "MagneticFieldItem.h"
+#include "ComboProperty.h"
 #include <QDebug>
 
 
@@ -73,9 +76,9 @@ ColorProperty MaterialUtils::suggestMaterialColorProperty(const QString &name)
 //}
 
 
-IMaterial *MaterialUtils::createDomainMaterial(const MaterialItem *item)
-{
-    Q_ASSERT(0);
+//IMaterial *MaterialUtils::createDomainMaterial(const MaterialItem *item)
+//{
+//    Q_ASSERT(0);
 //    if(item->getType() == MaterialItem::SubItem)
 //        throw GUIHelpers::Error("MaterialUtils::createDomainMaterial() -> Error. Unapropriate material type");
 
@@ -98,19 +101,51 @@ IMaterial *MaterialUtils::createDomainMaterial(const MaterialItem *item)
 //    }
 
 //    return result;
-}
+//}
 
 
-IMaterial *MaterialUtils::createDomainMaterial(const QString &name)
-{
-    Q_ASSERT(0);
+//IMaterial *MaterialUtils::createDomainMaterial(const QString &name)
+//{
+//    Q_ASSERT(0);
 //    MaterialModel *model = MaterialEditor::getMaterialModel();
 //    MaterialItem *materialItem = model->getMaterial(name);
 //    Q_ASSERT(materialItem);
 //    return createDomainMaterial(materialItem);
-}
+//}
+
+
 
 
 
 
 
+IMaterial *MaterialUtils::createDomainMaterial(const MaterialProperty &material_property)
+{
+    MaterialModel *model = MaterialEditor::getMaterialModel();
+    Q_ASSERT(model);
+
+    const MaterialItem *materialItem = model->getMaterial(material_property);
+    Q_ASSERT(materialItem);
+
+    const RefractiveIndexItem *refractiveIndexItem = dynamic_cast<const RefractiveIndexItem *>(materialItem->getSubItems()[MaterialItem::P_REFRACTIVE_INDEX]);
+    double delta = refractiveIndexItem->getDelta();
+    double beta = refractiveIndexItem->getBeta();
+
+    IMaterial *result(0);
+    if(materialItem->isHomogeneousMaterial()) {
+        result = new HomogeneousMaterial(materialItem->itemName().toStdString(), delta, beta);
+    }
+    else if(materialItem->isHomogeneousMagneticMaterial()) {
+        const MagneticFieldItem *magneticField = dynamic_cast<const MagneticFieldItem *>(materialItem->getSubItems()[MaterialItem::P_MAGNETIC_FIELD]);
+        Q_ASSERT(magneticField);
+        double Bx = magneticField->getRegisteredProperty(MagneticFieldItem::P_BX).toDouble();
+        double By = magneticField->getRegisteredProperty(MagneticFieldItem::P_BY).toDouble();
+        double Bz = magneticField->getRegisteredProperty(MagneticFieldItem::P_BZ).toDouble();
+        result = new HomogeneousMagneticMaterial(materialItem->itemName().toStdString(), delta, beta, kvector_t(Bx, By, Bz));
+    }
+    else {
+        throw GUIHelpers::Error("MaterialUtils::createDomainMaterial() -> Error. Unknown material type.");
+    }
+
+    return result;
+}
diff --git a/GUI/coregui/Views/Components/MaterialEditor/MaterialUtils.h b/GUI/coregui/Views/Components/MaterialEditor/MaterialUtils.h
index c06df5b1d84c0b1c5f383c11d7299472d5859f21..77fb434db76123257e5e5c49bf285da507871817 100644
--- a/GUI/coregui/Views/Components/MaterialEditor/MaterialUtils.h
+++ b/GUI/coregui/Views/Components/MaterialEditor/MaterialUtils.h
@@ -20,8 +20,10 @@ ColorProperty suggestMaterialColorProperty(const QString &name);
 //QString getMaterialName(const MaterialProperty &material_property);
 //QColor getMaterialColor(const MaterialProperty &material_property);
 
-IMaterial *createDomainMaterial(const MaterialItem *material);
-IMaterial *createDomainMaterial(const QString &name);
+IMaterial *createDomainMaterial(const MaterialProperty &material_property);
+
+//IMaterial *createDomainMaterial(const MaterialItem *material);
+//IMaterial *createDomainMaterial(const QString &name);
 
 }
 
diff --git a/GUI/coregui/Views/Components/SampleDesigner/PropertyVariantFactory.cpp b/GUI/coregui/Views/Components/SampleDesigner/PropertyVariantFactory.cpp
index 72bd9f8e0bee42564e7ac64164813d8b4a6b047a..f958a7880a902ef12fd2cd2da059d244a118e602 100644
--- a/GUI/coregui/Views/Components/SampleDesigner/PropertyVariantFactory.cpp
+++ b/GUI/coregui/Views/Components/SampleDesigner/PropertyVariantFactory.cpp
@@ -227,6 +227,8 @@ void PropertyVariantFactory::slotSetValue(const MaterialProperty &value)
             QVariant var;
             var.setValue(value);
             manager->setValue(property, var);
+            // FIXME g.p. Is it the right place to delete?
+            object->deleteLater();
             return;
         }
         itEditor++;
@@ -265,6 +267,8 @@ void PropertyVariantFactory::slotSetValue(const ColorProperty &value)
             QVariant var;
             var.setValue(value);
             manager->setValue(property, var);
+            // FIXME g.p. Is it the right place to delete?
+            object->deleteLater();
             return;
         }
         itEditor++;
diff --git a/GUI/coregui/utils/GUIFunctionalTest.cpp b/GUI/coregui/utils/GUIFunctionalTest.cpp
index 2b5d89865be89442d9c07e3683b323a6c89c42d0..5f67ed040d1b098ec9b68901d5fd12ea598ff1f3 100644
--- a/GUI/coregui/utils/GUIFunctionalTest.cpp
+++ b/GUI/coregui/utils/GUIFunctionalTest.cpp
@@ -9,6 +9,7 @@
 #include "ParameterizedItem.h"
 #include "OutputDataFunctions.h"
 #include <boost/scoped_ptr.hpp>
+#include <QDebug>
 
 
 GUIFunctionalTest::GUIFunctionalTest(const std::string &name)