diff --git a/modeling/SysMLSec/AliceAndBob.xml b/modeling/SysMLSec/AliceAndBob.xml
index 149344d0a85b5deb31f0c037523b9998fcbe4fa4..68a9b4849b72400e0465464b7851b8f12ac53231 100644
--- a/modeling/SysMLSec/AliceAndBob.xml
+++ b/modeling/SysMLSec/AliceAndBob.xml
@@ -46,7 +46,7 @@
 
 <COMPONENT type="302" id="23" >
 <cdparam x="517" y="154" />
-<sizeparam width="420" height="97" minWidth="80" minHeight="10" maxWidth="2000" maxHeight="2000" minDesiredWidth="0" minDesiredHeight="0" />
+<sizeparam width="455" height="97" minWidth="80" minHeight="10" maxWidth="2000" maxHeight="2000" minDesiredWidth="0" minDesiredHeight="0" />
 <hidden value="false" />
 <cdrectangleparam minX="10" maxX="1400" minY="10" maxY="900" />
 <infoparam name="Proverif Pragma" value="#InitialSystemKnowledge Alice.sk Bob.sk
@@ -154,11 +154,11 @@
 </COMPONENT>
 <SUBCOMPONENT type="5000" id="66" >
 <father id="116" num="0" />
-<cdparam x="36" y="233" />
-<sizeparam width="215" height="126" minWidth="5" minHeight="2" maxWidth="2000" maxHeight="2000" minDesiredWidth="0" minDesiredHeight="0" />
+<cdparam x="263" y="233" />
+<sizeparam width="139" height="126" minWidth="5" minHeight="2" maxWidth="2000" maxHeight="2000" minDesiredWidth="0" minDesiredHeight="0" />
 <hidden value="false" />
-<cdrectangleparam minX="0" maxX="223" minY="0" maxY="93" />
-<infoparam name="Block0" value="Alice" />
+<cdrectangleparam minX="0" maxX="299" minY="0" maxY="93" />
+<infoparam name="Block0" value="Bob" />
 <TGConnectingPoint num="0" id="42" />
 <TGConnectingPoint num="1" id="43" />
 <TGConnectingPoint num="2" id="44" />
@@ -185,10 +185,10 @@
 <TGConnectingPoint num="23" id="65" />
 <extraparam>
 <CryptoBlock value="false" />
-<Attribute access="0" id="secretData" value="" type="8" typeOther="" />
 <Attribute access="0" id="m" value="" type="5" typeOther="Message" />
-<Attribute access="0" id="m1" value="" type="5" typeOther="Message" />
+<Attribute access="0" id="m2" value="" type="5" typeOther="Message" />
 <Attribute access="0" id="sk" value="" type="5" typeOther="Key" />
+<Attribute access="0" id="receivedData" value="" type="8" typeOther="" />
 <Method value="Message encrypt(Message msg, Key k)" />
 <Method value="Message decrypt(Message msg, Key k)" />
 <Method value="Message sencrypt(Message msg, Key k)" />
@@ -205,11 +205,11 @@
 </SUBCOMPONENT>
 <SUBCOMPONENT type="5000" id="91" >
 <father id="116" num="1" />
-<cdparam x="263" y="233" />
-<sizeparam width="139" height="126" minWidth="5" minHeight="2" maxWidth="2000" maxHeight="2000" minDesiredWidth="0" minDesiredHeight="0" />
+<cdparam x="36" y="233" />
+<sizeparam width="215" height="126" minWidth="5" minHeight="2" maxWidth="2000" maxHeight="2000" minDesiredWidth="0" minDesiredHeight="0" />
 <hidden value="false" />
-<cdrectangleparam minX="0" maxX="299" minY="0" maxY="93" />
-<infoparam name="Block0" value="Bob" />
+<cdrectangleparam minX="0" maxX="223" minY="0" maxY="93" />
+<infoparam name="Block0" value="Alice" />
 <TGConnectingPoint num="0" id="67" />
 <TGConnectingPoint num="1" id="68" />
 <TGConnectingPoint num="2" id="69" />
@@ -236,10 +236,10 @@
 <TGConnectingPoint num="23" id="90" />
 <extraparam>
 <CryptoBlock value="false" />
+<Attribute access="0" id="secretData" value="" type="8" typeOther="" />
 <Attribute access="0" id="m" value="" type="5" typeOther="Message" />
-<Attribute access="0" id="m2" value="" type="5" typeOther="Message" />
+<Attribute access="0" id="m1" value="" type="5" typeOther="Message" />
 <Attribute access="0" id="sk" value="" type="5" typeOther="Key" />
-<Attribute access="0" id="receivedData" value="" type="8" typeOther="" />
 <Method value="Message encrypt(Message msg, Key k)" />
 <Method value="Message decrypt(Message msg, Key k)" />
 <Method value="Message sencrypt(Message msg, Key k)" />
@@ -271,19 +271,19 @@
 
 </AVATARStateMachineDiagramPanel>
 
-<AVATARStateMachineDiagramPanel name="Bob" minX="10" maxX="1400" minY="10" maxY="900" >
+<AVATARStateMachineDiagramPanel name="Alice" minX="10" maxX="1400" minY="10" maxY="900" >
 <CONNECTOR type="5102" id="125" >
-<cdparam x="416" y="379" />
-<sizeparam width="0" height="0" minWidth="0" minHeight="0" maxWidth="1000" maxHeight="2000" minDesiredWidth="0" minDesiredHeight="0" />
-<infoparam name="connector from state0 to state0" value="null" />
+<cdparam x="407" y="310" />
+<sizeparam width="0" height="0" minWidth="0" minHeight="0" maxWidth="2000" maxHeight="2000" minDesiredWidth="0" minDesiredHeight="0" />
+<infoparam name="connector" value="null" />
 <TGConnectingPoint num="0" id="124" />
-<P1  x="416" y="379" id="160" />
-<P2  x="420" y="424" id="196" />
+<P1  x="407" y="310" id="196" />
+<P2  x="416" y="356" id="155" />
 <AutomaticDrawing  data="true" />
 </CONNECTOR><SUBCOMPONENT type="-1" id="123" >
 <father id="125" num="0" />
-<cdparam x="431" y="403" />
-<sizeparam width="135" height="15" minWidth="0" minHeight="0" maxWidth="2000" maxHeight="2000" minDesiredWidth="0" minDesiredHeight="0" />
+<cdparam x="449" y="353" />
+<sizeparam width="10" height="15" minWidth="0" minHeight="0" maxWidth="2000" maxHeight="2000" minDesiredWidth="0" minDesiredHeight="0" />
 <hidden value="false" />
 <cdrectangleparam minX="10" maxX="1400" minY="10" maxY="900" />
 <infoparam name="List of all parameters of an Avatar SMD transition" value="" />
@@ -297,22 +297,21 @@
 <afterMax value="" />
 <computeMin value="" />
 <computeMax value="" />
-<actions value="receivedData = m.data" />
 </extraparam>
 </SUBCOMPONENT>
 
 <CONNECTOR type="5102" id="132" >
-<cdparam x="407" y="273" />
-<sizeparam width="0" height="0" minWidth="0" minHeight="0" maxWidth="1000" maxHeight="2000" minDesiredWidth="0" minDesiredHeight="0" />
-<infoparam name="connector from state0 to state0" value="null" />
+<cdparam x="492" y="446" />
+<sizeparam width="0" height="0" minWidth="0" minHeight="0" maxWidth="2000" maxHeight="2000" minDesiredWidth="0" minDesiredHeight="0" />
+<infoparam name="connector" value="null" />
 <TGConnectingPoint num="0" id="131" />
-<P1  x="407" y="273" id="242" />
-<P2  x="416" y="339" id="155" />
+<P1  x="416" y="406" id="160" />
+<P2  x="434" y="446" id="206" />
 <AutomaticDrawing  data="true" />
 </CONNECTOR><SUBCOMPONENT type="-1" id="130" >
 <father id="132" num="0" />
-<cdparam x="419" y="312" />
-<sizeparam width="127" height="15" minWidth="0" minHeight="0" maxWidth="2000" maxHeight="2000" minDesiredWidth="0" minDesiredHeight="0" />
+<cdparam x="449" y="440" />
+<sizeparam width="10" height="15" minWidth="0" minHeight="0" maxWidth="2000" maxHeight="2000" minDesiredWidth="0" minDesiredHeight="0" />
 <hidden value="false" />
 <cdrectangleparam minX="10" maxX="1400" minY="10" maxY="900" />
 <infoparam name="List of all parameters of an Avatar SMD transition" value="" />
@@ -326,21 +325,20 @@
 <afterMax value="" />
 <computeMin value="" />
 <computeMax value="" />
-<actions value="m = sdecrypt(m2, sk)" />
 </extraparam>
 </SUBCOMPONENT>
 
 <CONNECTOR type="5102" id="139" >
-<cdparam x="406" y="201" />
+<cdparam x="407" y="251" />
 <sizeparam width="0" height="0" minWidth="0" minHeight="0" maxWidth="1000" maxHeight="2000" minDesiredWidth="0" minDesiredHeight="0" />
-<infoparam name="connector from Send signal to state0" value="null" />
+<infoparam name="connector from state0 to stop state" value="null" />
 <TGConnectingPoint num="0" id="138" />
-<P1  x="406" y="201" id="278" />
-<P2  x="407" y="233" id="237" />
+<P1  x="407" y="251" id="214" />
+<P2  x="407" y="280" id="195" />
 <AutomaticDrawing  data="true" />
 </CONNECTOR><SUBCOMPONENT type="-1" id="137" >
 <father id="139" num="0" />
-<cdparam x="406" y="241" />
+<cdparam x="407" y="291" />
 <sizeparam width="10" height="15" minWidth="0" minHeight="0" maxWidth="2000" maxHeight="2000" minDesiredWidth="0" minDesiredHeight="0" />
 <hidden value="false" />
 <cdrectangleparam minX="10" maxX="1400" minY="10" maxY="900" />
@@ -359,17 +357,17 @@
 </SUBCOMPONENT>
 
 <CONNECTOR type="5102" id="146" >
-<cdparam x="406" y="141" />
+<cdparam x="407" y="132" />
 <sizeparam width="0" height="0" minWidth="0" minHeight="0" maxWidth="1000" maxHeight="2000" minDesiredWidth="0" minDesiredHeight="0" />
-<infoparam name="connector from state0 to Send signal" value="null" />
+<infoparam name="connector from state0 to state0" value="null" />
 <TGConnectingPoint num="0" id="145" />
-<P1  x="406" y="141" id="294" />
-<P2  x="406" y="171" id="277" />
+<P1  x="407" y="132" id="255" />
+<P2  x="407" y="211" id="209" />
 <AutomaticDrawing  data="true" />
 </CONNECTOR><SUBCOMPONENT type="-1" id="144" >
 <father id="146" num="0" />
-<cdparam x="406" y="181" />
-<sizeparam width="10" height="15" minWidth="0" minHeight="0" maxWidth="2000" maxHeight="2000" minDesiredWidth="0" minDesiredHeight="0" />
+<cdparam x="415" y="162" />
+<sizeparam width="126" height="30" minWidth="0" minHeight="0" maxWidth="2000" maxHeight="2000" minDesiredWidth="0" minDesiredHeight="0" />
 <hidden value="false" />
 <cdrectangleparam minX="10" maxX="1400" minY="10" maxY="900" />
 <infoparam name="List of all parameters of an Avatar SMD transition" value="" />
@@ -383,6 +381,8 @@
 <afterMax value="" />
 <computeMin value="" />
 <computeMax value="" />
+<actions value="m.data = secretData" />
+<actions value="m1 = sencrypt(m, sk)" />
 </extraparam>
 </SUBCOMPONENT>
 
@@ -391,8 +391,8 @@
 <sizeparam width="0" height="0" minWidth="0" minHeight="0" maxWidth="1000" maxHeight="2000" minDesiredWidth="0" minDesiredHeight="0" />
 <infoparam name="connector from start state to state0" value="null" />
 <TGConnectingPoint num="0" id="152" />
-<P1  x="407" y="70" id="329" />
-<P2  x="406" y="101" id="289" />
+<P1  x="407" y="70" id="290" />
+<P2  x="407" y="92" id="250" />
 <AutomaticDrawing  data="true" />
 </CONNECTOR><SUBCOMPONENT type="-1" id="151" >
 <father id="153" num="0" />
@@ -415,11 +415,11 @@
 </SUBCOMPONENT>
 
 <COMPONENT type="5106" id="194" >
-<cdparam x="327" y="339" />
-<sizeparam width="178" height="40" minWidth="40" minHeight="30" maxWidth="2000" maxHeight="2000" minDesiredWidth="0" minDesiredHeight="0" />
+<cdparam x="366" y="356" />
+<sizeparam width="100" height="50" minWidth="40" minHeight="30" maxWidth="2000" maxHeight="2000" minDesiredWidth="0" minDesiredHeight="0" />
 <hidden value="false" />
 <cdrectangleparam minX="10" maxX="1400" minY="10" maxY="900" />
-<infoparam name="state0" value="messageDecrypted" />
+<infoparam name="State" value="beforeFinish" />
 <TGConnectingPoint num="0" id="154" />
 <TGConnectingPoint num="1" id="155" />
 <TGConnectingPoint num="2" id="156" />
@@ -464,12 +464,12 @@
 </extraparam>
 </COMPONENT>
 
-<COMPONENT type="5106" id="235" >
-<cdparam x="350" y="424" />
-<sizeparam width="140" height="40" minWidth="40" minHeight="30" maxWidth="2000" maxHeight="2000" minDesiredWidth="0" minDesiredHeight="0" />
+<COMPONENT type="5103" id="205" >
+<cdparam x="373" y="285" />
+<sizeparam width="68" height="20" minWidth="30" minHeight="0" maxWidth="2000" maxHeight="2000" minDesiredWidth="0" minDesiredHeight="0" />
 <hidden value="false" />
 <cdrectangleparam minX="10" maxX="1400" minY="10" maxY="900" />
-<infoparam name="state0" value="SecretDataReceived" />
+<infoparam name="Send signal" value="chout(m1)" />
 <TGConnectingPoint num="0" id="195" />
 <TGConnectingPoint num="1" id="196" />
 <TGConnectingPoint num="2" id="197" />
@@ -480,246 +480,207 @@
 <TGConnectingPoint num="7" id="202" />
 <TGConnectingPoint num="8" id="203" />
 <TGConnectingPoint num="9" id="204" />
-<TGConnectingPoint num="10" id="205" />
-<TGConnectingPoint num="11" id="206" />
-<TGConnectingPoint num="12" id="207" />
-<TGConnectingPoint num="13" id="208" />
-<TGConnectingPoint num="14" id="209" />
-<TGConnectingPoint num="15" id="210" />
-<TGConnectingPoint num="16" id="211" />
-<TGConnectingPoint num="17" id="212" />
-<TGConnectingPoint num="18" id="213" />
-<TGConnectingPoint num="19" id="214" />
-<TGConnectingPoint num="20" id="215" />
-<TGConnectingPoint num="21" id="216" />
-<TGConnectingPoint num="22" id="217" />
-<TGConnectingPoint num="23" id="218" />
-<TGConnectingPoint num="24" id="219" />
-<TGConnectingPoint num="25" id="220" />
-<TGConnectingPoint num="26" id="221" />
-<TGConnectingPoint num="27" id="222" />
-<TGConnectingPoint num="28" id="223" />
-<TGConnectingPoint num="29" id="224" />
-<TGConnectingPoint num="30" id="225" />
-<TGConnectingPoint num="31" id="226" />
-<TGConnectingPoint num="32" id="227" />
-<TGConnectingPoint num="33" id="228" />
-<TGConnectingPoint num="34" id="229" />
-<TGConnectingPoint num="35" id="230" />
-<TGConnectingPoint num="36" id="231" />
-<TGConnectingPoint num="37" id="232" />
-<TGConnectingPoint num="38" id="233" />
-<TGConnectingPoint num="39" id="234" />
-<extraparam>
-</extraparam>
 </COMPONENT>
 
-<COMPONENT type="5106" id="276" >
-<cdparam x="336" y="233" />
-<sizeparam width="142" height="40" minWidth="40" minHeight="30" maxWidth="2000" maxHeight="2000" minDesiredWidth="0" minDesiredHeight="0" />
+<COMPONENT type="5101" id="207" >
+<cdparam x="424" y="451" />
+<sizeparam width="20" height="20" minWidth="0" minHeight="0" maxWidth="2000" maxHeight="2000" minDesiredWidth="0" minDesiredHeight="0" />
 <hidden value="false" />
 <cdrectangleparam minX="10" maxX="1400" minY="10" maxY="900" />
