diff --git a/src/main/java/avatartranslator/AvatarAttribute.java b/src/main/java/avatartranslator/AvatarAttribute.java
index bd089ee6c5be3f5a56a6a89963b6b1fa7b9f064e..1d6965715e6f36cfbf79cdd0447b6b501bc20803 100644
--- a/src/main/java/avatartranslator/AvatarAttribute.java
+++ b/src/main/java/avatartranslator/AvatarAttribute.java
@@ -56,29 +56,18 @@ public class AvatarAttribute extends AvatarLeftHand implements NameChecker.NameS
 
     // Types of parameters
     private AvatarType type;
-    private AvatarDataType dataType;
     private String initialValue;
     private boolean isConstant;
+    private AvatarDataType originalDataType; // applicable only if the attribute has been transformed from a data type
+    private int indexInDataType; // applicable only if the attribute has been transformed from a data type
 
     private AvatarStateMachineOwner block;
 
     public AvatarAttribute(String _name, AvatarType _type, AvatarStateMachineOwner _block, Object _referenceObject) {
         super(_name, _referenceObject);
-        /*if (_type == -1) {
-          TraceManager.addDev("- - - - - - - - - - - - " + _name + ": " + _type);
-          try {
-          int x = 1 / 0;
-          } catch (Exception e) {
-          e.printStackTrace();
-          System.exit(0);
-          }
-          }*/
         type = _type;
-        dataType = null;
         this.block = _block;
     }
-    public void setDataType(AvatarDataType _adt) { dataType = _adt; }
-    public AvatarDataType getDataType() { return  dataType; }
 
     public AvatarStateMachineOwner getBlock() {
         return this.block;
@@ -156,6 +145,8 @@ public class AvatarAttribute extends AvatarLeftHand implements NameChecker.NameS
         return (type == AvatarType.TIMER);
     }
 
+    public AvatarDataType getOriginalDataType() { return originalDataType; }
+    public int getIndexInDataType() { return indexInDataType; }
 
     public String toString() {
         String ret = this.type.getStringType() + " " + getName();
@@ -163,7 +154,13 @@ public class AvatarAttribute extends AvatarLeftHand implements NameChecker.NameS
             return ret;
         }
 
-        return ret + " = " + initialValue;
+        ret += " = " + initialValue;
+
+        if (originalDataType != null) {
+            ret += "(original type: " + originalDataType.getName() + "/" + indexInDataType + " elt)";
+        }
+
+        return ret;
     }
 
     public String toBasicString() {
@@ -184,6 +181,11 @@ public class AvatarAttribute extends AvatarLeftHand implements NameChecker.NameS
         return true;
     }
 
+    public void setDataType(AvatarDataType adt, int index) {
+        originalDataType = adt;
+        indexInDataType = index;
+    }
+
     @Override
     public boolean containsAMethodCall() {
         return false;
@@ -205,6 +207,9 @@ public class AvatarAttribute extends AvatarLeftHand implements NameChecker.NameS
         if (hasInitialValue()) {
             aa.setInitialValue(getInitialValue());
         }
+        if (originalDataType != null) {
+            aa.setDataType(originalDataType, indexInDataType);
+        }
 
         return aa;
     }
