diff --git a/src/main/java/avatartranslator/tosysmlv2/AvatarFromSysMLLexer.java b/src/main/java/avatartranslator/tosysmlv2/AvatarFromSysMLLexer.java
index 912b5afb01787ddf150198327eeb1e0e25c805f3..a94e25a11d007addd367e70cba2c033e5c5c1aab 100644
--- a/src/main/java/avatartranslator/tosysmlv2/AvatarFromSysMLLexer.java
+++ b/src/main/java/avatartranslator/tosysmlv2/AvatarFromSysMLLexer.java
@@ -1,4 +1,4 @@
-/* The following code was generated by JFlex 1.4.3 on 23/06/2024 13:52 */
+/* The following code was generated by JFlex 1.4.3 on 24/06/2024 14:11 */
 
 /* Copyright or (C) or Copr. GET / ENST, Telecom-Paris, Ludovic Apvrille
  *
@@ -46,7 +46,7 @@ import avatartranslator.tosysmlv2.AvatarFromSysMLSyntax.*;
 /**
  * This class is a scanner generated by 
  * <a href="http://www.jflex.de/">JFlex</a> 1.4.3
- * on 23/06/2024 13:52 from the specification file
+ * on 24/06/2024 14:11 from the specification file
  * <code>__AvatarFromSysMLLexer__.jflex</code>
  */
 public class AvatarFromSysMLLexer implements java_cup.runtime.Scanner {
diff --git a/src/main/java/avatartranslator/tosysmlv2/AvatarFromSysMLParser.java b/src/main/java/avatartranslator/tosysmlv2/AvatarFromSysMLParser.java
index d8bac394b6ef3c2e1ad07848da75f09f19cb5511..f8c7c1819e1c700e7ac254162ce03543ce1d6a9a 100644
--- a/src/main/java/avatartranslator/tosysmlv2/AvatarFromSysMLParser.java
+++ b/src/main/java/avatartranslator/tosysmlv2/AvatarFromSysMLParser.java
@@ -1193,37 +1193,15 @@ public class AvatarFromSysMLParser extends java_cup.runtime.lr_parser {
     }
     public StxModel parseModel() {
         try {
-            StxModel m = (StxModel) parse().value;
-            outMessageMap.forEach(new Complete());
-            for(StxTransition st: commTransitions) updateSignal(st);
-            return m;
+            parse();
+            return new StxModel(errors,dataTypeMap,relationMap,channelMap,blockMap,signalMap,outMessageMap,commTransitions);
         }
         catch (java.lang.Exception e) {
             addError(new AvatarFromSysMLError(AvatarFromSysMLError.HIGHERROR, lexer.getErrorLocation(), e.getMessage()));
-            return null;
-        }
-    }
-    private class Complete implements BiConsumer<String, StxOutMessage> {
-        public Complete(){};
-        public void accept(String s, StxOutMessage o) { o.complete(errors); }
-    }
-    private void updateSignal(StxTransition st) {
-        String name = st.getSignalName();
-        StxBlock blk = blockMap.get(st.getBlockName());
-        while (blk != null) {
-            int size = blk.getNbSignals();
-            int i;
-            for (i = 0; i < size; i++) {
-                StxSignal s = blk.getSignal(i);
-                if (s.getName().equals(name)) {
-                    st.setSignal(s);
-                    break;
-                }
-            }
-            if (i < size) blk = null;
-            else blk = blk.getFather();
+            return new StxModel(errors,dataTypeMap,relationMap,channelMap,blockMap,signalMap,outMessageMap,commTransitions);
         }
     }
+
     private StxField theField;
     private StringBuffer stringAcc = new StringBuffer();
     private ArrayList<AvatarFromSysMLError> errors;
@@ -1436,11 +1414,8 @@ class CUP$AvatarFromSysMLParser$actions {
           /*. . . . . . . . . . . . . . . . . . . .*/
           case 0: // model ::= PACKAGE IDENT LBRAC featureList RBRAC 
             {
-              StxModel RESULT =null;
-		
-        RESULT =
-        new StxModel(errors,dataTypeMap,relationMap,channelMap,blockMap,signalMap);
-      
+              Object RESULT =null;
+
               CUP$AvatarFromSysMLParser$result = parser.getSymbolFactory().newSymbol("model",2, CUP$AvatarFromSysMLParser$stack.elementAt(CUP$AvatarFromSysMLParser$top-4), CUP$AvatarFromSysMLParser$stack.peek(), RESULT);
             }
           return CUP$AvatarFromSysMLParser$result;
@@ -1451,7 +1426,7 @@ class CUP$AvatarFromSysMLParser$actions {
               Object RESULT =null;
 		Location start_valxleft = ((java_cup.runtime.ComplexSymbolFactory.ComplexSymbol)CUP$AvatarFromSysMLParser$stack.elementAt(CUP$AvatarFromSysMLParser$top-1)).xleft;
 		Location start_valxright = ((java_cup.runtime.ComplexSymbolFactory.ComplexSymbol)CUP$AvatarFromSysMLParser$stack.elementAt(CUP$AvatarFromSysMLParser$top-1)).xright;
-		StxModel start_val = CUP$AvatarFromSysMLParser$stack.elementAt(CUP$AvatarFromSysMLParser$top-1).<StxModel>value();
+		Object start_val = CUP$AvatarFromSysMLParser$stack.elementAt(CUP$AvatarFromSysMLParser$top-1).<Object>value();
 		RESULT = start_val;
               CUP$AvatarFromSysMLParser$result = parser.getSymbolFactory().newSymbol("$START",0, CUP$AvatarFromSysMLParser$stack.elementAt(CUP$AvatarFromSysMLParser$top-1), CUP$AvatarFromSysMLParser$stack.peek(), RESULT);
             }
@@ -1462,11 +1437,8 @@ class CUP$AvatarFromSysMLParser$actions {
           /*. . . . . . . . . . . . . . . . . . . .*/
           case 2: // model ::= PACKAGE IDENT LBRAC RBRAC 
             {
-              StxModel RESULT =null;
-		
-        RESULT =
-        new StxModel(errors,dataTypeMap,relationMap,channelMap,blockMap,signalMap);
-      
+              Object RESULT =null;
+
               CUP$AvatarFromSysMLParser$result = parser.getSymbolFactory().newSymbol("model",2, CUP$AvatarFromSysMLParser$stack.elementAt(CUP$AvatarFromSysMLParser$top-3), CUP$AvatarFromSysMLParser$stack.peek(), RESULT);
             }
           return CUP$AvatarFromSysMLParser$result;
diff --git a/src/main/java/avatartranslator/tosysmlv2/AvatarFromSysMLSyntax.java b/src/main/java/avatartranslator/tosysmlv2/AvatarFromSysMLSyntax.java
index 13869bb263bd96ae549abc16050e20d8be04326c..07879fa287f0701dbcf06568246f681e3a07a6fb 100644
--- a/src/main/java/avatartranslator/tosysmlv2/AvatarFromSysMLSyntax.java
+++ b/src/main/java/avatartranslator/tosysmlv2/AvatarFromSysMLSyntax.java
@@ -58,24 +58,7 @@ import java_cup.runtime.ComplexSymbolFactory.Location;
  * line and column in the source file
  */
 public class AvatarFromSysMLSyntax {
-    /** (technical) Arrays allowing to set a value at any index.
-     *
-     *  Missing values are set to null.
-     */
-    public static class MyArray<E> extends ArrayList<E> {
-        @Override
-        public E set(int index, E element){
-            int max = size();
-            for(int i = max; i <= index; i++)
-                add(null);
-            return super.set(index, element);
-        }
-       @Override
-       public E get(int index){
-            if (index >= size()) return null;
-            else return super.get(index);
-       }
-    }
+
      /** type of idents generated for datatype names */
     public static final byte DATATYPENAME = 0;
      /** type of idents generated for block names */
@@ -168,9 +151,31 @@ public class AvatarFromSysMLSyntax {
     public static final byte STXASSIGNACTION = 0;
      /** type of method-call transitions action */
     public static final byte STXMETHODACTION = 1;
-    /** idents collected while parsing an Avatar SysML Model
+
+    /** (technical) Arrays allowing to set a value at any index.
      *
-     * All these idents are without quotes (removed when found while parsing)
+     *  Missing values are set to null.
+     */
+    public static class MyArray<E> extends ArrayList<E> {
+        @Override
+        public E set(int index, E element){
+            int max = size();
+            for(int i = max; i <= index; i++)
+                add(null);
+            return super.set(index, element);
+        }
+        @Override
+
+        public E get(int index){
+            if (index < 0 || index >= size()) return null;
+            else return super.get(index);
+        }
+    }
+
+    /** idents collected while parsing an Avatar SysML Model.
+     *
+     * when generated, sysML names differ from original Avatar names.
+     * All these names are without quotes (removed when found while parsing)
      */
     public static class Ident  extends StxElement {
         /** type of the ident */
@@ -179,7 +184,7 @@ public class AvatarFromSysMLSyntax {
         private String sysMLName; // yet unused. perhaps to remove...
         /** Avatar name
          *
-         * different from sysMLName for generated idents: original names are
+         * different from sysMLName for generated idents: original Avatar names are
          * restored
          */
         private String avatarName;
@@ -188,6 +193,7 @@ public class AvatarFromSysMLSyntax {
          * @param _type the ident type
          * @param _smlName the SysML string
          */
+
         public Ident(byte _type, String _smlName) {
             super(_smlName.trim());
             setTypeName(_type, _smlName.trim());
@@ -216,7 +222,7 @@ public class AvatarFromSysMLSyntax {
          * Sets the names.
          *
          * Extract the Avatar original names from the generated names if relevant.
-         * If generated, _smlName must be consistant with _type
+         * If generated, _smlName must be consistent with _type
          *
          * @param _type known type
          * @param _smlName SysML String.
@@ -250,8 +256,9 @@ public class AvatarFromSysMLSyntax {
 
         /**  @return type of the ident */
         public byte getType() { return type; }
+
         /**  @return the SysML name */
-        public String getSysMLName() { return sysMLName; }
+        public String getSysMLName() { return sysMLName; } //unused
         /**  @return the Avatar name */
         public String getAvatarName() { return avatarName; }
         /** Check ident type */
@@ -303,27 +310,32 @@ public class AvatarFromSysMLSyntax {
         /** Check ident type */
         public boolean is_TIMERBLOCKNAME() { return type == TIMERBLOCKNAME || type == AVATARNAME; }
     }
+
     /** Class of classified expression terms */
     public abstract static class StxTerm extends StxElement {
         StxTerm(String _name, Location _left, Location _right) { super(_name, _left, _right); }
         StxTerm(String _name) { super(_name); }
         public String toString() { return getName(); }
     }
+
     /** Terms that are int/bool expressions.
      *
      *  They may be identifiers but not identified as such.*/
     public static class StxExpr extends StxTerm {
         public StxExpr(String v) { super(v); }
     }
+
     /** Terms that are Identifiers */
     public static class StxId extends StxTerm {
         private String value ;
         public StxId(String v) { super(v); }
     }
+
     /** Terms that are method call.
-     * intuitively, a call string is split into a sequence
-     * "segment ident ... segment ident segment"
-     * allowing to easyly replace the idents */
+     *
+     * (technical) a call string is split into a sequence
+     * "segment ident segment ... ident segment"
+     * allowing to easily replace the idents */
     public static class StxCall extends StxTerm {
         private ArrayList<String> segments;
         private ArrayList<String> idents;
@@ -333,11 +345,17 @@ public class AvatarFromSysMLSyntax {
             idents = new ArrayList<String>();
         }
         public String getName() { super.setName(toString()); return(super.getName()); }
+
         public void addSegment(String s) { segments.add(s); }
+
         public void addIdent(String s) { idents.add(s); }
+
         public int getNbIdents() { return idents.size(); }
+
         public String getSegment(int i) { return segments.get(i); }
+
         public String getIdent(int i) { return idents.get(i); }
+
         /** rebuilds the original string by concatenating segments and idents */
         public String toString() {
             StringBuffer result = new StringBuffer();
@@ -351,7 +369,9 @@ public class AvatarFromSysMLSyntax {
             return result.toString();
         }
     }
+
     /** Syntactic elements with a name and locations in the source code.
+     *
      *  When possible, usually the left is the beginning location and the right is the ending one.
      */
     public abstract static class StxElement {
@@ -360,13 +380,21 @@ public class AvatarFromSysMLSyntax {
         private Location left;
         private Location right;
         private boolean declared;
+
         public StxElement(String _name, Location _left, Location _right){ name = _name; left = _left; right = _right; declared = false; }
+
         public StxElement(String _name){ name = _name; left = defaultLocation; right = defaultLocation; declared = false; }
+
         public void setLeft(Location _left) { left = _left; }
+
         public void setRight(Location _right) { right = _right; }
+
         public String getName() { return name; }
+
         public void setName(String _name) { name = _name; }
+
         public Location  getLeft() { return left; }
+
         public Location  getRight() { return right; }
 
         /** sets the element as declared
@@ -374,43 +402,68 @@ public class AvatarFromSysMLSyntax {
          * @return true iff the element was not already declared
          */
         public boolean declare() { boolean res = !declared; declared = true; return res; }
+
         public boolean isDeclared() { return declared; }
     }
-    /** Typed fields for elements that are structures */
+
+    /** Typed fields for syntactic elements associated to structures. */
     public static class StxField extends StxElement {
-        private String type;
+       private String type;
         private String initialValue;
+        /** defaultValue = true means that the value is not explicitly set in Avatar */
         private boolean defaultValue;
+
         public StxField(String _name, String _type) {
             super(_name.trim());
             type = _type.trim();
             initialValue = "";
             defaultValue = false;
         }
+
         public StxField(Location _left, Location _right, String _name, String _type) {
             super(_name.trim(), _left, _right);
             type = _type.trim();
             initialValue = "";
             defaultValue = false;
         }
+
+        /** Primitive types are "Integer" and "Boolean".
+         * Other string are interpreted as datatype names.
+         */
         public String getType() { return type; }
+
         public void setType(String _type) { type = _type; }
+
         public void setInitialValue(String _initialValue) { initialValue = _initialValue; }
+
         public String getInitialValue() { return initialValue; }
+
+        /** defaultValue = true means that the value is not explicitly set in Avatar.
+         *
+         * Relevant only if initial value is equal to Avatar'initial value for the field's type
+         */
         public void setDefaultValue(boolean b) { defaultValue = b; }
+
+        /** defaultValue = true means that the value is not explicitly set in Avatar.
+         *
+         * Relevant only if initial value is equal to Avatar'initial value for the field's type
+         */
         public boolean getDefaultValue() { return defaultValue; }
     }
 
-    /** Elements that are Structures
+    /** Syntactiv Elements associated Structures
      *
-     * they are provided with an ordered list of fields
+     * Structures have an ordered list of fields
      */
     public static class StxStructure extends StxElement {
+
         protected MyArray<StxField> fields;
+
         public StxStructure(String _name, Location _left, Location _right) {
             super(_name.trim(), _left, _right);
             fields = new MyArray<StxField>();
         }
+
         public StxStructure(String _name) {
             super(_name.trim());
             fields = new MyArray<StxField>();
@@ -419,7 +472,7 @@ public class AvatarFromSysMLSyntax {
         /** add a field at the end of the list of fields.
          *
          * @param _field the field to add
-         * @return null if success. Otherwise the field found with same name.
+         * @return null if success. Otherwise, the field found with same name.
          */
         public StxField addField(StxField _field){
             StxField result = null;
@@ -432,17 +485,31 @@ public class AvatarFromSysMLSyntax {
             if (result == null) fields.add(_field);
             return result;
         }
+
         /** amount of fields */
         public int getSize() { return fields.size(); }
 
         public StxField getField(int i) { return fields.get(i);}
+
         public String getFieldName(int i) { return fields.get(i).getName();}
+
         public String getFieldType(int i) { return fields.get(i).getType();}
     }
+
+    /**
+     * Syntactic elements associated to Avatar datatype types.
+      */
     public static class StxDataType extends StxStructure {
+
         public StxDataType(Location _left, Location _right, String _name) { super(_name, _left, _right); }
+
         public StxDataType(String _name) { super(_name); }
     }
+
+    /** Syntactic elements associated to Avatar Relations.
+     *
+     * They are typed communication connections between blocks
+     * that contain channels linking input and output signals */
     public static class StxRelation extends StxElement {
         ArrayList<StxChannel> channels;
         StxBlock block1;
@@ -452,6 +519,7 @@ public class AvatarFromSysMLSyntax {
         boolean isprivate;
         int sizeOfFIFO;
         boolean asynchronous;
+
         public StxRelation(String _name, Location _left, Location _right) {
             super(_name.trim(), _left, _right);
             channels = new ArrayList<StxChannel>();
@@ -460,6 +528,7 @@ public class AvatarFromSysMLSyntax {
             String block1 = null;
             String block2 = null;
         }
+
         public StxRelation(String _name) {
             super(_name.trim());
             channels = new ArrayList<StxChannel>();
@@ -468,64 +537,112 @@ public class AvatarFromSysMLSyntax {
             String block1 = null;
             String block2 = null;
         }
+
         public void setBlock1(StxBlock _block) { block1 = _block; }
+
         public void setBlock2(StxBlock _block) { block2 = _block; }
+
         public void setBlocking(Boolean _b) { blocking = _b; }
+
         public void setPrivate(Boolean _b) { isprivate = _b; }
+
         public void setLossy(Boolean _b) { lossy = _b; }
+
         public void setFifoSize(int _size) { sizeOfFIFO = _size; }
+
         public void setAsynchronous(boolean _b) { asynchronous = _b; }
+
         public void addChannel(StxChannel ch) { channels.add(ch); }
+
         public StxBlock getBlock1() { return block1; }
+
         public StxBlock getBlock2() { return block2; }
+
         public Boolean getBlocking() { return blocking; }
+
         public Boolean getPrivate() { return isprivate; }
+
         public Boolean getLossy() { return lossy; }
+
         public int getFifoSize() { return sizeOfFIFO; }
+
         public boolean getAsynchronous() { return asynchronous; }
+
         public int getSize() { return channels.size(); }
+
         public StxChannel getChannel(int i) { return channels.get(i); }
     }
+
+    /** Syntactic elements associated to Avatar methods.
+     *
+     * Fields of structure correspond to the method's input profile.  */
     public static class StxMethod extends StxStructure {
+
+        private String returnType;
+
         public StxMethod(Location _left, Location _right, String _name) { super(_name, _left, _right); returnType = null; }
+
         public StxMethod(String _name) { super(_name); returnType = null; }
-        private String returnType;
+
         public String getReturnType() { return returnType; }
+
         public void setReturnType(String _s) { returnType = _s; }
     }
 
-
+    /** Syntactic elements associated to Avatar attributes of blocks.
+     *
+     * defaultValue = true means that the initial value is not explicitly set.
+     * It is ignored if the initial value is not the Avatar default one.
+     */
     public static class StxAttribute extends StxElement {
         private String type;
         private String init;
         private boolean defaultValue;
+
         public StxAttribute(String _name, Location _left, Location _right, String _type){
             super(_name.trim(), _left, _right);
             type = _type;
             init = "";
             defaultValue = false;
         }
+
         public StxAttribute(String _name, String _type){
             super(_name.trim());
             type = _type;
             init = "";
             defaultValue = false;
         }
+
         public String getType() { return type; }
+
         public void setInit(String _s) { init = _s; }
+
+        /** defaultValue = true means that the initial value is not explicitly set.
+        * It is ignored if the initial value is not the Avatar default one.
+        */
         public void setDefaultValue(boolean b) { defaultValue = b; }
+
         public String getInit() { return init; }
+
+        /** defaultValue = true means that the initial value is not explicitly set.
+        * It is ignored if the initial value is not the Avatar default one.
+        */
         public boolean getDefaultValue() { return defaultValue; }
    }
 
+    /** Syntactic elements associated to Avatar Timers, among attributes */
     public static class StxTimer extends StxAttribute {
-        public StxTimer( String _name, Location _left, Location _right){
-            super(_name, _left, _right, "");
-        }
-        public StxTimer(String _name){
-            super(_name, "");
-        }
+
+        public StxTimer( String _name, Location _left, Location _right){ super(_name, _left, _right, ""); }
+
+        public StxTimer(String _name){ super(_name, ""); }
     }
+
+    /** Syntactic elements associated to Avatar  Blocks.
+     *
+     * (technical) Transitions are contained in their source state.
+     * Names of constants, attributes, methods, signals and timers
+     * must be different. */
     public static class StxBlock extends StxElement {
         StxBlock father = null;
         ArrayList<StxAttribute> attributes;
@@ -534,6 +651,7 @@ public class AvatarFromSysMLSyntax {
         ArrayList<StxSignal> signals;
         ArrayList<StxTimer> timers;
         StxState[] states;
+
         public StxBlock(String _name, Location _left, Location _right) {
             super(_name, _left, _right);
             father = null;
@@ -543,6 +661,7 @@ public class AvatarFromSysMLSyntax {
             signals = new ArrayList<StxSignal>();
             timers = new ArrayList<StxTimer>();
         }
+
         public StxBlock(String _name) {
             super(_name);
             father = null;
@@ -552,9 +671,18 @@ public class AvatarFromSysMLSyntax {
             signals = new ArrayList<StxSignal>();
             timers = new ArrayList<StxTimer>();
         }
+
         public void setFather(StxBlock _father) { father = _father; }
+
         public StxState[] getStates() { return states; }
+
         public void setStates(StxState[] l) { states = l; }
+
+        /**
+         * Add an attribute (at the end: order respected)
+         * @param a the attribute to add
+         * @return null in case of success. Otherwise, the found element with same name.
+         */
         public StxElement addAttribute(StxAttribute a){
             for (StxSignal sig : signals) if (sig.getName().equals(a.getName())) return sig;
             for (StxAttribute att : constants) if (att.getName().equals(a.getName())) return att;
@@ -564,6 +692,12 @@ public class AvatarFromSysMLSyntax {
             attributes.add(a);
             return null;
         }
+
+         /**
+         * Add a constant (at the end: order respected)
+         * @param a the constant to add
+         * @return null in case of success. Otherwise, the found element with same name.
+         */
         public StxElement addConstant(StxAttribute a){
             for (StxSignal sig : signals) if (sig.getName().equals(a.getName())) return sig;
             for (StxAttribute att : constants) if (att.getName().equals(a.getName())) return att;
@@ -573,6 +707,12 @@ public class AvatarFromSysMLSyntax {
             constants.add(a);
             return null;
         }
+
+        /**
+        * Add a method (at the end)
+        * @param m the method to add
+        * @return null in case of success. Otherwise, the found element with same name.
+        */
         public StxElement addMethod(StxMethod m){
             for (StxSignal sig : signals) if (sig.getName().equals(m.getName())) return sig;
             for (StxAttribute att : constants) if (att.getName().equals(m.getName())) return att;
@@ -582,6 +722,12 @@ public class AvatarFromSysMLSyntax {
             methods.add(m);
             return null;
         }
+
+        /**
+         * Add a signal (at the end)
+         * @param s the signal to add
+         * @return null in case of success. Otherwise, the found element with same name.
+         */
         public StxElement addSignal(StxSignal s){
             for (StxSignal sig : signals) if (sig.getName().equals(s.getName())) return sig;
             for (StxAttribute att : constants) if (att.getName().equals(s.getName())) return att;
@@ -591,6 +737,12 @@ public class AvatarFromSysMLSyntax {
             signals.add(s);
             return null;
         }
+
+        /**
+        * Add a timer (at the end)
+        * @param t the timer to add
+        * @return null in case of success. Otherwise, the found element with same name.
+        */
         public StxElement addTimer(StxTimer t){
             for (StxSignal sig : signals) if (sig.getName().equals(t.getName())) return sig;
             for (StxAttribute att : constants) if (att.getName().equals(t.getName())) return att;
@@ -600,25 +752,43 @@ public class AvatarFromSysMLSyntax {
             timers.add(t);
             return null;
         }
+
+        /**
+         *
+         * @return the containing block (null if none)
+         */
         public StxBlock getFather() { return father; }
+
         public int getNbAttributes() { return attributes.size(); }
+
         public int getNbConstants() { return constants.size(); }
+
         public int getNbMethods() { return methods.size(); }
+
         public int getNbSignals() { return signals.size(); }
+
         public int getNbTimers() { return timers.size(); }
+
         public StxAttribute getAttribute(int i) { return attributes.get(i); }
+
         public StxAttribute getConstant(int i) { return constants.get(i); }
+
         public StxMethod getMethod(int i) { return methods.get(i); }
+
         public StxSignal getSignal(int i) { return signals.get(i); }
         public StxTimer getTimer(int i) { return timers.get(i); }
     }
+
+    /** Syntactic elements associated to Avatar signal connections (in Relations) **/
     public static class StxChannel extends StxElement {
-        private StxInMessage inProfile;
-        private StxOutMessage outProfile;
-        private String blockA;
-        private StxSignal signalA;
-        private String blockB;
-        private StxSignal signalB;
+
+        private StxInMessage inProfile; // typing the connected  input signal
+        private StxOutMessage outProfile; // typing the connected  output signal
+        private String blockA; // block of signalA
+        private StxSignal signalA; // one of the connected signals
+        private String blockB; // block of signalB
+        private StxSignal signalB; // the other connected signals
+
         public StxChannel(String _name, Location _left, Location _right){
             super(_name, _left, _right);
             inProfile = null;
@@ -628,6 +798,7 @@ public class AvatarFromSysMLSyntax {
             signalA = null;
             signalB = null;
         }
+
         public StxChannel(String _name){
             super(_name);
             inProfile = null;
@@ -637,12 +808,27 @@ public class AvatarFromSysMLSyntax {
             signalA = null;
             signalB = null;
         }
+
         public void setInProfile(StxInMessage m) { inProfile = m; }
+
         public void setOutProfile(StxOutMessage m) { outProfile = m; }
+
+        /** Set one of the connected signals.
+         *
+         * To be used twice: does nothing if both signals are set.
+         * @param _block the bloc of the signal to set
+         * @param s the signal to set
+         */
         public void setSignal(String _block, StxSignal s) {
             if (signalA == null) { blockA = _block; signalA = s; }
             else if (signalB == null) { blockB = _block; signalB = s; }
         }
+
+        /** commute signals so that signalA is the signal of the parameter block
+         *
+         * If possible... Usefull to respect block order in relations.
+         * @param _block1 the block to which signalA is expected to belong
+         */
         public void commuteSignals(String _block1) {
             boolean permut =
                     (blockB != null && blockB.equals(_block1)) || (blockA != null && ! blockA.equals(_block1));
@@ -655,34 +841,73 @@ public class AvatarFromSysMLSyntax {
                 signalB = auxSig;
             }
         }
-        public void setSignalA(StxSignal s) { signalA = s; }
-        public void setSignalB(StxSignal s) { signalB = s; }
+
         public StxInMessage getInProfile() { return inProfile; }
+
         public StxOutMessage getOutProfile() { return outProfile; }
+
         public StxSignal getSignalA() { return signalA; }
+
         public StxSignal getSignalB() { return signalB; }
+
         public String getBlockA() { return blockA; }
+
         public String getBlockB() { return blockB; }
     }
+
+    /** Syntactic elements associated to Avatar Signals */
     public static class StxSignal extends StxElement {
+
         private boolean input;
         private StxChannel channel;
+
         public StxSignal(String _name, Location _left, Location _right){
             super(_name, _left, _right);
         }
+
         public StxSignal(String _name){
             super(_name);
         }
+
+        /** Set signal direction
+         * @param _b true for an input signal
+         */
         public void setInput(boolean _b) { input = _b; }
+
+        /** set the channel that connects the signal
+         *
+         * @param _c the channel (connection belonging to a relation)
+         */
         public void setChannel(StxChannel _c) { channel = _c; }
+
+        /** get the channel of the signal **/
         public StxChannel getChannel() { return channel; }
+
+        /** signal direction
+         *
+         * @return true for receiving signals, false for sending
+         */
        public boolean isInput() { return input; }
     }
+
+    /** Syntactic elements associated to receiving signal profiles.
+     *
+     *  A profile is associated to one single signal (through an associated channel) */
     public static class StxInMessage extends StxStructure {
+
         protected StxChannel channel;
+
         public StxInMessage(String _name, Location _left, Location _right) { super(_name, _left, _right); }
+
+
         public StxInMessage(String _name) { super(_name); }
+
+        /** Set the channel connecting the associated signal */
         public void setChannel(StxChannel c) {channel = c; }
+
+        /** get the index of a field/parameter
+         *
+         * @return the index, or -1 if not found */
         public int indexOf(String s) {
             int i = 0;
             for (StxField f : fields) {
@@ -693,19 +918,26 @@ public class AvatarFromSysMLSyntax {
             return i;
         }
     }
+
+    /** Syntactic elements associated to sending signal profiles */
     public static class StxOutMessage extends StxInMessage {
-        public StxInMessage inMessage;
-        private HashMap<StxField,String> fieldMap;
+
+        private StxInMessage inMessage; // associated input profile
+        private HashMap<StxField,String> fieldMap; // maps parameters/fields to associated names in input profile
+
         public StxOutMessage(String _name, Location _left, Location _right, StxInMessage _inMessage) {
             super(_name, _left, _right);
             inMessage = _inMessage;
             fieldMap = new HashMap<StxField,String>();
         }
+
         public StxOutMessage(String _name, StxInMessage _inMessage) {
             super(_name);
             inMessage = _inMessage;
             fieldMap = new HashMap<StxField,String>();
         }
+
+        /** Associate an input field name to an output field */
         public boolean addFieldLink(StxField outField, String inField){
             String test = fieldMap.get(outField);
             if (test == null) {
@@ -715,15 +947,25 @@ public class AvatarFromSysMLSyntax {
             return false;
         }
 
+
+        /** to complete the output profile using infos from the associated input profile
+         *
+         * Applied to fieldMap which links both profiles. Used to set the type and the order
+         *  (thus the relevant order is the one in the declaration of the input profile)
+         */
+
         private class Complete implements BiConsumer<StxField, String> {
-            List<AvatarFromSysMLError> errors;
-            private boolean[] inProfile;
+            List<AvatarFromSysMLError> errors; // to put encountered errors
+            private boolean[] inProfile; // to verify that all input fields have been handled at the end
+
             public boolean[] getInProfile() { return inProfile; }
+
             public Complete(List<AvatarFromSysMLError> l){
                 errors = l;
                 inProfile = new boolean[inMessage.getSize()];
                 for (int i = 0; i < inMessage.getSize(); i++) { inProfile[i] = false; }
             };
+
             public void accept(StxField o, String i) {
                 int index = inMessage.indexOf(i);
                 if ( index == -1) {
@@ -732,12 +974,21 @@ public class AvatarFromSysMLSyntax {
                             "associated to a field (" + i + ") in in-message that does not exist", inMessage.getLeft()));
                 }
                 else {
-                    inProfile[index] = true;
-                    o.setType(inMessage.fields.get(index).getType());
-                    fields.set(index, o);
+                    inProfile[index] = true; // input field handled
+                    o.setType(inMessage.fields.get(index).getType()); // set type
+                    fields.set(index, o); // respects input order
                 }
             }
         }
+
+        /** to complete the output profile (and some other data) using infos from the associated input profile.
+         *
+         *  Builds field list. Get types and fields order from associated input profile.
+         *  (thus the relevant order is the one in the declaration of the input profile)
+         *
+         *  Also updates some other data in associated components (channel,...)
+         *  To be run after Parsing for a consistent abstract syntax tree/model
+         */
         public void complete(List<AvatarFromSysMLError> errors) {
             if (inMessage == null)
                 if (errors != null) {
@@ -745,22 +996,24 @@ public class AvatarFromSysMLSyntax {
                             "in-message associated to out-message has not been set",null));
                     return;
                 }
+            // error case or default: missing fields -> copy input fields.
             if (fieldMap.isEmpty()) for (StxField f: inMessage.fields) fields.add(f);
             else {
                 Complete cmp = new Complete(errors);
-                fieldMap.forEach(cmp);
+                fieldMap.forEach(cmp); // handle fields
                 boolean[] inProfile = cmp.getInProfile();
-                for(int i =0; i < inProfile.length; i++) {
+                for(int i =0; i < inProfile.length; i++) { // verify that no input field is missing
                     if (!inProfile[i]) {
                         errors.add(new AvatarFromSysMLError(AvatarFromSysMLError.LOWWARNING, getLeft(),
                                 "out-message has no field associated to in-message field " + inMessage.getFieldName(i) + " --> field added",
                                 inMessage.getLeft()));
+                        // for consistency, to avoid some redoundant error messages later.
                         fields.set(i, new StxField(inMessage.getFieldName(i), inMessage.getFieldType(i)));
                     }
                 }
             }
 
-            channel = inMessage.channel;
+            channel = inMessage.channel; // set Channel
             if (channel == null)
                 if (errors != null) {
                     errors.add(new AvatarFromSysMLError(AvatarFromSysMLError.HIGHERROR, getLeft(),
@@ -768,7 +1021,7 @@ public class AvatarFromSysMLSyntax {
                             inMessage.getLeft()));
                 return;
             }
-            channel.setOutProfile(this);
+            channel.setOutProfile(this); //update channel
             if (channel.getSignalA() == null)
                 if (errors != null) {
                     errors.add(new AvatarFromSysMLError(AvatarFromSysMLError.HIGHERROR, getLeft(),
@@ -776,7 +1029,7 @@ public class AvatarFromSysMLSyntax {
                             channel.getLeft()));
                     return;
             }
-            channel.getSignalA().setChannel(channel);
+            channel.getSignalA().setChannel(channel); // complete one signal
             if (channel.getSignalB() == null)
                 if (errors != null) {
                     errors.add(new AvatarFromSysMLError(AvatarFromSysMLError.HIGHERROR, getLeft(),
@@ -784,16 +1037,19 @@ public class AvatarFromSysMLSyntax {
                             channel.getLeft()));
                     return;
             }
-            channel.getSignalB().setChannel(channel);
+            channel.getSignalB().setChannel(channel); // complete the other signal
         }
     }
+
+    /** Syntactic elements associated to "boxes" of state-machines (states,communications,...) */
     public static class StxState extends StxElement {
-        private byte type;
-        private StxSignal signal;
-        private String variable;
-        private String minValue;
-        private String maxValue;
-        private MyArray<StxTransition>  transitions;
+        private byte type; // box kind
+        private StxSignal signal; // for count (Avatar QueryOnSignal=
+        private String variable; // for count and random
+        private String minValue; // for random
+        private String maxValue; // for random
+        private MyArray<StxTransition>  transitions; // outgoing transitions
+
         public StxState(String _name) {
             super(_name);
             type = -1;
@@ -803,17 +1059,29 @@ public class AvatarFromSysMLSyntax {
             maxValue = null;
             transitions = new MyArray<StxTransition>();
         }
+
         public byte getType() { return type; };
+
         public void setType(byte _b) { type = _b; };
+
         public StxSignal getSignal() { return signal; };
+
         public void setSignal(StxSignal _s) { signal = _s; };
+
         public String getVariable() { return variable; };
+
         public void setVariable(String _s) { variable = _s; };
+
         public String getMinValue() { return minValue; };
+
         public void setMinValue(String _s) { minValue = _s; };
+
         public String getMaxValue() { return maxValue; };
+
         public void setMaxValue(String _s) { maxValue = _s; };
+
         public List<StxTransition> getTransitions() { return transitions; }
+
         public StxTransition getTransition(int i) {
             if (i<0) return null;
             StxTransition result = transitions.get(i);
@@ -824,26 +1092,34 @@ public class AvatarFromSysMLSyntax {
             return result;
         }
     }
+
+    /** Syntactic elements associated to transitions of state-machines.
+     *
+     *  some information associated to these transition is finally associated
+     *  to their target state-machine "boxes" in Avatar model, in particular
+     *  signal and timer information.
+     */
     public static class StxTransition extends StxElement {
-        private byte type;
-        private final int index;
-        private String guard;
-        private String signalName;
-        private String blockName;
-        private StxSignal signal;
-        private String timer;
-        private ArrayList<StxTerm> sendPayload;
-        private HashMap<String,String> receivePayload;
-        private String minDelay;
-        private String maxDelay;
-        private double probability;
-        private String delayDistributionLaw;
-        private HashMap<String,String> delayExtra;
-        private StxState target;
-        private ArrayList<StxAction> actions;
-        private Location rleft;
-        private Location rright;
-        private boolean requested;
+
+        private byte type; // kind : ordinary, sending, ...
+        private final int index; // from sysML Model, yet useless for Avatar ...?
+        private String guard; // for all transitions
+        private String signalName; // for sending and receiveving transitions
+        private String blockName;  // block of the containing state-machine (technical)
+        private StxSignal signal; // for sending and receiveving transitions, set from signalName, once parsing is completed.
+        private String timer; // for timer operation transitions
+        private ArrayList<StxTerm> sendPayload;  // for sending transitions
+        private HashMap<String,String> receivePayload; // for receiving transitions
+        private String minDelay; // for all transitions
+        private String maxDelay; // for all transitions
+        private double probability; // for all transitions
+        private String delayDistributionLaw; // for all transitions
+        private HashMap<String,String> delayExtra; // for all transitions
+        private StxState target; // for all transitions
+        private ArrayList<StxAction> actions; // for standard transitions (no communication & no timer)
+        private Location rleft; // location of associated request in source state
+        private Location rright; // location of associated request in source state
+        private boolean requested; // set when associated request is parsed;
 
         public StxTransition(int _index){
             super("transition_" + _index);
@@ -864,101 +1140,215 @@ public class AvatarFromSysMLSyntax {
             requested = false;
             probability = AvatarTransition.DEFAULT_PROBABILITY;
         }
+
         public void setType(byte _t) { type = _t; };
+
         public void setGuard(String _s) { guard = _s; }
+
         public void setSignal(StxSignal _s) { signal = _s; }
+
         public void setSignalName(String _blockname, String _signalName) {
             signalName  = _signalName; blockName = _blockname;
         }
+
         public void setSendPayload(ArrayList<StxTerm> _p) { sendPayload = _p; }
+
         public void setReceivePayload(HashMap<String,String> _p) { receivePayload = _p; }
+
         public void setTimer(String _s) { timer = _s; }
+
         public void setMinDelay(String _s) { minDelay = _s; }
+
         public void setMaxDelay(String _s) { maxDelay = _s; }
+
         public void setProbability(double _p) { probability = _p; }
+
         public void setDelayDistributionLaw(String _s) { delayDistributionLaw = _s; }
+
         public void setDelayExtra(HashMap<String,String> _m) { delayExtra = _m; }
+
         public void setTarget(StxState _s) { target = _s; }
+
         public void setActions(ArrayList<StxAction> _a) { actions = _a; }
+
+        /** location of associated request in source state */
         public void setRleft(Location _l) { rleft = _l; }
+
+        /** location of associated request in source state */
         public void setRright(Location _l) { rright = _l; }
+
+        /** to set when associated request is parsed */
         public void setRequested(boolean _b) { requested = _b; }
+
         public byte getType() { return type; }
+
         public int getIndex() { return index; }
+
         public String getGuard() { return guard; }
+
         public String getTimer() { return timer; }
+
         public StxSignal getSignal() { return signal; }
+
         public String getSignalName() { return signalName; }
+
         public String getBlockName() { return blockName; }
+
         public ArrayList<StxTerm> getSendPayload() { return sendPayload; }
+
         public HashMap<String, String> getReceivePayload() { return receivePayload; }
+
         public String getMinDelay() { return minDelay; }
+
         public String getMaxDelay() { return maxDelay; }
+
         public double getProbability() { return probability; }
+
         public String getDelayDistributionLaw() { return delayDistributionLaw; }
+
+
         public HashMap<String,String> getDelayExtra() { return delayExtra; }
+
         public StxState getTarget() { return target; }
+
         public ArrayList<StxAction> getActions() { return actions; }
+
+        /** location of associated request in source state */
         public Location getRleft() { return rleft; }
+
+        /** location of associated request in source state */
+
         public Location getRright() { return rright; }
+
+        /** test if associated request is parsed */
         public boolean isRequested() { return requested; }
     }
+
+    /** Syntactic elements associated to transitions of state-machines.
+     *
+     *  some information associated to these transition is finally associated
+     *  to their target state-machine "boxes" in Avatar model, in particular
+     *  signal and timer information.
+     */
     public static class StxAction extends StxElement {
-        private byte type;
-        private StxTerm value;
-        private String target;
+
+        private byte type; // assignment or method call
+        private StxTerm value; // method call or assigned value
+        private String target; // assignad variable
+
         public StxAction (StxTerm _value) {
             super("methodCall_" + _value.toString());
             type = STXMETHODACTION;
             value = _value;
         }
+
         public StxAction (Location _left, Location _right, StxTerm _value) {
             super("methodCall_" + _value.toString(), _left, _right);
             type = STXMETHODACTION;
             value = _value;
         }
+
         public StxAction (String _target, StxTerm _value) {
             super("assignment_" + _target + "<-" + _value.toString() );
             type = STXASSIGNACTION;
             value = _value;
             target = _target;
         }
+
          public StxAction (Location _left, Location _right, String _target, StxTerm _value) {
             super("assignment_" + _target + "<-" + _value.toString(), _left, _right);
             type = STXASSIGNACTION;
             value = _value;
             target = _target;
         }
+
         public byte getType() { return type; }
+
         public StxTerm getValue() { return value; }
+
         public String getTarget() { return target; }
     }
+
+    /** syntactic element corresponding to a complete model -- complex Abstract Syntax Tree */
     public static class StxModel{
-        private ArrayList<AvatarFromSysMLError> errors;
+
+        private ArrayList<AvatarFromSysMLError> errors; // error encountered while parsing and finalizing the syntactic model
         private HashMap<String,StxDataType> dataTypeMap;
         private HashMap<String,StxRelation> relationMap;
         private HashMap<String,StxChannel> channelMap;
         private HashMap<String,StxBlock> blockMap;
         private HashMap<String,StxSignal> signalMap;
+
+        /** parameters are the ones filled by the associated parser.
+         *
+         * all parameters are kept as internal attribute except the two last ones that are used for finalization (called by constructor)
+         * @param outMessageMap out messages that require finalization
+         * @param commTransitions transitions that require finalization
+         */
         public StxModel(
                 ArrayList<AvatarFromSysMLError> _errors,
                 HashMap<String,StxDataType> _dataTypeMap,
                 HashMap<String,StxRelation> _relationMap,
                 HashMap<String,StxChannel> _channelMap,
                 HashMap<String,StxBlock> _blockMap,
-                HashMap<String,StxSignal> _signalMap) {
+                HashMap<String,StxSignal> _signalMap,
+                HashMap<String, StxOutMessage> outMessageMap,
+                List<StxTransition> commTransitions
+        ) {
             errors = _errors;
             dataTypeMap = _dataTypeMap;
             relationMap = _relationMap;
             channelMap = _channelMap;
             blockMap = _blockMap;
             signalMap = _signalMap;
+            this.finalize(outMessageMap, commTransitions);
         }
+
         public ArrayList<AvatarFromSysMLError> getErrors() { return errors; }
+
         public HashMap<String,StxDataType> getDataTypeMap() { return dataTypeMap; }
+
         public HashMap<String,StxRelation> getRelationMap() { return relationMap; }
+
         public HashMap<String,StxChannel> getChannelMap() { return channelMap; }
+
         public HashMap<String,StxBlock> getBlockMap() { return blockMap; }
+
         public HashMap<String,StxSignal> getSignalMap() { return signalMap; }
+
+        /** complete Signal information
+         *
+         * Find signals associated to signal names in transitions */
+        private void updateSignal(StxTransition st) {
+            String name = st.getSignalName();
+            StxBlock blk = blockMap.get(st.getBlockName());
+            while (blk != null) {
+                int size = blk.getNbSignals();
+                int i;
+                for (i = 0; i < size; i++) {
+                    StxSignal s = blk.getSignal(i);
+                    if (s.getName().equals(name)) {
+                        st.setSignal(s);
+                        break;
+                    }
+                }
+                if (i < size) blk = null;
+                else blk = blk.getFather();
+            }
+        }
+
+        private class CompleteOutMessage implements BiConsumer<String, StxOutMessage> {
+            public CompleteOutMessage(){};
+            public void accept(String s, StxOutMessage o) { o.complete(errors); }
+        }
+
+        /** complete OutMessage related information.
+         *
+         * Run completion algorithm provided by OutMessage class: set missing links between channels, signals and profiles.
+         */
+        public void finalize(HashMap<String, StxOutMessage> outMessageMap, List<StxTransition> commTransitions) {
+            outMessageMap.forEach(new CompleteOutMessage());
+            for(StxTransition st: commTransitions) updateSignal(st);
+        }
     }
 }
diff --git a/src/main/java/avatartranslator/tosysmlv2/javacup/AvatarFromSysML.jcup b/src/main/java/avatartranslator/tosysmlv2/javacup/AvatarFromSysML.jcup
index ce12cc5d59baca6d9f7053c84f9e34bb6da8f2bf..922f8070b6627796da3347be7e49c482b77527d3 100644
--- a/src/main/java/avatartranslator/tosysmlv2/javacup/AvatarFromSysML.jcup
+++ b/src/main/java/avatartranslator/tosysmlv2/javacup/AvatarFromSysML.jcup
@@ -63,37 +63,15 @@ parser code {:
     }
     public StxModel parseModel() {
         try {
-            StxModel m = (StxModel) parse().value;
-            outMessageMap.forEach(new Complete());
-            for(StxTransition st: commTransitions) updateSignal(st);
-            return m;
+            parse();
+            return new StxModel(errors,dataTypeMap,relationMap,channelMap,blockMap,signalMap,outMessageMap,commTransitions);
         }
         catch (java.lang.Exception e) {
             addError(new AvatarFromSysMLError(AvatarFromSysMLError.HIGHERROR, lexer.getErrorLocation(), e.getMessage()));
-            return null;
-        }
-    }
-    private class Complete implements BiConsumer<String, StxOutMessage> {
-        public Complete(){};
-        public void accept(String s, StxOutMessage o) { o.complete(errors); }
-    }
-    private void updateSignal(StxTransition st) {
-        String name = st.getSignalName();
-        StxBlock blk = blockMap.get(st.getBlockName());
-        while (blk != null) {
-            int size = blk.getNbSignals();
-            int i;
-            for (i = 0; i < size; i++) {
-                StxSignal s = blk.getSignal(i);
-                if (s.getName().equals(name)) {
-                    st.setSignal(s);
-                    break;
-                }
-            }
-            if (i < size) blk = null;
-            else blk = blk.getFather();
+            return new StxModel(errors,dataTypeMap,relationMap,channelMap,blockMap,signalMap,outMessageMap,commTransitions);
         }
     }
+
     private StxField theField;
     private StringBuffer stringAcc = new StringBuffer();
     private ArrayList<AvatarFromSysMLError> errors;
@@ -331,7 +309,7 @@ terminal PLUS, MINUS, MULT, DIV, MOD, DIF, LT, GT, LEQ, GEQ, UMINUS;
 
 /* Non terminals */
 non terminal String typeIdent, fulllIdent;
-non terminal StxModel model;
+non terminal model;
 non terminal featureList, feature, specializes, subsets, blockAlias, blockChain, datatypeDecl, datatypeDeclHEADER,
     fieldDecls, fieldDecl, relationDecl, syncRelDecl, nbfRelDecl, bfRelDecl, relParams, relParam,
     block1Param, block2Param, privateParam, maxsizeParam, lossyParam,
@@ -378,14 +356,8 @@ precedence left MULT, DIV, MOD;
 precedence left UMINUS;
 
 model ::=
-      PACKAGE IDENT LBRAC featureList RBRAC {:
-        RESULT =
-        new StxModel(errors,dataTypeMap,relationMap,channelMap,blockMap,signalMap);
-      :}
-    | PACKAGE IDENT LBRAC  RBRAC {:
-        RESULT =
-        new StxModel(errors,dataTypeMap,relationMap,channelMap,blockMap,signalMap);
-      :}
+      PACKAGE IDENT LBRAC featureList RBRAC
+    | PACKAGE IDENT LBRAC  RBRAC
 ;