-<infoparam name="state0" value="messageDecrypt" />
-<TGConnectingPoint num="0" id="236" />
-<TGConnectingPoint num="1" id="237" />
-<TGConnectingPoint num="2" id="238" />
-<TGConnectingPoint num="3" id="239" />
-<TGConnectingPoint num="4" id="240" />
-<TGConnectingPoint num="5" id="241" />
-<TGConnectingPoint num="6" id="242" />
-<TGConnectingPoint num="7" id="243" />
-<TGConnectingPoint num="8" id="244" />
-<TGConnectingPoint num="9" id="245" />
-<TGConnectingPoint num="10" id="246" />
-<TGConnectingPoint num="11" id="247" />
-<TGConnectingPoint num="12" id="248" />
-<TGConnectingPoint num="13" id="249" />
-<TGConnectingPoint num="14" id="250" />
-<TGConnectingPoint num="15" id="251" />
-<TGConnectingPoint num="16" id="252" />
-<TGConnectingPoint num="17" id="253" />
-<TGConnectingPoint num="18" id="254" />
-<TGConnectingPoint num="19" id="255" />
-<TGConnectingPoint num="20" id="256" />
-<TGConnectingPoint num="21" id="257" />
-<TGConnectingPoint num="22" id="258" />
-<TGConnectingPoint num="23" id="259" />
-<TGConnectingPoint num="24" id="260" />
-<TGConnectingPoint num="25" id="261" />
-<TGConnectingPoint num="26" id="262" />
-<TGConnectingPoint num="27" id="263" />
-<TGConnectingPoint num="28" id="264" />
-<TGConnectingPoint num="29" id="265" />
-<TGConnectingPoint num="30" id="266" />
-<TGConnectingPoint num="31" id="267" />
-<TGConnectingPoint num="32" id="268" />
-<TGConnectingPoint num="33" id="269" />
-<TGConnectingPoint num="34" id="270" />
-<TGConnectingPoint num="35" id="271" />
-<TGConnectingPoint num="36" id="272" />
-<TGConnectingPoint num="37" id="273" />
-<TGConnectingPoint num="38" id="274" />
-<TGConnectingPoint num="39" id="275" />
-<extraparam>
-</extraparam>
+<infoparam name="stop state" value="null" />
+<TGConnectingPoint num="0" id="206" />
 </COMPONENT>
 
-<COMPONENT type="5104" id="287" >
-<cdparam x="372" y="176" />
-<sizeparam width="68" height="20" minWidth="30" minHeight="0" maxWidth="2000" maxHeight="2000" minDesiredWidth="0" minDesiredHeight="0" />
+<COMPONENT type="5106" id="248" >
+<cdparam x="336" y="211" />
+<sizeparam width="143" height="40" minWidth="40" minHeight="30" maxWidth="2000" maxHeight="2000" minDesiredWidth="0" minDesiredHeight="0" />
 <hidden value="false" />
 <cdrectangleparam minX="10" maxX="1400" minY="10" maxY="900" />
-<infoparam name="Send signal" value="chin(m2)" />
-<TGConnectingPoint num="0" id="277" />
-<TGConnectingPoint num="1" id="278" />
-<TGConnectingPoint num="2" id="279" />
-<TGConnectingPoint num="3" id="280" />
-<TGConnectingPoint num="4" id="281" />
-<TGConnectingPoint num="5" id="282" />
-<TGConnectingPoint num="6" id="283" />
-<TGConnectingPoint num="7" id="284" />
-<TGConnectingPoint num="8" id="285" />
-<TGConnectingPoint num="9" id="286" />
+<infoparam name="state0" value="sendingMessage" />
+<TGConnectingPoint num="0" id="208" />
+<TGConnectingPoint num="1" id="209" />
+<TGConnectingPoint num="2" id="210" />
+<TGConnectingPoint num="3" id="211" />
+<TGConnectingPoint num="4" id="212" />
+<TGConnectingPoint num="5" id="213" />
+<TGConnectingPoint num="6" id="214" />
+<TGConnectingPoint num="7" id="215" />
+<TGConnectingPoint num="8" id="216" />
+<TGConnectingPoint num="9" id="217" />
+<TGConnectingPoint num="10" id="218" />
+<TGConnectingPoint num="11" id="219" />
+<TGConnectingPoint num="12" id="220" />
+<TGConnectingPoint num="13" id="221" />
+<TGConnectingPoint num="14" id="222" />
+<TGConnectingPoint num="15" id="223" />
+<TGConnectingPoint num="16" id="224" />
+<TGConnectingPoint num="17" id="225" />
+<TGConnectingPoint num="18" id="226" />
+<TGConnectingPoint num="19" id="227" />
+<TGConnectingPoint num="20" id="228" />
+<TGConnectingPoint num="21" id="229" />
+<TGConnectingPoint num="22" id="230" />
+<TGConnectingPoint num="23" id="231" />
+<TGConnectingPoint num="24" id="232" />
+<TGConnectingPoint num="25" id="233" />
+<TGConnectingPoint num="26" id="234" />
+<TGConnectingPoint num="27" id="235" />
+<TGConnectingPoint num="28" id="236" />
+<TGConnectingPoint num="29" id="237" />
+<TGConnectingPoint num="30" id="238" />
+<TGConnectingPoint num="31" id="239" />
+<TGConnectingPoint num="32" id="240" />
+<TGConnectingPoint num="33" id="241" />
+<TGConnectingPoint num="34" id="242" />
+<TGConnectingPoint num="35" id="243" />
+<TGConnectingPoint num="36" id="244" />
+<TGConnectingPoint num="37" id="245" />
+<TGConnectingPoint num="38" id="246" />
+<TGConnectingPoint num="39" id="247" />
+<extraparam>
+</extraparam>
 </COMPONENT>
 
-<COMPONENT type="5106" id="328" >
-<cdparam x="340" y="101" />
-<sizeparam width="132" height="40" minWidth="40" minHeight="30" maxWidth="2000" maxHeight="2000" minDesiredWidth="0" minDesiredHeight="0" />
+<COMPONENT type="5106" id="289" >
+<cdparam x="340" y="92" />
+<sizeparam width="134" height="40" minWidth="40" minHeight="30" maxWidth="2000" maxHeight="2000" minDesiredWidth="0" minDesiredHeight="0" />
 <hidden value="false" />
 <cdrectangleparam minX="10" maxX="1400" minY="10" maxY="900" />
-<infoparam name="state0" value="waitingForMessage" />
-<TGConnectingPoint num="0" id="288" />
-<TGConnectingPoint num="1" id="289" />
-<TGConnectingPoint num="2" id="290" />
-<TGConnectingPoint num="3" id="291" />
-<TGConnectingPoint num="4" id="292" />
-<TGConnectingPoint num="5" id="293" />
-<TGConnectingPoint num="6" id="294" />
-<TGConnectingPoint num="7" id="295" />
-<TGConnectingPoint num="8" id="296" />
-<TGConnectingPoint num="9" id="297" />
-<TGConnectingPoint num="10" id="298" />
-<TGConnectingPoint num="11" id="299" />
-<TGConnectingPoint num="12" id="300" />
-<TGConnectingPoint num="13" id="301" />
-<TGConnectingPoint num="14" id="302" />
-<TGConnectingPoint num="15" id="303" />
-<TGConnectingPoint num="16" id="304" />
-<TGConnectingPoint num="17" id="305" />
-<TGConnectingPoint num="18" id="306" />
-<TGConnectingPoint num="19" id="307" />
-<TGConnectingPoint num="20" id="308" />
-<TGConnectingPoint num="21" id="309" />
-<TGConnectingPoint num="22" id="310" />
-<TGConnectingPoint num="23" id="311" />
-<TGConnectingPoint num="24" id="312" />
-<TGConnectingPoint num="25" id="313" />
-<TGConnectingPoint num="26" id="314" />
-<TGConnectingPoint num="27" id="315" />
-<TGConnectingPoint num="28" id="316" />
-<TGConnectingPoint num="29" id="317" />
-<TGConnectingPoint num="30" id="318" />
-<TGConnectingPoint num="31" id="319" />
-<TGConnectingPoint num="32" id="320" />
-<TGConnectingPoint num="33" id="321" />
-<TGConnectingPoint num="34" id="322" />
-<TGConnectingPoint num="35" id="323" />
-<TGConnectingPoint num="36" id="324" />
-<TGConnectingPoint num="37" id="325" />
-<TGConnectingPoint num="38" id="326" />
-<TGConnectingPoint num="39" id="327" />
+<infoparam name="state0" value="makingMessage" />
+<TGConnectingPoint num="0" id="249" />
+<TGConnectingPoint num="1" id="250" />
+<TGConnectingPoint num="2" id="251" />
+<TGConnectingPoint num="3" id="252" />
+<TGConnectingPoint num="4" id="253" />
+<TGConnectingPoint num="5" id="254" />
+<TGConnectingPoint num="6" id="255" />
+<TGConnectingPoint num="7" id="256" />
+<TGConnectingPoint num="8" id="257" />
+<TGConnectingPoint num="9" id="258" />
+<TGConnectingPoint num="10" id="259" />
+<TGConnectingPoint num="11" id="260" />
+<TGConnectingPoint num="12" id="261" />
+<TGConnectingPoint num="13" id="262" />
+<TGConnectingPoint num="14" id="263" />
+<TGConnectingPoint num="15" id="264" />
+<TGConnectingPoint num="16" id="265" />
+<TGConnectingPoint num="17" id="266" />
+<TGConnectingPoint num="18" id="267" />
+<TGConnectingPoint num="19" id="268" />
+<TGConnectingPoint num="20" id="269" />
+<TGConnectingPoint num="21" id="270" />
+<TGConnectingPoint num="22" id="271" />
+<TGConnectingPoint num="23" id="272" />
+<TGConnectingPoint num="24" id="273" />
+<TGConnectingPoint num="25" id="274" />
+<TGConnectingPoint num="26" id="275" />
+<TGConnectingPoint num="27" id="276" />
+<TGConnectingPoint num="28" id="277" />
+<TGConnectingPoint num="29" id="278" />
+<TGConnectingPoint num="30" id="279" />
+<TGConnectingPoint num="31" id="280" />
+<TGConnectingPoint num="32" id="281" />
+<TGConnectingPoint num="33" id="282" />
+<TGConnectingPoint num="34" id="283" />
+<TGConnectingPoint num="35" id="284" />
+<TGConnectingPoint num="36" id="285" />
+<TGConnectingPoint num="37" id="286" />
+<TGConnectingPoint num="38" id="287" />
+<TGConnectingPoint num="39" id="288" />
 <extraparam>
 </extraparam>
 </COMPONENT>
 
-<COMPONENT type="5100" id="330" >
+<COMPONENT type="5100" id="291" >
 <cdparam x="400" y="50" />
 <sizeparam width="15" height="15" minWidth="0" minHeight="0" maxWidth="2000" maxHeight="2000" minDesiredWidth="0" minDesiredHeight="0" />
 <hidden value="false" />
 <cdrectangleparam minX="10" maxX="1400" minY="10" maxY="900" />
 <infoparam name="start state" value="null" />
-<TGConnectingPoint num="0" id="329" />
+<TGConnectingPoint num="0" id="290" />
 </COMPONENT>
 
 
 </AVATARStateMachineDiagramPanel>
 
-<AVATARStateMachineDiagramPanel name="Alice" minX="10" maxX="1400" minY="10" maxY="900" >
-<CONNECTOR type="5102" id="523" >
-<cdparam x="407" y="310" />
-<sizeparam width="0" height="0" minWidth="0" minHeight="0" maxWidth="2000" maxHeight="2000" minDesiredWidth="0" minDesiredHeight="0" />
-<infoparam name="connector" value="null" />
-<TGConnectingPoint num="0" id="524" />
-<P1  x="407" y="310" id="426" />
-<P2  x="416" y="356" id="374" />
+<AVATARStateMachineDiagramPanel name="Bob" minX="10" maxX="1400" minY="10" maxY="900" >
+<CONNECTOR type="5102" id="298" >
+<cdparam x="416" y="379" />
+<sizeparam width="0" height="0" minWidth="0" minHeight="0" maxWidth="1000" maxHeight="2000" minDesiredWidth="0" minDesiredHeight="0" />
+<infoparam name="connector from state0 to state0" value="null" />
+<TGConnectingPoint num="0" id="297" />
+<P1  x="416" y="379" id="333" />
+<P2  x="420" y="424" id="369" />
 <AutomaticDrawing  data="true" />
-</CONNECTOR><SUBCOMPONENT type="-1" id="525" >
-<father id="523" num="0" />
-<cdparam x="449" y="353" />
-<sizeparam width="10" height="15" minWidth="0" minHeight="0" maxWidth="2000" maxHeight="2000" minDesiredWidth="0" minDesiredHeight="0" />
+</CONNECTOR><SUBCOMPONENT type="-1" id="296" >
+<father id="298" num="0" />
+<cdparam x="431" y="403" />
+<sizeparam width="135" height="15" minWidth="0" minHeight="0" maxWidth="2000" maxHeight="2000" minDesiredWidth="0" minDesiredHeight="0" />
 <hidden value="false" />
 <cdrectangleparam minX="10" maxX="1400" minY="10" maxY="900" />
 <infoparam name="List of all parameters of an Avatar SMD transition" value="" />
-<TGConnectingPoint num="0" id="526" />
-<TGConnectingPoint num="1" id="527" />
-<TGConnectingPoint num="2" id="528" />
-<TGConnectingPoint num="3" id="529" />
+<TGConnectingPoint num="0" id="292" />
+<TGConnectingPoint num="1" id="293" />
+<TGConnectingPoint num="2" id="294" />
+<TGConnectingPoint num="3" id="295" />
 <extraparam>
 <guard value="[ ]" />
 <afterMin value="" />
 <afterMax value="" />
 <computeMin value="" />
 <computeMax value="" />
+<actions value="receivedData = m.data" />
 </extraparam>
 </SUBCOMPONENT>
 
-<CONNECTOR type="5102" id="337" >
-<cdparam x="492" y="446" />
-<sizeparam width="0" height="0" minWidth="0" minHeight="0" maxWidth="2000" maxHeight="2000" minDesiredWidth="0" minDesiredHeight="0" />
-<infoparam name="connector" value="null" />
-<TGConnectingPoint num="0" id="336" />
-<P1  x="416" y="406" id="379" />
-<P2  x="434" y="446" id="436" />
+<CONNECTOR type="5102" id="305" >
+<cdparam x="407" y="273" />
+<sizeparam width="0" height="0" minWidth="0" minHeight="0" maxWidth="1000" maxHeight="2000" minDesiredWidth="0" minDesiredHeight="0" />
+<infoparam name="connector from state0 to state0" value="null" />
+<TGConnectingPoint num="0" id="304" />
+<P1  x="407" y="273" id="415" />
+<P2  x="416" y="339" id="328" />
 <AutomaticDrawing  data="true" />
-</CONNECTOR><SUBCOMPONENT type="-1" id="335" >
-<father id="337" num="0" />
-<cdparam x="449" y="440" />
-<sizeparam width="10" height="15" minWidth="0" minHeight="0" maxWidth="2000" maxHeight="2000" minDesiredWidth="0" minDesiredHeight="0" />
+</CONNECTOR><SUBCOMPONENT type="-1" id="303" >
+<father id="305" num="0" />
+<cdparam x="419" y="312" />
+<sizeparam width="127" height="15" minWidth="0" minHeight="0" maxWidth="2000" maxHeight="2000" minDesiredWidth="0" minDesiredHeight="0" />
 <hidden value="false" />
 <cdrectangleparam minX="10" maxX="1400" minY="10" maxY="900" />
 <infoparam name="List of all parameters of an Avatar SMD transition" value="" />
-<TGConnectingPoint num="0" id="331" />
-<TGConnectingPoint num="1" id="332" />
-<TGConnectingPoint num="2" id="333" />
-<TGConnectingPoint num="3" id="334" />
+<TGConnectingPoint num="0" id="299" />
+<TGConnectingPoint num="1" id="300" />
+<TGConnectingPoint num="2" id="301" />
+<TGConnectingPoint num="3" id="302" />
 <extraparam>
 <guard value="[ ]" />
 <afterMin value="" />
 <afterMax value="" />
 <computeMin value="" />
 <computeMax value="" />
