diff --git a/src/avatartranslator/AvatarLibraryFunction.java b/src/avatartranslator/AvatarLibraryFunction.java
index 600f08e3c859761458ade1f5692f604a2cc3ccf2..41affaf7c842bf2800e6990b162236967f71c6d9 100644
--- a/src/avatartranslator/AvatarLibraryFunction.java
+++ b/src/avatartranslator/AvatarLibraryFunction.java
@@ -42,6 +42,8 @@ import java.util.LinkedList;
 import java.util.HashMap;
 import java.util.Iterator;
 
+import myutil.TraceManager;
+
 /**
  * AvatarLibraryFunction is used to represent a library function that can be further used in state machine diagrams.
  * <p>
@@ -224,12 +226,7 @@ public class AvatarLibraryFunction extends AvatarElement implements AvatarTransl
         return result;
     }
 
-    /**
-     * Add an attribute local to this function.
-     *
-     * @param attribute
-     *      The local attribute to add.
-     */
+    @Override
     public void addAttribute (AvatarAttribute attribute) {
         this.attributes.add (attribute);
     }
@@ -293,8 +290,10 @@ public class AvatarLibraryFunction extends AvatarElement implements AvatarTransl
         for (AvatarAttribute attribute: this.attributes) {
             String name = this.name + "__" + attribute.getName ();
             AvatarAttribute attr = block.getAvatarAttributeWithName (name);
-            if (attr == null)
+            if (attr == null) {
                 attr = new AvatarAttribute (name, attribute.getType (), block, block.getReferenceObject ());
+                block.addAttribute (attr);
+            }
 
             mapping.put (attribute, attr);
         }
@@ -482,7 +481,7 @@ public class AvatarLibraryFunction extends AvatarElement implements AvatarTransl
             // TODO: isn't the name used for the timer ?
             asme = new AvatarSetTimer (this.name + "__" + _asme.getName (), arg.referenceObject);
 
-            // TODO: should probably replace attributes to, right ?
+            // TODO: should probably replace attributes too, right ?
             ((AvatarSetTimer) asme).setTimerValue (((AvatarSetTimer) _asme).getTimerValue ());
         } else if (_asme instanceof AvatarResetTimer)
             asme = new AvatarResetTimer (this.name + "__" + _asme.getName (), arg.referenceObject);
@@ -529,7 +528,6 @@ public class AvatarLibraryFunction extends AvatarElement implements AvatarTransl
         for (AvatarAction _action: _asme.getActions ()) {
             AvatarAction action = _action.clone ();
             action.replaceAttributes (arg.placeholdersMapping);
-
             asme.addAction (action);
         }
 
diff --git a/src/avatartranslator/AvatarLibraryFunctionCall.java b/src/avatartranslator/AvatarLibraryFunctionCall.java
index 31b19640b56fc96e2699db3ed7ca50d227f23335..7688b2fb39739c2e47605b56cf2542fda89d6e5d 100644
--- a/src/avatartranslator/AvatarLibraryFunctionCall.java
+++ b/src/avatartranslator/AvatarLibraryFunctionCall.java
@@ -38,9 +38,8 @@
 
 package avatartranslator;
 