diff --git a/src/main/java/avatartranslator/AvatarDataType.java b/src/main/java/avatartranslator/AvatarDataType.java
index 47357c0aa360c42ee0712553d5d3f3f356674389..d1694d55c933bfba408c2849c79f7e2d5541803c 100644
--- a/src/main/java/avatartranslator/AvatarDataType.java
+++ b/src/main/java/avatartranslator/AvatarDataType.java
@@ -8,71 +8,85 @@ import java.util.List;
 import java.util.Map;
 
 public class AvatarDataType extends AvatarElement implements NameChecker.NameStartWithUpperCase {
-    public final static int INTEGER = 0;
-    public final static int BOOLEAN = 1;
-    public final static int DATATYPE = 2;
     public static Map<String,AvatarDataType> dataTypeMap = new HashMap<String,AvatarDataType>();
 
     private List<String> fieldStrings; // list of all primitive fields, unrolling sub-datatypes
-    private List<Integer> fieldStringTypes; // list of primitive types associated to fieldStrings
-    private List<String> fieldNames; // list of direct fields
-    private List<Integer> fieldTypes; // types of direct fields
+    private List<AvatarType> fieldStringTypes; // list of primitive types associated to fieldStrings
+     private List<AvatarAttribute> attributes; // list of direct fields
     private List<String> dataTypeNames; // datatypes of direct fields (null for primitive types)
     private int fullSize;
 
     public AvatarDataType(String _name, Object _referenceObject) {
         super(_name, _referenceObject);
         fieldStrings = new ArrayList<String>();
-        fieldStringTypes = new ArrayList<Integer>();
-        fieldNames = new ArrayList<String>();
-        fieldTypes = new ArrayList<Integer>();
+        fieldStringTypes = new ArrayList<AvatarType>();
+        attributes = new ArrayList<AvatarAttribute>();
         dataTypeNames = new ArrayList<String>();
         fullSize = -1;
     }
     public int getFullSize() { return fullSize; }
-    public int getNbFields() { return fieldNames.size(); }
-    public String getFieldName(int _i) { return fieldNames.get(_i); }
+    public int getAttributeNb() { return attributes.size(); }
+    public AvatarAttribute getAttribute(int _index) { return attributes.get(_index); }
+    public void clearAttributes() { attributes.clear(); fullSize = -1; }
+    public List<AvatarAttribute> getAttributes() { return attributes; }
+    public boolean setAttributeValue(int _index, String _value) {
+        AvatarAttribute aa = attributes.get(_index);
+        if (aa == null)
+            return false;
+        aa.setInitialValue(_value);
+        return true;
+    }
+    public int getIndexOfAvatarAttributeWithName(String _name) {
+        int cpt = 0;
+        for (AvatarAttribute attribute : attributes) {
+            if (attribute.getName().compareTo(_name) == 0) {
+                return cpt;
+            }
+            cpt++;
+        }
+        return -1;
+    }
     public String getFieldString(int _i) { return fieldStrings.get(_i); }
-    public int getFieldStringType(int _i) { return fieldStringTypes.get(_i); }
-    public int getFieldType(int _i) { return fieldTypes.get(_i); }
+    public AvatarType getFieldStringType(int _i) { return fieldStringTypes.get(_i); }
     public String getDataTypeName(int _i) { return dataTypeNames.get(_i); }
 
-    public void addField(String _fieldName, int _fieldType, String _dataTypeName) {
-        if (fullSize != -1) return; // DataType has already been finalized
-        if (_fieldType == AvatarDataType.INTEGER || _fieldType == AvatarDataType.BOOLEAN)
-            dataTypeNames.add(null);
-        else if (_fieldType != DATATYPE)
-            return;
-        else
-            dataTypeNames.add(_dataTypeName);
-        fieldTypes.add(_fieldType);
-        fieldNames.add(_fieldName);
+    public void addAttribute(AvatarAttribute _attribute, String _dataTypeName) {
+        if (getIndexOfAvatarAttributeWithName(_attribute.getName()) == -1) {
+            fullSize = -1;
+            if (_attribute.getType() == AvatarType.INTEGER || _attribute.getType() == AvatarType.BOOLEAN)
+                dataTypeNames.add(null);
+            else if (_attribute.getType() != AvatarType.UNDEFINED)
+                return;
+            else
+                dataTypeNames.add(_dataTypeName);
+            attributes.add(_attribute);
+        }
     }
     public static void finalize(AvatarDataType adt) {
         if (adt.fullSize != -1) return;
         int size = 0;
-        int length = adt.getNbFields();
+        int length = adt.getAttributeNb();
         for (int i = 0; i < length; i++) {
-            if (adt.getFieldType(i) == AvatarDataType.INTEGER) {
-                adt.fieldStrings.add(adt.fieldNames.get(i));
-                adt.fieldStringTypes.add(AvatarDataType.INTEGER);
+            if (adt.getAttribute(i).getType() == AvatarType.INTEGER) {
+                adt.fieldStrings.add(adt.attributes.get(i).getName());
+                adt.fieldStringTypes.add(AvatarType.INTEGER);
                 size += 1;
                 continue;
             }
-            if (adt.getFieldType(i) == AvatarDataType.BOOLEAN) {
-                adt.fieldStrings.add(adt.fieldNames.get(i));
-                adt.fieldStringTypes.add(AvatarDataType.BOOLEAN);
+            if (adt.getAttribute(i).getType() == AvatarType.BOOLEAN) {
+                adt.fieldStrings.add(adt.attributes.get(i).getName());
+                adt.fieldStringTypes.add(AvatarType.BOOLEAN);
                 size += 1;
                 continue;
             }
             AvatarDataType fieldDataType = dataTypeMap.get(adt.getDataTypeName(i));
             if (fieldDataType == null)  return; // ERROR CASE
             finalize(fieldDataType); // loops if recursion => recursive types are forbidden
-            int fieldSize = fieldDataType.getFullSize();  // ERROR CASE
-            if (fieldSize == -1)  return;
+            int fieldSize = fieldDataType.getFullSize();
+            if (fieldSize == -1)  return;  // ERROR CASE
             size += fieldSize;
             for(int j=0; j<fieldSize; j++) {
-                adt.fieldStrings.add(adt.fieldNames.get(i) + "__" + fieldDataType.getFieldString(i));
+                adt.fieldStrings.add(adt.attributes.get(i).getName() + "__" + fieldDataType.getFieldString(i));
                 adt.fieldStringTypes.add(fieldDataType.getFieldStringType(i));
             }
         }
@@ -81,22 +95,22 @@ public class AvatarDataType extends AvatarElement implements NameChecker.NameSta
     public String toString() {
         //Thread.currentThread().dumpStack();
         StringBuffer sb = new StringBuffer("DataType:" + getName() + " ID=" + getID() + " \n");
-        int size = fieldNames.size();
+        int size = attributes.size();
         for (int i = 0; i < size; i++) {
             String type;
-            if (fieldTypes.get(i) == AvatarDataType.INTEGER) type = "Integer";
-            else if (fieldTypes.get(i) == AvatarDataType.BOOLEAN) type = "Boolean";
+            if (attributes.get(i).getType() == AvatarType.INTEGER) type = "Integer";
+            else if (attributes.get(i).getType() == AvatarType.BOOLEAN) type = "Boolean";
             else type = dataTypeNames.get(i);
-            sb.append("  field: " + fieldNames.get(i) + ", type = " + type + "\n");
+            sb.append("  field: " + attributes.get(i).getName() + ", type = " + type + "\n");
         }
         return sb.toString();
     }
     public String toStringRecursive() { return toString(); }
     public String toShortString() { return toString(); }
-    public int getIndexOfFieldWithName(String _name) {
+    public int getIndexOfAttributeWithName(String _name) {
         int cpt = 0;
-        for (String fieldName : fieldNames) {
-            if (fieldName.compareTo(_name) == 0) {
+        for (AvatarAttribute aa : attributes) {
+            if (aa.getName().compareTo(_name) == 0) {
                 return cpt;
             }
             cpt++;
@@ -104,13 +118,20 @@ public class AvatarDataType extends AvatarElement implements NameChecker.NameSta
         return -1;
     }
 
+    public NameChecker.NamedElement[] getSubNamedElements() {
+        NameChecker.NamedElement[] nes = new NameChecker.NamedElement[attributes.size()];
+        int index = 0;
+        for (AvatarAttribute aa : attributes) {
+            nes[index] = aa;
+            index++;
+        }
+        return nes;
+    }
     public AvatarDataType advancedClone() {
         AvatarDataType adt = new AvatarDataType(getName(), getReferenceObject());
-        int size = fieldNames.size();
+        int size = attributes.size();
         for (int i=0; i < size; i++) {
-            adt.fieldNames.add(fieldNames.get(i));
-            adt.fieldTypes.add(fieldTypes.get(i));
-            adt.dataTypeNames.add(dataTypeNames.get(i));
+            adt.addAttribute(attributes.get(i).advancedClone(null), new String(dataTypeNames.get(i)));
         }
         size = fieldStrings.size();
         for (int i=0; i < size; i++) {
diff --git a/src/main/java/avatartranslator/AvatarSpecification.java b/src/main/java/avatartranslator/AvatarSpecification.java
index 700c217a7a5283f3f83f06b19e446d4bfb90d6ac..1dc590e85fddfa7d68a3d20bd489bfe5339cf405 100644
--- a/src/main/java/avatartranslator/AvatarSpecification.java
+++ b/src/main/java/avatartranslator/AvatarSpecification.java
@@ -39,7 +39,6 @@
 package avatartranslator;
 
 import avatartranslator.intboolsolver.AvatarIBSolver;
-import avatartranslator.tosysmlv2.AvatarFromSysML;
 import myutil.Conversion;
 import myutil.NameChecker;
 import myutil.TraceManager;
@@ -69,6 +68,8 @@ public class AvatarSpecification extends AvatarElement implements IBSParamSpec {
     private final List<AvatarBlock> blocks;
     private final List<AvatarRelation> relations;
     private final List<AvatarAMSInterface> interfaces;
+    private final List<AvatarDataType> dataTypes;
+
     /**
      * The list of all library functions that can be called.
      */
@@ -77,7 +78,6 @@ public class AvatarSpecification extends AvatarElement implements IBSParamSpec {
     private final List<String> safetyPragmas;
     private final HashMap<String, String> safetyPragmasRefs;
     private final List<AvatarPragmaLatency> latencyPragmas;
-    private final List<AvatarDataType> dataTypes;
     private final List<AvatarConstant> constants;
     private final boolean robustnessMade = false;
     public List<String> checkedIDs;
@@ -95,12 +95,12 @@ public class AvatarSpecification extends AvatarElement implements IBSParamSpec {
         blocks = new LinkedList<>();
         interfaces = new LinkedList<>();
         relations = new LinkedList<>();
+        dataTypes = new LinkedList<>();
         pragmas = new LinkedList<>();
         constants = new LinkedList<>();
         safetyPragmas = new LinkedList<>();
         safetyPragmasRefs = new HashMap<>();
         latencyPragmas = new LinkedList<>();
-        dataTypes = new LinkedList<>();
         this.constants.add(AvatarConstant.FALSE);
         this.constants.add(AvatarConstant.TRUE);
         checkedIDs = new ArrayList<>();
@@ -672,6 +672,10 @@ public class AvatarSpecification extends AvatarElement implements IBSParamSpec {
         return relations;
     }
 
+    public List<AvatarDataType> getDataTypes() {
+        return dataTypes;
+    }
+
     public List<AvatarPragma> getPragmas() {
         return pragmas;
     }
@@ -684,8 +688,6 @@ public class AvatarSpecification extends AvatarElement implements IBSParamSpec {
         return latencyPragmas;
     }
 
-    public List<AvatarDataType> getDataTypes() { return dataTypes; }
-
     public List<AvatarConstant> getAvatarConstants() {
         return constants;
     }
@@ -766,6 +768,10 @@ public class AvatarSpecification extends AvatarElement implements IBSParamSpec {
         relations.add(_relation);
     }
 
+    public void addDataType(AvatarDataType _adt) {
+        dataTypes.add(_adt);
+    }
+
     public void addInterfaceRelation(AvatarInterfaceRelation _irelation) {
         irelations.add(_irelation);
     }
@@ -790,6 +796,34 @@ public class AvatarSpecification extends AvatarElement implements IBSParamSpec {
         }
     }
 
+    public AvatarDataType getDataTypeByName(String _name) {
+        for(AvatarDataType adt: dataTypes) {
+            if (adt.getName().compareTo(_name) == 0) {
+                return adt;
+            }
+        }
+        return null;
+    }
+
+    public List<String> keepOnlyOriginalValues(List<String> input) {
+        List<String> ret = new LinkedList<>();
+        String currentStart = "";
+        for(String s: input) {
+            int index = s.indexOf("__");
+            if (index > 0) {
+                String start = s.substring(0, index);
+                if (start.compareTo(currentStart) != 0) {
+                    ret.add(start);
+                    currentStart = start;
+                }
+            } else {
+                ret.add(s);
+                currentStart = "";
+            }
+        }
+        return ret;
+    }
+
     @Override
     public String toString() {
         return toStringRecursive(false);
@@ -812,6 +846,10 @@ public class AvatarSpecification extends AvatarElement implements IBSParamSpec {
         for (AvatarRelation relation : relations) {
             sb.append("Relation:" + relation.toString() + "\n");
         }
+        sb.append("\nData types:\n");
+        for (AvatarDataType type : dataTypes) {
+            sb.append("Data type:" + type.toString() + "\n");
+        }
         sb.append("\nPragmas:\n");
         for (AvatarPragma pragma : pragmas) {
             sb.append("Pragma:" + pragma.toString() + "\n");
@@ -1019,6 +1057,7 @@ public class AvatarSpecification extends AvatarElement implements IBSParamSpec {
     }
 
     public void removeTimers() {
+        //TraceManager.addDev("Spec before timer remove: " + toStringRecursive(false));
         //renameTimers();
 
         List<AvatarBlock> addedBlocks = new LinkedList<AvatarBlock>();
@@ -1031,6 +1070,8 @@ public class AvatarSpecification extends AvatarElement implements IBSParamSpec {
         for (int i = 0; i < addedBlocks.size(); i++) {
             addBlock(addedBlocks.get(i));
         }
+
+        //TraceManager.addDev("Spec after timer remove: " + toStringRecursive(false));
     }
 
     public void removeConstants() {
@@ -1249,7 +1290,7 @@ public class AvatarSpecification extends AvatarElement implements IBSParamSpec {
                     continue;
 
                 //TraceManager.addDev("[[[[[[[[[[[[[[[ Guard before: " + ancientGuard.toString() + " type:" + ancientGuard.getClass().toString());
-                at.setGuard(ancientGuard.getRealGuard(asme));
+                at.setGuard(ancientGuard.getRealGuard(asme), at.getOriginalGuard());
                 //TraceManager.addDev("]]]]]]]]]]]]]]] Guard after: " + at.getGuard().toString());
             }
         }
@@ -1416,6 +1457,13 @@ public class AvatarSpecification extends AvatarElement implements IBSParamSpec {
             }
         }
 
+        for (AvatarDataType dt : dataTypes) {
+            AvatarDataType dt2 = dt.advancedClone();
+            if (dt2 != null) {
+                spec.addDataType(dt2);
+            }
+        }
+
 		/*for(AvatarPragma pragma: pragmas) {
 		    AvatarPragma nP = pragma.advancedClone();
 		    spec.addPragma(nP);
@@ -1698,8 +1746,8 @@ public class AvatarSpecification extends AvatarElement implements IBSParamSpec {
 
     // SysML V2
     public static AvatarSpecification makeFromSysMLV2(String pathToFile) {
-        AvatarFromSysML builder = new AvatarFromSysML();
-        return builder.sysMLtoSpec(pathToFile);
+        AvatarSpecification as = new AvatarSpecification(pathToFile, null);
+        return as;
     }
 
 }
diff --git a/src/main/java/avatartranslator/AvatarTransition.java b/src/main/java/avatartranslator/AvatarTransition.java
index c1bc9b4aeec0eb367d209730ca0ee2cc32e26d96..702aadfa80bb59ff0bece9310e119347fc752bb1 100644
--- a/src/main/java/avatartranslator/AvatarTransition.java
+++ b/src/main/java/avatartranslator/AvatarTransition.java
@@ -41,6 +41,7 @@ package avatartranslator;
 import avatartranslator.intboolsolver.*;
 import myutil.TraceManager;
 
+import java.util.ArrayList;
 import java.util.Iterator;
 import java.util.LinkedList;
 import java.util.List;
@@ -86,7 +87,10 @@ public class AvatarTransition extends AvatarStateMachineElement {
 
     private double probability = DEFAULT_PROBABILITY;
     private AvatarGuard guard;
+    private String originalGuard;
     private String minDelay = "", maxDelay = "";
+    private String originalMinDelay = "";
+    private String originalMaxDelay = "";
     private String delayExtra1 = ""; // Used for some of the distribution law
     private String delayExtra2 = ""; // Used for some of the distribution law
     private int delayDistributionLaw = 0;
@@ -99,10 +103,12 @@ public class AvatarTransition extends AvatarStateMachineElement {
     private AvatarIBSExpressions.IExpr maxDelaySolver;
 
     private List<AvatarAction> actions; // actions on variable, or method call
+    private List<String> originalActions; // Keeping tack of actions before modification
 
     public AvatarTransition(AvatarStateMachineOwner _block, String _name, Object _referenceObject) {
         super(_name, _referenceObject, _block);
         actions = new LinkedList<>();
+        originalActions = new LinkedList<>();
         this.guard = new AvatarGuardEmpty();
         this.block = _block;
         guardSolver = null;
@@ -113,6 +119,10 @@ public class AvatarTransition extends AvatarStateMachineElement {
     public AvatarGuard getGuard() {
         return guard;
     }
+
+    public String getOriginalGuard() {
+        return originalGuard;
+    }
     
     public boolean buildGuardSolver() {
         if (isGuarded()) {
@@ -155,13 +165,23 @@ public class AvatarTransition extends AvatarStateMachineElement {
         return maxDelaySolver;
     }
 
-    public void setGuard(AvatarGuard _guard) {
+    public void setGuard(AvatarGuard _guard, String _originalGuard) {
         this.guard = _guard;
+        originalGuard = _originalGuard;
     }
 
-    public void setGuard(String _guard) {
+    public void setGuard(AvatarGuard _guard) {
+        setGuard(_guard, "");
+    }
+
+    public void setGuard(String _guard, String _originalGuard) {
         this.guard = AvatarGuard.createFromString(this.block, _guard);
         //TraceManager.addDev("Setting guard = " + guard);
+        originalGuard = _originalGuard;
+    }
+
+    public void setGuard(String _guard) {
+        setGuard(_guard, "");
     }
 
     public void setProbability(double _probability) {
@@ -172,10 +192,11 @@ public class AvatarTransition extends AvatarStateMachineElement {
     }
 
 
-    public void addGuard(String _g) {
+    public void addGuard(String _g, String _originalGuard) {
         AvatarGuard guard = AvatarGuard.createFromString(this.block, _g);
         //TraceManager.addDev("Adding guard = " + guard);
         this.guard = AvatarGuard.addGuard(this.guard, guard, "and");
+        originalGuard = _originalGuard;
     }
 
     public int getNbOfAction() {
@@ -273,22 +294,47 @@ public class AvatarTransition extends AvatarStateMachineElement {
         return actions.get(_index);
     }
 
-    public void addAction(String _action) {
+    public String getOriginalAction(int _index) {
+        return originalActions.get(_index);
+    }
+
+    public void addAction(String _action, String originalAction) {
         //TraceManager.addDev("\n****************************  String expr to be added: >" + _action + "<");
         AvatarAction aa = AvatarTerm.createActionFromString(block, _action);
         //TraceManager.addDev("****************************  Adding Avatar action from String : " + aa + "\n");
         if (aa != null) {
             actions.add(aa);
+            if (originalAction == null) {
+                originalAction = "";
+            }
+            this.originalActions.add(originalAction);
         }
     }
 
+    public void addAction(String _action) {
+        addAction(_action, "");
+
+    }
+
     public void addAction(AvatarAction _action) {
-        if (_action != null)
+        addAction(_action, "");
+    }
+
+    public void addAction(AvatarAction _action, String originalAction) {
+        if (_action != null) {
             //TraceManager.addDev("****************************  Avatar action from AvatarAction: " + _action);
             this.actions.add(_action);
+            if (originalAction == null) {
+                originalAction = "";
+            }
+            this.originalActions.add(originalAction);
+        }
     }
 
     public void setDelays(String _minDelay, String _maxDelay) {
+        setDelays(_minDelay, _maxDelay, "", "");
+    }
+    public void setDelays(String _minDelay, String _maxDelay, String _originalMinDelay, String _originalMaxDelay) {
         /*TraceManager.addDev("Block " + getBlock().getName() + " / Setting delay: " + _minDelay + "," + _maxDelay);
         System.out.println("Printing stack trace:");
         StackTraceElement[] elements = Thread.currentThread().getStackTrace();
@@ -299,6 +345,8 @@ public class AvatarTransition extends AvatarStateMachineElement {
 
         minDelay = _minDelay;
         maxDelay = _maxDelay;
+        originalMinDelay = _originalMinDelay;
+        originalMaxDelay = _originalMaxDelay;
     }
 
     public void setDistributionLaw(int _law, String _delayExtra1, String _delayExtra2 ) {
@@ -316,6 +364,14 @@ public class AvatarTransition extends AvatarStateMachineElement {
         return minDelay;
     }
 
+    public String getOriginalMinDelay() {
+        return originalMinDelay;
+    }
+
+    public String getOriginalMaxDelay() {
+        return originalMaxDelay;
+    }
+
 
 
     public String getMaxDelay() {
@@ -374,8 +430,8 @@ public class AvatarTransition extends AvatarStateMachineElement {
 
     public AvatarTransition cloneMe() {
         AvatarTransition at = new AvatarTransition(block, getName(), getReferenceObject());
-        at.setGuard(getGuard());
-        at.setDelays(getMinDelay(), getMaxDelay());
+        at.setGuard(getGuard(), getOriginalGuard());
+        at.setDelays(getMinDelay(), getMaxDelay(), getOriginalMinDelay(), getOriginalMaxDelay());
         at.setComputes(getMinCompute(), getMaxCompute());
         at.setProbability(getProbability());
 
@@ -384,7 +440,7 @@ public class AvatarTransition extends AvatarStateMachineElement {
         //TraceManager.addDev("-------------- Cloning actions of " + this);
         for (int i = 0; i < getNbOfAction(); i++) {
             //TraceManager.addDev("-------------- Cloning actions:" + getAction(i));
-            at.addAction(getAction(i));
+            at.addAction(getAction(i), getOriginalAction(i));
         }
 
         for (int i = 0; i < nbOfNexts(); i++) {
@@ -397,16 +453,16 @@ public class AvatarTransition extends AvatarStateMachineElement {
     public AvatarStateMachineElement basicCloneMe(AvatarStateMachineOwner _block) {
         AvatarTransition at = new AvatarTransition(_block, getName() + "_clone", getReferenceObject());
 
-        at.setGuard(getGuard());
+        at.setGuard(getGuard(), getOriginalGuard());
 
         //TraceManager.addDev("Cloning actions of " + this);
         for (int i = 0; i < getNbOfAction(); i++) {
             //TraceManager.addDev("-------------- Cloning actions:" + getAction(i));
-            at.addAction(getAction(i));
+            at.addAction(getAction(i), getOriginalAction(i));
         }
 
         at.setComputes(getMinCompute(), getMaxCompute());
-        at.setDelays(getMinDelay(), getMaxDelay());
+        at.setDelays(getMinDelay(), getMaxDelay(), getOriginalMinDelay(), getOriginalMaxDelay());
         at.setProbability(getProbability());
 
         return at;
diff --git a/src/main/java/avatartranslator/tosysmlv2/Avatar2SysML.java b/src/main/java/avatartranslator/tosysmlv2/Avatar2SysML.java
index c37b5e5a40d220bf94ef86fd878cac558c5c0730..cc73337220b96bcc915730b6fd14c2baf41971b6 100644
--- a/src/main/java/avatartranslator/tosysmlv2/Avatar2SysML.java
+++ b/src/main/java/avatartranslator/tosysmlv2/Avatar2SysML.java
@@ -57,28 +57,28 @@ public class Avatar2SysML {
         private String name;
         private String msgtype; // null for methods that are not signals
         private ArrayList<String> fieldNames;
-        private ArrayList<Integer> fieldTypes;
+        private ArrayList<AvatarType> fieldTypes;
         private ArrayList<AvatarDataType> dataTypes;
-        private int returnType;
+        private AvatarType returnType;
         private AvatarDataType returnDataType;
 
        MethodInfo(String _name) { // for void methods
             name = _name;
             msgtype = null;
             fieldNames = new ArrayList<String>();
-            fieldTypes = new ArrayList<Integer>();
+            fieldTypes = new ArrayList<AvatarType>();
             dataTypes = new ArrayList<AvatarDataType>();
-            returnType = -1;
+            returnType = null;
             returnDataType = null;
         }
-       MethodInfo(String _name, int _returnType, AvatarDataType dt) { // for non-void methods
+       MethodInfo(String _name, AvatarType _returnType, AvatarDataType dt) { // for non-void methods
             name = _name;
             msgtype = null;
             fieldNames = new ArrayList<String>();
-            fieldTypes = new ArrayList<Integer>();
+            fieldTypes = new ArrayList<AvatarType>();
             dataTypes = new ArrayList<AvatarDataType>();
             returnType = _returnType;
-            if (_returnType != AvatarDataType.DATATYPE)
+            if (_returnType != AvatarType.UNDEFINED)
                 returnDataType = null;
             else
                 returnDataType = dt;
@@ -87,15 +87,15 @@ public class Avatar2SysML {
             name = _name;
             msgtype = _msgtype;
             fieldNames = new ArrayList<String>();
-            fieldTypes = new ArrayList<Integer>();
+            fieldTypes = new ArrayList<AvatarType>();
             dataTypes = new ArrayList<AvatarDataType>();
-            returnType = -1;
+            returnType = null;
             returnDataType = null;
        }
-       public void addField(String _fieldName, int _type, AvatarDataType _dt){
-           if (_type == AvatarDataType.DATATYPE)
+       public void addField(String _fieldName, AvatarType _type, AvatarDataType _dt){
+           if (_type == AvatarType.UNDEFINED)
                dataTypes.add(_dt);
-           else if (!(_type == AvatarDataType.BOOLEAN || _type == AvatarDataType.INTEGER))
+           else if (!(_type == AvatarType.BOOLEAN || _type == AvatarType.INTEGER))
                return; // unknown type
            else
                dataTypes.add(null);
@@ -105,10 +105,10 @@ public class Avatar2SysML {
        public int getArity() { return fieldNames.size(); }
        public String getName(){ return name; }
        public String getMessageType(){ return msgtype; }
-       public int getReturnType(){ return returnType; }
+       public AvatarType getReturnType(){ return returnType; }
        public AvatarDataType getReturnDataType(){ return returnDataType; }
        public String getFieldName(int i){ return fieldNames.get(i); }
-       public int getFieldType(int i){ return fieldTypes.get(i); }
+       public AvatarType getFieldType(int i){ return fieldTypes.get(i); }
        public AvatarDataType getDataType(int i){ return dataTypes.get(i); }
     }
    /**
@@ -194,9 +194,9 @@ public class Avatar2SysML {
         //parser.sysMLtoSpec(avsysml.toString()); /// !!!!!!!!!!!!!! TESTEUR
         return avsysml;
     }
-    String removeFieldName(String fullName, AvatarDataType dt) {
-        if (fullName == null || dt.getNbFields() == 0) return fullName;
-        String fieldString = dt.getFieldString(0);
+    String removeFieldName(String fullName, int index, AvatarDataType dt) {
+        if (fullName == null || dt.getAttributeNb() -1 < index) return fullName;
+        String fieldString = dt.getFieldString(index);
         int prefixSize = fullName.length() - fieldString.length() - 2;
         if (fieldString.equals(fullName.substring(fullName.length() - fieldString.length()))
             && prefixSize >= 0)
@@ -205,25 +205,25 @@ public class Avatar2SysML {
             return null;
     }
     String removeFieldName(AvatarAttribute aa) {
-        if (aa.getDataType() == null) return null;
-        return removeFieldName(aa.getName(), aa.getDataType());
+        if (aa.getOriginalDataType() == null) return null;
+        return removeFieldName(aa.getName(), aa.getIndexInDataType(), aa.getOriginalDataType());
     }
     void dataTypes2SysML(){
         if (avspec.getDataTypes() == null || avspec.getDataTypes().size() == 0) return;
         avsysml.append("\n" + indent + "// DATATYPES $$$$$$$$$$$$$$$$$$$$$$$$\n");
         for(AvatarDataType dt : avspec.getDataTypes()){
             avsysml.append("\n" + indent + "attribute def " + dataTypeSysMLname(dt.getName()) + " :> '#AvatarDataType'");
-            int nbFields = dt.getNbFields();
+            int nbFields = dt.getAttributeNb();
             if (nbFields == 0)
                 avsysml.append(";\n");
             else {
                 avsysml.append(" { \n");
                 indent += indentStep;
                 for (int i = 0; i < nbFields; i++) {
-                    avsysml.append( indent + "attribute " + fieldSysMLname(dt.getFieldName(i)) + " : " );
-                    if (dt.getFieldType(i) == AvatarDataType.BOOLEAN)
+                    avsysml.append( indent + "attribute " + fieldSysMLname(dt.getAttribute(i).getName()) + " : " );
+                    if (dt.getAttribute(i).getType() == AvatarType.BOOLEAN)
                         avsysml.append("Boolean;\n");
-                    else if (dt.getFieldType(i) == AvatarDataType.INTEGER)
+                    else if (dt.getAttribute(i).getType() == AvatarType.INTEGER)
                         avsysml.append("Integer;\n");
                     else
                         avsysml.append(dt.getDataTypeName(i) + ";\n");
@@ -362,21 +362,21 @@ public class Avatar2SysML {
                 // message fields. SysML names preserve Avatar sender and receiver names
                 int channelSize = sig1.getListOfAttributes().size();
                 int j=0;
-                int type;
+                AvatarType type;
                 String attributeType;
                 String fieldName1;
                 String fieldName2;
                 while (j < channelSize ) { // browse channels' parameters
-                    AvatarDataType dataType = sig1.getListOfAttributes().get(j).getDataType();
-                    if (dataType == null) {
+                    AvatarDataType dataType = sig1.getListOfAttributes().get(j).getOriginalDataType();
+                    if (dataType == null || sig1.getListOfAttributes().get(j).getIndexInDataType() != 0) {
                         attributeType = (sig1.getListOfAttributes().get(j).isInt() ? "Integer;\n" : "Boolean;\n");
-                        type = (sig1.getListOfAttributes().get(j).isInt() ? AvatarDataType.INTEGER : AvatarDataType.BOOLEAN);
+                        type = sig1.getListOfAttributes().get(j).getType();
                         fieldName1 = fieldSysMLname(sig1.getListOfAttributes().get(j).getName());
                         fieldName2 = fieldSysMLname(sig2.getListOfAttributes().get(j).getName());
                         j++;
                     } else {
                         attributeType = dataTypeSysMLname(dataType.getName()) + ";\n";
-                        type = AvatarDataType.DATATYPE;
+                        type = AvatarType.UNDEFINED;
                         fieldName1 = fieldSysMLname(removeFieldName(sig1.getListOfAttributes().get(j)));
                         fieldName2 = fieldSysMLname(removeFieldName(sig2.getListOfAttributes().get(j)));
                         j += dataType.getFullSize();
@@ -421,19 +421,19 @@ public class Avatar2SysML {
             methodInfo = new MethodInfo(methodSysMLname(am.getName()));
         }
         else {
-            returnDataType = returns.get(0).getDataType();
+            returnDataType = returns.get(0).getOriginalDataType();
             if (returnDataType == null) {
                 String avatarType = returns.get(0).getType().getStringType();
                 if (avatarType.equals("int")) {
                     returnType = "Integer";
-                    methodInfo = new MethodInfo(methodSysMLname(am.getName()), AvatarDataType.INTEGER, null);
+                    methodInfo = new MethodInfo(methodSysMLname(am.getName()), AvatarType.INTEGER, null);
                 } else {
                     returnType = "Boolean";
-                    methodInfo = new MethodInfo(methodSysMLname(am.getName()), AvatarDataType.BOOLEAN, null);
+                    methodInfo = new MethodInfo(methodSysMLname(am.getName()), AvatarType.BOOLEAN, null);
                 }
             } else {
                 returnType = dataTypeSysMLname(returnDataType.getName());
-                methodInfo = new MethodInfo(methodSysMLname(am.getName()), AvatarDataType.DATATYPE, returnDataType);
+                methodInfo = new MethodInfo(methodSysMLname(am.getName()), AvatarType.UNDEFINED, returnDataType);
             }
         }
 
@@ -447,20 +447,20 @@ public class Avatar2SysML {
         int nbFields = am.getListOfAttributes().size();
         while (j < nbFields) {
             AvatarAttribute aa = am.getListOfAttributes().get(j);
-            AvatarDataType fieldDataType = aa.getDataType();
-            if (fieldDataType == null) {
+            AvatarDataType fieldDataType = aa.getOriginalDataType();
+            if (fieldDataType == null || aa.getIndexInDataType() != 0) {
                 if (aa.isInt()) {
                     avsysml.append(indent + "attribute " + fieldSysMLname(aa.getName()) + " : Integer;\n");
-                    methodInfo.addField(fieldSysMLname(aa.getName()), AvatarDataType.INTEGER, null);
+                    methodInfo.addField(fieldSysMLname(aa.getName()), AvatarType.INTEGER, null);
                 } else {
                     avsysml.append(indent + "attribute " + fieldSysMLname(aa.getName()) + " : Boolean;\n");
-                    methodInfo.addField(fieldSysMLname(aa.getName()), AvatarDataType.BOOLEAN, null);
+                    methodInfo.addField(fieldSysMLname(aa.getName()), AvatarType.BOOLEAN, null);
                 }
                 j++;
             } else {
                 avsysml.append(indent + "attribute " + fieldSysMLname(removeFieldName(aa))
                         + " : " + dataTypeSysMLname(fieldDataType.getName())+ ";\n");
-                methodInfo.addField(fieldSysMLname(aa.getName()), AvatarDataType.DATATYPE, fieldDataType);
+                methodInfo.addField(fieldSysMLname(aa.getName()), AvatarType.UNDEFINED, fieldDataType);
                 j += fieldDataType.getFullSize();
             }
         }
@@ -499,8 +499,8 @@ public class Avatar2SysML {
                     j++;
                 }
                 else {
-                    AvatarDataType dataType = aa.getDataType();
-                    if (dataType == null) {
+                    AvatarDataType dataType = aa.getOriginalDataType();
+                    if (dataType == null || aa.getIndexInDataType() != 0) {
                         avsysml.append(indent + "attribute " + attributeSysMLname(aa.getName()) + " : ");
                         if (aa.isInt()) avsysml.append("Integer");
                         else avsysml.append("Boolean");
@@ -522,8 +522,8 @@ public class Avatar2SysML {
             int nbConstants = block.getConstants().size();
             while(j < nbConstants)  {
                 AvatarAttribute cs = block.getConstants().get(j);
-                AvatarDataType dataType = cs.getDataType();
-                if (dataType == null) {
+                AvatarDataType dataType = cs.getOriginalDataType();
+                if (dataType == null || cs.getIndexInDataType() != 0) {
                     avsysml.append(indent + "readonly attribute " + attributeSysMLname(cs.getName()) + " : ");
                     if (cs.isInt()) avsysml.append("Integer");
                     else avsysml.append("Boolean");
@@ -1025,12 +1025,12 @@ public class Avatar2SysML {
             int j = 0;
             int k = 0;
             while (j < nbFields) { //for(String vl : values)
-                if (signalInfo.getFieldType(j) != AvatarDataType.DATATYPE) {
+                if (signalInfo.getFieldType(j) != AvatarType.UNDEFINED) {
                     result.append(indent + expr2SysML(values.get(k)) + ",\n");
                     k++; j++;
                 } else {
                     AvatarDataType dt = signalInfo.getDataType(j);
-                    result.append(indent + expr2SysML(removeFieldName(values.get(k), dt)) + ",\n");
+                    result.append(indent + expr2SysML(removeFieldName(values.get(k), 0,dt)) + ",\n");
                     k += dt.getFullSize(); j++;
                 }
             }
@@ -1132,7 +1132,7 @@ public class Avatar2SysML {
         int j = 0; // index in method profile;
         int k = 0; // index in method parameters;
         while (j < nbFields) {
-            if (methodInfo.getFieldType(j) != AvatarDataType.DATATYPE) {
+            if (methodInfo.getFieldType(j) != AvatarType.UNDEFINED) {
                 if (parameters.get(k) instanceof AvatarTermFunction)
                     result.append(methodCall2SysML((AvatarTermFunction) parameters.get(k)) + ",");
                 else
@@ -1141,7 +1141,7 @@ public class Avatar2SysML {
                 j++;
             } else {
                 AvatarDataType dt = methodInfo.getDataType(j);
-                result.append(expr2SysML(removeFieldName(((AvatarAttribute) parameters.get(k)).getName(), dt)) + ",");
+                result.append(expr2SysML(removeFieldName(((AvatarAttribute) parameters.get(k)).getName(), 0, dt)) + ",");
                 k += dt.getFullSize();
                 j++;
             }
@@ -1192,13 +1192,13 @@ public class Avatar2SysML {
         int j = 0;
         int k = 0;
         while (j < nbFields) {
-            if (signalInfo.getFieldType(j) != AvatarDataType.DATATYPE) {
+            if (signalInfo.getFieldType(j) != AvatarType.UNDEFINED) {
                 result.append(indent + "then assign " + leftHandSysMLname(values.get(k)) +
                                 " := '@msg'." + signalInfo.getFieldName(j) + ";\n");
                 k++; j++;
             } else {
                 AvatarDataType dt = signalInfo.getDataType(j);
-                result.append(indent + "then assign " + leftHandSysMLname(removeFieldName(values.get(k), dt)) +
+                result.append(indent + "then assign " + leftHandSysMLname(removeFieldName(values.get(k), 0, dt)) +
                         " := '@msg'." + signalInfo.getFieldName(j) + ";\n");
                 k += dt.getFullSize(); j++;
             }
diff --git a/src/main/java/avatartranslator/tosysmlv2/AvatarFromSysML.java b/src/main/java/avatartranslator/tosysmlv2/AvatarFromSysML.java
index 3c949a6359de03ee53232b7f2e9720e77c715a6b..d53b5d29ba130628c3f227d40812a6bea882e24f 100644
--- a/src/main/java/avatartranslator/tosysmlv2/AvatarFromSysML.java
+++ b/src/main/java/avatartranslator/tosysmlv2/AvatarFromSysML.java
@@ -38,7 +38,6 @@
 package avatartranslator.tosysmlv2;
 
 import java.io.FileReader;
-import java.io.StringReader;
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
@@ -176,12 +175,18 @@ public class AvatarFromSysML {
             int nbFields = d.getSize();
             for (int i = 0; i < nbFields; i++) {
                 String type =  d.getFieldType(i);
-                if(type.equals("Integer"))
-                    dataType.addField(d.getFieldName(i), AvatarDataType.INTEGER, null);
-                else if(type.equals("Boolean"))
-                    dataType.addField(d.getFieldName(i), AvatarDataType.BOOLEAN, null);
-                else
-                    dataType.addField(d.getFieldName(i), AvatarDataType.DATATYPE, type);
+                if(type.equals("Integer")) {
+                    AvatarAttribute aa = new AvatarAttribute(d.getFieldName(i),AvatarType.INTEGER,null,null);
+                    dataType.addAttribute(aa, null);
+                }
+                else if(type.equals("Boolean")) {
+                    AvatarAttribute aa = new AvatarAttribute(d.getFieldName(i),AvatarType.BOOLEAN,null,null);
+                    dataType.addAttribute(aa, null);
+                }
+                else {
+                    AvatarAttribute aa = new AvatarAttribute(d.getFieldName(i),AvatarType.UNDEFINED,null,null);
+                    dataType.addAttribute(aa, type);
+                }
             }
         }
     }
@@ -226,11 +231,11 @@ public class AvatarFromSysML {
                     for(int j = 0; j < tsize; j++) {
                         aa = new AvatarAttribute(
                                 a.getName() + "__" + adt.getFieldString(j),
-                                (adt.getFieldStringType(j) == AvatarDataType.BOOLEAN ? AvatarType.BOOLEAN : AvatarType.INTEGER),
+                                (adt.getFieldStringType(j) == AvatarType.BOOLEAN ? AvatarType.BOOLEAN : AvatarType.INTEGER),
                                 theBlock, null);
                         theBlock.addAttribute(aa);
                         aa.setAsConstant(false);
-                        if (j == 0) aa.setDataType(adt);
+                        aa.setDataType(adt,j);
                     }
                 }
             }
@@ -257,11 +262,11 @@ public class AvatarFromSysML {
                     for(int j = 0; j < tsize; j++) {
                         aa = new AvatarAttribute(
                                 a.getName() + "__" + adt.getFieldString(j),
-                                (adt.getFieldStringType(j) == AvatarDataType.BOOLEAN ? AvatarType.BOOLEAN : AvatarType.INTEGER),
+                                (adt.getFieldStringType(j) == AvatarType.BOOLEAN ? AvatarType.BOOLEAN : AvatarType.INTEGER),
                                 theBlock, null);
                         theBlock.addAttribute(aa);
                         aa.setAsConstant(true);
-                        if (j == 0) aa.setDataType(adt);
+                        aa.setDataType(adt,j);
                     }
                 }
             }
@@ -287,9 +292,9 @@ public class AvatarFromSysML {
                     am.addReturnParameter(new AvatarAttribute("return__0", AvatarType.BOOLEAN, theBlock, null));
                 else {
                     AvatarDataType adt = AvatarDataType.dataTypeMap.get(returnType);
-                    int nbFields = adt.getNbFields();
+                    int nbFields = adt.getAttributeNb();
                     for (int j = 0; j < nbFields; j++) {
-                        AvatarType type = (adt.getFieldStringType(j) == AvatarDataType.INTEGER ? AvatarType.INTEGER : AvatarType.BOOLEAN);
+                        AvatarType type = (adt.getFieldStringType(j) == AvatarType.INTEGER ? AvatarType.INTEGER : AvatarType.BOOLEAN);
                         am.addReturnParameter(new AvatarAttribute("return__" + j, type, theBlock, null));
                     }
                 }
@@ -340,8 +345,7 @@ public class AvatarFromSysML {
                         for (int k = 0; k < asize; k++) {
                             StxAction action = actions.get(k);
                             if(action.getType() == AvatarFromSysMLSyntax.STXASSIGNACTION){
-                                String leftHandStr = extendIdent(action.getTarget(),blk);
-                                AvatarDataType dataType = extendType;
+                                String leftHandStr = action.getTarget();
                                 String rightHandStr;
                                 StxTerm value = action.getValue();
                                 if (value instanceof StxId){ rightHandStr = extendIdent(((StxId)value).getString(),blk); }
@@ -349,12 +353,6 @@ public class AvatarFromSysML {
                                 else { rightHandStr = extendCall((StxCall)value,blk); }
                                 AvatarAction act = AvatarTerm.createActionFromString(theBlock, leftHandStr + "=" + rightHandStr);
                                 theTransition.addAction(act);
-                                if(dataType != null && act != null && ((AvatarActionAssignment)act).getLeftHand() instanceof AvatarTuple ) {
-                                    AvatarAttribute head =
-                                            (AvatarAttribute)((AvatarTuple) ((AvatarActionAssignment)act).getLeftHand()).getComponents().get(0);
-                                    head.setDataType(dataType);
-                                }
-                                //!!! Ajouter le tagging datatype
                             }
                             else { // STXMETHODACTION
                                 if (action.getValue() instanceof StxCall) { // else ERROR
@@ -477,11 +475,11 @@ public class AvatarFromSysML {
                 for(int j = 0; j < tsize; j++) {
                     aa = new AvatarAttribute(
                             ss.getFieldName(i) + "__" + adt.getFieldString(j),
-                            (adt.getFieldStringType(j) == AvatarDataType.BOOLEAN ? AvatarType.BOOLEAN : AvatarType.INTEGER),
+                            (adt.getFieldStringType(j) == AvatarType.BOOLEAN ? AvatarType.BOOLEAN : AvatarType.INTEGER),
                             b, null);
                     am.addParameter(aa);
                     aa.setAsConstant(false);
-                    if (j == 0) aa.setDataType(adt);
+                    aa.setDataType(adt,j);
                 }
             }
         }
@@ -500,15 +498,15 @@ public class AvatarFromSysML {
         for (int i = 1; i < size; i++) {
             AvatarDataType adt = AvatarDataType.dataTypeMap.get(type);
             if (adt == null) return null;
-            int nbFields = adt.getNbFields();
+            int nbFields = adt.getAttributeNb();
             int j;
             for (j = 0; j < nbFields; j++)
-                if (adt.getFieldName(j).equals(path[i])) break;
+                if (adt.getAttribute(j).getName().equals(path[i])) break;
             if (j == nbFields) return null;
-            int adtType = adt.getFieldType(j);
-            if (adtType == AvatarDataType.INTEGER)
+            AvatarType adtType = adt.getAttribute(j).getType();
+            if (adtType == AvatarType.INTEGER)
                 type = "Integer";
-            else if (adtType == AvatarDataType.BOOLEAN)
+            else if (adtType == AvatarType.BOOLEAN)
                 type = "Boolean";
             else
                 type = adt.getDataTypeName(j);
diff --git a/src/main/java/ui/AvatarDesignPanelTranslator.java b/src/main/java/ui/AvatarDesignPanelTranslator.java
index 8cd2a283fc37d83c8790199c0677ac5b13741075..f841a0aabd1c0f65909c6fcabda29b64f45f2126 100644
--- a/src/main/java/ui/AvatarDesignPanelTranslator.java
+++ b/src/main/java/ui/AvatarDesignPanelTranslator.java
@@ -47,7 +47,6 @@ import ui.avatarbd.*;
 import ui.avatarsmd.*;
 
 import java.util.*;
-import java.util.function.BiConsumer;
 
 /**
  * Class AvatarDesignPanelTranslator
@@ -112,6 +111,7 @@ public class AvatarDesignPanelTranslator {
                     }
                 }
                 // Find data types
+
             }
         }
 
@@ -1047,34 +1047,6 @@ public class AvatarDesignPanelTranslator {
         return optype;
     }
 
-    private class FinalizeAvatarDataType implements BiConsumer<String, AvatarDataType> {
-        List<AvatarDataType> dataTypeList;
-        public FinalizeAvatarDataType(List<AvatarDataType> _dataTypeList){ dataTypeList = _dataTypeList; }
-        public void accept(String n, AvatarDataType d) {
-            AvatarDataType.finalize(d);
-            dataTypeList.add(d);
-        }
-    }
-    public void createDataTypes(AvatarSpecification as, List<AvatarBDDataType> _dataTypes) {
-        AvatarDataType.dataTypeMap.clear();
-
-        for (AvatarBDDataType dtt : _dataTypes) {
-                String dtName = dtt.getDataTypeName();
-                AvatarDataType dataType = new AvatarDataType(dtName,dtt);
-                List<TAttribute> fields = dtt.getAttributeList();
-                for (TAttribute f : fields) {
-                    if(f.getType() == TAttribute.INTEGER || f.getType() == TAttribute.NATURAL)
-                        dataType.addField(f.getId(), AvatarDataType.INTEGER, null);
-                    else if (f.getType() == TAttribute.BOOLEAN)
-                        dataType.addField(f.getId(), AvatarDataType.BOOLEAN, null);
-                    else
-                        dataType.addField(f.getId(), AvatarDataType.DATATYPE, f.getTypeOther());
-                }
-                AvatarDataType.dataTypeMap.put(dtName, dataType);
-        }
-        AvatarDataType.dataTypeMap.forEach(new FinalizeAvatarDataType(as.getDataTypes()));
-    }
-
     private AvatarAttribute createRegularAttribute(AvatarStateMachineOwner _ab, TAttribute _a, String _preName, TAttribute originAttribute) {
         AvatarType type = AvatarType.UNDEFINED;
         if (_a.getType() == TAttribute.INTEGER) {
@@ -1107,6 +1079,25 @@ public class AvatarDesignPanelTranslator {
         _ai.addAttribute(this.createRegularAttribute(_ai, _a, _preName, originAttribute));
     }
 
+    private void createDataTypes(AvatarSpecification _as, List<AvatarBDDataType> _dataTypes) {
+        for(AvatarBDDataType type: _dataTypes) {
+            AvatarDataType adt = new AvatarDataType(type.getDataTypeName(), type);
+            for(TAttribute ta: type.getAttributeList()) {
+                AvatarType ty;
+                if (ta.getType() == TAttribute.INTEGER) {
+                    ty = AvatarType.INTEGER;
+                } else if (ta.getType() == TAttribute.BOOLEAN) {
+                    ty = AvatarType.BOOLEAN;
+                } else {
+                    ty = AvatarType.UNDEFINED;
+                }
+                AvatarAttribute aa = new AvatarAttribute(ta.getName(), ty, null, type);
+                adt.addAttribute(aa,ta.getTypeOther().trim());
+            }
+            _as.addDataType(adt);
+        }
+    }
+
     private void createLibraryFunctions(AvatarSpecification _as, List<AvatarBDLibraryFunction> _libraryFunctions) {
         for (AvatarBDLibraryFunction libraryFunction : _libraryFunctions) {
             AvatarLibraryFunction alf = new AvatarLibraryFunction(libraryFunction.getFunctionName(), _as, libraryFunction);
@@ -1140,12 +1131,8 @@ public class AvatarDesignPanelTranslator {
                         } else {
                             nameTypeMap.put(libraryFunction.getFunctionName() + "." + attr.getId(), attr.getTypeOther());
                             typeAttributesMap.put(attr.getTypeOther(), types);
-                            AvatarAttribute aa = this.createRegularAttribute(alf, types.get(0), attr.getId() + "__", attr);
-                            aa.setDataType(AvatarDataType.dataTypeMap.get(attr.getTypeOther()));
-                            alf.addParameter(aa);
-                            int nbFields = types.size();
-                            for (int i = 1; i < nbFields; i++)
-                                alf.addParameter(this.createRegularAttribute(alf, types.get(i), attr.getId() + "__", attr));
+                            for (TAttribute type : types)
+                                alf.addParameter(this.createRegularAttribute(alf, type, attr.getId() + "__", attr));
                         }
                     }
                 }
@@ -1175,12 +1162,8 @@ public class AvatarDesignPanelTranslator {
                         } else {
                             nameTypeMap.put(libraryFunction.getFunctionName() + "." + attr.getId(), attr.getTypeOther());
                             typeAttributesMap.put(attr.getTypeOther(), types);
-                            AvatarAttribute aa = this.createRegularAttribute(alf, types.get(0), attr.getId() + "__", attr);
-                            aa.setDataType(AvatarDataType.dataTypeMap.get(attr.getTypeOther()));
-                            alf.addReturnAttribute(aa);
-                            int nbFields = types.size();
-                            for (int i = 1; i < nbFields; i++)
-                                alf.addReturnAttribute(this.createRegularAttribute(alf, types.get(i), attr.getId() + "__", attr));
+                            for (TAttribute type : types)
+                                alf.addReturnAttribute(this.createRegularAttribute(alf, type, attr.getId() + "__", attr));
                         }
                     }
                 }
@@ -1210,12 +1193,6 @@ public class AvatarDesignPanelTranslator {
                         } else {
                             nameTypeMap.put(libraryFunction.getFunctionName() + "." + attr.getId(), attr.getTypeOther());
                             typeAttributesMap.put(attr.getTypeOther(), types);
-                            AvatarAttribute aa = this.createRegularAttribute(alf, types.get(0), attr.getId() + "__", attr);
-                            aa.setDataType(AvatarDataType.dataTypeMap.get(attr.getTypeOther()));
-                            alf.addAttribute(aa);
-                            int nbFields = types.size();
-                            for (int i = 1; i < nbFields; i++)
-                                alf.addAttribute(this.createRegularAttribute(alf, types.get(i), attr.getId() + "__", attr));
                             for (TAttribute type : types)
                                 alf.addAttribute(this.createRegularAttribute(alf, type, attr.getId() + "__", attr));
                         }
@@ -1279,13 +1256,22 @@ public class AvatarDesignPanelTranslator {
                             ce.setTDiagramPanel(adp.getAvatarBDPanel());
                             addCheckingError(ce);
                         } else {
-                            nameTypeMap.put(block.getBlockName() + "." + a.getId(), a.getTypeOther());
-                            typeAttributesMap.put(a.getTypeOther(), types);
-                            AvatarAttribute aa = addRegularAttribute(ab, types.get(0), a.getId() + "__", a);
-                            aa.setDataType(AvatarDataType.dataTypeMap.get(a.getTypeOther()));
-                            int nbFields = types.size();
-                            for (int i = 1; i < nbFields; i++)
-                                addRegularAttribute(ab, types.get(i), a.getId() + "__", a);
+                            AvatarDataType adt = _as.getDataTypeByName(a.getTypeOther());
+                            if (adt == null) {
+                                UICheckingError ce = new UICheckingError(CheckingError.STRUCTURE_ERROR,
+                                        "Invalid data type definition:  " + a.getTypeOther());
+                                ce.setTDiagramPanel(adp.getAvatarBDPanel());
+                                addCheckingError(ce);
+                            } else {
+                                nameTypeMap.put(block.getBlockName() + "." + a.getId(), a.getTypeOther());
+                                typeAttributesMap.put(a.getTypeOther(), types);
+                                int cpt = 0;
+                                for (TAttribute type : types) {
+                                    AvatarAttribute aa = addRegularAttribute(ab, type, a.getId() + "__", a);
+                                    aa.setDataType(adt, cpt);
+                                    cpt++;
+                                }
+                            }
                         }
                     }
                 }
@@ -1353,93 +1339,10 @@ public class AvatarDesignPanelTranslator {
         }
     }
 
-    //ajoute DG 28.02.
 
-    /* private void createInterfaces(AvatarSpecification _as, List<AvatarBDInterface> _interfaces) {
-     for (AvatarBDInterface interf : _interfaces) {
-     //for (AvatarBDInterface interf : _as.getListOfInterfaces()) {
-            AvatarAMSInterface ai = new AvatarAMSInterface(interf.getInterfaceName(), _as, interf);
-            _as.addInterface(ai);
-            listE.addCor(ai, interf);
-            interf.setAVATARID(ai.getID());
-
-            // Create attributes
-            for (TAttribute a : interf.getAttributeList()) {
-                if (a.getType() == TAttribute.INTEGER) {
-                    addRegularAttributeInterface(ai, a, "");
-                } else if (a.getType() == TAttribute.NATURAL) {
-                    addRegularAttributeInterface(ai, a, "");
-                } else if (a.getType() == TAttribute.BOOLEAN) {
-                    addRegularAttributeInterface(ai, a, "");
-                } else if (a.getType() == TAttribute.TIMER) {
-                    addRegularAttributeInterface(ai, a, "");
-                } else {
-                    // other
-                    // TraceManager.addDev(" -> Other type found: " + a.getTypeOther());
-                    List<TAttribute> types = adp.getAvatarBDPanel().getAttributesOfDataType(a.getTypeOther());
-                    if (types == null) {
-                        UICheckingError ce = new UICheckingError(CheckingError.STRUCTURE_ERROR, "Unknown data type:  " + a.getTypeOther() + " used in " + ai.getName());
-                        ce.setTDiagramPanel(adp.getAvatarBDPanel());
-                        addCheckingError(ce);
-                        return;
-                    } else {
-                        if (types.size() == 0) {
-                            UICheckingError ce = new UICheckingError(CheckingError.STRUCTURE_ERROR, "Data type definition must contain at least one attribute:  " + ai.getName());
-                            ce.setTDiagramPanel(adp.getAvatarBDPanel());
-                            addCheckingError(ce);
-                        } else {
-                            nameTypeMap.put(interf.getInterfaceName() + "." + a.getId(), a.getTypeOther());
-                            typeAttributesMap.put(a.getTypeOther(), types);
-                            for (TAttribute type : types)
-                                addRegularAttributeInterface(ai, type, a.getId() + "__");
-                        }
-                    }
 
-                }
-            }
-
-            // Create methods
-            for (ui.AvatarMethod uiam : interf.getMethodList()) {
-                avatartranslator.AvatarMethod atam = new avatartranslator.AvatarMethod(uiam.getId(), uiam);
-                atam.setImplementationProvided(uiam.isImplementationProvided());
-                ai.addMethod(atam);
-                makeParameters(ai, atam, uiam);
-                makeReturnParameters(ai, interf, atam, uiam);
-            }
-
-            // Create signals
-            for (ui.AvatarSignal uias : interf.getSignalList()) {
-                avatartranslator.AvatarSignal atas;
-                if (uias.getInOut() == AvatarSignal.IN) {
-                    atas = new avatartranslator.AvatarSignal(uias.getId(), avatartranslator.AvatarSignal.IN, uias);
-                } else {
-                    atas = new avatartranslator.AvatarSignal(uias.getId(), avatartranslator.AvatarSignal.OUT, uias);
-                }
-                ai.addSignal(atas);
-                makeParameters(ai, atas, uias);
-            }
-
-            // Put global code
-            ai.addGlobalCode(interf.getGlobalCode());
-
-        }
-
-        // Make interface hierarchy
-        for (AvatarAMSInterface interf : _as.getListOfInterfaces()) {
-            TGComponent tgc1 = listE.getTG(interf);
-            if ((tgc1 != null) && (tgc1.getFather() != null)) {
-                TGComponent tgc2 = tgc1.getFather();
-                AvatarAMSInterface ai = listE.getAvatarAMSInterface(tgc2);
-                if (ai != null) {
-                    interf.setFather(ai);
-                }
-            }
-        }
-	}*/
-
-    //fin ajoute DG
-
-    private void makeReturnParameters(AvatarStateMachineOwner _ab, AvatarBDStateMachineOwner _block, avatartranslator.AvatarMethod _atam, ui.AvatarMethod _uiam) {
+    private void makeReturnParameters(AvatarStateMachineOwner _ab, AvatarBDStateMachineOwner _block, avatartranslator.AvatarMethod _atam,
+                                      ui.AvatarMethod _uiam) {
         String rt = _uiam.getReturnType().trim();
         AvatarAttribute aa;
         AvatarType type = AvatarType.UNDEFINED;
@@ -1454,28 +1357,36 @@ public class AvatarDesignPanelTranslator {
         } else {
             List<TAttribute> types = adp.getAvatarBDPanel().getAttributesOfDataType(rt);
             if (types == null) {
-                UICheckingError ce = new UICheckingError(CheckingError.STRUCTURE_ERROR, "Unknown data type:  " + rt + " declared as a return parameter of a method of " + _block.getOwnerName());
+                UICheckingError ce = new UICheckingError(CheckingError.STRUCTURE_ERROR, "Unknown data type:  " + rt +
+                        " declared as a return parameter of a method of " + _block.getOwnerName());
                 // TODO: adapt
                 // ce.setAvatarBlock(_ab);
                 ce.setTDiagramPanel(adp.getAvatarBDPanel());
                 addCheckingError(ce);
                 return;
             } else {
-                int nbFields = types.size();
-                int j = 0;
-                while (j < nbFields) {
-                    if (types.get(j).getType() == TAttribute.INTEGER)
-                        type = AvatarType.INTEGER;
-                    else if (types.get(j).getType() == TAttribute.NATURAL)
-                        type = AvatarType.INTEGER;
-                    else if (types.get(j).getType() == TAttribute.BOOLEAN)
+                AvatarDataType adt = _ab.getAvatarSpecification().getDataTypeByName(rt);
+                if (adt == null) {
+                    UICheckingError ce = new UICheckingError(CheckingError.STRUCTURE_ERROR, "No data type for  \"" + type.getStringType()
+                            + "\" declared in method " + _atam + " of block " + _ab.getName());
+                    // TODO: adapt
+                    // ce.setAvatarBlock(_block);
+                    ce.setTDiagramPanel(adp.getAvatarBDPanel());
+                    addCheckingError(ce);
+                } else {
+                    int j = 0;
+                    for (TAttribute ta : types) {
                         type = AvatarType.BOOLEAN;
-                    else
-                        type = AvatarType.INTEGER;
-                    aa = new AvatarAttribute("return__" + j, type, _ab, _block);
-                    if (j==0) aa.setDataType(AvatarDataType.dataTypeMap.get(rt));
-                    _atam.addReturnParameter(aa);
-                    j++;
+                        if (ta.getType() == TAttribute.INTEGER)
+                            type = AvatarType.INTEGER;
+                        else if (ta.getType() == TAttribute.NATURAL)
+                            type = AvatarType.INTEGER;
+
+                        aa = new AvatarAttribute("return__" + j, type, _ab, _block);
+                        aa.setDataType(adt, j);
+                        j++;
+                        _atam.addReturnParameter(aa);
+                    }
                 }
             }
         }
@@ -1488,9 +1399,10 @@ public class AvatarDesignPanelTranslator {
 
         for (int i = 0; i < types.length; i++) {
             List<TAttribute> v = adp.getAvatarBDPanel().getAttributesOfDataType(types[i]);
-            if (v == null) {
+            if (v == null) { // It is a regular type
                 if (AvatarType.getType(types[i]) == AvatarType.UNDEFINED) {
-                    UICheckingError ce = new UICheckingError(CheckingError.STRUCTURE_ERROR, "Unknown data type:  \"" + types[i] + "\" declared in method " + _atam + " of block " + _block.getName());
+                    UICheckingError ce = new UICheckingError(CheckingError.STRUCTURE_ERROR, "Unknown data type:  \"" + types[i]
+                            + "\" declared in method " + _atam + " of block " + _block.getName());
                     // TODO: adapt
                     // ce.setAvatarBlock(_block);
                     ce.setTDiagramPanel(adp.getAvatarBDPanel());
@@ -1499,21 +1411,29 @@ public class AvatarDesignPanelTranslator {
                 AvatarAttribute aa = new AvatarAttribute(typeIds[i], AvatarType.getType(types[i]), _block, _uiam);
                 _atam.addParameter(aa);
             } else {
-                int nbFields = v.size();
-                for (int j = 0; j < nbFields; j++) {
-                    AvatarType type = AvatarType.UNDEFINED;
-                    if (v.get(j).getType() == TAttribute.INTEGER) {
-                        type = AvatarType.INTEGER;
-                    } else if (v.get(j).getType() == TAttribute.NATURAL) {
-                        type = AvatarType.INTEGER;
-                    } else if (v.get(j).getType() == TAttribute.BOOLEAN) {
-                        type = AvatarType.BOOLEAN;
-                    } else if (v.get(j).getType() == TAttribute.TIMER) {
-                        type = AvatarType.TIMER;
+                AvatarDataType adt = _block.getAvatarSpecification().getDataTypeByName(types[i]);
+                if (adt == null) {
+                    UICheckingError ce = new UICheckingError(CheckingError.STRUCTURE_ERROR, "No data type for  \"" + types[i]
+                            + "\" declared in method " + _atam + " of block " + _block.getName());
+                    // TODO: adapt
+                    // ce.setAvatarBlock(_block);
+                    ce.setTDiagramPanel(adp.getAvatarBDPanel());
+                    addCheckingError(ce);
+                } else {
+                    int cpt = 0;
+                    for (TAttribute ta : v) {
+                        AvatarType type = AvatarType.BOOLEAN;
+                        if (ta.getType() == TAttribute.INTEGER) {
+                            type = AvatarType.INTEGER;
+                        } else if (ta.getType() == TAttribute.NATURAL) {
+                            type = AvatarType.INTEGER;
+                        }
+                        TraceManager.addDev("Adding attribute for method: " + typeIds[i] + "__" + ta.getId());
+                        AvatarAttribute aa = new AvatarAttribute(typeIds[i] + "__" + ta.getId(), type, _block, _uiam);
+                        aa.setDataType(adt, cpt);
+                        cpt ++;
+                        _atam.addParameter(aa);
                     }
-                    AvatarAttribute aa = new AvatarAttribute(typeIds[i] + "__" + v.get(j).getId(), type, _block, _uiam);
-                    if ( j == 0 ) aa.setDataType(AvatarDataType.dataTypeMap.get(types[i]));
-                    _atam.addParameter(aa);
                 }
             }
         }
@@ -1806,13 +1726,11 @@ public class AvatarDesignPanelTranslator {
                         if (types == null || types.isEmpty())
                             throw new CheckingError(CheckingError.STRUCTURE_ERROR, "Unknown data type:  " + returnTA.getTypeOther() + " when calling " + libraryFunction.getFunctionName());
 
-                        int nbFields = types.size();
-                        for (int j = 0; j < nbFields; j++) {
-                            String attributeName = dummyName + "__" + types.get(j).getId();
+                        for (TAttribute type : types) {
+                            String attributeName = dummyName + "__" + type.getId();
                             AvatarAttribute attr = _ab.getAvatarAttributeWithName(attributeName);
                             if (attr == null) {
-                                attr = this.createRegularAttribute(_ab, types.get(j), dummyName + "__", null);
-                                if (j == 0) attr.setDataType(AvatarDataType.dataTypeMap.get(returnTA.getTypeOther()));
+                                attr = this.createRegularAttribute(_ab, type, dummyName + "__", null);
                                 _ab.addAttribute(attr);
                             }
                             attrs.add(attr);
@@ -1877,13 +1795,11 @@ public class AvatarDesignPanelTranslator {
                     if (types == null || types.isEmpty())
                         throw new CheckingError(CheckingError.STRUCTURE_ERROR, "Unknown data type:  " + returnTA.getTypeOther() + " when calling " + libraryFunction.getFunctionName());
 
-                    int nbField = types.size();
-                    for (int j = 0; j < types.size(); j++) {
-                        String attributeName = dummyName + "__" + types.get(j).getId();
+                    for (TAttribute type : types) {
+                        String attributeName = dummyName + "__" + type.getId();
                         AvatarAttribute attr = _ab.getAvatarAttributeWithName(attributeName);
                         if (attr == null) {
-                            attr = this.createRegularAttribute(_ab, types.get(j), dummyName + "__", null);
-                            if (j == 0) attr.setDataType(AvatarDataType.dataTypeMap.get(returnTA.getTypeOther()));
+                            attr = this.createRegularAttribute(_ab, type, dummyName + "__", null);
                             _ab.addAttribute(attr);
                         }
                         attrs.add(attr);
@@ -2279,7 +2195,7 @@ public class AvatarDesignPanelTranslator {
             makeError(error, connector.tdp, block, connector, "transition guard", toCheck);
         } else {
             final AvatarGuard guard = AvatarGuard.createFromString(block, toCheck);
-            transition.setGuard(guard);
+            transition.setGuard(guard, connector.getEffectiveGuard());
         }
 
     }
@@ -2309,7 +2225,7 @@ public class AvatarDesignPanelTranslator {
 
         if (afterMinDelayStr != null && afterMaxDelayStr != null) {
             //TraceManager.addDev("Delays:" + afterMinDelayStr + "," + afterMaxDelayStr);
-            transition.setDelays(afterMinDelayStr, afterMaxDelayStr);
+            transition.setDelays(afterMinDelayStr, afterMaxDelayStr, connector.getEffectiveAfterMinDelay(), connector.getEffectiveAfterMaxDelay());
 
             // Must handle distribution law and extra attributes
             int law = connector.getEffectiveDelayDistributionLaw();
@@ -2384,6 +2300,7 @@ public class AvatarDesignPanelTranslator {
 
         for (String actionText : connector.getEffectiveActions()) {
             if (actionText.trim().length() > 0) {
+                String originalAction = actionText.trim();
                 //TraceManager.addDev("Action1:" + actionText);
                 actionText = modifyString(actionText.trim());
                 //TraceManager.addDev("Action2:" + actionText);
@@ -2425,7 +2342,7 @@ public class AvatarDesignPanelTranslator {
                             addCheckingError(ce);
                         } else {
                             //TraceManager.addDev("Valid: Adding method call action\n");
-                            transition.addAction(actionText);
+                            transition.addAction(actionText, originalAction);
                         }
                     }
                 } else {
@@ -2442,7 +2359,7 @@ public class AvatarDesignPanelTranslator {
                         }
                     } else {
                         TraceManager.addDev("Adding regular action:" + actionText);
-                        transition.addAction(actionText);
+                        transition.addAction(actionText, originalAction);
                     }
                 }
             }