+<actions value="m = sdecrypt(m2, sk)" />
 </extraparam>
 </SUBCOMPONENT>
 
-<CONNECTOR type="5102" id="351" >
-<cdparam x="407" y="251" />
+<CONNECTOR type="5102" id="312" >
+<cdparam x="406" y="201" />
 <sizeparam width="0" height="0" minWidth="0" minHeight="0" maxWidth="1000" maxHeight="2000" minDesiredWidth="0" minDesiredHeight="0" />
-<infoparam name="connector from state0 to stop state" value="null" />
-<TGConnectingPoint num="0" id="350" />
-<P1  x="407" y="251" id="444" />
-<P2  x="407" y="280" id="425" />
+<infoparam name="connector from Send signal to state0" value="null" />
+<TGConnectingPoint num="0" id="311" />
+<P1  x="406" y="201" id="451" />
+<P2  x="407" y="233" id="410" />
 <AutomaticDrawing  data="true" />
-</CONNECTOR><SUBCOMPONENT type="-1" id="349" >
-<father id="351" num="0" />
-<cdparam x="407" y="291" />
+</CONNECTOR><SUBCOMPONENT type="-1" id="310" >
+<father id="312" num="0" />
+<cdparam x="406" y="241" />
 <sizeparam width="10" height="15" minWidth="0" minHeight="0" maxWidth="2000" maxHeight="2000" minDesiredWidth="0" minDesiredHeight="0" />
 <hidden value="false" />
 <cdrectangleparam minX="10" maxX="1400" minY="10" maxY="900" />
 <infoparam name="List of all parameters of an Avatar SMD transition" value="" />
-<TGConnectingPoint num="0" id="345" />
-<TGConnectingPoint num="1" id="346" />
-<TGConnectingPoint num="2" id="347" />
-<TGConnectingPoint num="3" id="348" />
+<TGConnectingPoint num="0" id="306" />
+<TGConnectingPoint num="1" id="307" />
+<TGConnectingPoint num="2" id="308" />
+<TGConnectingPoint num="3" id="309" />
 <extraparam>
 <guard value="[ ]" />
 <afterMin value="" />
@@ -729,55 +690,53 @@
 </extraparam>
 </SUBCOMPONENT>
 
-<CONNECTOR type="5102" id="358" >
-<cdparam x="407" y="132" />
+<CONNECTOR type="5102" id="319" >
+<cdparam x="406" y="141" />
 <sizeparam width="0" height="0" minWidth="0" minHeight="0" maxWidth="1000" maxHeight="2000" minDesiredWidth="0" minDesiredHeight="0" />
-<infoparam name="connector from state0 to state0" value="null" />
-<TGConnectingPoint num="0" id="357" />
-<P1  x="407" y="132" id="485" />
-<P2  x="407" y="211" id="439" />
+<infoparam name="connector from state0 to Send signal" value="null" />
+<TGConnectingPoint num="0" id="318" />
+<P1  x="406" y="141" id="467" />
+<P2  x="406" y="171" id="450" />
 <AutomaticDrawing  data="true" />
-</CONNECTOR><SUBCOMPONENT type="-1" id="356" >
-<father id="358" num="0" />
-<cdparam x="415" y="162" />
-<sizeparam width="126" height="30" minWidth="0" minHeight="0" maxWidth="2000" maxHeight="2000" minDesiredWidth="0" minDesiredHeight="0" />
+</CONNECTOR><SUBCOMPONENT type="-1" id="317" >
+<father id="319" num="0" />
+<cdparam x="406" y="181" />
+<sizeparam width="10" height="15" minWidth="0" minHeight="0" maxWidth="2000" maxHeight="2000" minDesiredWidth="0" minDesiredHeight="0" />
 <hidden value="false" />
 <cdrectangleparam minX="10" maxX="1400" minY="10" maxY="900" />
 <infoparam name="List of all parameters of an Avatar SMD transition" value="" />
-<TGConnectingPoint num="0" id="352" />
-<TGConnectingPoint num="1" id="353" />
-<TGConnectingPoint num="2" id="354" />
-<TGConnectingPoint num="3" id="355" />
+<TGConnectingPoint num="0" id="313" />
+<TGConnectingPoint num="1" id="314" />
+<TGConnectingPoint num="2" id="315" />
+<TGConnectingPoint num="3" id="316" />
 <extraparam>
 <guard value="[ ]" />
 <afterMin value="" />
 <afterMax value="" />
 <computeMin value="" />
 <computeMax value="" />
-<actions value="m.data = secretData" />
-<actions value="m1 = sencrypt(m, sk)" />
 </extraparam>
 </SUBCOMPONENT>
 
-<CONNECTOR type="5102" id="365" >
+<CONNECTOR type="5102" id="326" >
 <cdparam x="407" y="70" />
 <sizeparam width="0" height="0" minWidth="0" minHeight="0" maxWidth="1000" maxHeight="2000" minDesiredWidth="0" minDesiredHeight="0" />
 <infoparam name="connector from start state to state0" value="null" />
-<TGConnectingPoint num="0" id="364" />
-<P1  x="407" y="70" id="520" />
-<P2  x="407" y="92" id="480" />
+<TGConnectingPoint num="0" id="325" />
+<P1  x="407" y="70" id="502" />
+<P2  x="406" y="101" id="462" />
 <AutomaticDrawing  data="true" />
-</CONNECTOR><SUBCOMPONENT type="-1" id="363" >
-<father id="365" num="0" />
+</CONNECTOR><SUBCOMPONENT type="-1" id="324" >
+<father id="326" num="0" />
 <cdparam x="407" y="110" />
 <sizeparam width="10" height="15" minWidth="0" minHeight="0" maxWidth="2000" maxHeight="2000" minDesiredWidth="0" minDesiredHeight="0" />
 <hidden value="false" />
 <cdrectangleparam minX="10" maxX="1400" minY="10" maxY="900" />
 <infoparam name="List of all parameters of an Avatar SMD transition" value="" />
-<TGConnectingPoint num="0" id="359" />
-<TGConnectingPoint num="1" id="360" />
-<TGConnectingPoint num="2" id="361" />
-<TGConnectingPoint num="3" id="362" />
+<TGConnectingPoint num="0" id="320" />
+<TGConnectingPoint num="1" id="321" />
+<TGConnectingPoint num="2" id="322" />
+<TGConnectingPoint num="3" id="323" />
 <extraparam>
 <guard value="[ ]" />
 <afterMin value="" />
@@ -787,190 +746,231 @@
 </extraparam>
 </SUBCOMPONENT>
 
-<COMPONENT type="5106" id="413" >
-<cdparam x="366" y="356" />
-<sizeparam width="100" height="50" minWidth="40" minHeight="30" maxWidth="2000" maxHeight="2000" minDesiredWidth="0" minDesiredHeight="0" />
+<COMPONENT type="5106" id="367" >
+<cdparam x="327" y="339" />
+<sizeparam width="178" height="40" minWidth="40" minHeight="30" maxWidth="2000" maxHeight="2000" minDesiredWidth="0" minDesiredHeight="0" />
 <hidden value="false" />
 <cdrectangleparam minX="10" maxX="1400" minY="10" maxY="900" />
-<infoparam name="State" value="beforeFinish" />
-<TGConnectingPoint num="0" id="373" />
-<TGConnectingPoint num="1" id="374" />
-<TGConnectingPoint num="2" id="375" />
-<TGConnectingPoint num="3" id="376" />
-<TGConnectingPoint num="4" id="377" />
-<TGConnectingPoint num="5" id="378" />
-<TGConnectingPoint num="6" id="379" />
-<TGConnectingPoint num="7" id="380" />
-<TGConnectingPoint num="8" id="381" />
-<TGConnectingPoint num="9" id="382" />
-<TGConnectingPoint num="10" id="383" />
-<TGConnectingPoint num="11" id="384" />
-<TGConnectingPoint num="12" id="385" />
-<TGConnectingPoint num="13" id="386" />
-<TGConnectingPoint num="14" id="387" />
-<TGConnectingPoint num="15" id="388" />
-<TGConnectingPoint num="16" id="389" />
-<TGConnectingPoint num="17" id="390" />
-<TGConnectingPoint num="18" id="391" />
-<TGConnectingPoint num="19" id="392" />
-<TGConnectingPoint num="20" id="393" />
-<TGConnectingPoint num="21" id="394" />
-<TGConnectingPoint num="22" id="395" />
-<TGConnectingPoint num="23" id="396" />
-<TGConnectingPoint num="24" id="397" />
-<TGConnectingPoint num="25" id="398" />
-<TGConnectingPoint num="26" id="399" />
-<TGConnectingPoint num="27" id="400" />
-<TGConnectingPoint num="28" id="401" />
-<TGConnectingPoint num="29" id="402" />
-<TGConnectingPoint num="30" id="403" />
-<TGConnectingPoint num="31" id="404" />
-<TGConnectingPoint num="32" id="405" />
-<TGConnectingPoint num="33" id="406" />
-<TGConnectingPoint num="34" id="407" />
-<TGConnectingPoint num="35" id="408" />
-<TGConnectingPoint num="36" id="409" />
-<TGConnectingPoint num="37" id="410" />
-<TGConnectingPoint num="38" id="411" />
-<TGConnectingPoint num="39" id="412" />
+<infoparam name="state0" value="messageDecrypted" />
+<TGConnectingPoint num="0" id="327" />
+<TGConnectingPoint num="1" id="328" />
+<TGConnectingPoint num="2" id="329" />
+<TGConnectingPoint num="3" id="330" />
+<TGConnectingPoint num="4" id="331" />
+<TGConnectingPoint num="5" id="332" />
+<TGConnectingPoint num="6" id="333" />
+<TGConnectingPoint num="7" id="334" />
+<TGConnectingPoint num="8" id="335" />
+<TGConnectingPoint num="9" id="336" />
+<TGConnectingPoint num="10" id="337" />
+<TGConnectingPoint num="11" id="338" />
+<TGConnectingPoint num="12" id="339" />
+<TGConnectingPoint num="13" id="340" />
+<TGConnectingPoint num="14" id="341" />
+<TGConnectingPoint num="15" id="342" />
+<TGConnectingPoint num="16" id="343" />
+<TGConnectingPoint num="17" id="344" />
+<TGConnectingPoint num="18" id="345" />
+<TGConnectingPoint num="19" id="346" />
+<TGConnectingPoint num="20" id="347" />
+<TGConnectingPoint num="21" id="348" />
+<TGConnectingPoint num="22" id="349" />
+<TGConnectingPoint num="23" id="350" />
+<TGConnectingPoint num="24" id="351" />
+<TGConnectingPoint num="25" id="352" />
+<TGConnectingPoint num="26" id="353" />
+<TGConnectingPoint num="27" id="354" />
+<TGConnectingPoint num="28" id="355" />
+<TGConnectingPoint num="29" id="356" />
+<TGConnectingPoint num="30" id="357" />
+<TGConnectingPoint num="31" id="358" />
+<TGConnectingPoint num="32" id="359" />
+<TGConnectingPoint num="33" id="360" />
+<TGConnectingPoint num="34" id="361" />
+<TGConnectingPoint num="35" id="362" />
+<TGConnectingPoint num="36" id="363" />
+<TGConnectingPoint num="37" id="364" />
+<TGConnectingPoint num="38" id="365" />
+<TGConnectingPoint num="39" id="366" />
 <extraparam>
 </extraparam>
 </COMPONENT>
 
-<COMPONENT type="5103" id="435" >
-<cdparam x="373" y="285" />
-<sizeparam width="68" height="20" minWidth="30" minHeight="0" maxWidth="2000" maxHeight="2000" minDesiredWidth="0" minDesiredHeight="0" />
+<COMPONENT type="5106" id="408" >
+<cdparam x="350" y="424" />
+<sizeparam width="140" height="40" minWidth="40" minHeight="30" maxWidth="2000" maxHeight="2000" minDesiredWidth="0" minDesiredHeight="0" />
 <hidden value="false" />
 <cdrectangleparam minX="10" maxX="1400" minY="10" maxY="900" />
-<infoparam name="Send signal" value="chout(m1)" />
-<TGConnectingPoint num="0" id="425" />
-<TGConnectingPoint num="1" id="426" />
-<TGConnectingPoint num="2" id="427" />
-<TGConnectingPoint num="3" id="428" />
-<TGConnectingPoint num="4" id="429" />
-<TGConnectingPoint num="5" id="430" />
-<TGConnectingPoint num="6" id="431" />
-<TGConnectingPoint num="7" id="432" />
-<TGConnectingPoint num="8" id="433" />
-<TGConnectingPoint num="9" id="434" />
+<infoparam name="state0" value="SecretDataReceived" />
+<TGConnectingPoint num="0" id="368" />
+<TGConnectingPoint num="1" id="369" />
+<TGConnectingPoint num="2" id="370" />
+<TGConnectingPoint num="3" id="371" />
+<TGConnectingPoint num="4" id="372" />
+<TGConnectingPoint num="5" id="373" />
+<TGConnectingPoint num="6" id="374" />
+<TGConnectingPoint num="7" id="375" />
+<TGConnectingPoint num="8" id="376" />
+<TGConnectingPoint num="9" id="377" />
+<TGConnectingPoint num="10" id="378" />
+<TGConnectingPoint num="11" id="379" />
+<TGConnectingPoint num="12" id="380" />
+<TGConnectingPoint num="13" id="381" />
+<TGConnectingPoint num="14" id="382" />
+<TGConnectingPoint num="15" id="383" />
+<TGConnectingPoint num="16" id="384" />
+<TGConnectingPoint num="17" id="385" />
+<TGConnectingPoint num="18" id="386" />
+<TGConnectingPoint num="19" id="387" />
+<TGConnectingPoint num="20" id="388" />
+<TGConnectingPoint num="21" id="389" />
+<TGConnectingPoint num="22" id="390" />
+<TGConnectingPoint num="23" id="391" />
+<TGConnectingPoint num="24" id="392" />
+<TGConnectingPoint num="25" id="393" />
+<TGConnectingPoint num="26" id="394" />
+<TGConnectingPoint num="27" id="395" />
+<TGConnectingPoint num="28" id="396" />
+<TGConnectingPoint num="29" id="397" />
+<TGConnectingPoint num="30" id="398" />
+<TGConnectingPoint num="31" id="399" />
+<TGConnectingPoint num="32" id="400" />
+<TGConnectingPoint num="33" id="401" />
+<TGConnectingPoint num="34" id="402" />
+<TGConnectingPoint num="35" id="403" />
+<TGConnectingPoint num="36" id="404" />
+<TGConnectingPoint num="37" id="405" />
+<TGConnectingPoint num="38" id="406" />
+<TGConnectingPoint num="39" id="407" />
+<extraparam>
+</extraparam>
 </COMPONENT>
 
-<COMPONENT type="5101" id="437" >
-<cdparam x="424" y="451" />
-<sizeparam width="20" height="20" minWidth="0" minHeight="0" maxWidth="2000" maxHeight="2000" minDesiredWidth="0" minDesiredHeight="0" />
+<COMPONENT type="5106" id="449" >
+<cdparam x="336" y="233" />
+<sizeparam width="142" height="40" minWidth="40" minHeight="30" maxWidth="2000" maxHeight="2000" minDesiredWidth="0" minDesiredHeight="0" />
 <hidden value="false" />
 <cdrectangleparam minX="10" maxX="1400" minY="10" maxY="900" />