-import java.util.*;
-
-import myutil.*;
+import java.util.LinkedList;
+import java.util.HashMap;
 
 /**
  * AvatarLibraryFunctionCall represent a call to a library function. It is part of an {@link AvatarStateMachine}.
diff --git a/src/avatartranslator/AvatarStateMachineOwner.java b/src/avatartranslator/AvatarStateMachineOwner.java
index 40587b481918c86dcf823ff6a519c9989f80c830..d86c141c034b0e6c07225e0629747d7bb61e207c 100644
--- a/src/avatartranslator/AvatarStateMachineOwner.java
+++ b/src/avatartranslator/AvatarStateMachineOwner.java
@@ -63,4 +63,5 @@ public interface AvatarStateMachineOwner {
 
     public AvatarSpecification getAvatarSpecification ();
     public LinkedList<AvatarAttribute> getAttributes ();
+    public void addAttribute (AvatarAttribute attribute);
 }
diff --git a/src/avatartranslator/AvatarTermFunction.java b/src/avatartranslator/AvatarTermFunction.java
index f49e0387b0dea63cd0ade9b5098c5e735724cdb9..6f091b5c43e43b24f9a60f9141136efada7e3f8c 100644
--- a/src/avatartranslator/AvatarTermFunction.java
+++ b/src/avatartranslator/AvatarTermFunction.java
@@ -77,12 +77,9 @@ public class AvatarTermFunction extends AvatarTerm implements AvatarAction {
         }
 
         AvatarMethod meth = block.getAvatarMethodWithName (methodName);
-        if (meth != null && argsTuple != null && meth.getListOfAttributes ().size () == argsTuple.getComponents ().size ()){
+        if (meth != null && argsTuple != null && meth.getListOfAttributes ().size () == argsTuple.getComponents ().size ())
             // Method was found and the arguments provided are correct
-        TraceManager.addDev ("Function call '" + toParse + "' added parsed");
             return new AvatarTermFunction (meth, argsTuple, block);
-}
-        TraceManager.addDev ("Function call '" + toParse + "' couldn't be parsed");
 
         return null;
     }
diff --git a/src/avatartranslator/AvatarTuple.java b/src/avatartranslator/AvatarTuple.java
index d9243f6dc72d4a9e1c820a127103b438806886c7..1af1233c002f1e0efe0e683240f6c17736e8d057 100644
--- a/src/avatartranslator/AvatarTuple.java
+++ b/src/avatartranslator/AvatarTuple.java
@@ -72,7 +72,7 @@ public class AvatarTuple extends AvatarLeftHand {
             AvatarTuple argsTuple = new AvatarTuple (block);
             for (String arg: components) {
                 if (!arg.isEmpty()) {
-                    TraceManager.addDev("In for with arg=" + arg+"|");
+                    // TraceManager.addDev("In for with arg=" + arg+"|");
                     AvatarTerm t = AvatarTerm.createFromString (block, arg);
                     if (t == null) {
                         // Term couldn't be parsed
@@ -143,5 +143,6 @@ public class AvatarTuple extends AvatarLeftHand {
                 components.add (term);
                 term.replaceAttributes (attributesMapping);
             }
+        this.components = components;
     }
 }
diff --git a/src/avatartranslator/toproverif/AVATAR2ProVerif.java b/src/avatartranslator/toproverif/AVATAR2ProVerif.java
index de0466ca585db46b289c927ce70be6d89217b5d7..fba29cc280019bfd1e0e0d46b1f7bcb8fb6effa9 100755
--- a/src/avatartranslator/toproverif/AVATAR2ProVerif.java
+++ b/src/avatartranslator/toproverif/AVATAR2ProVerif.java
@@ -921,8 +921,10 @@ public class AVATAR2ProVerif implements AvatarTranslator {
         for (AvatarStateMachineElement asme: simplifiedElements.keySet ())
             if (asme != null) {
                 HashMap<AvatarAttribute, Integer> attributeCmp = new HashMap<AvatarAttribute, Integer> ();
-                for (AvatarAttribute attr: ab.getAttributes ())
+                for (AvatarAttribute attr: ab.getAttributes ()) {
+                    TraceManager.addDev ("=== " + attr);
                     attributeCmp.put (attr, 0);
+                }
 
                 // Create the ProVerif process and add it to the ProVerif specification
                 ProVerifProcInstr p = new ProVerifProcess(AVATAR2ProVerif.makeAttrName(ab.getName(), simplifiedElements.get (asme).toString ()), new ProVerifVar[] {new ProVerifVar ("sessionID", "bitstring")});
diff --git a/src/ui/AvatarDesignPanelTranslator.java b/src/ui/AvatarDesignPanelTranslator.java
index b5cb826638f51ad0f165d2deb573295a6d933ac6..c8bb2d488eed74519eca4e2d93cff64692801e17 100644
--- a/src/ui/AvatarDesignPanelTranslator.java
+++ b/src/ui/AvatarDesignPanelTranslator.java
@@ -547,7 +547,7 @@ public class AvatarDesignPanelTranslator {
                         || attr.getType() == TAttribute.NATURAL
                         || attr.getType() == TAttribute.BOOLEAN
                         || attr.getType() == TAttribute.TIMER)
-                    alf.addReturnAttribute (this.createRegularAttribute (alf, attr, ""));
+                    alf.addAttribute (this.createRegularAttribute (alf, attr, ""));
                 else {
                     // other
                     LinkedList<TAttribute> types = adp.getAvatarBDPanel ().getAttributesOfDataType (attr.getTypeOther ());
@@ -855,6 +855,215 @@ public class AvatarDesignPanelTranslator {
         asm.addElement (aaos);
     }
 
+    private void translateAvatarSMDLibraryFunctionCall (TDiagramPanel tdp, AvatarSpecification _as, AvatarStateMachineOwner _ab, AvatarSMDLibraryFunctionCall asmdlfc) throws CheckingError {
+        AvatarStateMachine asm = _ab.getStateMachine ();
+
+        /* Get Function corresponding to this call */
+        AvatarBDLibraryFunction libraryFunction = asmdlfc.getLibraryFunction ();
+        if (libraryFunction == null)
+            throw new CheckingError (CheckingError.BEHAVIOR_ERROR, "Should define a library function for this call");
+
+        /* Get Avatar representation of this function */
+        AvatarLibraryFunction aLibraryFunction = listE.getAvatarLibraryFunction (libraryFunction);
+        if (aLibraryFunction == null)
+            throw new CheckingError (CheckingError.BEHAVIOR_ERROR, "Unknown library function '" + libraryFunction.getFunctionName () + "'");
+
+        /* create Avatar representation of the function call */
+        AvatarLibraryFunctionCall alfc = new AvatarLibraryFunctionCall ("library_function_call", aLibraryFunction, asmdlfc);
+
+        /* Get the list of parameters passed to the function */
+        LinkedList<TAttribute> parameters = asmdlfc.getParameters ();
+        /* If the number of parameters does not match raise an error */
+        if (parameters.size () != libraryFunction.getParameters ().size ())
+            throw new CheckingError (CheckingError.BEHAVIOR_ERROR, "Calling library function " + libraryFunction.getFunctionName () + " requires " + libraryFunction.getParameters ().size () + "parameters (" + parameters.size () + " provided)");
+
+        /* Loop through the parameters */
+        int i=0;
+        for (TAttribute ta: parameters) {
+            i ++;
+            /* If parameter has not be filled in raise an error */
+            if (ta == null)
+                throw new CheckingError (CheckingError.BEHAVIOR_ERROR, "Missing parameter #" + i + " when calling library function " + libraryFunction.getFunctionName ());
+
+            /* Check if type of parameter matches what's expected */
+            TAttribute returnTA = libraryFunction.getParameters ().get (i-1);
+            if (!ta.hasSameType (returnTA))
+                throw new CheckingError (CheckingError.BEHAVIOR_ERROR, "Type of parameter #" + i + " when calling library function " + libraryFunction.getFunctionName () + " does not match");
+
+            /* Creates all the parameters corresponding to this parameter */
+            LinkedList<String> parameterNames = new LinkedList<String> ();
+            if (ta.getType() == TAttribute.INTEGER
+                    || ta.getType() == TAttribute.NATURAL
+                    || ta.getType() == TAttribute.BOOLEAN
+                    || ta.getType() == TAttribute.TIMER)
+                parameterNames.add (ta.getId ());
+            else {
+                LinkedList<TAttribute> types = adp.getAvatarBDPanel ().getAttributesOfDataType (ta.getTypeOther ());
+                if (types == null || types.isEmpty ())
+                    throw new CheckingError (CheckingError.STRUCTURE_ERROR, "Unknown data type:  " + ta.getTypeOther () + " when calling " + libraryFunction.getFunctionName ());
+
+                for (TAttribute type: types)
+                    parameterNames.add (ta.getId () + "__" + type.getId ());
+            }
+
+            /* Add flattened parameters */
+            for (String parameterName: parameterNames) {
+                /* Try to get the corresponding attribute */
+                AvatarAttribute attr = _ab.getAvatarAttributeWithName (parameterName);
+                /* If it does not exist raise an error */
+                if (attr == null)
+                    throw new CheckingError (CheckingError.BEHAVIOR_ERROR, "Parameter '" + ta.getId () + "' passed when calling library function " + libraryFunction.getFunctionName () + " does not exist");
+                alfc.addParameter (attr);
+            }
+        }
+
+        /* Get the list of signals mapped to the function's placeholders */
+        LinkedList<ui.AvatarSignal> signals = asmdlfc.getSignals ();
+        /* If the number of signals does not match raise an error */
+        if (signals.size () != libraryFunction.getSignals ().size ())
+            throw new CheckingError (CheckingError.BEHAVIOR_ERROR, "Calling library function " + libraryFunction.getFunctionName () + " requires " + libraryFunction.getSignals ().size () + " signals (" + signals.size () + " mapped)");
+
+        /* Loop through the signals */
+        i=0;
+        for (ui.AvatarSignal uias: signals) {
+            i ++;
+            /* If signal has not be filled in raise an error */
+            if (uias == null)
+                throw new CheckingError (CheckingError.BEHAVIOR_ERROR, "Missing mapping for signal #" + i + " when calling library function " + libraryFunction.getFunctionName ());
+
+            /* Check if prototype of signal matches what's expected */
+            ui.AvatarSignal expectedSig = libraryFunction.getSignals ().get (i-1);
+            if (!expectedSig.hasSamePrototype (uias))
+                throw new CheckingError (CheckingError.BEHAVIOR_ERROR, "Prototype of signal #" + i + " when calling library function " + libraryFunction.getFunctionName () + " does not match");
+
+            /* Try to get the corresponding signal */
+            avatartranslator.AvatarSignal sig = _ab.getAvatarSignalWithName (uias.getId ());
+            /* If it does not exist raise an error */
+            if (sig == null)
+                throw new CheckingError (CheckingError.BEHAVIOR_ERROR, "Signal '" + uias.getId () + "' mapped when calling library function " + libraryFunction.getFunctionName () + " does not exist");
+            alfc.addSignal (sig);
+        }
+
+        /* Get the list of return attributes passed to the function */
+        LinkedList<TAttribute> returnAttributes = asmdlfc.getReturnAttributes ();
+        /* If the number of return attributes is greater that what the function can return raise an error */
+        if (returnAttributes.size () > libraryFunction.getReturnAttributes ().size ())
+            throw new CheckingError (CheckingError.BEHAVIOR_ERROR, "Calling library function " + libraryFunction.getFunctionName () + " can only return " + libraryFunction.getReturnAttributes ().size () + " values (" + returnAttributes.size () + " expected)");
+
+        /* Loop through the return attributes */
+        i=0;
+        for (TAttribute ta: returnAttributes) {
+            LinkedList<AvatarAttribute> attrs = new LinkedList<AvatarAttribute> ();
+            /* If return attribute has not be filled in, add a dummy one */
+            if (ta == null) {
+                TAttribute returnTA = libraryFunction.getReturnAttributes ().get (i);
+                String dummyName = "__dummy_return_attribute_" + returnTA.getId ();
+
+                /* Creates all the attributes corresponding to this return attribute */
+                if (returnTA.getType() == TAttribute.INTEGER
+                        || returnTA.getType() == TAttribute.NATURAL
+                        || returnTA.getType() == TAttribute.BOOLEAN
+                        || returnTA.getType() == TAttribute.TIMER) {
+                    AvatarAttribute attr = _ab.getAvatarAttributeWithName (dummyName);
+                    if (attr == null) {
+                        attr = this.createRegularAttribute (_ab, returnTA, "__dummy_return_attribute_");
+                        _ab.addAttribute (attr);
+                    }
+                    attrs.add (attr);
+                } else {
+                    LinkedList<TAttribute> types = adp.getAvatarBDPanel ().getAttributesOfDataType (returnTA.getTypeOther ());
+                    if (types == null || types.isEmpty ())
+                        throw new CheckingError (CheckingError.STRUCTURE_ERROR, "Unknown data type:  " + returnTA.getTypeOther () + " when calling " + libraryFunction.getFunctionName ());
+
+                    for (TAttribute type: types) {
+                        String attributeName = dummyName + "__" + type.getId ();
+                        AvatarAttribute attr = _ab.getAvatarAttributeWithName (attributeName);
+                        if (attr == null) {
+                            attr = this.createRegularAttribute (_ab, type, dummyName + "__");
+                            _ab.addAttribute (attr);
+                        }
+                        attrs.add (attr);
+                    }
+                }
+            } else {
+                /* Check if type of return attribute matches what's expected */
+                TAttribute returnTA = libraryFunction.getReturnAttributes ().get (i);
+                if (!ta.hasSameType (returnTA))
+                    throw new CheckingError (CheckingError.BEHAVIOR_ERROR, "Type of return attribute #" + (i+1) + " when calling library function " + libraryFunction.getFunctionName () + " does not match");
+
+                /* Creates all the attributes corresponding to this return attribute */
+                LinkedList<String> attributeNames = new LinkedList<String> ();
+                if (ta.getType() == TAttribute.INTEGER
+                        || ta.getType() == TAttribute.NATURAL
+                        || ta.getType() == TAttribute.BOOLEAN
+                        || ta.getType() == TAttribute.TIMER)
+                    attributeNames.add (ta.getId ());
+                else {
+                    LinkedList<TAttribute> types = adp.getAvatarBDPanel ().getAttributesOfDataType (ta.getTypeOther ());
+                    if (types == null || types.isEmpty ())
+                        throw new CheckingError (CheckingError.STRUCTURE_ERROR, "Unknown data type:  " + ta.getTypeOther () + " when calling " + libraryFunction.getFunctionName ());
+
+                    for (TAttribute type: types)
+                        attributeNames.add (ta.getId () + "__" + type.getId ());
+                }
+
+                /* Add flattened parameters */
+                for (String attributeName: attributeNames) {
+                    AvatarAttribute attr = _ab.getAvatarAttributeWithName (attributeName);
+                    /* If a return attribute was given but we can't find the corresponding one raise an error */
+                    if (attr == null)
+                        throw new CheckingError (CheckingError.BEHAVIOR_ERROR, "Attribute '" + ta.getId () + "' expected to hold return value #" + (i+1) + " when calling library function " + libraryFunction.getFunctionName () + " does not exist");
+                    attrs.add (attr);
+                }
+            }
+
+            for (AvatarAttribute attr: attrs)
+                alfc.addReturnAttribute (attr);
+            i ++;
+        }
+
+        /* If there were missing return attributes, add dummies ones */
+        for (; i<libraryFunction.getReturnAttributes ().size (); i++) {
+            TAttribute returnTA = libraryFunction.getReturnAttributes ().get (i);
+            String dummyName = "__dummy_return_attribute_" + returnTA.getId ();
+
+            LinkedList<AvatarAttribute> attrs = new LinkedList<AvatarAttribute> ();
+            /* Creates all the attributes corresponding to this return attribute */
+            if (returnTA.getType() == TAttribute.INTEGER
+                    || returnTA.getType() == TAttribute.NATURAL
+                    || returnTA.getType() == TAttribute.BOOLEAN
+                    || returnTA.getType() == TAttribute.TIMER) {
+                AvatarAttribute attr = _ab.getAvatarAttributeWithName (dummyName);
+                if (attr == null) {
+                    attr = this.createRegularAttribute (_ab, returnTA, "__dummy_return_attribute_");
+                    _ab.addAttribute (attr);
+                }
+                attrs.add (attr);
+            } else {
+                LinkedList<TAttribute> types = adp.getAvatarBDPanel ().getAttributesOfDataType (returnTA.getTypeOther ());
+                if (types == null || types.isEmpty ())
+                    throw new CheckingError (CheckingError.STRUCTURE_ERROR, "Unknown data type:  " + returnTA.getTypeOther () + " when calling " + libraryFunction.getFunctionName ());
+
+                for (TAttribute type: types) {
+                    String attributeName = dummyName + "__" + type.getId ();
+                    AvatarAttribute attr = _ab.getAvatarAttributeWithName (attributeName);
+                    if (attr == null) {
+                        attr = this.createRegularAttribute (_ab, type, dummyName + "__");
+                        _ab.addAttribute (attr);
+                    }
+                    attrs.add (attr);
+                }
+            }
+
+            for (AvatarAttribute attr: attrs)
+                alfc.addReturnAttribute (attr);
+        }
+
+        this.listE.addCor (alfc, asmdlfc);
+        asmdlfc.setAVATARID (alfc.getID());
+        asm.addElement (alfc);
+    }
+
 
     private void translateAvatarSMDReceiveSignal (TDiagramPanel tdp, AvatarSpecification _as, AvatarStateMachineOwner _ab, AvatarSMDReceiveSignal asmdrs) throws CheckingError {
         AvatarStateMachine asm = _ab.getStateMachine ();
@@ -1079,6 +1288,9 @@ public class AvatarDesignPanelTranslator {
                 // Send signals
                 else if (tgc instanceof AvatarSMDSendSignal)
                     this.translateAvatarSMDSendSignal (tdp, _as, _ab, (AvatarSMDSendSignal) tgc);
+                // Library Function Call
+                else if (tgc instanceof AvatarSMDLibraryFunctionCall)
+                    this.translateAvatarSMDLibraryFunctionCall (tdp, _as, _ab, (AvatarSMDLibraryFunctionCall) tgc);
                 // State
                 else if (tgc instanceof AvatarSMDState)
                     this.translateAvatarSMDState (tdp, _as, _ab, (AvatarSMDState) tgc);
diff --git a/src/ui/CorrespondanceTGElement.java b/src/ui/CorrespondanceTGElement.java
index 5123be49423d040f17d07857ad2dd76f44a6ed91..4386d04f6af49acf920a0dcff5cbb826946bbf87 100755
--- a/src/ui/CorrespondanceTGElement.java
+++ b/src/ui/CorrespondanceTGElement.java
@@ -203,6 +203,18 @@ public class CorrespondanceTGElement {
         }
         return null;
     }
+
+    public AvatarLibraryFunction getAvatarLibraryFunction (TGComponent _tgc) {
+        int index = tg.indexOf (_tgc);
+        if (index == -1)
+            return null;
+
+        Object o = data.elementAt (index);
+        if (o instanceof AvatarLibraryFunction)
+            return (AvatarLibraryFunction) o;
+
+        return null;
+    }
     
     public HMSCNode getNodeAt(int index) {
         if ((index != -1) && (data.size() > index)) {
diff --git a/src/ui/TGComponent.java b/src/ui/TGComponent.java
index 68192e995149642f3dbcc0e2f45ec05bad41c5c6..e6f19a2802d9d774ac14a5636797a518f8482818 100755
--- a/src/ui/TGComponent.java
+++ b/src/ui/TGComponent.java
@@ -2388,7 +2388,7 @@ public abstract class TGComponent implements CDElement, GenericTree {
         return name;
     }
 
-    public final void setName(String s) {
+    public void setName(String s) {
         name = s;
     }
 
diff --git a/src/ui/avatarbd/AvatarBDBlock.java b/src/ui/avatarbd/AvatarBDBlock.java
index c0cd1d0efcb8f2dff260f1b2ac42b1b18ebc7d7a..6f677c64a6af7da9f044070484d556235937ecc3 100644
--- a/src/ui/avatarbd/AvatarBDBlock.java
+++ b/src/ui/avatarbd/AvatarBDBlock.java
@@ -418,15 +418,14 @@ public class AvatarBDBlock extends TGCScalableWithInternalComponent implements S
         if (h + textY1 >= this.height)
             return;
 
-        graph.drawLine (this.x, this.y+h, this.x+this.width, this.y+h);
-        h += textY1;
-
         // Global code
         if (hasGlobalCode()) {
-            h += step;
-            if (h >= this.height - textX)
+            if (h+textY1+step >= this.height - textX)
                 return;
 
+            graph.drawLine (this.x, this.y+h, this.x+this.width, this.y+h);
+            h += textY1+step;
+
             w = graph.getFontMetrics ().stringWidth (GLOBAL_CODE_INFO);
             if (w + 2*textX < this.width)
                 graph.drawString (GLOBAL_CODE_INFO, this.x + (this.width - w)/2, this.y + h);
diff --git a/src/ui/avatarbd/AvatarBDLibraryFunction.java b/src/ui/avatarbd/AvatarBDLibraryFunction.java
index 001e034e45a9d2350606977f94e360acfb3028d6..c078f7795e8bd165ac1820cc8a4979070066a9af 100644
--- a/src/ui/avatarbd/AvatarBDLibraryFunction.java
+++ b/src/ui/avatarbd/AvatarBDLibraryFunction.java
@@ -222,7 +222,7 @@ public class AvatarBDLibraryFunction extends TGCScalableWithoutInternalComponent
             if (this.tdp.isAvatarBlockNameUnique (tmpName) &&
                 true) { // TODO: check if no other tab has same name
                 this.name = tmpName;
-                this.setValue(tmpName);
+                this.value = tmpName;
                 break;
             }
         }
@@ -588,6 +588,13 @@ public class AvatarBDLibraryFunction extends TGCScalableWithoutInternalComponent
         }
     }
 
+    @Override
+    public void setName (String s) {
+        this.tdp.changeStateMachineTabName (this.name, s);
+        this.name = s;
+        this.setValue (s);
+    }
+
     @Override
     public TGComponent isOnMe (int x1, int y1) {
 
@@ -647,8 +654,9 @@ public class AvatarBDLibraryFunction extends TGCScalableWithoutInternalComponent
             }
 
             this.name = s;
-            this.setValue (s);
+            this.value = s;
             this.recalculateSize ();
+            this.repaint = true;
 
             return true;
         }
@@ -749,6 +757,20 @@ public class AvatarBDLibraryFunction extends TGCScalableWithoutInternalComponent
             sb.append("\" />\n");
         }
 