-<infoparam name="stop state" value="null" />
-<TGConnectingPoint num="0" id="436" />
+<infoparam name="state0" value="messageDecrypt" />
+<TGConnectingPoint num="0" id="409" />
+<TGConnectingPoint num="1" id="410" />
+<TGConnectingPoint num="2" id="411" />
+<TGConnectingPoint num="3" id="412" />
+<TGConnectingPoint num="4" id="413" />
+<TGConnectingPoint num="5" id="414" />
+<TGConnectingPoint num="6" id="415" />
+<TGConnectingPoint num="7" id="416" />
+<TGConnectingPoint num="8" id="417" />
+<TGConnectingPoint num="9" id="418" />
+<TGConnectingPoint num="10" id="419" />
+<TGConnectingPoint num="11" id="420" />
+<TGConnectingPoint num="12" id="421" />
+<TGConnectingPoint num="13" id="422" />
+<TGConnectingPoint num="14" id="423" />
+<TGConnectingPoint num="15" id="424" />
+<TGConnectingPoint num="16" id="425" />
+<TGConnectingPoint num="17" id="426" />
+<TGConnectingPoint num="18" id="427" />
+<TGConnectingPoint num="19" id="428" />
+<TGConnectingPoint num="20" id="429" />
+<TGConnectingPoint num="21" id="430" />
+<TGConnectingPoint num="22" id="431" />
+<TGConnectingPoint num="23" id="432" />
+<TGConnectingPoint num="24" id="433" />
+<TGConnectingPoint num="25" id="434" />
+<TGConnectingPoint num="26" id="435" />
+<TGConnectingPoint num="27" id="436" />
+<TGConnectingPoint num="28" id="437" />
+<TGConnectingPoint num="29" id="438" />
+<TGConnectingPoint num="30" id="439" />
+<TGConnectingPoint num="31" id="440" />
+<TGConnectingPoint num="32" id="441" />
+<TGConnectingPoint num="33" id="442" />
+<TGConnectingPoint num="34" id="443" />
+<TGConnectingPoint num="35" id="444" />
+<TGConnectingPoint num="36" id="445" />
+<TGConnectingPoint num="37" id="446" />
+<TGConnectingPoint num="38" id="447" />
+<TGConnectingPoint num="39" id="448" />
+<extraparam>
+</extraparam>
 </COMPONENT>
 
-<COMPONENT type="5106" id="478" >
-<cdparam x="336" y="211" />
-<sizeparam width="143" height="40" minWidth="40" minHeight="30" maxWidth="2000" maxHeight="2000" minDesiredWidth="0" minDesiredHeight="0" />
+<COMPONENT type="5104" id="460" >
+<cdparam x="372" y="176" />
+<sizeparam width="68" height="20" minWidth="30" minHeight="0" maxWidth="2000" maxHeight="2000" minDesiredWidth="0" minDesiredHeight="0" />
 <hidden value="false" />
 <cdrectangleparam minX="10" maxX="1400" minY="10" maxY="900" />
-<infoparam name="state0" value="sendingMessage" />
-<TGConnectingPoint num="0" id="438" />
-<TGConnectingPoint num="1" id="439" />
-<TGConnectingPoint num="2" id="440" />
-<TGConnectingPoint num="3" id="441" />
-<TGConnectingPoint num="4" id="442" />
-<TGConnectingPoint num="5" id="443" />
-<TGConnectingPoint num="6" id="444" />
-<TGConnectingPoint num="7" id="445" />
-<TGConnectingPoint num="8" id="446" />
-<TGConnectingPoint num="9" id="447" />
-<TGConnectingPoint num="10" id="448" />
-<TGConnectingPoint num="11" id="449" />
-<TGConnectingPoint num="12" id="450" />
-<TGConnectingPoint num="13" id="451" />
-<TGConnectingPoint num="14" id="452" />
-<TGConnectingPoint num="15" id="453" />
-<TGConnectingPoint num="16" id="454" />
-<TGConnectingPoint num="17" id="455" />
-<TGConnectingPoint num="18" id="456" />
-<TGConnectingPoint num="19" id="457" />
-<TGConnectingPoint num="20" id="458" />
-<TGConnectingPoint num="21" id="459" />
-<TGConnectingPoint num="22" id="460" />
-<TGConnectingPoint num="23" id="461" />
-<TGConnectingPoint num="24" id="462" />
-<TGConnectingPoint num="25" id="463" />
-<TGConnectingPoint num="26" id="464" />
-<TGConnectingPoint num="27" id="465" />
-<TGConnectingPoint num="28" id="466" />
-<TGConnectingPoint num="29" id="467" />
-<TGConnectingPoint num="30" id="468" />
-<TGConnectingPoint num="31" id="469" />
-<TGConnectingPoint num="32" id="470" />
-<TGConnectingPoint num="33" id="471" />
-<TGConnectingPoint num="34" id="472" />
-<TGConnectingPoint num="35" id="473" />
-<TGConnectingPoint num="36" id="474" />
-<TGConnectingPoint num="37" id="475" />
-<TGConnectingPoint num="38" id="476" />
-<TGConnectingPoint num="39" id="477" />
-<extraparam>
-</extraparam>
+<infoparam name="Send signal" value="chin(m2)" />
+<TGConnectingPoint num="0" id="450" />
+<TGConnectingPoint num="1" id="451" />
+<TGConnectingPoint num="2" id="452" />
+<TGConnectingPoint num="3" id="453" />
+<TGConnectingPoint num="4" id="454" />
+<TGConnectingPoint num="5" id="455" />
+<TGConnectingPoint num="6" id="456" />
+<TGConnectingPoint num="7" id="457" />
+<TGConnectingPoint num="8" id="458" />
+<TGConnectingPoint num="9" id="459" />
 </COMPONENT>
 
-<COMPONENT type="5106" id="519" >
-<cdparam x="340" y="92" />
-<sizeparam width="134" height="40" minWidth="40" minHeight="30" maxWidth="2000" maxHeight="2000" minDesiredWidth="0" minDesiredHeight="0" />
+<COMPONENT type="5106" id="501" >
+<cdparam x="340" y="101" />
+<sizeparam width="132" height="40" minWidth="40" minHeight="30" maxWidth="2000" maxHeight="2000" minDesiredWidth="0" minDesiredHeight="0" />
 <hidden value="false" />
 <cdrectangleparam minX="10" maxX="1400" minY="10" maxY="900" />
-<infoparam name="state0" value="makingMessage" />
-<TGConnectingPoint num="0" id="479" />
-<TGConnectingPoint num="1" id="480" />
-<TGConnectingPoint num="2" id="481" />
-<TGConnectingPoint num="3" id="482" />
-<TGConnectingPoint num="4" id="483" />
-<TGConnectingPoint num="5" id="484" />
-<TGConnectingPoint num="6" id="485" />
-<TGConnectingPoint num="7" id="486" />
-<TGConnectingPoint num="8" id="487" />
-<TGConnectingPoint num="9" id="488" />
-<TGConnectingPoint num="10" id="489" />
-<TGConnectingPoint num="11" id="490" />
-<TGConnectingPoint num="12" id="491" />
-<TGConnectingPoint num="13" id="492" />
-<TGConnectingPoint num="14" id="493" />
-<TGConnectingPoint num="15" id="494" />
-<TGConnectingPoint num="16" id="495" />
-<TGConnectingPoint num="17" id="496" />
-<TGConnectingPoint num="18" id="497" />
-<TGConnectingPoint num="19" id="498" />
-<TGConnectingPoint num="20" id="499" />
-<TGConnectingPoint num="21" id="500" />
-<TGConnectingPoint num="22" id="501" />
-<TGConnectingPoint num="23" id="502" />
-<TGConnectingPoint num="24" id="503" />
-<TGConnectingPoint num="25" id="504" />
-<TGConnectingPoint num="26" id="505" />
-<TGConnectingPoint num="27" id="506" />
-<TGConnectingPoint num="28" id="507" />
-<TGConnectingPoint num="29" id="508" />
-<TGConnectingPoint num="30" id="509" />
-<TGConnectingPoint num="31" id="510" />
-<TGConnectingPoint num="32" id="511" />
-<TGConnectingPoint num="33" id="512" />
-<TGConnectingPoint num="34" id="513" />
-<TGConnectingPoint num="35" id="514" />
-<TGConnectingPoint num="36" id="515" />
-<TGConnectingPoint num="37" id="516" />
-<TGConnectingPoint num="38" id="517" />
-<TGConnectingPoint num="39" id="518" />
+<infoparam name="state0" value="waitingForMessage" />
+<TGConnectingPoint num="0" id="461" />
+<TGConnectingPoint num="1" id="462" />
+<TGConnectingPoint num="2" id="463" />
+<TGConnectingPoint num="3" id="464" />
+<TGConnectingPoint num="4" id="465" />
+<TGConnectingPoint num="5" id="466" />
+<TGConnectingPoint num="6" id="467" />
+<TGConnectingPoint num="7" id="468" />
+<TGConnectingPoint num="8" id="469" />
+<TGConnectingPoint num="9" id="470" />
+<TGConnectingPoint num="10" id="471" />
+<TGConnectingPoint num="11" id="472" />
+<TGConnectingPoint num="12" id="473" />
+<TGConnectingPoint num="13" id="474" />
+<TGConnectingPoint num="14" id="475" />
+<TGConnectingPoint num="15" id="476" />
+<TGConnectingPoint num="16" id="477" />
+<TGConnectingPoint num="17" id="478" />
+<TGConnectingPoint num="18" id="479" />
+<TGConnectingPoint num="19" id="480" />
+<TGConnectingPoint num="20" id="481" />
+<TGConnectingPoint num="21" id="482" />
+<TGConnectingPoint num="22" id="483" />
+<TGConnectingPoint num="23" id="484" />
+<TGConnectingPoint num="24" id="485" />
+<TGConnectingPoint num="25" id="486" />
+<TGConnectingPoint num="26" id="487" />
+<TGConnectingPoint num="27" id="488" />
+<TGConnectingPoint num="28" id="489" />
+<TGConnectingPoint num="29" id="490" />
+<TGConnectingPoint num="30" id="491" />
+<TGConnectingPoint num="31" id="492" />
+<TGConnectingPoint num="32" id="493" />
+<TGConnectingPoint num="33" id="494" />
+<TGConnectingPoint num="34" id="495" />
+<TGConnectingPoint num="35" id="496" />
+<TGConnectingPoint num="36" id="497" />
+<TGConnectingPoint num="37" id="498" />
+<TGConnectingPoint num="38" id="499" />
+<TGConnectingPoint num="39" id="500" />
 <extraparam>
 </extraparam>
 </COMPONENT>
 
-<COMPONENT type="5100" id="521" >
+<COMPONENT type="5100" id="503" >
 <cdparam x="400" y="50" />
 <sizeparam width="15" height="15" minWidth="0" minHeight="0" maxWidth="2000" maxHeight="2000" minDesiredWidth="0" minDesiredHeight="0" />
 <hidden value="false" />
 <cdrectangleparam minX="10" maxX="1400" minY="10" maxY="900" />
 <infoparam name="start state" value="null" />
-<TGConnectingPoint num="0" id="520" />
+<TGConnectingPoint num="0" id="502" />
 </COMPONENT>
 
 