+        for (TAttribute attr: this.attributes) {
+            sb.append("<Attribute access=\"");
+            sb.append(attr.getAccess());
+            sb.append("\" id=\"");
+            sb.append(attr.getId());
+            sb.append("\" value=\"");
+            sb.append(attr.getInitialValue());
+            sb.append("\" type=\"");
+            sb.append(attr.getType());
+            sb.append("\" typeOther=\"");
+            sb.append(attr.getTypeOther());
+            sb.append("\" />\n");
+        }
+
         for(AvatarMethod method: this.methods) {
             sb.append("<Method value=\"");
             sb.append(method.toSaveString());
@@ -858,6 +880,28 @@ public class AvatarBDLibraryFunction extends TGCScalableWithoutInternalComponent
 
                             break;
 
+                        case "Attribute":
+                            {
+                                Integer access = Integer.decode (elt.getAttribute ("access")).intValue ();
+                                Integer type = Integer.decode (elt.getAttribute ("type")).intValue ();
+                                String typeOther = elt.getAttribute ("typeOther");
+                                String id = elt.getAttribute("id");
+                                String valueAtt = elt.getAttribute("value");
+                                if (valueAtt.equals("null"))
+                                    valueAtt = "";
+
+                                if (TAttribute.isAValidId (id, false, false) && TAttribute.isAValidInitialValue (type, valueAtt)) {
+                                    if (type == TAttribute.NATURAL)
+                                        type = TAttribute.INTEGER;
+
+                                    TAttribute ta = new TAttribute(access, id, valueAtt, type, typeOther);
+                                    ta.isAvatar = true;
+                                    this.attributes.add (ta);
+                                }
+                            }
+
+                            break;
+
                         case "Method":
                             String method = elt.getAttribute("value");