diff --git a/src/ui/GTMLModeling.java b/src/ui/GTMLModeling.java
index 121a87869de8a13e18e2c01f409f89adbc1aec7e..6e3f04cad3980f8870830fa547b0ac2c4c638ffb 100755
--- a/src/ui/GTMLModeling.java
+++ b/src/ui/GTMLModeling.java
@@ -1671,7 +1671,12 @@ public class GTMLModeling  {
 		    		if (securityPatterns.get(((TMLADReadChannel)tgc).securityContext)!=null){
 						tmlreadchannel.securityPattern= securityPatterns.get(((TMLADReadChannel)tgc).securityContext);
 		    			//NbOfSamples will increase due to extra overhead from MAC
-		    			int cur = Integer.valueOf(modifyString(((TMLADReadChannel)tgc).getSamplesValue()));
+						int cur=1;
+						try {
+			    			cur = Integer.valueOf(modifyString(((TMLADReadChannel)tgc).getSamplesValue()));
+						} catch(NumberFormatException e) { 
+   						} catch(NullPointerException e) {
+    					}
 		    			int add = Integer.valueOf(tmlreadchannel.securityPattern.overhead);
 						if (!tmlreadchannel.securityPattern.nonce.equals("")){
 						    SecurityPattern nonce = securityPatterns.get(tmlreadchannel.securityPattern.nonce);
diff --git a/src/ui/GTURTLEModeling.java b/src/ui/GTURTLEModeling.java
index 75e80c89d9e6f64a540f20d9e60f0033bbeb4513..4d558f25e25114f8b7b560278a9a8841fb8afbf8 100755
--- a/src/ui/GTURTLEModeling.java
+++ b/src/ui/GTURTLEModeling.java
@@ -207,6 +207,8 @@ import ui.sysmlsecmethodology.SysmlsecMethodologyDiagramPanel;
 import ui.tmlad.TGConnectorTMLAD;
 import ui.tmlad.TMLADDecrypt;
 import ui.tmlad.TMLADEncrypt;
+import ui.tmlad.TMLADSendRequest;
+import ui.tmlad.TMLADReadRequestArg;
 import ui.tmlad.TMLADReadChannel;
 import ui.tmlad.TMLADExecI;
 import ui.tmlad.TMLADChoice;
@@ -225,9 +227,14 @@ import ui.tmlad.TMLADStopState;
 import ui.tmlcompd.TMLComponentTaskDiagramPanel;
 import ui.tmlcp.TMLCPPanel;
 import ui.tmldd.TMLArchiCPNode;
+import ui.tmldd.TMLArchiCPUNode;
 import ui.tmldd.TMLArchiDiagramPanel;
 import ui.tmldd.TMLArchiKey;
+import ui.tmldd.TMLArchiArtifact;
+import ui.tmldd.TMLArchiBUSNode;
+import ui.tmldd.TMLArchiHWANode;
 import ui.tmldd.TMLArchiMemoryNode;
+import ui.tmldd.TMLArchiConnectorNode;
 import ui.tmlsd.TMLSDPanel;
 import ui.tree.InvariantDataTree;
 import ui.tree.SearchTree;
@@ -1091,15 +1098,29 @@ public class GTURTLEModeling {
         return map;
     }
 
+	class ChannelData {
+		public String name;
+		public boolean isOrigin;
+		public boolean isChan;
+		public ChannelData(String n, boolean orig, boolean isCh){
+			name=n;
+			isOrigin=orig;
+			isChan=isCh;
+		}
+
+	}
+
 	public void addHSM(MainGUI gui, String compName){	
-		List<String> hsmInChans = new ArrayList<String>();
+		String encComp="100";
+		String decComp="100";
+		String overhead ="0";
 		String name="hsm";
 		if (tmap==null){
 			return;
 		}
 		//Clone diagrams
 		int arch = gui.tabs.indexOf(tmap.tmlap);
-        gui.cloneRenameTab(arch,"enc");
+        gui.cloneRenameTab(arch,"hsm");
         TMLArchiPanel newarch = (TMLArchiPanel) gui.tabs.get(gui.tabs.size()-1);
 
 		TMLComponentDesignPanel tmlcdp = tmap.getTMLCDesignPanel();
@@ -1111,34 +1132,561 @@ public class GTURTLEModeling {
 		//Create clone of architecture panel and map tasks to it
 		newarch.renameMapping(tabName, tabName+"_"+name);
 	
+		
+		
+		//Find the component to add a HSM to
 		TMLCPrimitiveComponent comp =null;
 		for (TGComponent tg: tcdp.getComponentList()){
 			if (tg instanceof TMLCPrimitiveComponent){
 				if (tg.getValue().equals(compName)){
 					comp = (TMLCPrimitiveComponent) tg;
+					break;
+				}
+			}
+			else if (tg instanceof TMLCCompositeComponent){
+				TMLCCompositeComponent cc = (TMLCCompositeComponent) tg;
+				List<TMLCPrimitiveComponent> pcomps =cc.getAllPrimitiveComponents();
+				for (TMLCPrimitiveComponent pc: pcomps){
+					if (pc.getValue().equals(compName)){
+						comp=(TMLCPrimitiveComponent) pc;
+						break;
+					}
 				}
 			}
 		}
 		if (comp==null){
 			return;
 		}
+		TGConnector fromStart;
+		HashSet<String> chanNames = new HashSet<String>();
+		TMLActivityDiagramPanel tad = t.getTMLActivityDiagramPanel(compName);
+		HashSet<TGComponent> channelInstances = new HashSet<TGComponent>(); 
+		for (TGComponent tg: tad.getComponentList()){
+			if (tg instanceof TMLADWriteChannel){
+				TMLADWriteChannel writeChannel = (TMLADWriteChannel) tg;
+				if (writeChannel.securityContext.equals("")){
+					fromStart = tad.findTGConnectorEndingAt(tg.getTGConnectingPointAtIndex(0));
+					if (fromStart!=null){
+						channelInstances.add(tg);
+						chanNames.add(writeChannel.getChannelName());
+					}
+				}
+			}
+			if (tg instanceof TMLADReadChannel){
+				TMLADReadChannel readChannel = (TMLADReadChannel) tg;
+				if (readChannel.securityContext.equals("")){
+					fromStart = tad.findTGConnectorEndingAt(tg.getTGConnectingPointAtIndex(0));
+					if (fromStart!=null){
+						channelInstances.add(tg);
+						chanNames.add(readChannel.getChannelName());
+					}
+				}
+			}
+		}
+
+		List<ChannelData> hsmChans = new ArrayList<ChannelData>();
+		ChannelData ch = new ChannelData("startHSM",false,false);
+		hsmChans.add(ch);
+		for (String s: chanNames){
+			ch = new ChannelData("data_"+s,false,true);
+			hsmChans.add(ch);
+			ch = new ChannelData("retData_"+s,true,true);
+			hsmChans.add(ch);
+		}
+
 		TMLCPrimitiveComponent hsm = new TMLCPrimitiveComponent(0, 500, tcdp.getMinX(), tcdp.getMaxX(), tcdp.getMinY(), tcdp.getMaxY(), false, null, tcdp);
-		hsm.setValue("HSM");
+		TAttribute isEnc = new TAttribute(2, "isEnc", "true", 4);
+		hsm.getAttributes().add(isEnc);
 		tcdp.addComponent(hsm, 0,500,false,true);
+		hsm.setValueWithChange("HSM");
 	
-		for (String hsmChan: hsmInChans){
+		comp.getAttributes().add(isEnc);
+
+		for (ChannelData hsmChan: hsmChans){
 			TMLCChannelOutPort originPort =new TMLCChannelOutPort(comp.getX(), comp.getY(), tcdp.getMinX(), tcdp.getMaxX(), tcdp.getMinY(), tcdp.getMaxX(), true, hsm, tcdp);
 			TMLCChannelOutPort destPort = new TMLCChannelOutPort(comp.getX(), comp.getY(), tcdp.getMinX(), tcdp.getMaxX(), tcdp.getMinY(), tcdp.getMaxX(), true, comp, tcdp);
-			originPort.commName=hsmChan;
-			tcdp.addComponent(originPort,comp.getX(), comp.getY(),true,true);
-			
-			destPort.isOrigin=false;
-			destPort.commName=hsmChan;
+			originPort.commName=hsmChan.name;
+			originPort.isOrigin=hsmChan.isOrigin;
+			tcdp.addComponent(originPort,hsm.getX(), hsm.getY(),true,true);
+	
+			destPort.commName=hsmChan.name;	
+			if (!hsmChan.isChan){
+				originPort.typep=2;
+				destPort.typep=2;
+				originPort.setParam(0, new TType(2));
+			}
+			destPort.isOrigin=!hsmChan.isOrigin;
+
 			tcdp.addComponent(destPort,comp.getX(), comp.getY(),true,true);
 			
 			TMLCPortConnector conn = new TMLCPortConnector(0, 0, tcdp.getMinX(), tcdp.getMaxX(), tcdp.getMinY(), tcdp.getMaxX(), true, null, tcdp, originPort.getTGConnectingPointAtIndex(0), destPort.getTGConnectingPointAtIndex(0), new Vector<Point>());
 			tcdp.addComponent(conn, 0,0,false,true);
 		}
+		int xpos=0;
+		int ypos=0;
+
+		//Modify component activity diagram to add read/write to HSM
+
+		//Add actions before Write Channel
+		for (TGComponent chan: channelInstances){
+			String chanName="";
+			if (chan instanceof TMLADWriteChannel){
+				TMLADWriteChannel writeChannel = (TMLADWriteChannel) chan;
+				chanName=writeChannel.getChannelName();		
+				writeChannel.securityContext = "hsmSec_"+chanName;	
+			}
+			else {
+				continue;
+			}
+
+			xpos = chan.getX();
+			ypos = chan.getY();
+			fromStart = tad.findTGConnectorEndingAt(chan.getTGConnectingPointAtIndex(0));
+			TGConnectingPoint point = fromStart.getTGConnectingPointP2();
+			//Add send request operator
+			int yShift=50;
+
+			TMLADSendRequest req = new TMLADSendRequest(xpos, ypos+yShift, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad);
+			req.setRequestName("startHSM");
+			req.setParam(0,"isEnc");
+			tad.addComponent(req, xpos, ypos+yShift, false,true);
+			fromStart.setP2(req.getTGConnectingPointAtIndex(0));
+
+
+			yShift+=50;
+			//Add write channel operator
+			TMLADWriteChannel wr = new TMLADWriteChannel(xpos, ypos+yShift, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad);
+			wr.setChannelName("data_"+chanName);
+			wr.securityContext = "hsmSec_"+chanName;
+			tad.addComponent(wr, xpos, ypos+yShift, false,true);
+
+
+			//Add connection
+			fromStart=new TGConnectorTMLAD(xpos, ypos, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad, null, null, new Vector());			
+			fromStart.setP1(req.getTGConnectingPointAtIndex(1));
+			fromStart.setP2(wr.getTGConnectingPointAtIndex(0));
+			tad.addComponent(fromStart, xpos, ypos, false, true);
+
+			//Add read channel operator
+
+			yShift+=60;
+			TMLADReadChannel rd = new TMLADReadChannel(xpos, ypos+yShift, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad);
+			rd.setChannelName("retData_"+chanName);
+			rd.securityContext = "hsmSec_"+chanName;		
+			tad.addComponent(rd, xpos, ypos+yShift, false,true);
+			
+			fromStart=new TGConnectorTMLAD(xpos, ypos, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad, null, null, new Vector());
+			tad.addComponent(fromStart, xpos, ypos, false, true);
+			fromStart.setP1(wr.getTGConnectingPointAtIndex(1));
+			fromStart.setP2(rd.getTGConnectingPointAtIndex(0));
+			yShift+=50;
+		
+				
+			fromStart=new TGConnectorTMLAD(xpos, ypos, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad, null, null, new Vector());
+			tad.addComponent(fromStart, xpos, ypos, false, true);
+			fromStart.setP1(rd.getTGConnectingPointAtIndex(1));
+			yShift+=50;
+			
+				//Direct the last TGConnector back to the start of the write channel operator
+
+			
+			fromStart.setP2(point);
+			//Shift components down to make room for the added ones, and add security contexts to write channels
+			for (TGComponent tg:tad.getComponentList()){
+				if (tg.getY() >= ypos && tg !=wr && tg!=req && tg!=rd){
+					tg.setCd(tg.getX(), tg.getY()+yShift);
+				}
+			}	
+			tad.setMaxPanelSize(tad.getMaxX(), tad.getMaxY()+yShift);
+			tad.repaint();
+			
+		}
+		//Add actions after Read Channel
+		for (TGComponent chan: channelInstances){
+			String chanName="";
+			if (chan instanceof TMLADReadChannel) {
+				TMLADReadChannel readChannel = (TMLADReadChannel) chan;
+				chanName=readChannel.getChannelName();	
+				readChannel.securityContext = "hsmSec_"+chanName;
+			}
+			else {
+				continue;
+			}
+			xpos = chan.getX()+10;
+			ypos = chan.getY();
+			fromStart = tad.findTGConnectorStartingAt(chan.getTGConnectingPointAtIndex(1));
+			if (fromStart==null){
+				fromStart=new TGConnectorTMLAD(xpos, ypos, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad, null, null, new Vector());
+				fromStart.setP1(chan.getTGConnectingPointAtIndex(1));
+				tad.addComponent(fromStart, xpos,ypos,false,true);
+			}
+			TGConnectingPoint point = fromStart.getTGConnectingPointP2();
+			//Add send request operator
+			int yShift=50;
+
+			TMLADSendRequest req = new TMLADSendRequest(xpos, ypos+yShift, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad);
+			req.setRequestName("startHSM");
+			req.setParam(0,"isEnc");
+			req.makeValue();
+			tad.addComponent(req, xpos, ypos+yShift, false,true);
+			fromStart.setP2(req.getTGConnectingPointAtIndex(0));
+
+
+			yShift+=50;
+			//Add write channel operator
+			TMLADWriteChannel wr = new TMLADWriteChannel(xpos, ypos+yShift, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad);
+			wr.setChannelName("data_"+chanName);
+			wr.securityContext = "hsmSec_"+chanName;
+			tad.addComponent(wr, xpos, ypos+yShift, false,true);
+
+
+			//Add connection
+			fromStart=new TGConnectorTMLAD(xpos, ypos, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad, null, null, new Vector());			
+			fromStart.setP1(req.getTGConnectingPointAtIndex(1));
+			fromStart.setP2(wr.getTGConnectingPointAtIndex(0));
+			tad.addComponent(fromStart, xpos, ypos, false, true);
+
+			//Add read channel operator
+
+			yShift+=60;
+			TMLADReadChannel rd = new TMLADReadChannel(xpos, ypos+yShift, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad);
+			rd.setChannelName("retData_"+chanName);
+			rd.securityContext = "hsmSec_"+chanName;		
+			tad.addComponent(rd, xpos, ypos+yShift, false,true);
+			
+			fromStart=new TGConnectorTMLAD(xpos, ypos, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad, null, null, new Vector());
+			tad.addComponent(fromStart, xpos, ypos, false, true);
+			fromStart.setP1(wr.getTGConnectingPointAtIndex(1));
+			fromStart.setP2(rd.getTGConnectingPointAtIndex(0));
+			yShift+=50;
+		
+			if (point!=null){
+				fromStart=new TGConnectorTMLAD(xpos, ypos, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad, null, null, new Vector());
+				tad.addComponent(fromStart, xpos, ypos, false, true);
+				fromStart.setP1(rd.getTGConnectingPointAtIndex(1));
+				//Direct the last TGConnector back to the start of the write channel operator
+				
+				fromStart.setP2(point);
+			}
+			yShift+=50;
+			
+
+			//Shift components down to make room for the added ones, and add security contexts to write channels
+			for (TGComponent tg:tad.getComponentList()){
+				if (tg.getY() >= ypos && tg !=wr && tg!=req && tg!=rd && tg!=chan){
+					tg.setCd(tg.getX(), tg.getY()+yShift);
+				}
+			}	
+			tad.setMaxPanelSize(tad.getMaxX(), tad.getMaxY()+yShift);
+			tad.repaint();
+		}
+
+		//Build HSM
+
+		tad = t.getTMLActivityDiagramPanel("HSM");
+
+		TMLADStartState start = (TMLADStartState) tad.getComponentList().get(0);
+		fromStart = new TGConnectorTMLAD(xpos, ypos, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad, null, null, new Vector());
+
+
+		TMLADReadRequestArg req = new TMLADReadRequestArg(300, 100, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad);
+		tad.addComponent(req, 300,100,false,true);
+		req.setParam(0, "isEnc");
+		req.makeValue();
+
+		//Connect start and readrequest
+		fromStart.setP1(start.getTGConnectingPointAtIndex(0));
+		fromStart.setP2(req.getTGConnectingPointAtIndex(0));
+		tad.addComponent(fromStart, 300,200,false,true);
+	
+		TMLADChoice choice = new TMLADChoice(300, 200, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad);
+		tad.addComponent(choice, 300,200,false,true);
+
+
+		//Connect readrequest and choice
+		fromStart = new TGConnectorTMLAD(xpos, ypos, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad, null, null, new Vector());
+		fromStart.setP1(req.getTGConnectingPointAtIndex(1));
+		fromStart.setP2(choice.getTGConnectingPointAtIndex(0));
+		tad.addComponent(fromStart, 300,200,false,true);
+	
+	
+
+		int xc = 150;
+		//Allows 3 channels max to simplify the diagram
+		int i=1;
+		for (String chan: chanNames){
+			if (i>3){
+				break;
+			}
+			TMLADReadChannel rd = new TMLADReadChannel(xc, 300, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad);
+			rd.setChannelName("data_"+chan);
+			tad.addComponent(rd, xc,300,false,true);
+			//Connect choice and readchannel
+
+			fromStart = new TGConnectorTMLAD(xpos, ypos, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad, null, null, new Vector());
+			fromStart.setP1(choice.getTGConnectingPointAtIndex(i));
+			fromStart.setP2(rd.getTGConnectingPointAtIndex(0));
+			tad.addComponent(fromStart, 300,200,false,true);
+
+			TMLADChoice choice2 = new TMLADChoice(xc, 400, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad);
+			tad.addComponent(choice2, xc, 400,false,true);
+			choice2.setGuard("[isEnc]", 0);
+			choice2.setGuard("[else]",1);
+
+			//connect readchannel and choice 2
+			fromStart = new TGConnectorTMLAD(xpos, ypos, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad, null, null, new Vector());
+			fromStart.setP1(rd.getTGConnectingPointAtIndex(1));
+			fromStart.setP2(choice2.getTGConnectingPointAtIndex(0));
+			tad.addComponent(fromStart, 300,200,false,true);
+
+			TMLADEncrypt enc = new TMLADEncrypt(xc-75, 500, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad);
+			enc.securityContext = "hsmSec_"+chan;
+			enc.type = "Symmetric Encryption";
+			enc.message_overhead = overhead;
+			enc.encTime= encComp;
+			enc.decTime=decComp;
+			tad.addComponent(enc, xc-75, 500,false,true);
+			
+			//Connect choice 2 and encrypt
+			fromStart = new TGConnectorTMLAD(xpos, ypos, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad, null, null, new Vector());
+			fromStart.setP1(choice2.getTGConnectingPointAtIndex(1));
+			fromStart.setP2(enc.getTGConnectingPointAtIndex(0));
+			tad.addComponent(fromStart, 300,200,false,true);
+
+			TMLADWriteChannel wr = new TMLADWriteChannel(xc-75, 600, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad);
+			wr.setChannelName("retData_"+chan);
+			tad.addComponent(wr, xc-75, 600,false,true);
+			wr.securityContext = "hsmSec_"+chan;
+
+			//Connect encrypt and writeChannel
+			fromStart = new TGConnectorTMLAD(xpos, ypos, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad, null, null, new Vector());
+			fromStart.setP1(enc.getTGConnectingPointAtIndex(1));
+			fromStart.setP2(wr.getTGConnectingPointAtIndex(0));
+			tad.addComponent(fromStart, 300,200,false,true);
+
+
+			TMLADDecrypt dec = new TMLADDecrypt(xc+75, 500, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad);
+			dec.securityContext = "hsmSec_"+chan;
+			tad.addComponent(dec, xc+75, 500,false,true);
+
+			//Connect choice2 and decrypt
+
+			fromStart = new TGConnectorTMLAD(xpos, ypos, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad, null, null, new Vector());
+			fromStart.setP1(choice2.getTGConnectingPointAtIndex(2));
+			fromStart.setP2(dec.getTGConnectingPointAtIndex(0));
+			tad.addComponent(fromStart, 300,200,false,true);
+
+			TMLADWriteChannel wr2 = new TMLADWriteChannel(xc+75, 600, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad);
+			wr2.setChannelName("retData_"+chan);
+			wr2.securityContext = "hsmSec_"+chan;
+			tad.addComponent(wr2, xc+75, 600,false,true);
+
+			//Connect decrypt and writeChannel
+			fromStart = new TGConnectorTMLAD(xpos, ypos, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad, null, null, new Vector());
+			fromStart.setP1(dec.getTGConnectingPointAtIndex(1));
+			fromStart.setP2(wr2.getTGConnectingPointAtIndex(0));
+			tad.addComponent(fromStart, 300,200,false,true);
+			
+			xc+=300;
+			i++;
+		}	
+	//For all the tasks that receive encrypted data, decrypt it
+		for (TMLTask task: tmap.getTMLModeling().getTasks()){
+			tad = t.getTMLActivityDiagramPanel(task.getName());
+			for (String chan: chanNames){
+				channelInstances.clear(); 
+				for (TGComponent tg: tad.getComponentList()){
+					if (tg instanceof TMLADReadChannel){
+						TMLADReadChannel readChannel = (TMLADReadChannel) tg;
+						if (readChannel.getChannelName().equals(chan) && readChannel.securityContext.equals("")){					 						
+							fromStart = tad.findTGConnectorStartingAt(tg.getTGConnectingPointAtIndex(1));
+							if (fromStart!=null){
+								channelInstances.add(tg);
+							}
+						}
+					}
+				}
+			for (TGComponent chI: channelInstances){
+				TMLADReadChannel readChannel = (TMLADReadChannel) chI;
+				readChannel.securityContext="hsmSec_"+chan;
+				xpos = chI.getX();
+				ypos = chI.getY()+10;
+				fromStart = tad.findTGConnectorStartingAt(chI.getTGConnectingPointAtIndex(1));
+				if (fromStart==null){
+					fromStart=new TGConnectorTMLAD(xpos, ypos, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad, null, null, new Vector());
+					fromStart.setP1(chI.getTGConnectingPointAtIndex(1));
+					tad.addComponent(fromStart, xpos,ypos,false,true);
+				}
+				TGConnectingPoint point = fromStart.getTGConnectingPointP2();
+				//Add decryption operator
+				int yShift=100;
+				TMLADDecrypt dec = new TMLADDecrypt(xpos, ypos+yShift, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad);
+				dec.securityContext = "hsmSec_"+chan;
+				tad.addComponent(dec, xpos,ypos+yShift, false, true);
+
+
+				fromStart.setP2(dec.getTGConnectingPointAtIndex(0));
+				if (point!=null){
+				fromStart=new TGConnectorTMLAD(dec.getX(), dec.getY(), tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad, null, null, new Vector());
+				tad.addComponent(fromStart, xpos, ypos, false, true);
+				fromStart.setP1(dec.getTGConnectingPointAtIndex(1));
+			
+				//Direct the last TGConnector back to the next action
+			
+				fromStart.setP2(point);
+				}
+				//Shift components down to make room for the added ones, and add security contexts to write channels
+				for (TGComponent tg:tad.getComponentList()){
+					if (tg.getY() >= ypos && tg!=dec){
+						tg.setCd(tg.getX(), tg.getY()+yShift);
+					}
+				}	
+				tad.setMaxPanelSize(tad.getMaxX(), tad.getMaxY()+yShift);
+				tad.repaint();
+			
+			}
+			}
+			//Next find channels that send encrypted data, and add the encryption operator
+			for (String chan: chanNames){
+				channelInstances.clear(); 
+				for (TGComponent tg: tad.getComponentList()){
+					if (tg instanceof TMLADWriteChannel){
+						TMLADWriteChannel writeChannel = (TMLADWriteChannel) tg;
+						if (writeChannel.getChannelName().equals(chan) && writeChannel.securityContext.equals("")){					 						
+							fromStart = tad.findTGConnectorEndingAt(tg.getTGConnectingPointAtIndex(0));
+							if (fromStart!=null){
+								channelInstances.add(tg);
+							}
+						}
+					}
+				}
+			for (TGComponent chI: channelInstances){
+				TMLADWriteChannel writeChannel = (TMLADWriteChannel) chI;
+				writeChannel.securityContext="hsmSec_"+chan;
+				xpos = chI.getX();
+				ypos = chI.getY()-10;
+				fromStart = tad.findTGConnectorEndingAt(chI.getTGConnectingPointAtIndex(0));
+				TGConnectingPoint point = fromStart.getTGConnectingPointP2();
+				//Add encryption operator
+				int yShift=100;
+
+				TMLADEncrypt enc = new TMLADEncrypt(xpos, ypos, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad);
+				tad.addComponent(enc,xpos, ypos, false,true);
+				enc.securityContext = "hsmSec_"+chan;
+				enc.type = "Symmetric Encryption";
+				enc.message_overhead = overhead;
+				enc.encTime= encComp;
+				enc.decTime=decComp;
+				enc.size=overhead;
+
+
+				fromStart.setP2(enc.getTGConnectingPointAtIndex(0));
+				fromStart=new TGConnectorTMLAD(enc.getX(), enc.getY(), tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad, null, null, new Vector());
+				tad.addComponent(fromStart, xpos, ypos, false, true);
+				fromStart.setP1(enc.getTGConnectingPointAtIndex(1));
+			
+				//Direct the last TGConnector back to the start of the write channel operator
+			
+				fromStart.setP2(point);
+				//Shift components down to make room for the added ones, and add security contexts to write channels
+				for (TGComponent tg:tad.getComponentList()){
+					if (tg.getY() >= ypos && tg !=enc){
+						tg.setCd(tg.getX(), tg.getY()+yShift);
+					}
+				}	
+				tad.setMaxPanelSize(tad.getMaxX(), tad.getMaxY()+yShift);
+				tad.repaint();
+			
+			}
+			}
+
+
+		}
+
+		//Add a private bus to Hardware Accelerator with the task for hsm
+	
+		//Find the CPU the task is mapped to
+		TMLArchiDiagramPanel archPanel = newarch.tmlap;
+		TMLArchiCPUNode cpu=null;
+		String refTask="";
+		loop:
+		for (TGComponent tg: archPanel.getComponentList()){
+			if (tg instanceof TMLArchiCPUNode){
+				TMLArchiCPUNode cp = (TMLArchiCPUNode) tg;
+				Vector v= cp.getArtifactList();
+				for (int j=0; j< v.size(); j++){
+					TMLArchiArtifact art = (TMLArchiArtifact) v.elementAt(j);
+					if (art.getTaskName().equals(compName)){
+						//CPU and Artifact found
+						cpu=cp;
+						refTask= art.getReferenceTaskName();
+						break loop;
+					}
+				}
+			}
+		}
+
+		if (cpu==null){
+			return;
+		}
+
+		//Add new memory
+		TMLArchiMemoryNode mem = new TMLArchiMemoryNode(cpu.getX()+100, cpu.getY()+100, archPanel.getMinX(), archPanel.getMaxX(), archPanel.getMinY(), archPanel.getMaxY(), true, null, archPanel); 
+		archPanel.addComponent(mem, cpu.getX()+100, cpu.getY()+100, false, true);
+		mem.setName("HSMMemory");
+		//Add Hardware Accelerator
+		
+		TMLArchiHWANode hwa = new TMLArchiHWANode(cpu.getX()+100, cpu.getY()+100, archPanel.getMinX(), archPanel.getMaxX(), archPanel.getMinY(), archPanel.getMaxY(), true, null, archPanel); 
+		archPanel.addComponent(hwa, cpu.getX()+100, cpu.getY()+100, false, true);
+		hwa.setName("HSM");
+		//Add hsm task to hwa
+			
+
+		TMLArchiArtifact hsmArt = new TMLArchiArtifact(cpu.getX()+100, cpu.getY()+100, archPanel.getMinX(), archPanel.getMaxX(), archPanel.getMinY(), archPanel.getMaxY(), true, hwa, archPanel); 
+		archPanel.addComponent(hsmArt, cpu.getX()+100, cpu.getY()+100, true, true);
+		hsmArt.setFullName("HSM", refTask);
+		//Add bus connecting the cpu and HWA
+		
+		TMLArchiBUSNode bus = new TMLArchiBUSNode(cpu.getX()+100, cpu.getY()+100, archPanel.getMinX(), archPanel.getMaxX(), archPanel.getMinY(), archPanel.getMaxY(), true, null, archPanel); 
+		bus.setPrivacy(1);
+		bus.setName("HSMBus");
+		archPanel.addComponent(bus, cpu.getX()+200, cpu.getY()+200, false, true);
+
+		//Connect Bus and CPU
+		TMLArchiConnectorNode connect =new  TMLArchiConnectorNode(cpu.getX()+100, cpu.getY()+100, archPanel.getMinX(), archPanel.getMaxX(), archPanel.getMinY(), archPanel.getMaxY(), true, null, archPanel, null, null, new Vector());
+		TGConnectingPoint p1 = bus.findFirstFreeTGConnectingPoint(true,true);
+        p1.setFree(false);
+		connect.setP2(p1);
+
+
+
+		TGConnectingPoint p2 = cpu.findFirstFreeTGConnectingPoint(true,true);
+        p1.setFree(false);
+		connect.setP1(p2);
+		archPanel.addComponent(connect, cpu.getX()+100, cpu.getY()+100, false, true);
+		//Connect Bus and HWA
+
+		connect = new TMLArchiConnectorNode(cpu.getX()+100, cpu.getY()+100, archPanel.getMinX(), archPanel.getMaxX(), archPanel.getMinY(), archPanel.getMaxY(), true, null, archPanel, null, null, new Vector());
+		p1 = bus.findFirstFreeTGConnectingPoint(true,true);
+        p1.setFree(false);
+		connect.setP2(p1);
+
+		p2 = hwa.findFirstFreeTGConnectingPoint(true,true);
+        p1.setFree(false);
+		connect.setP1(p2);
+
+		archPanel.addComponent(connect, cpu.getX()+100, cpu.getY()+100, false, true);
+		//Connect Bus and Memory
+
+		connect = new TMLArchiConnectorNode(cpu.getX()+100, cpu.getY()+100, archPanel.getMinX(), archPanel.getMaxX(), archPanel.getMinY(), archPanel.getMaxY(), true, null, archPanel, null, null, new Vector());
+		p1 = bus.findFirstFreeTGConnectingPoint(true,true);
+        p1.setFree(false);
+		connect.setP2(p1);
+
+		p2 = mem.findFirstFreeTGConnectingPoint(true,true);
+        p1.setFree(false);
+		connect.setP1(p2);
+		archPanel.addComponent(connect, cpu.getX()+100, cpu.getY()+100, false, true);
 
 	}
 
@@ -1482,7 +2030,6 @@ public class GTURTLEModeling {
 							if (fromStart!=null){
 								channelInstances.add(tg);
 							}
-							break;
 						}
 					}
 				}
@@ -1801,7 +2348,6 @@ public class GTURTLEModeling {
         return secure;
     }
     public void autoMapKeys(){
-        System.out.println("Mapping keys");
         TraceManager.addDev("auto map keys");
         if (tmap==null){
             return;
@@ -1812,7 +2358,7 @@ public class GTURTLEModeling {
         if (tmlm.securityTaskMap ==null){
             return;
         }
-        System.out.println(tmlm.securityTaskMap);
+    //    System.out.println(tmlm.securityTaskMap);
         for (SecurityPattern sp: tmlm.securityTaskMap.keySet()){
             if (sp.type.contains("Encryption") || sp.type.equals("MAC")){
                 TraceManager.addDev("Finding security "+sp);
@@ -1838,15 +2384,16 @@ public class GTURTLEModeling {
                             if (curr == link.bus){
                                 if (link.hwnode instanceof HwMemory){
                                     mems.add((HwMemory) link.hwnode);
-                                    ArrayList<SecurityPattern> patterns = tmap.getMappedPatterns((HwMemory) link.hwnode);
+									TMLArchiMemoryNode memNode= (TMLArchiMemoryNode) listE.getTG(link.hwnode);
+                                    ArrayList<TMLArchiKey> keys = memNode.getKeyList();
                                     String patternString= "";
-                                    for (SecurityPattern pattern: patterns){
-                                        if (pattern.name.equals(sp.name)){
+                                    for (TMLArchiKey key: keys){
+                                        if (key.getValue().equals(sp.name)){
 
                                             keyFound=true;
                                             break memloop;
                                         }
-                                        patternString += pattern.name;
+                                        patternString += key.getValue();
                                         patternString += " ";
                                     }
                                     TraceManager.addDev("Memory "+ link.hwnode.getName() + " has currently mapped: " + patternString);
diff --git a/src/ui/TGComponentManager.java b/src/ui/TGComponentManager.java
index 8036dee67e92a69a591d81ead5244c897dcf2249..ee8c2639d63817c1bdd3a7b30adec1740527d2f1 100755
--- a/src/ui/TGComponentManager.java
+++ b/src/ui/TGComponentManager.java
@@ -170,7 +170,7 @@ public class TGComponentManager {
     public static final int PRAGMA = 302;
     public static final int SAFETY_PRAGMA = 303;
     public static final int INFO_PANEL = 304;
-	public static final int AVATAR_FIREWALL = 306;
+    public static final int AVATAR_FIREWALL = 306;
 
     public static final int IOD_CHOICE = 501;
     public static final int IOD_START_STATE = 502;
@@ -481,8 +481,8 @@ public class TGComponentManager {
     public  static LinkedList<ADDConnector> addconnectors = new LinkedList<ADDConnector>(); //DG 21.02.
 
 
-public static LinkedList<ADDConnector> getAllADDConnectors(){     
-      return addconnectors;
+    public static LinkedList<ADDConnector> getAllADDConnectors(){
+        return addconnectors;
     }//DG 21.02.
 
     public final static TGComponent addComponent(int x, int y, int id, TDiagramPanel tdp) {
@@ -648,11 +648,11 @@ public static LinkedList<ADDConnector> getAllADDConnectors(){
         case ADD_BUSNODE:
             tgc = new ADDBusNode(x, y, tdp.getMinX(), tdp.getMaxX(), tdp.getMinY(), tdp.getMaxY(), false, null, tdp);
             break;
-        case ADD_VGMNNODE: 	   
-		tgc = new ADDVgmnNode(x, y, tdp.getMinX(), tdp.getMaxX(), tdp.getMinY(), tdp.getMaxY(), false, null, tdp);	   
+        case ADD_VGMNNODE:
+            tgc = new ADDVgmnNode(x, y, tdp.getMinX(), tdp.getMaxX(), tdp.getMinY(), tdp.getMaxY(), false, null, tdp);
             break;
-        case ADD_CROSSBARNODE:	   
-		tgc = new ADDCrossbarNode(x, y, tdp.getMinX(), tdp.getMaxX(), tdp.getMinY(), tdp.getMaxY(), false, null, tdp);	   
+        case ADD_CROSSBARNODE:
+            tgc = new ADDCrossbarNode(x, y, tdp.getMinX(), tdp.getMaxX(), tdp.getMinY(), tdp.getMaxY(), false, null, tdp);
             break;
         case ADD_TTYNODE:
             tgc = new ADDTTYNode(x, y, tdp.getMinX(), tdp.getMaxX(), tdp.getMinY(), tdp.getMaxY(), false, null, tdp);
@@ -827,7 +827,7 @@ public static LinkedList<ADDConnector> getAllADDConnectors(){
         case UML_NOTE:
             tgc = new TGCNote(x, y, tdp.getMinX(), tdp.getMaxX(), tdp.getMinY(), tdp.getMaxY(), false, null, tdp);
             break;
-	case INFO_PANEL:
+        case INFO_PANEL:
             tgc = new TGCPanelInfo(x, y, tdp.getMinX(), tdp.getMaxX(), tdp.getMinY(), tdp.getMaxY(), false, null, tdp);
             break;
         case PRAGMA:
@@ -836,9 +836,9 @@ public static LinkedList<ADDConnector> getAllADDConnectors(){
         case SAFETY_PRAGMA:
             tgc = new AvatarBDSafetyPragma(x, y, tdp.getMinX(), tdp.getMaxX(), tdp.getMinY(), tdp.getMaxY(), false, null, tdp);
             break;
-//        case AVATAR_FIREWALL:
-//            tgc = new AvatarBDFirewall(x, y, tdp.getMinX(), tdp.getMaxX(), tdp.getMinY(), tdp.getMaxY(), false, null, tdp);
-//            break;
+            //        case AVATAR_FIREWALL:
+            //            tgc = new AvatarBDFirewall(x, y, tdp.getMinX(), tdp.getMaxX(), tdp.getMinY(), tdp.getMaxY(), false, null, tdp);
+            //            break;
         case IOD_CHOICE:
             tgc = new IODChoice(x, y, tdp.getMinX(), tdp.getMaxX(), tdp.getMinY(), tdp.getMaxY(), false, null, tdp);
             break;
@@ -869,7 +869,7 @@ public static LinkedList<ADDConnector> getAllADDConnectors(){
         case SD_INSTANCE:
             tgc = new SDInstance(x, y, tdp.getMinX(), tdp.getMaxX(), tdp.getMinY(), tdp.getMaxY(), false, null, tdp);
             break;
-	case SD_PORT_MESSAGE:
+        case SD_PORT_MESSAGE:
             tgc = new SDPortForMessage(x, y, tdp.getMinX(), tdp.getMaxX(), tdp.getMinY(), tdp.getMaxY(), false, null, tdp);
             break;
         case SD_ABSOLUTE_TIME_CONSTRAINT:
@@ -1098,10 +1098,10 @@ public static LinkedList<ADDConnector> getAllADDConnectors(){
         case TMLARCHI_BUSNODE:
             tgc = new TMLArchiBUSNode(x, y, tdp.getMinX(), tdp.getMaxX(), tdp.getMinY(), tdp.getMaxY(), false, null, tdp);
             break;
- case TMLARCHI_VGMNNODE:
+        case TMLARCHI_VGMNNODE:
             tgc = new TMLArchiVGMNNode(x, y, tdp.getMinX(), tdp.getMaxX(), tdp.getMinY(), tdp.getMaxY(), false, null, tdp);
             break;
- case TMLARCHI_CROSSBARNODE:
+        case TMLARCHI_CROSSBARNODE:
             tgc = new TMLArchiCrossbarNode(x, y, tdp.getMinX(), tdp.getMaxX(), tdp.getMinY(), tdp.getMaxY(), false, null, tdp);
             break;
         case TMLARCHI_CPNODE:
@@ -1340,9 +1340,9 @@ public static LinkedList<ADDConnector> getAllADDConnectors(){
             return ADD_CHANNELARTIFACT;
         } else if (tgc instanceof ADDBusNode) {
             return ADD_BUSNODE;
-	} else if (tgc instanceof ADDVgmnNode) {
+        } else if (tgc instanceof ADDVgmnNode) {
             return ADD_VGMNNODE;
-	} else if (tgc instanceof ADDCrossbarNode) {
+        } else if (tgc instanceof ADDCrossbarNode) {
             return ADD_CROSSBARNODE;
         } else if (tgc instanceof ADDTTYNode) {
             return ADD_TTYNODE;
@@ -1575,7 +1575,7 @@ public static LinkedList<ADDConnector> getAllADDConnectors(){
             return      CONNECTOR_INTERACTION;
         } else if (tgc instanceof TGCNote) {
             return      UML_NOTE;
-	} else if (tgc instanceof TGCPanelInfo) {
+        } else if (tgc instanceof TGCPanelInfo) {
             return      INFO_PANEL;
         } else if (tgc instanceof IODChoice) {
             return IOD_CHOICE;
@@ -1603,8 +1603,8 @@ public static LinkedList<ADDConnector> getAllADDConnectors(){
             return CONNECTOR_RELATIVE_TIME_SD;
         } else if (tgc instanceof SDInstance) {
             return SD_INSTANCE;
-	} else if (tgc instanceof SDPortForMessage) {
-            return SD_PORT_MESSAGE;  
+        } else if (tgc instanceof SDPortForMessage) {
+            return SD_PORT_MESSAGE;
         } else if (tgc instanceof SDAbsoluteTimeConstraint) {
             return SD_ABSOLUTE_TIME_CONSTRAINT;
         } else if (tgc instanceof SDRelativeTimeConstraint) {
@@ -1782,11 +1782,11 @@ public static LinkedList<ADDConnector> getAllADDConnectors(){
             return CONNECTOR_NODE_TMLARCHI;
         } else if (tgc instanceof TMLArchiCPUNode) {
             return TMLARCHI_CPUNODE;
-	} else if (tgc instanceof TMLArchiBUSNode) {
+        } else if (tgc instanceof TMLArchiBUSNode) {
             return TMLARCHI_BUSNODE;
-	} else if (tgc instanceof TMLArchiVGMNNode) {
+        } else if (tgc instanceof TMLArchiVGMNNode) {
             return TMLARCHI_VGMNNODE;
-	} else if (tgc instanceof TMLArchiCrossbarNode) {
+        } else if (tgc instanceof TMLArchiCrossbarNode) {
             return TMLARCHI_CROSSBARNODE;
         } else if (tgc instanceof TMLArchiCPNode) {
             return TMLARCHI_CPNODE;
@@ -1794,8 +1794,8 @@ public static LinkedList<ADDConnector> getAllADDConnectors(){
             return TMLARCHI_BRIDGENODE;
         } else if (tgc instanceof TMLArchiFirewallNode) {
             return TMLARCHI_FIREWALL;
-//        } else if (tgc instanceof AvatarBDFirewall) {
-//            return AVATAR_FIREWALL;
+            //        } else if (tgc instanceof AvatarBDFirewall) {
+            //            return AVATAR_FIREWALL;
         } else if (tgc instanceof TMLArchiHWANode) {
             return TMLARCHI_HWANODE;
         } else if (tgc instanceof TMLArchiMemoryNode) {
@@ -1949,7 +1949,7 @@ public static LinkedList<ADDConnector> getAllADDConnectors(){
 
     public final static TGConnector addConnector(int x, int y, int id, TDiagramPanel tdp, TGConnectingPoint p1, TGConnectingPoint p2, Vector listPoint) {
         TGConnector tgc = null;
-	
+
         switch(id) {
             // AVATAR
             // AVATAR BD
@@ -1996,7 +1996,7 @@ public static LinkedList<ADDConnector> getAllADDConnectors(){
             // AVATAR RD
         case AVATARRD_DERIVE_CONNECTOR:
             tgc = new AvatarRDDeriveConnector(x, y, tdp.getMinX(), tdp.getMaxX(), tdp.getMinY(), tdp.getMaxY(), false, null, tdp, p1, p2, listPoint);
-	    break;
+            break;
         case AVATARRD_SATISFY_CONNECTOR:
             tgc = new AvatarRDSatisfyConnector(x, y, tdp.getMinX(), tdp.getMaxX(), tdp.getMinY(), tdp.getMaxY(), false, null, tdp, p1, p2, listPoint);
             break;
@@ -2029,9 +2029,9 @@ public static LinkedList<ADDConnector> getAllADDConnectors(){
             // AVATAR DD
         case ADD_CONNECTOR:
             tgc = new ADDConnector(x, y, tdp.getMinX(), tdp.getMaxX(), tdp.getMinY(), tdp.getMaxY(), false, null, tdp, p1, p2, listPoint);
-	    //DG 21.02.
-	    
-addconnectors.add((ADDConnector)tgc);//DG 21.02.
+            //DG 21.02.
+
+            addconnectors.add((ADDConnector)tgc);//DG 21.02.
             break;
 
             // AVATAR PD
diff --git a/src/ui/TURTLEModelingDrawer.java b/src/ui/TURTLEModelingDrawer.java
index 10139026233e44a3712913150f66470e034cecf2..1c2db407c9c0e106cb4d01a78621dd6c221e8b9b 100755
--- a/src/ui/TURTLEModelingDrawer.java
+++ b/src/ui/TURTLEModelingDrawer.java
@@ -59,7 +59,7 @@ public class TURTLEModelingDrawer {
     private DesignPanel dp;
     private Vector telements;
     private Vector gelements;
-    
+
     private double radius;
     private double centerX;
     private double centerY;
@@ -67,13 +67,13 @@ public class TURTLEModelingDrawer {
     public TURTLEModelingDrawer(MainGUI _mgui) {
         mgui = _mgui;
     }
-    
+
     public void setTURTLEModeling(TURTLEModeling _tm) {
         tm = _tm;
         //tm.simplify(true, false);
         //tm.countJunctions();
     }
-    
+
     public boolean draw(int designNb) {
         telements = new Vector();
         gelements = new Vector();
@@ -89,13 +89,13 @@ public class TURTLEModelingDrawer {
             drawRelations();
             //System.out.println("all done");
         } catch (MalformedTURTLEModelingException mtm) {
-        	System.out.println(mtm.getMessage());
+            System.out.println(mtm.getMessage());
             return false;
         }
-        
+
         return true;
     }
-    
+
     private void addDesign(int designNb) throws MalformedTURTLEModelingException {
         indexDesign = mgui.createDesign("Generated Design " + designNb);
         //System.out.println("indexDesign=" + indexDesign);
@@ -107,21 +107,21 @@ public class TURTLEModelingDrawer {
         } catch (Exception e) {
             throw new MalformedTURTLEModelingException("design panel not found");
         }
-        
+
         dp.tcdp.setMinX(10);
         dp.tcdp.setMaxX(1900);
         dp.tcdp.setMinY(10);
         dp.tcdp.setMaxY(900);
         //dp.tcdp.updateSize();
     }
-    
+
     private void drawTClasses() throws MalformedTURTLEModelingException {
         TClass t;
         int total = tm.classNb();
         radius = 200 + 30 * total;
         centerX = radius + 50;
         centerY = radius + 50;
-        
+
         int maxX = 1900;
         int maxY = 900;
         while(maxX < (radius *2 + 200)) {
@@ -133,47 +133,47 @@ public class TURTLEModelingDrawer {
             dp.tcdp.setMaxY(maxY);
         }
         dp.tcdp.updateSize();
-        
+
         for(int i=0; i<total; i++) {
             drawTClass(tm.getTClassAtIndex(i), i, total);
         }
     }
-    
+
     private void drawTClass(TClass t, int index, int total) throws MalformedTURTLEModelingException {
         // Calculate where the class should be added
         // We use a circle to dipose classes
         double angle = 2*Math.PI*index/total;
         int myX = (int)(Math.cos(angle)*radius + centerX);
         int myY = (int)(Math.sin(angle)*radius + centerY);
-        
+
         // Creating tclass
         TGComponent tgc = TGComponentManager.addComponent(myX, myY, TGComponentManager.TCD_TCLASS, dp.tcdp);
         TCDTClass tcd = (TCDTClass)tgc;
-        
+
         telements.add(t);
         gelements.add(tgc);
-        
+
         // setting tclass properties
         tgc.setValue(t.getName());
         tgc.setValueWithChange(t.getName());
         tcd.setStart(t.isActive());
-        
+
         // Adding tclass to the diagram
         dp.tcdp.addBuiltComponent(tgc);
         tcd.recalculateSize();
-        
+
         // Managing gates
         addAttributes(t, tcd);
         addGates(t, tcd);
         tcd.checkSizeOfSons();
     }
-    
+
     public void addAttributes(TClass t, TCDTClass tcd) throws MalformedTURTLEModelingException {
         Vector params = t.getParamList();
         LinkedList<TAttribute> attributes = new LinkedList<TAttribute> ();
         Param p;
         TAttribute ta;
-        
+
         for(int i=0; i<params.size(); i++) {
             p = (Param)(params.elementAt(i));
             ta = null;
@@ -190,32 +190,32 @@ public class TURTLEModelingDrawer {
                 attributes.add(ta);
             }
         }
-        
+
         tcd.setAttributes(attributes);
     }
-    
+
     public void addGates(TClass t, TCDTClass tcd) throws MalformedTURTLEModelingException {
         Vector tmgates = t.getGateList();
         LinkedList<TAttribute> gates = new LinkedList<TAttribute> ();
         Gate g;
         TAttribute ta;
-        
+
         for(int i=0; i<tmgates.size(); i++) {
             g = (Gate)(tmgates.elementAt(i));
             ta = new TAttribute(TAttribute.PUBLIC, g.getName(), "", g.getType()+1);
             gates.add(ta);
         }
-        
+
         tcd.setGates(gates);
     }
-    
+
     private void drawActivityDiagrams()  throws MalformedTURTLEModelingException {
         int total = tm.classNb();
         for(int i=0; i<total; i++) {
             drawActivityDiagram(tm.getTClassAtIndex(i));
         }
     }
-    
+
     private void drawActivityDiagram(TClass t) throws MalformedTURTLEModelingException {
         ActivityDiagram ad = t.getActivityDiagram();
         ADStart ads = ad.getStartState();
@@ -225,7 +225,7 @@ public class TURTLEModelingDrawer {
         makeADOf(ads, tadp, null, 0, 0);
         tadp.makeGraphicalOptimizations();
     }
-    
+
     private void makeADOf(ADComponent adc, TActivityDiagramPanel tadp, TGComponent previous, int indexNext, int totalNext) throws MalformedTURTLEModelingException {
         // Check if component has already been computed
         if (telements.contains(adc)) {
@@ -238,7 +238,7 @@ public class TURTLEModelingDrawer {
             }
             return;
         }
-        
+
         // make component from adc
         //System.out.println("Make component");
         TGComponent tgc = addToAD(adc, tadp);
@@ -246,37 +246,37 @@ public class TURTLEModelingDrawer {
             System.out.println("null component");
             throw new MalformedTURTLEModelingException("null component");
         }
-        
+
         // Adding component
         tadp.addBuiltComponent(tgc);
         telements.add(adc);
         gelements.add(tgc);
-        
+
         // Linking component to the previous one
         if (!(tgc instanceof TADStartState)) {
             TGConnector tgco = connectAD(tgc, previous, tadp, true, indexNext, totalNext);
             tadp.addBuiltConnector(tgco);
         }
-        
+
         // Managing nexts of this component
         ADComponent nextAdc;
         for(int i=0; i<adc.getNbNext(); i++) {
             makeADOf(adc.getNext(i), tadp, tgc, i, adc.getNbNext());
         }
     }
-    
+
     public TGComponent addToAD(ADComponent adc, TDiagramPanel tadp) throws MalformedTURTLEModelingException {
         int i;
-        
+
         if (adc instanceof ADActionStateWithGate) {
             ADActionStateWithGate adasw = (ADActionStateWithGate)adc;
             TADActionState tadas = (TADActionState)(TGComponentManager.addComponent(10, 10, TGComponentManager.TAD_ACTION_STATE, tadp));
-			//System.out.println("action = " + adasw.getActionValue()
-			try {
-				tadas.setValue(adasw.getGate().getName() + adasw.getLimitOnGate() + adasw.getActionValue());
-			} catch (Exception e) {
-				tadas.setValue("Unknown gate");
-			}
+            //System.out.println("action = " + adasw.getActionValue()
+            try {
+                tadas.setValue(adasw.getGate().getName() + adasw.getLimitOnGate() + adasw.getActionValue());
+            } catch (Exception e) {
+                tadas.setValue("Unknown gate");
+            }
             return tadas;
         } else if(adc instanceof ADActionStateWithMultipleParam) {
             ADActionStateWithMultipleParam adawp = ((ADActionStateWithMultipleParam)adc);
@@ -286,19 +286,19 @@ public class TURTLEModelingDrawer {
         } else if(adc instanceof ADActionStateWithParam) {
             ADActionStateWithParam adawp = ((ADActionStateWithParam)adc);
             TADActionState tadas = (TADActionState)(TGComponentManager.addComponent(10, 10, TGComponentManager.TAD_ACTION_STATE, tadp));
-			try {
-				//System.out.println("name = " + adawp.getParam().getName());
-				//System.out.println("action=" + adawp.getActionValue());
-				tadas.setValue(adawp.getParam().getName() + " = " + adawp.getActionValue());
-			} catch (Exception e) {
-				tadas.setValue("unknown = unknown");
-			}
+            try {
+                //System.out.println("name = " + adawp.getParam().getName());
+                //System.out.println("action=" + adawp.getActionValue());
+                tadas.setValue(adawp.getParam().getName() + " = " + adawp.getActionValue());
+            } catch (Exception e) {
+                tadas.setValue("unknown = unknown");
+            }
             return tadas;
         } else if (adc instanceof ADChoice) {
             TADChoice tadc = (TADChoice)(TGComponentManager.addComponent(10, 10, TGComponentManager.TAD_CHOICE, tadp));
             /*if (adc.getNbNext() > 3) {
-               System.out.println("Malformed choice... : TOO MANY next");
-            }*/
+              System.out.println("Malformed choice... : TOO MANY next");
+              }*/
             for(i=0; i<3; i++) {
                 if (((ADChoice)(adc)).isGuarded(i)) {
                     tadc.setGuard(((ADChoice)adc).getGuard(i), i);
@@ -344,66 +344,66 @@ public class TURTLEModelingDrawer {
             adti.setMaxValue(((ADTimeInterval)adc).getMaxValue());
             return adti;
         }
-        
+
         System.out.println("adc = " + adc);
         throw new MalformedTURTLEModelingException("unknown component ->"+adc);
     }
-    
+
     public TGConnector connectAD(TGComponent tgc, TGComponent previous, TActivityDiagramPanel tadp, boolean move, int indexNext, int totalNext) throws MalformedTURTLEModelingException {
         boolean makeSquare = true;
         int index = -1;
-        
+
         // Find TGconnectingPoints
-        
+
         //P1
         TGConnectingPoint p1 = null;
-        
+
         if ((previous instanceof TADParallel) || (previous instanceof TADPreemption) || (previous instanceof TADSequence)) {
             switch(totalNext) {
-                case 1:
-                    index=7;
+            case 1:
+                index=7;
+                break;
+            case 2:
+                switch(indexNext) {
+                case 0:
+                    index = 6;
                     break;
-                case 2:
-                    switch(indexNext) {
-                        case 0:
-                            index = 6;
-                            break;
-                        default:
-                            index = 8;
-                            break;
-                    }
+                default:
+                    index = 8;
                     break;
-                case 3:
-                    switch(indexNext) {
-                        case 0:
-                            index = 5;
-                            break;
-                        case 1:
-                            index = 7;
-                            break;
-                        default:
-                            index = 9;
-                            break;
-                    }
+                }
+                break;
+            case 3:
+                switch(indexNext) {
+                case 0:
+                    index = 5;
+                    break;
+                case 1:
+                    index = 7;
                     break;
                 default:
+                    index = 9;
+                    break;
+                }
+                break;
+            default:
             }
         }
-        
+
         if ((index != -1) && ((previous instanceof TADPreemption) || (previous instanceof TADSequence))) {
             index = index - 4;
         }
-        
+
         if (index > -1 ) {
             p1 = previous.tgconnectingPointAtIndex(index);
         } else {
             p1 = previous.findFirstFreeTGConnectingPoint(true, false);
         }
-        
+
         if (p1 == null) {
             throw new MalformedTURTLEModelingException("p1 connecting point not found");
         }
-        
+
         TGConnectingPoint p2 = null;
         if (tgc instanceof TADJunction) {
             if (tgc.tgconnectingPointAtIndex(0).isFree()) {
@@ -414,12 +414,12 @@ public class TURTLEModelingDrawer {
         } else {
             p2 = tgc.findFirstFreeTGConnectingPoint(false, true);
         }
-        
-        
+
+
         if (p2 == null) {
             throw new MalformedTURTLEModelingException("p2 connecting point not found on component:" + tgc);
         }
-        
+
         // Move tgc component according to points
         if (move) {
             int decX = 0;
@@ -434,13 +434,13 @@ public class TURTLEModelingDrawer {
                 }
                 decY = 20;
             }
-            
+
             if (previous instanceof TADTimeLimitedOfferWithLatency) {
                 if (p1 == previous.tgconnectingPointAtIndex(2)) {
                     decX = 50;
                 }
             }
-            
+
             if ((previous instanceof TADSequence) || (previous instanceof TADPreemption)) {
                 makeSquare = false;
                 if (p1 == previous.tgconnectingPointAtIndex(1)) {
@@ -457,7 +457,7 @@ public class TURTLEModelingDrawer {
                 }
                 decY = 20;
             }
-            
+
             if (previous instanceof TADParallel) {
                 makeSquare = false;
                 if (p1 == previous.tgconnectingPointAtIndex(5)) {
@@ -474,37 +474,37 @@ public class TURTLEModelingDrawer {
                 }
                 decY = 20;
             }
-            
+
             decX = Math.max(p1.getX() - p2.getX() + tgc.getX() + decX, tadp.getMinX());
             decY = Math.max(p1.getY() - p2.getY() + tgc.getY() + decY, tadp.getMinY());
-            
+
             if (decX > tadp.getMaxX()) {
                 tadp.setMaxX(tadp.getMaxX() + 500);
                 tadp.updateSize();
             }
-            
+
             if (decY > tadp.getMaxY()) {
                 //System.out.println("Increasing vertical size");
                 tadp.setMaxY(tadp.getMaxY() + 500);
                 tadp.updateSize();
             }
-            
+
             tgc.setMoveCd(decX, decY);
         }
-        
+
         // Connect both points
         p1.setFree(false);
         p2.setFree(false);
-        
+
         TGConnector tgco = TGComponentManager.addConnector(p1.x, p1.y, TGComponentManager.CONNECTOR_AD_DIAGRAM, tadp, p1, p2, new Vector());
-        
+
         if (makeSquare) {
             tgco.makeSquareWithoutMovingTGComponents();
         }
-        
+
         return tgco;
     }
-    
+
     private void drawRelations()  throws MalformedTURTLEModelingException {
         Relation r;
         for(int i = 0; i < tm.relationNb(); i++) {
@@ -512,26 +512,26 @@ public class TURTLEModelingDrawer {
             drawRelation(r);
         }
     }
-    
+
     private void drawRelation(Relation r) throws MalformedTURTLEModelingException {
         // Identify invloved TClasses
         int index1 = telements.indexOf(r.t1);
         int index2 = telements.indexOf(r.t2);
-        
+
         if ((index1 <0) ||(index2 <0)) {
             throw new MalformedTURTLEModelingException("relation with no tclasses");
         }
-        
+
         try {
             TCDTClass t1 = (TCDTClass)(gelements.elementAt(index1));
             TCDTClass t2 = (TCDTClass)(gelements.elementAt(index2));
-            
+
             // Make connector
             //System.out.println("Make association between " + t1.getValue() + " and " + t2.getValue());
             TGConnector tgco = makeAssociation(r, t1, t2);
             tgco.makeSquareWithoutMovingTGComponents();
             dp.tcdp.addBuiltConnector(tgco);
-            
+
             // Add relation semantics to connector (and gates if necessary)
             TGComponent operator = makeSemantics(r, tgco, t1, t2);
             if ((r.type == Relation.SYN) || (r.type == Relation.INV)) {
@@ -540,13 +540,13 @@ public class TURTLEModelingDrawer {
         } catch (Exception e) {
             throw new MalformedTURTLEModelingException("error happened when making a relation");
         }
-        
+
     }
-    
+
     private TGConnector makeAssociation(Relation r, TCDTClass t1, TCDTClass t2) throws MalformedTURTLEModelingException {
         TGConnectingPoint p1 = t1.closerFreeTGConnectingPoint(t2.getX(), t2.getY());
         TGConnectingPoint p2 = t2.closerFreeTGConnectingPoint(t1.getX(), t1.getY());
-        
+
         if ((p1 != null) && (p2 != null)) {
             p1.setFree(false);
             p2.setFree(false);
@@ -556,56 +556,56 @@ public class TURTLEModelingDrawer {
                 return TGComponentManager.addConnector(p1.x, p1.y, TGComponentManager.CONNECTOR_ASSOCIATION, dp.tcdp, p1, p2, new Vector());
             }
         }
-        
+
         return null;
     }
-    
-    
+
+
     private TGComponent makeSemantics(Relation r, TGConnector tgco, TCDTClass t1, TCDTClass t2) throws MalformedTURTLEModelingException {
         // has at leat 3 tgconnecting points -> take the one in thne middle
         TGConnectingPoint pt;
         if (tgco.getNbConnectingPoint() < 1) {
             throw new MalformedTURTLEModelingException("No connecting point");
         }
-        
+
         pt = tgco.getTGConnectingPointAtIndex(Math.min(1, tgco.getNbConnectingPoint()-1));
-        
+
         TGComponent operator = null;
         int type = 0;
         // Add a operator corresponding to the relation semantics
         switch(r.type) {
-            case   Relation.PAR:
-                type = TGComponentManager.TCD_PARALLEL_OPERATOR;
-                break;
-            case Relation.SYN:
-                type = TGComponentManager.TCD_SYNCHRO_OPERATOR;
-                break;
-            case Relation.INV:
-                type = TGComponentManager.TCD_INVOCATION_OPERATOR;
-                break;
-            case Relation.SEQ:
-                type = TGComponentManager.TCD_SEQUENCE_OPERATOR;
-                break;
-            case Relation.PRE:
-                type = TGComponentManager.TCD_PREEMPTION_OPERATOR;
-                break;
-            default:
-                type = -1;
+        case   Relation.PAR:
+            type = TGComponentManager.TCD_PARALLEL_OPERATOR;
+            break;
+        case Relation.SYN:
+            type = TGComponentManager.TCD_SYNCHRO_OPERATOR;
+            break;
+        case Relation.INV:
+            type = TGComponentManager.TCD_INVOCATION_OPERATOR;
+            break;
+        case Relation.SEQ:
+            type = TGComponentManager.TCD_SEQUENCE_OPERATOR;
+            break;
+        case Relation.PRE:
+            type = TGComponentManager.TCD_PREEMPTION_OPERATOR;
+            break;
+        default:
+            type = -1;
         }
-        
+
         // Add operator if non null
         if (type == -1) {
             throw new MalformedTURTLEModelingException("Unknown relation type");
         }
-        
+
         // Is the line horizontal or vertical?
         boolean vertical = true ;
         if (tgco.isPtOnVerticalSegment(pt)) {
             vertical = false;
         }
-        
+
         int myX, myY;
-        
+
         if (vertical) {
             myX = pt.getX() - 50;
             myY = pt.getY() - 100;
@@ -613,34 +613,34 @@ public class TURTLEModelingDrawer {
             myX = pt.getX() + 75;
             myY = pt.getY() - 12;
         }
-        
+
         operator = TGComponentManager.addComponent(myX, myY, type, dp.tcdp);
         telements.add(r);
         gelements.add(operator);
         dp.tcdp.addBuiltComponent(operator);
-        
+
         TGConnectingPoint pop;
         if (vertical) {
             pop = operator.getTGConnectingPointAtIndex(2);
         } else {
             pop = operator.getTGConnectingPointAtIndex(0);
         }
-        
+
         // Connects the connector to the operator
         pt.setFree(false);
         pop.setFree(false);
         TGConnector dashco = TGComponentManager.addConnector(pt.x, pt.y, TGComponentManager.CONNECTOR_ATTRIBUTE, dp.tcdp, pt, pop, new Vector());
         //dashco.makeSquareWithoutMovingTGComponents();
         dp.tcdp.addBuiltConnector(dashco);
-        
+
         if (operator instanceof TCDCompositionOperatorWithSynchro) {
             ((TCDCompositionOperatorWithSynchro)(operator)).structureChanged();
         }
-        
+
         return operator;
-        
+
     }
-    
+
     // If invocation / synchro -> set synchronization gates
     public void makeGates(TGComponent operator, Relation r, TCDTClass t1, TCDTClass t2)  throws MalformedTURTLEModelingException {
         LinkedList<TTwoAttributes> gates = null;
@@ -649,11 +649,11 @@ public class TURTLEModelingDrawer {
         Gate g1, g2;
         try {
             gates = ((TCDCompositionOperatorWithSynchro)operator).getGates();
-            
+
         } catch (Exception e){
             throw new MalformedTURTLEModelingException("Gates of synchro relation may not be set");
         }
-        
+
         for(int i=0; i<r.gatesOfT1.size(); i++) {
             g1 = (Gate)(r.gatesOfT1.elementAt(i));
             g2 = (Gate)(r.gatesOfT2.elementAt(i));
@@ -662,29 +662,29 @@ public class TURTLEModelingDrawer {
             tt = new TTwoAttributes(t1, t2, ta1, ta2);
             gates.add(tt);
         }
-        
+
         ((TCDCompositionOperatorWithSynchro)operator).getSynchroGateList().makeValue();
-        
+
     }
-    
+
     public void makeDrawable() {
         tm.unmergeChoices();
-		
+
         TClass t;
         for(int i=0; i<tm.classNb(); i++) {
             t = tm.getTClassAtIndex(i);
             makeDrawable(t.getActivityDiagram(), false);
         }
     }
-    
+
     public int makeDrawable(ActivityDiagram ad, boolean debug) {
         ADComponent adc, adc1;
         ADJunction adj1, adj2 = null;
         int i=0;
-        
+
         while(i<ad.size()) {
             adc = (ADComponent)(ad.elementAt(i));
-            
+
             // Ensure that at most 3 elements lead to a junction -> if more, remove one
             if (adc instanceof ADJunction) {
                 adj1 = (ADJunction)adc;
@@ -712,9 +712,9 @@ public class TURTLEModelingDrawer {
                     adc1.updateNext(adj1, adj2);
                     return makeDrawable(ad, debug);
                 }
-            }      
+            }
             i++;
-        }   
+        }
         return 0;
     }
 }
diff --git a/src/ui/tmlad/TMLADReadRequestArg.java b/src/ui/tmlad/TMLADReadRequestArg.java
index dd1426a0d225c7dabcf07d5551cc22bf3bd5c80e..122caeafaf0f31140dade50c76abe001f3a39c3a 100755
--- a/src/ui/tmlad/TMLADReadRequestArg.java
+++ b/src/ui/tmlad/TMLADReadRequestArg.java
@@ -117,6 +117,9 @@ public class TMLADReadRequestArg extends TGCWithoutInternalComponent implements
 	public int nbOfParams() {
 		return nParam;
 	}
+	public void setParam(int i, String s){
+		params[i] = s;
+	}
 	
 	public String getRealParamValue(int index) {
 		int cpt = 0;
diff --git a/src/ui/tmlad/TMLADSendRequest.java b/src/ui/tmlad/TMLADSendRequest.java
index 2bcefc2fcf1ad48d3dbda2aab8a1a45309c3e39c..bf7d398ea0d6ccc989a7a79d568f7a7de3a744aa 100755
--- a/src/ui/tmlad/TMLADSendRequest.java
+++ b/src/ui/tmlad/TMLADSendRequest.java
@@ -214,10 +214,19 @@ public class TMLADSendRequest extends TGCWithoutInternalComponent implements Che
         return requestName;
     }
 
+
+	public void setRequestName(String name){
+		requestName=name;
+		makeValue();
+	}	
+
     public String getParamValue(int i) {
         return params[i];
     }
 
+	public void setParam(int i, String s){
+		params[i]=s;
+	}
     public int nbOfParams() {
         return nParam;
     }
diff --git a/src/ui/tmlcompd/TMLCPrimitivePort.java b/src/ui/tmlcompd/TMLCPrimitivePort.java
index 28c5a81a51c9d8ab265b6e8bb3c6e29b88e2c7e3..0930a73f5795cfe477b6ad97fa53e288d3d1d344 100755
--- a/src/ui/tmlcompd/TMLCPrimitivePort.java
+++ b/src/ui/tmlcompd/TMLCPrimitivePort.java
@@ -795,6 +795,9 @@ public abstract class TMLCPrimitivePort extends TGCScalableWithInternalComponent
     public TType getParamAt(int index) {
         return list[index];
     }
+	public void setParam(int index, TType t){
+		list[index] = t;
+	}
 
     public int getDefaultConnector() {
         return TGComponentManager.CONNECTOR_PORT_TMLC;
diff --git a/src/ui/tmldd/TMLArchiBUSNode.java b/src/ui/tmldd/TMLArchiBUSNode.java
index fb5e040b3e7045a2d0e65a315f3fde30806257f9..089cf122c1b98c89b8460abd876c9846f44d9461 100755
--- a/src/ui/tmldd/TMLArchiBUSNode.java
+++ b/src/ui/tmldd/TMLArchiBUSNode.java
@@ -399,6 +399,10 @@ public class TMLArchiBUSNode extends TMLArchiCommunicationNode implements Swallo
         return privacy;
     }
 
+
+    public void setPrivacy(int p){
+        privacy=p;
+    }
     public String getAttributes() {
         String attr = "";
         attr += "Data size (in byte) = " + byteDataSize + "\n";
diff --git a/src/ui/window/JDialogDSE.java b/src/ui/window/JDialogDSE.java
index 287e1774daff0f9043340e5eb669531f2fc8af4a..d1017e4b106ece9d1368c064230f6749937caf88 100644
--- a/src/ui/window/JDialogDSE.java
+++ b/src/ui/window/JDialogDSE.java
@@ -91,8 +91,8 @@ public class JDialogDSE extends javax.swing.JDialog implements ActionListener, R
 
     protected JCheckBox autoConf, autoAuth, autoMapKeys, custom, outputTXT, outputHTML, addHSM;
 
-    protected JTextField encTime, decTime, secOverhead;
-
+    protected JTextField encTime, decTime, secOverhead, addToComp;
+	String compName="";
     protected JTextField tmlDirectory, mappingFile, modelFile, simulationThreads, resultsDirectory, simulationCycles, minCPU, maxCPU, simulationsPerMapping;
     protected JTextArea outputText;
     protected String output = "";
@@ -186,6 +186,11 @@ public class JDialogDSE extends javax.swing.JDialog implements ActionListener, R
         addHSM = new JCheckBox("Add HSM");
         jp01.add(addHSM,c01);
 
+		jp01.add(new JLabel("Add HSM to component:"),c01);
+        addToComp = new JTextField(compName);
+        jp01.add(addToComp,c01);
+
+
         custom = new JCheckBox("Custom performance attributes");
         jp01.add(custom,c01);
 
@@ -597,6 +602,7 @@ public class JDialogDSE extends javax.swing.JDialog implements ActionListener, R
 	Nbsim = simulationsPerMapping.getText();
 	encCC = encTime2.getText();
 	decCC = decTime2.getText();
+	compName=addToComp.getText();
 	secAnalysisState = secAnalysis.isSelected();
 	secOv = secOverhead2.getText();
 	outputTXTState = outputTXT.isSelected();
@@ -709,7 +715,7 @@ public class JDialogDSE extends javax.swing.JDialog implements ActionListener, R
                 }
             }
 			else if (addHSM.isSelected()){
-				mgui.gtm.addHSM(mgui, "comp0");
+				mgui.gtm.addHSM(mgui, addToComp.getText());
 			}
             if (autoMapKeys.isSelected()){
                 mgui.gtm.autoMapKeys();