Bug 498308: RTS library loaded twice by codegen

Change-Id: I0455b93699c21e6b1777d65b3e164d31dd1d69e6
Signed-off-by: Ernesto Posse <eposse@gmail.com>
diff --git a/models/samples/ComputerSystem/expected_src/CMakeLists.txt b/models/samples/ComputerSystem/expected_src/CMakeLists.txt
index aa9d4f4..cbd6a9f 100644
--- a/models/samples/ComputerSystem/expected_src/CMakeLists.txt
+++ b/models/samples/ComputerSystem/expected_src/CMakeLists.txt
@@ -1,4 +1,4 @@
-# Generated 2016-07-20 11:17:23
+# Generated 2016-07-21 17:59:04
 
 cmake_minimum_required(VERSION 2.8.7)
 set(TARGET TopMain)
diff --git a/models/tests/PingPong-data/PingPong-data.uml b/models/tests/PingPong-data/PingPong-data.uml
index ec60c34..47c7d8d 100755
--- a/models/tests/PingPong-data/PingPong-data.uml
+++ b/models/tests/PingPong-data/PingPong-data.uml
@@ -1,43 +1,42 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <xmi:XMI xmi:version="20131001" xmlns:xmi="http://www.omg.org/spec/XMI/20131001" xmlns:RTCppProperties="http://www.eclipse.org/papyrus/umlrt/cppproperties" xmlns:UMLRealTime="http://www.eclipse.org/papyrus/umlrt" xmlns:UMLRealTimeStateMach="http://www.eclipse.org/papyrus/umlrt/statemachine" xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" xmlns:uml="http://www.eclipse.org/uml2/5.0.0/UML">
   <uml:Model xmi:id="_yKukYCSQEeS0XNKzoL660g" name="PingPong-data">
-    <packageImport xmi:type="uml:PackageImport" xmi:id="_yKukYSSQEeS0XNKzoL660g">
+    <packageImport xmi:id="_yKukYSSQEeS0XNKzoL660g">
       <importedPackage xmi:type="uml:Model" href="pathmap://UML_LIBRARIES/UMLPrimitiveTypes.library.uml#_0"/>
     </packageImport>
     <packagedElement xmi:type="uml:Class" xmi:id="_97ZrMCSSEeS0XNKzoL660g" name="Top" classifierBehavior="_C6h7EDnxEeSo2vxA1pB3zA" isActive="true">
-      <ownedAttribute xmi:type="uml:Property" xmi:id="_AkoIgCSZEeS0XNKzoL660g" name="pinger" visibility="protected" type="__EW3UCSSEeS0XNKzoL660g" aggregation="composite" association="_AkpWoCSZEeS0XNKzoL660g">
+      <ownedAttribute xmi:id="_AkoIgCSZEeS0XNKzoL660g" name="pinger" visibility="protected" type="__EW3UCSSEeS0XNKzoL660g" aggregation="composite" association="_AkpWoCSZEeS0XNKzoL660g">
         <lowerValue xmi:type="uml:LiteralInteger" xmi:id="_AkoIgSSZEeS0XNKzoL660g" value="1"/>
         <upperValue xmi:type="uml:LiteralUnlimitedNatural" xmi:id="_AkoIgiSZEeS0XNKzoL660g" value="1"/>
       </ownedAttribute>
-      <ownedAttribute xmi:type="uml:Property" xmi:id="_CRig0CSaEeS0XNKzoL660g" name="ponger" visibility="protected" type="_BMMGgCSTEeS0XNKzoL660g" aggregation="composite" association="_CRjH4CSaEeS0XNKzoL660g">
+      <ownedAttribute xmi:id="_CRig0CSaEeS0XNKzoL660g" name="ponger" visibility="protected" type="_BMMGgCSTEeS0XNKzoL660g" aggregation="composite" association="_CRjH4CSaEeS0XNKzoL660g">
         <lowerValue xmi:type="uml:LiteralInteger" xmi:id="_CRig0SSaEeS0XNKzoL660g"/>
         <upperValue xmi:type="uml:LiteralUnlimitedNatural" xmi:id="_CRig0iSaEeS0XNKzoL660g" value="1"/>
       </ownedAttribute>
       <ownedAttribute xmi:type="uml:Port" xmi:id="_-j4hcH_tEeS4qaq7ty9adQ" name="frame" visibility="private" aggregation="composite">
         <type xmi:type="uml:Collaboration" href="pathmap://UMLRTRTSLIB/UMLRT-RTS.uml#_TWVjwGtVEeSCmtGQ-V4nzg"/>
       </ownedAttribute>
-      <ownedConnector xmi:type="uml:Connector" xmi:id="_nfqtsCbyEeSBQ4h-CZj2Uw" name="Connector1">
-        <end xmi:type="uml:ConnectorEnd" xmi:id="_nfyCcCbyEeSBQ4h-CZj2Uw" partWithPort="_AkoIgCSZEeS0XNKzoL660g" role="_PQ_kMCbnEeSBQ4h-CZj2Uw">
+      <ownedConnector xmi:id="_nfqtsCbyEeSBQ4h-CZj2Uw" name="Connector1">
+        <end xmi:id="_nfyCcCbyEeSBQ4h-CZj2Uw" partWithPort="_AkoIgCSZEeS0XNKzoL660g" role="_PQ_kMCbnEeSBQ4h-CZj2Uw">
           <lowerValue xmi:type="uml:LiteralInteger" xmi:id="_nfyCcSbyEeSBQ4h-CZj2Uw" value="1"/>
           <upperValue xmi:type="uml:LiteralUnlimitedNatural" xmi:id="_nfyCcibyEeSBQ4h-CZj2Uw" value="1"/>
         </end>
-        <end xmi:type="uml:ConnectorEnd" xmi:id="_nfypgCbyEeSBQ4h-CZj2Uw" partWithPort="_CRig0CSaEeS0XNKzoL660g" role="_aXdiUCbnEeSBQ4h-CZj2Uw">
+        <end xmi:id="_nfypgCbyEeSBQ4h-CZj2Uw" partWithPort="_CRig0CSaEeS0XNKzoL660g" role="_aXdiUCbnEeSBQ4h-CZj2Uw">
           <lowerValue xmi:type="uml:LiteralInteger" xmi:id="_nfypgSbyEeSBQ4h-CZj2Uw" value="1"/>
           <upperValue xmi:type="uml:LiteralUnlimitedNatural" xmi:id="_nfypgibyEeSBQ4h-CZj2Uw" value="1"/>
         </end>
       </ownedConnector>
       <ownedBehavior xmi:type="uml:StateMachine" xmi:id="_C6h7EDnxEeSo2vxA1pB3zA" name="StateMachine1">
-        <region xmi:type="uml:Region" xmi:id="_DM9H0DnxEeSo2vxA1pB3zA" name="Region1">
-          <transition xmi:type="uml:Transition" xmi:id="_HknEkDnxEeSo2vxA1pB3zA" name="initial" source="_F4SFoDnxEeSo2vxA1pB3zA" target="_G6GH8DnxEeSo2vxA1pB3zA">
+        <region xmi:id="_DM9H0DnxEeSo2vxA1pB3zA" name="Region1">
+          <transition xmi:id="_HknEkDnxEeSo2vxA1pB3zA" name="initial" source="_F4SFoDnxEeSo2vxA1pB3zA" target="_G6GH8DnxEeSo2vxA1pB3zA">
             <effect xmi:type="uml:OpaqueBehavior" xmi:id="_DjVVEFYMEeSmi4Fyw18d0w" name="onInit" isAbstract="true">
               <language>C++</language>
-              <body>std::cout &lt;&lt; &quot;Top initialised!\n&quot;;
-
-UMLRTCapsuleId pongerId = frame.incarnate( ponger, Ponger );
-if( ! pongerId.isValid() )
+              <body>    std::cout &lt;&lt; &quot;Top initialised!\n&quot;;
+    UMLRTCapsuleId pongerId = frame.incarnate( ponger, Ponger );
+    if( ! pongerId.isValid() )
     context()->perror(&quot;ponger incarnate failed.&quot;);
-printf( &quot;incarnated ponger valid:%d @%p\n&quot;,
-           pongerId.isValid(), pongerId.getCapsule() );
+    printf( &quot;incarnated ponger valid:%d @%p\n&quot;,
+    pongerId.isValid(), pongerId.getCapsule() );
 </body>
             </effect>
           </transition>
@@ -52,39 +51,40 @@
         <type xmi:type="uml:Collaboration" href="pathmap://UMLRTRTSLIB/UMLRT-RTS.uml#_MxQZgGXsEeS_4daqvwyFrg"/>
       </ownedAttribute>
       <ownedBehavior xmi:type="uml:StateMachine" xmi:id="_aKvpECb0EeSBQ4h-CZj2Uw" name="Pinger_SM">
-        <region xmi:type="uml:Region" xmi:id="_ibsLkCb0EeSBQ4h-CZj2Uw" name="Region1">
-          <transition xmi:type="uml:Transition" xmi:id="_9D_DYCb1EeSBQ4h-CZj2Uw" name="initialise" source="_XswHMCb1EeSBQ4h-CZj2Uw" target="_lY5HECb1EeSBQ4h-CZj2Uw">
+        <region xmi:id="_ibsLkCb0EeSBQ4h-CZj2Uw" name="Region1">
+          <transition xmi:id="_9D_DYCb1EeSBQ4h-CZj2Uw" name="initialise" source="_XswHMCb1EeSBQ4h-CZj2Uw" target="_lY5HECb1EeSBQ4h-CZj2Uw">
             <effect xmi:type="uml:OpaqueBehavior" xmi:id="_GPufUFYLEeSmi4Fyw18d0w" name="onInit" isAbstract="true">
               <language>C++</language>
-              <body>std::cout &lt;&lt; &quot;Pinger initialised&quot; &lt;&lt; std::endl;
-timer.informIn( UMLRTTimespec( 2, 0 ) );</body>
+              <body>    std::cout &lt;&lt; &quot;Pinger initialised&quot; &lt;&lt; std::endl;
+    timer.informIn( UMLRTTimespec( 2, 0 ) );
+</body>
             </effect>
           </transition>
-          <transition xmi:type="uml:Transition" xmi:id="_9xGBACb1EeSBQ4h-CZj2Uw" name="onPong" source="_lY5HECb1EeSBQ4h-CZj2Uw" target="_lY5HECb1EeSBQ4h-CZj2Uw">
-            <ownedRule xmi:type="uml:Constraint" xmi:id="_y9GtMFYMEeSmi4Fyw18d0w" name="true">
+          <transition xmi:id="_9xGBACb1EeSBQ4h-CZj2Uw" name="onPong" source="_lY5HECb1EeSBQ4h-CZj2Uw" target="_lY5HECb1EeSBQ4h-CZj2Uw">
+            <ownedRule xmi:id="_y9GtMFYMEeSmi4Fyw18d0w" name="true">
               <specification xmi:type="uml:LiteralBoolean" xmi:id="_y9GtMVYMEeSmi4Fyw18d0w" value="true"/>
             </ownedRule>
             <effect xmi:type="uml:OpaqueBehavior" xmi:id="_XTukYCcPEeSlGd4okkPIfw" name="onPong" isAbstract="true">
               <language>C++</language>
-              <body>std::cout &lt;&lt; &quot;Pong received&quot; &lt;&lt; std::endl;
-timer.informIn( UMLRTTimespec( 2, 0 ) );
+              <body>    std::cout &lt;&lt; &quot;Pong received&quot; &lt;&lt; std::endl;
+    timer.informIn( UMLRTTimespec( 2, 0 ) );
 </body>
             </effect>
-            <trigger xmi:type="uml:Trigger" xmi:id="_byJF4CcOEeSlGd4okkPIfw" name="" event="_zFJ2YCS-EeS0XNKzoL660g" port="_PQ_kMCbnEeSBQ4h-CZj2Uw"/>
+            <trigger xmi:id="_byJF4CcOEeSlGd4okkPIfw" name="" event="_zFJ2YCS-EeS0XNKzoL660g" port="_PQ_kMCbnEeSBQ4h-CZj2Uw"/>
           </transition>
-          <transition xmi:type="uml:Transition" xmi:id="_4p71EGxxEeSWy5Y1YWzXfQ" name="onTimeout" source="_lY5HECb1EeSBQ4h-CZj2Uw" target="_lY5HECb1EeSBQ4h-CZj2Uw">
+          <transition xmi:id="_4p71EGxxEeSWy5Y1YWzXfQ" name="onTimeout" source="_lY5HECb1EeSBQ4h-CZj2Uw" target="_lY5HECb1EeSBQ4h-CZj2Uw">
             <effect xmi:type="uml:OpaqueBehavior" xmi:id="__I0kEGxxEeSWy5Y1YWzXfQ" name="onTimeout" isAbstract="true">
               <language>C++</language>
-              <body>static int * ptr = NULL;
-if( ! ptr )
-	ptr = new int( 0 );
-std::cout &lt;&lt; &quot;Sending Ping from timeout transition action&quot; &lt;&lt; std::endl;
-++*ptr;
-DataType1 dt = { one, 0, true, 3., ptr, 1.618f, &quot;hello&quot; };
-ping.ping( dt ).send();
+              <body>    static int * ptr = NULL;
+    if( ! ptr )
+    ptr = new int( 0 );
+    std::cout &lt;&lt; &quot;Sending Ping from timeout transition action&quot; &lt;&lt; std::endl;
+    ++*ptr;
+    DataType1 dt = { one, 0, true, 3., ptr, 1.618f, &quot;hello&quot; };
+    ping.ping( dt ).send();
 </body>
             </effect>
-            <trigger xmi:type="uml:Trigger" xmi:id="_B9aZUGx3EeSqHojLEIPEZQ" port="_cV5-wGxxEeSWy5Y1YWzXfQ">
+            <trigger xmi:id="_B9aZUGx3EeSqHojLEIPEZQ" port="_cV5-wGxxEeSWy5Y1YWzXfQ">
               <event xmi:type="uml:CallEvent" href="pathmap://UMLRTRTSLIB/UMLRT-RTS.uml#_IaEO8HDxEeSwWKwNKw1iAA"/>
             </trigger>
           </transition>
@@ -96,15 +96,16 @@
     <packagedElement xmi:type="uml:Class" xmi:id="_BMMGgCSTEeS0XNKzoL660g" name="Ponger" classifierBehavior="_ltVRwCcQEeSlGd4okkPIfw" isActive="true">
       <ownedAttribute xmi:type="uml:Port" xmi:id="_aXdiUCbnEeSBQ4h-CZj2Uw" name="pong" visibility="public" type="_bEbXYCS1EeS0XNKzoL660g" aggregation="composite" isBehavior="true" isConjugated="true"/>
       <ownedBehavior xmi:type="uml:StateMachine" xmi:id="_ltVRwCcQEeSlGd4okkPIfw" name="Ponger_SM">
-        <region xmi:type="uml:Region" xmi:id="_mjyYoCcQEeSlGd4okkPIfw" name="Region1">
-          <transition xmi:type="uml:Transition" xmi:id="_Cf6sUCcREeSlGd4okkPIfw" name="initial" source="_0s6PcCcQEeSlGd4okkPIfw" target="_1KbR4CcQEeSlGd4okkPIfw">
+        <region xmi:id="_mjyYoCcQEeSlGd4okkPIfw" name="Region1">
+          <transition xmi:id="_Cf6sUCcREeSlGd4okkPIfw" name="initial" source="_0s6PcCcQEeSlGd4okkPIfw" target="_1KbR4CcQEeSlGd4okkPIfw">
             <effect xmi:type="uml:OpaqueBehavior" xmi:id="__Obm0FYKEeSmi4Fyw18d0w" name="onInit" isAbstract="true">
               <language>C++</language>
-              <body>std::cout &lt;&lt; &quot;Ponger initialised&quot; &lt;&lt; std::endl;</body>
+              <body>    std::cout &lt;&lt; &quot;Ponger initialised&quot; &lt;&lt; std::endl;
+</body>
             </effect>
           </transition>
-          <transition xmi:type="uml:Transition" xmi:id="_DEnU0CcREeSlGd4okkPIfw" name="onPing" source="_1KbR4CcQEeSlGd4okkPIfw" target="_1KbR4CcQEeSlGd4okkPIfw">
-            <ownedRule xmi:type="uml:Constraint" xmi:id="_owLJsFYNEeSmi4Fyw18d0w" name="true">
+          <transition xmi:id="_DEnU0CcREeSlGd4okkPIfw" name="onPing" source="_1KbR4CcQEeSlGd4okkPIfw" target="_1KbR4CcQEeSlGd4okkPIfw">
+            <ownedRule xmi:id="_owLJsFYNEeSmi4Fyw18d0w" name="true">
               <specification xmi:type="uml:LiteralBoolean" xmi:id="_owLJsVYNEeSmi4Fyw18d0w" value="true"/>
             </ownedRule>
             <effect xmi:type="uml:OpaqueBehavior" xmi:id="_szp-wCcREeSlGd4okkPIfw" name="onPing" isAbstract="true">
@@ -122,14 +123,15 @@
 pong.pong().send();
 </body>
             </effect>
-            <trigger xmi:type="uml:Trigger" xmi:id="_mEy6ECcREeSlGd4okkPIfw" name="" event="_yIlgcCS-EeS0XNKzoL660g" port="_aXdiUCbnEeSBQ4h-CZj2Uw"/>
+            <trigger xmi:id="_mEy6ECcREeSlGd4okkPIfw" name="" event="_yIlgcCS-EeS0XNKzoL660g" port="_aXdiUCbnEeSBQ4h-CZj2Uw"/>
           </transition>
-          <transition xmi:type="uml:Transition" xmi:id="_6Q3f4OzUEeSSF9-rYvvBtA" name="onBound" source="_1KbR4CcQEeSlGd4okkPIfw" target="_1KbR4CcQEeSlGd4okkPIfw">
+          <transition xmi:id="_6Q3f4OzUEeSSF9-rYvvBtA" name="onBound" source="_1KbR4CcQEeSlGd4okkPIfw" target="_1KbR4CcQEeSlGd4okkPIfw">
             <effect xmi:type="uml:OpaqueBehavior" xmi:id="_TM3DYOzVEeSSF9-rYvvBtA" name="onBound">
               <language>C++</language>
-              <body>std::cout &lt;&lt; getName() &lt;&lt; &quot; onBound&quot; &lt;&lt; std::endl;</body>
+              <body>    std::cout &lt;&lt; getName() &lt;&lt; &quot; onBound&quot; &lt;&lt; std::endl;
+</body>
             </effect>
-            <trigger xmi:type="uml:Trigger" xmi:id="_NjHMoOzVEeSSF9-rYvvBtA" name="bound" port="_aXdiUCbnEeSBQ4h-CZj2Uw">
+            <trigger xmi:id="_NjHMoOzVEeSSF9-rYvvBtA" name="bound" port="_aXdiUCbnEeSBQ4h-CZj2Uw">
               <event xmi:type="uml:CallEvent" href="pathmap://UMLRTRTSLIB/UMLRT-RTS.uml#_PQtAwOzeEeSRtqCWFwOf8g"/>
             </trigger>
           </transition>
@@ -139,13 +141,13 @@
       </ownedBehavior>
     </packagedElement>
     <packagedElement xmi:type="uml:Association" xmi:id="_AkpWoCSZEeS0XNKzoL660g" name="A_top_pinger_1" visibility="protected" memberEnd="_AkpWoSSZEeS0XNKzoL660g _AkoIgCSZEeS0XNKzoL660g">
-      <ownedEnd xmi:type="uml:Property" xmi:id="_AkpWoSSZEeS0XNKzoL660g" name="top" type="_97ZrMCSSEeS0XNKzoL660g" association="_AkpWoCSZEeS0XNKzoL660g">
+      <ownedEnd xmi:id="_AkpWoSSZEeS0XNKzoL660g" name="top" type="_97ZrMCSSEeS0XNKzoL660g" association="_AkpWoCSZEeS0XNKzoL660g">
         <lowerValue xmi:type="uml:LiteralInteger" xmi:id="_AkpWoiSZEeS0XNKzoL660g" value="1"/>
         <upperValue xmi:type="uml:LiteralUnlimitedNatural" xmi:id="_AkpWoySZEeS0XNKzoL660g" value="1"/>
       </ownedEnd>
     </packagedElement>
     <packagedElement xmi:type="uml:Association" xmi:id="_CRjH4CSaEeS0XNKzoL660g" name="A_top_ponger_1" visibility="protected" memberEnd="_CRjH4SSaEeS0XNKzoL660g _CRig0CSaEeS0XNKzoL660g">
-      <ownedEnd xmi:type="uml:Property" xmi:id="_CRjH4SSaEeS0XNKzoL660g" name="top" type="_97ZrMCSSEeS0XNKzoL660g" association="_CRjH4CSaEeS0XNKzoL660g">
+      <ownedEnd xmi:id="_CRjH4SSaEeS0XNKzoL660g" name="top" type="_97ZrMCSSEeS0XNKzoL660g" association="_CRjH4CSaEeS0XNKzoL660g">
         <lowerValue xmi:type="uml:LiteralInteger" xmi:id="_CRjH4iSaEeS0XNKzoL660g" value="1"/>
         <upperValue xmi:type="uml:LiteralUnlimitedNatural" xmi:id="_CRjH4ySaEeS0XNKzoL660g" value="1"/>
       </ownedEnd>
@@ -153,11 +155,11 @@
     <packagedElement xmi:type="uml:Package" xmi:id="_AsGVkCSxEeS0XNKzoL660g" name="PingPongProtocol">
       <packagedElement xmi:type="uml:Collaboration" xmi:id="_bEbXYCS1EeS0XNKzoL660g" name="PingPongProtocol"/>
       <packagedElement xmi:type="uml:Interface" xmi:id="_P5bzsCS3EeS0XNKzoL660g" name="PingPongProtocol">
-        <ownedOperation xmi:type="uml:Operation" xmi:id="_wRxiECS5EeS0XNKzoL660g" name="pong"/>
+        <ownedOperation xmi:id="_wRxiECS5EeS0XNKzoL660g" name="pong"/>
       </packagedElement>
       <packagedElement xmi:type="uml:Interface" xmi:id="_s_Lv8CS5EeS0XNKzoL660g" name="PingPongProtocol~">
-        <ownedOperation xmi:type="uml:Operation" xmi:id="_k7sskCS3EeS0XNKzoL660g" name="ping">
-          <ownedParameter xmi:type="uml:Parameter" xmi:id="_NBLSYFmXEeSDPbT4aJ98QA" name="param" type="_e0UDgO-aEeSU0p2mD5v6Qg"/>
+        <ownedOperation xmi:id="_k7sskCS3EeS0XNKzoL660g" name="ping">
+          <ownedParameter xmi:id="_NBLSYFmXEeSDPbT4aJ98QA" name="param" type="_e0UDgO-aEeSU0p2mD5v6Qg"/>
         </ownedOperation>
       </packagedElement>
       <packagedElement xmi:type="uml:Interface" xmi:id="_xSYDcCS5EeS0XNKzoL660g" name="PingPongProtocolIO"/>
@@ -172,52 +174,52 @@
     <packagedElement xmi:type="uml:Usage" xmi:id="_yt4-MCTEEeS0XNKzoL660g" name="Ponger uses PingPong Protocol" client="_BMMGgCSTEeS0XNKzoL660g" supplier="_bEbXYCS1EeS0XNKzoL660g"/>
     <packagedElement xmi:type="uml:Usage" xmi:id="_zQ-dICTEEeS0XNKzoL660g" name="Pinger uses PingPong Protocol" client="__EW3UCSSEeS0XNKzoL660g" supplier="_bEbXYCS1EeS0XNKzoL660g"/>
     <packagedElement xmi:type="uml:DataType" xmi:id="_e0UDgO-aEeSU0p2mD5v6Qg" name="DataType1" visibility="package">
-      <ownedAttribute xmi:type="uml:Property" xmi:id="_x3HXYATVEeWFjb8h7DOpLA" name="field0_enum" type="_mygPsAmREeWONKxFDyE-2A"/>
-      <ownedAttribute xmi:type="uml:Property" xmi:id="_i7svoO-aEeSU0p2mD5v6Qg" name="field1_int">
+      <ownedAttribute xmi:id="_x3HXYATVEeWFjb8h7DOpLA" name="field0_enum" type="_mygPsAmREeWONKxFDyE-2A"/>
+      <ownedAttribute xmi:id="_i7svoO-aEeSU0p2mD5v6Qg" name="field1_int">
         <type xmi:type="uml:PrimitiveType" href="pathmap://UML_LIBRARIES/UMLPrimitiveTypes.library.uml#Integer"/>
       </ownedAttribute>
-      <ownedAttribute xmi:type="uml:Property" xmi:id="_oTHgQO-aEeSU0p2mD5v6Qg" name="field2_bool">
+      <ownedAttribute xmi:id="_oTHgQO-aEeSU0p2mD5v6Qg" name="field2_bool">
         <type xmi:type="uml:PrimitiveType" href="pathmap://UML_LIBRARIES/UMLPrimitiveTypes.library.uml#Boolean"/>
       </ownedAttribute>
-      <ownedAttribute xmi:type="uml:Property" xmi:id="_rr5Z8O-aEeSU0p2mD5v6Qg" name="field3_double">
+      <ownedAttribute xmi:id="_rr5Z8O-aEeSU0p2mD5v6Qg" name="field3_double">
         <type xmi:type="uml:PrimitiveType" href="pathmap://UML_LIBRARIES/UMLPrimitiveTypes.library.uml#Real"/>
       </ownedAttribute>
-      <ownedAttribute xmi:type="uml:Property" xmi:id="_nCjuwApeEeWG8bKvzQotIw" name="field4_ptr">
+      <ownedAttribute xmi:id="_nCjuwApeEeWG8bKvzQotIw" name="field4_ptr">
         <type xmi:type="uml:PrimitiveType" href="pathmap://UML_LIBRARIES/UMLPrimitiveTypes.library.uml#Integer"/>
       </ownedAttribute>
-      <ownedAttribute xmi:type="uml:Property" xmi:id="_f-IzwJUZEeWHaf1KPO8yqw" name="field5_freeform"/>
-      <ownedAttribute xmi:type="uml:Property" xmi:id="_22wxUJUZEeWHaf1KPO8yqw" name="field6_string">
+      <ownedAttribute xmi:id="_f-IzwJUZEeWHaf1KPO8yqw" name="field5_freeform"/>
+      <ownedAttribute xmi:id="_22wxUJUZEeWHaf1KPO8yqw" name="field6_string">
         <type xmi:type="uml:PrimitiveType" href="pathmap://UML_LIBRARIES/UMLPrimitiveTypes.library.uml#String"/>
       </ownedAttribute>
     </packagedElement>
     <packagedElement xmi:type="uml:Enumeration" xmi:id="_mygPsAmREeWONKxFDyE-2A" name="Enumeration1">
-      <ownedLiteral xmi:type="uml:EnumerationLiteral" xmi:id="_oRvN0AmREeWONKxFDyE-2A" name="one"/>
-      <ownedLiteral xmi:type="uml:EnumerationLiteral" xmi:id="_pJ4WwAmREeWONKxFDyE-2A" name="two"/>
+      <ownedLiteral xmi:id="_oRvN0AmREeWONKxFDyE-2A" name="one"/>
+      <ownedLiteral xmi:id="_pJ4WwAmREeWONKxFDyE-2A" name="two"/>
     </packagedElement>
-    <profileApplication xmi:type="uml:ProfileApplication" xmi:id="_ubQ9AFSIEeSJBo_pyoMAEg">
-      <eAnnotations xmi:type="ecore:EAnnotation" xmi:id="_uc2RYFSIEeSJBo_pyoMAEg" source="http://www.eclipse.org/uml2/2.0.0/UML">
+    <profileApplication xmi:id="_ubQ9AFSIEeSJBo_pyoMAEg">
+      <eAnnotations xmi:id="_uc2RYFSIEeSJBo_pyoMAEg" source="http://www.eclipse.org/uml2/2.0.0/UML">
         <references xmi:type="ecore:EPackage" href="http://www.eclipse.org/papyrus/umlrt#/"/>
       </eAnnotations>
-      <appliedProfile xmi:type="uml:Profile" href="pathmap://UML_RT_PROFILE/uml-rt.profile.uml#_1h74oEeVEeO0lv5O1DTHOQ"/>
+      <appliedProfile href="pathmap://UML_RT_PROFILE/uml-rt.profile.uml#_1h74oEeVEeO0lv5O1DTHOQ"/>
     </profileApplication>
-    <profileApplication xmi:type="uml:ProfileApplication" xmi:id="_uc7J4FSIEeSJBo_pyoMAEg">
-      <eAnnotations xmi:type="ecore:EAnnotation" xmi:id="_ufYoAFSIEeSJBo_pyoMAEg" source="http://www.eclipse.org/uml2/2.0.0/UML">
+    <profileApplication xmi:id="_uc7J4FSIEeSJBo_pyoMAEg">
+      <eAnnotations xmi:id="_ufYoAFSIEeSJBo_pyoMAEg" source="http://www.eclipse.org/uml2/2.0.0/UML">
         <references xmi:type="ecore:EPackage" href="http://www.eclipse.org/papyrus/umlrt/statemachine#/"/>
       </eAnnotations>
-      <appliedProfile xmi:type="uml:Profile" href="pathmap://UML_RT_PROFILE/UMLRealTimeSM-addendum.profile.uml#_KLcn0FDtEeOA4ecmvfqvaw"/>
+      <appliedProfile href="pathmap://UML_RT_PROFILE/UMLRealTimeSM-addendum.profile.uml#_KLcn0FDtEeOA4ecmvfqvaw"/>
     </profileApplication>
-    <profileApplication xmi:type="uml:ProfileApplication" xmi:id="_QKLlgJIpEeWrP_jM1JIb9w">
-      <eAnnotations xmi:type="ecore:EAnnotation" xmi:id="_V54BkKKjEeW-eLsWdYL8rQ" source="PapyrusVersion">
-        <details xmi:type="ecore:EStringToStringMapEntry" xmi:id="_V54BkaKjEeW-eLsWdYL8rQ" key="Version" value="0.0.11"/>
-        <details xmi:type="ecore:EStringToStringMapEntry" xmi:id="_V54BkqKjEeW-eLsWdYL8rQ" key="Comment" value=""/>
-        <details xmi:type="ecore:EStringToStringMapEntry" xmi:id="_V54Bk6KjEeW-eLsWdYL8rQ" key="Copyright" value=""/>
-        <details xmi:type="ecore:EStringToStringMapEntry" xmi:id="_V54BlKKjEeW-eLsWdYL8rQ" key="Date" value="2015-12-10"/>
-        <details xmi:type="ecore:EStringToStringMapEntry" xmi:id="_V54BlaKjEeW-eLsWdYL8rQ" key="Author" value=""/>
+    <profileApplication xmi:id="_QKLlgJIpEeWrP_jM1JIb9w">
+      <eAnnotations xmi:id="_V54BkKKjEeW-eLsWdYL8rQ" source="PapyrusVersion">
+        <details xmi:id="_V54BkaKjEeW-eLsWdYL8rQ" key="Version" value="0.0.11"/>
+        <details xmi:id="_V54BkqKjEeW-eLsWdYL8rQ" key="Comment" value=""/>
+        <details xmi:id="_V54Bk6KjEeW-eLsWdYL8rQ" key="Copyright" value=""/>
+        <details xmi:id="_V54BlKKjEeW-eLsWdYL8rQ" key="Date" value="2015-12-10"/>
+        <details xmi:id="_V54BlaKjEeW-eLsWdYL8rQ" key="Author" value=""/>
       </eAnnotations>
-      <eAnnotations xmi:type="ecore:EAnnotation" xmi:id="_QKMMkJIpEeWrP_jM1JIb9w" source="http://www.eclipse.org/uml2/2.0.0/UML">
+      <eAnnotations xmi:id="_QKMMkJIpEeWrP_jM1JIb9w" source="http://www.eclipse.org/uml2/2.0.0/UML">
         <references xmi:type="ecore:EPackage" href="http://www.eclipse.org/papyrus/umlrt/cppproperties#/"/>
       </eAnnotations>
-      <appliedProfile xmi:type="uml:Profile" href="pathmap://UMLRT_CPP/RTCppProperties.profile.uml#_vl5LALs8EeSTjNEQkASznQ"/>
+      <appliedProfile href="pathmap://UMLRT_CPP/RTCppProperties.profile.uml#_vl5LALs8EeSTjNEQkASznQ"/>
     </profileApplication>
   </uml:Model>
   <UMLRealTime:Capsule xmi:id="_xRIW4FSIEeSJBo_pyoMAEg" base_Class="__EW3UCSSEeS0XNKzoL660g"/>
diff --git a/models/tests/PingPong-data/expected_src/CMakeLists.txt b/models/tests/PingPong-data/expected_src/CMakeLists.txt
new file mode 100644
index 0000000..802ee34
--- /dev/null
+++ b/models/tests/PingPong-data/expected_src/CMakeLists.txt
@@ -0,0 +1,36 @@
+# Generated 2016-07-21 17:58:31
+
+cmake_minimum_required(VERSION 2.8.7)
+set(TARGET TopMain)
+project(${TARGET})
+
+# require location of supporting RTS
+if (NOT UMLRTS_ROOT)
+  if (DEFINED ENV{UMLRTS_ROOT})
+    set(UMLRTS_ROOT $ENV{UMLRTS_ROOT})
+  else ()
+    set(UMLRTS_ROOT ${CMAKE_CURRENT_SOURCE_DIR}/umlrt.rts)
+  endif ()
+endif ()
+
+# setup primary envars - provides tooling config
+include(${UMLRTS_ROOT}/build/buildenv.cmake)
+
+# model sources
+set(SRCS TopMain.cc PingPongProtocol.cc DataType1.cc Pinger.cc Ponger.cc Top.cc TopControllers.cc )
+
+# specify target
+add_executable(${TARGET} ${SRCS})
+
+# setup lib dependency support after defining TARGET
+include(${UMLRTS_ROOT}/build/rtslib.cmake)
+
+# compiler parameters
+set_target_properties(${TARGET} PROPERTIES COMPILE_OPTIONS "${COPTS}")
+set_target_properties(${TARGET} PROPERTIES COMPILE_DEFINITIONS "${CDEFS}")
+include_directories(${INCS})
+
+# linker parameters
+set_target_properties(${TARGET} PROPERTIES CMAKE_EXE_LINKER_FLAGS "${LOPTS}")
+target_link_libraries(${TARGET} ${LIBS})
+
diff --git a/models/tests/PingPong-data/expected_src/DataType1.cc b/models/tests/PingPong-data/expected_src/DataType1.cc
index 7723ec6..0a3f79f 100644
--- a/models/tests/PingPong-data/expected_src/DataType1.cc
+++ b/models/tests/PingPong-data/expected_src/DataType1.cc
@@ -44,7 +44,7 @@
     },
     {
         "field6_string",
-        &UMLRTType_ptr,
+        &UMLRTType_charptr,
         offsetof( DataType1, field6_string ),
         1,
         0
diff --git a/models/tests/PingPong-data/expected_src/MakefileTop.mk b/models/tests/PingPong-data/expected_src/MakefileTop.mk
index e07368e..2551f8b 100644
--- a/models/tests/PingPong-data/expected_src/MakefileTop.mk
+++ b/models/tests/PingPong-data/expected_src/MakefileTop.mk
@@ -29,7 +29,7 @@
 LD_LIBS:=$(foreach i, $(LD_LIBS), $(LD_LIB)$i)
 LD_PATHS:=$(foreach i, $(LD_PATHS), $(LD_LIBPATH)$i)
 
-SRCS = TopMain.cc DataType1.cc PingPongProtocol.cc Pinger.cc Ponger.cc Top.cc TopControllers.cc 
+SRCS = TopMain.cc PingPongProtocol.cc DataType1.cc Pinger.cc Ponger.cc Top.cc TopControllers.cc 
 OBJS = $(subst $(CC_EXT),$(OBJ_EXT),$(SRCS))
 
 MAIN = TopMain$(EXE_EXT)
diff --git a/models/tests/PingPong-data/expected_src/PingPongProtocol.cc b/models/tests/PingPong-data/expected_src/PingPongProtocol.cc
index b79e171..cb7df26 100644
--- a/models/tests/PingPong-data/expected_src/PingPongProtocol.cc
+++ b/models/tests/PingPong-data/expected_src/PingPongProtocol.cc
@@ -8,12 +8,21 @@
 
 static UMLRTObject_field fields_pong[] = 
 {
+#ifdef NEED_NON_FLEXIBLE_ARRAY
+    {
+        0,
+        0,
+        0,
+        0,
+        0
+    },
+#endif
 };
 
 static UMLRTObject payload_pong = 
 {
     0,
-    0,
+    1,
     fields_pong
 };
 
diff --git a/models/tests/PingPong-data/expected_src/Pinger.cc b/models/tests/PingPong-data/expected_src/Pinger.cc
index 28a16b7..5345e4a 100644
--- a/models/tests/PingPong-data/expected_src/Pinger.cc
+++ b/models/tests/PingPong-data/expected_src/Pinger.cc
@@ -87,36 +87,28 @@
 
 void Capsule_Pinger::transitionaction_____PingPong_data__Pinger__Pinger_SM__Region1__initialise__onInit( const UMLRTMessage * msg )
 {
-    // the following code has been generated
-    /* UMLRT-CODEGEN:platform:/resource/PingPong-data/PingPong-data.uml#_GPufUFYLEeSmi4Fyw18d0w */
     #define rtdata ( (void *)msg->getParam( 0 ) )
-    // generated code ends
+    /* UMLRTGEN-USERREGION-BEGIN platform:/resource/PingPong-data/PingPong-data.uml PingPong-data::Pinger transition Initial,Running */
     std::cout << "Pinger initialised" << std::endl;
     timer.informIn( UMLRTTimespec( 2, 0 ) );
-    // the following code has been generated
+    /* UMLRTGEN-USERREGION-END */
     #undef rtdata
-    // generated code ends
 }
 
 void Capsule_Pinger::transitionaction_____PingPong_data__Pinger__Pinger_SM__Region1__onPong__onPong( const UMLRTMessage * msg )
 {
-    // the following code has been generated
-    /* UMLRT-CODEGEN:platform:/resource/PingPong-data/PingPong-data.uml#_XTukYCcPEeSlGd4okkPIfw */
     #define rtdata ( (void *)msg->getParam( 0 ) )
-    // generated code ends
+    /* UMLRTGEN-USERREGION-BEGIN platform:/resource/PingPong-data/PingPong-data.uml PingPong-data::Pinger transition Running,Running,pong:ping */
     std::cout << "Pong received" << std::endl;
     timer.informIn( UMLRTTimespec( 2, 0 ) );
-    // the following code has been generated
+    /* UMLRTGEN-USERREGION-END */
     #undef rtdata
-    // generated code ends
 }
 
 void Capsule_Pinger::transitionaction_____PingPong_data__Pinger__Pinger_SM__Region1__onTimeout__onTimeout( const UMLRTMessage * msg )
 {
-    // the following code has been generated
-    /* UMLRT-CODEGEN:platform:/resource/PingPong-data/PingPong-data.uml#__I0kEGxxEeSWy5Y1YWzXfQ */
     #define rtdata ( (void *)msg->getParam( 0 ) )
-    // generated code ends
+    /* UMLRTGEN-USERREGION-BEGIN platform:/resource/PingPong-data/PingPong-data.uml PingPong-data::Pinger transition Running,Running,timeout:timer */
     static int * ptr = NULL;
     if( ! ptr )
     ptr = new int( 0 );
@@ -124,9 +116,8 @@
     ++*ptr;
     DataType1 dt = { one, 0, true, 3., ptr, 1.618f, "hello" };
     ping.ping( dt ).send();
-    // the following code has been generated
+    /* UMLRTGEN-USERREGION-END */
     #undef rtdata
-    // generated code ends
 }
 
 void Capsule_Pinger::actionchain_____action_____PingPong_data__Pinger__Pinger_SM__Region1__initialise( const UMLRTMessage * msg )
diff --git a/models/tests/PingPong-data/expected_src/Ponger.cc b/models/tests/PingPong-data/expected_src/Ponger.cc
index a665cc7..f42ab86 100644
--- a/models/tests/PingPong-data/expected_src/Ponger.cc
+++ b/models/tests/PingPong-data/expected_src/Ponger.cc
@@ -79,35 +79,27 @@
 
 void Capsule_Ponger::transitionaction_____PingPong_data__Ponger__Ponger_SM__Region1__initial__onInit( const UMLRTMessage * msg )
 {
-    // the following code has been generated
-    /* UMLRT-CODEGEN:platform:/resource/PingPong-data/PingPong-data.uml#__Obm0FYKEeSmi4Fyw18d0w */
     #define rtdata ( (void *)msg->getParam( 0 ) )
-    // generated code ends
+    /* UMLRTGEN-USERREGION-BEGIN platform:/resource/PingPong-data/PingPong-data.uml PingPong-data::Ponger transition Initial,Running */
     std::cout << "Ponger initialised" << std::endl;
-    // the following code has been generated
+    /* UMLRTGEN-USERREGION-END */
     #undef rtdata
-    // generated code ends
 }
 
 void Capsule_Ponger::transitionaction_____PingPong_data__Ponger__Ponger_SM__Region1__onBound__onBound( const UMLRTMessage * msg )
 {
-    // the following code has been generated
-    /* UMLRT-CODEGEN:platform:/resource/PingPong-data/PingPong-data.uml#_TM3DYOzVEeSSF9-rYvvBtA */
     #define rtdata ( (void *)msg->getParam( 0 ) )
-    // generated code ends
+    /* UMLRTGEN-USERREGION-BEGIN platform:/resource/PingPong-data/PingPong-data.uml PingPong-data::Ponger transition Running,Running,rtBound:pong */
     std::cout << getName() << " onBound" << std::endl;
-    // the following code has been generated
+    /* UMLRTGEN-USERREGION-END */
     #undef rtdata
-    // generated code ends
 }
 
 void Capsule_Ponger::transitionaction_____PingPong_data__Ponger__Ponger_SM__Region1__onPing__onPing( const UMLRTMessage * msg )
 {
-    // the following code has been generated
-    /* UMLRT-CODEGEN:platform:/resource/PingPong-data/PingPong-data.uml#_szp-wCcREeSlGd4okkPIfw */
     #define umlrtparam_param ( *(const DataType1 * )msg->getParam( 0 ) )
     #define rtdata ( (const DataType1 * )msg->getParam( 0 ) )
-    // generated code ends
+    /* UMLRTGEN-USERREGION-BEGIN platform:/resource/PingPong-data/PingPong-data.uml PingPong-data::Ponger transition Running,Running,ping:pong */
     std::cout << "Ping received"
     << " field0:" << rtdata->field0_enum
     << " field1:" << rtdata->field1_int
@@ -119,10 +111,9 @@
     << std::endl;
     std::cout << "Sending Pong" << std::endl;
     pong.pong().send();
-    // the following code has been generated
+    /* UMLRTGEN-USERREGION-END */
     #undef rtdata
     #undef umlrtparam_param
-    // generated code ends
 }
 
 void Capsule_Ponger::actionchain_____action_____PingPong_data__Ponger__Ponger_SM__Region1__initial( const UMLRTMessage * msg )
diff --git a/models/tests/PingPong-data/expected_src/Top.cc b/models/tests/PingPong-data/expected_src/Top.cc
index 45d544d..d376793 100644
--- a/models/tests/PingPong-data/expected_src/Top.cc
+++ b/models/tests/PingPong-data/expected_src/Top.cc
@@ -55,19 +55,16 @@
 
 void Capsule_Top::transitionaction_____PingPong_data__Top__StateMachine1__Region1__initial__onInit( const UMLRTMessage * msg )
 {
-    // the following code has been generated
-    /* UMLRT-CODEGEN:platform:/resource/PingPong-data/PingPong-data.uml#_DjVVEFYMEeSmi4Fyw18d0w */
     #define rtdata ( (void *)msg->getParam( 0 ) )
-    // generated code ends
+    /* UMLRTGEN-USERREGION-BEGIN platform:/resource/PingPong-data/PingPong-data.uml PingPong-data::Top transition Initial1,State1 */
     std::cout << "Top initialised!\n";
     UMLRTCapsuleId pongerId = frame.incarnate( ponger, Ponger );
     if( ! pongerId.isValid() )
     context()->perror("ponger incarnate failed.");
     printf( "incarnated ponger valid:%d @%p\n",
     pongerId.isValid(), pongerId.getCapsule() );
-    // the following code has been generated
+    /* UMLRTGEN-USERREGION-END */
     #undef rtdata
-    // generated code ends
 }
 
 void Capsule_Top::actionchain_____action_____PingPong_data__Top__StateMachine1__Region1__initial( const UMLRTMessage * msg )
diff --git a/models/tests/PingPong/expected_src/CMakeLists.txt b/models/tests/PingPong/expected_src/CMakeLists.txt
index afbb7fc..4d42538 100644
--- a/models/tests/PingPong/expected_src/CMakeLists.txt
+++ b/models/tests/PingPong/expected_src/CMakeLists.txt
@@ -1,4 +1,4 @@
-# Generated 2016-07-20 11:17:11
+# Generated 2016-07-21 17:58:01
 
 cmake_minimum_required(VERSION 2.8.7)
 set(TARGET TopMain)
diff --git a/plugins/umlrt/codegen/org.eclipse.papyrusrt.codegen.cpp.profile/src/org/eclipse/papyrusrt/codegen/cpp/profile/facade/RTCppPropertiesProfileMetadata.java b/plugins/umlrt/codegen/org.eclipse.papyrusrt.codegen.cpp.profile/src/org/eclipse/papyrusrt/codegen/cpp/profile/facade/RTCppPropertiesProfileMetadata.java
index 400eca2..ea23218 100644
--- a/plugins/umlrt/codegen/org.eclipse.papyrusrt.codegen.cpp.profile/src/org/eclipse/papyrusrt/codegen/cpp/profile/facade/RTCppPropertiesProfileMetadata.java
+++ b/plugins/umlrt/codegen/org.eclipse.papyrusrt.codegen.cpp.profile/src/org/eclipse/papyrusrt/codegen/cpp/profile/facade/RTCppPropertiesProfileMetadata.java
@@ -29,7 +29,7 @@
 	private static final String NS_URI = RTCppPropertiesPackage.eNS_URI;
 
 	/** Pathmap. */
-	private static final String BASEPATHMAP = "pathmap://UMLRT_CPP/RTCppProperties.profile.uml";
+	private static final String BASEPATHMAP = "pathmap://UMLRT_CPP";
 
 	/** Root node id. */
 	// TODO: Find out if this can be extracted programatically
diff --git a/plugins/xtumlrt/common/org.eclipse.papyrusrt.xtumlrt.external/src/org/eclipse/papyrusrt/xtumlrt/external/ExternalPackageManager.java b/plugins/xtumlrt/common/org.eclipse.papyrusrt.xtumlrt.external/src/org/eclipse/papyrusrt/xtumlrt/external/ExternalPackageManager.java
index 001f99d..1684336 100644
--- a/plugins/xtumlrt/common/org.eclipse.papyrusrt.xtumlrt.external/src/org/eclipse/papyrusrt/xtumlrt/external/ExternalPackageManager.java
+++ b/plugins/xtumlrt/common/org.eclipse.papyrusrt.xtumlrt.external/src/org/eclipse/papyrusrt/xtumlrt/external/ExternalPackageManager.java
@@ -271,23 +271,40 @@
 	 */
 	private boolean loadPackage(ExternalPackageMetadata metadata) {
 		boolean success = false;
-		String packageId = metadata.getPackageId();
-		if (pluginFinder.found(packageId)) {
-			resolvePackageLocation(metadata);
-			URI fullURI = metadata.getPackageLocationURI();
-			Resource resource = resourceSet.getResource(fullURI, true);
-			metadata.setResource(resource);
-			EList<EObject> contents = resource.getContents();
-			EObject root = contents.get(0);
-			metadata.setRoot(root);
+		URI pathmap = metadata.getPathmapURI();
+		Resource existingResource = resourceSet.getResource(pathmap, !standalone);
+		if (existingResource != null) {
+			loadResourceContents(existingResource, metadata);
 			success = true;
 		} else {
-			XTUMLRTLogger.warning("Unable to find plugin with id '" + packageId + "'");
+			String packageId = metadata.getPackageId();
+			if (pluginFinder.found(packageId)) {
+				resolvePackageLocation(metadata);
+				URI fullURI = metadata.getPackageLocationURI();
+				Resource resource = resourceSet.getResource(fullURI, true);
+				loadResourceContents(resource, metadata);
+				success = true;
+			} else {
+				XTUMLRTLogger.warning("Unable to find plugin with id '" + packageId + "'");
+			}
 		}
 		return success;
 	}
 
 	/**
+	 * @param existingResource
+	 *            - A {@link Resource}.
+	 * @param metadata
+	 *            - An {@link ExternalPackageMetadata}.
+	 */
+	private void loadResourceContents(Resource existingResource, ExternalPackageMetadata metadata) {
+		metadata.setResource(existingResource);
+		EList<EObject> contents = existingResource.getContents();
+		EObject root = contents.get(0);
+		metadata.setRoot(root);
+	}
+
+	/**
 	 * Obtain the actual file system location of the package file and update the
 	 * package's metadata.
 	 * 
diff --git a/plugins/xtumlrt/common/org.eclipse.papyrusrt.xtumlrt.external/src/org/eclipse/papyrusrt/xtumlrt/external/predefined/UMLRTProfileUtil.java b/plugins/xtumlrt/common/org.eclipse.papyrusrt.xtumlrt.external/src/org/eclipse/papyrusrt/xtumlrt/external/predefined/UMLRTProfileUtil.java
index b10d6f9..3a2987b 100644
--- a/plugins/xtumlrt/common/org.eclipse.papyrusrt.xtumlrt.external/src/org/eclipse/papyrusrt/xtumlrt/external/predefined/UMLRTProfileUtil.java
+++ b/plugins/xtumlrt/common/org.eclipse.papyrusrt.xtumlrt.external/src/org/eclipse/papyrusrt/xtumlrt/external/predefined/UMLRTProfileUtil.java
@@ -21,7 +21,6 @@
 import org.eclipse.papyrusrt.umlrt.profile.UMLRealTime.RTPort;
 import org.eclipse.papyrusrt.umlrt.profile.UMLRealTime.RTRedefinedElement;
 import org.eclipse.papyrusrt.xtumlrt.util.UML2Util;
-import org.eclipse.papyrusrt.xtumlrt.util.UML2Util.NameComparator;
 //import org.eclipse.papyrus.umlrt.UMLRealTime.RTRExcludedElement;
 import org.eclipse.uml2.uml.Class;
 import org.eclipse.uml2.uml.Collaboration;
@@ -420,6 +419,25 @@
 	}
 
 	/**
+	 * Get the protocol container of a message.
+	 * 
+	 * @param umlOperation
+	 *            - An {@link Operation} (the message).
+	 * @return A {@link Package} which is a {@link ProtocolContainer}, or {@code null}
+	 *         if the operation is not a message or not in a protocol container.
+	 */
+	public static Package getProtocol(Operation umlOperation) {
+		Package protocolContainer = null;
+		if (isSignal(umlOperation)) {
+			Package pkg = umlOperation.getNearestPackage();
+			if (isProtocolContainer(pkg)) {
+				protocolContainer = pkg;
+			}
+		}
+		return protocolContainer;
+	}
+
+	/**
 	 * A filter that produces only Properties owned by the classifier that are properly stereotyped as
 	 * CapsulePart.
 	 * 
diff --git a/plugins/xtumlrt/trans/org.eclipse.papyrusrt.xtumlrt.trans.from.uml/src/org/eclipse/papyrusrt/xtumlrt/trans/from/uml/UML2xtumlrtModelTranslator.xtend b/plugins/xtumlrt/trans/org.eclipse.papyrusrt.xtumlrt.trans.from.uml/src/org/eclipse/papyrusrt/xtumlrt/trans/from/uml/UML2xtumlrtModelTranslator.xtend
index 6ea3f8d..885353a 100644
--- a/plugins/xtumlrt/trans/org.eclipse.papyrusrt.xtumlrt.trans.from.uml/src/org/eclipse/papyrusrt/xtumlrt/trans/from/uml/UML2xtumlrtModelTranslator.xtend
+++ b/plugins/xtumlrt/trans/org.eclipse.papyrusrt.xtumlrt.trans.from.uml/src/org/eclipse/papyrusrt/xtumlrt/trans/from/uml/UML2xtumlrtModelTranslator.xtend
@@ -275,11 +275,12 @@
         if (it === null) return;
         name = collaboration.name
         initProtocol( collaboration, it )
-        if (collaboration.isSystemElement)
+        val isSystemElement = collaboration.isSystemElement
+        if (isSystemElement)
             addSysAnnotation
         translateGeneralizationToRedefinition( collaboration, it )
         translateRedefinableElement( collaboration, it )
-        if (redefines === null)
+        if (redefines === null && !isSystemElement)
         {
             val BaseCommProtocol = getBaseCommProtocol
             if (BaseCommProtocol === null)
@@ -358,7 +359,8 @@
         {
             parameters.add( translateElement(parameter) as Parameter )
         }
-        if (operation.interface.isRTMessageSet)
+        val interface = operation.interface
+        if (interface.isRTMessageSet)
         {
             val rtMsgKind = operation.interface.getRTMessageSet.rtMsgKind
             switch (rtMsgKind)
@@ -367,6 +369,8 @@
                 case RTMessageKind.OUT:     kind = ProtocolBehaviourFeatureKind.OUT
                 case RTMessageKind.IN_OUT:  kind = ProtocolBehaviourFeatureKind.INOUT
             }
+            // Ensure that we translate its container protocol
+            translateElement( operation.protocol )
         }
     }
 
diff --git a/plugins/xtumlrt/trans/org.eclipse.papyrusrt.xtumlrt.trans.from.uml/src/org/eclipse/papyrusrt/xtumlrt/trans/from/uml/UML2xtumlrtSMTranslator.xtend b/plugins/xtumlrt/trans/org.eclipse.papyrusrt.xtumlrt.trans.from.uml/src/org/eclipse/papyrusrt/xtumlrt/trans/from/uml/UML2xtumlrtSMTranslator.xtend
index 460571a..46cee2e 100644
--- a/plugins/xtumlrt/trans/org.eclipse.papyrusrt.xtumlrt.trans.from.uml/src/org/eclipse/papyrusrt/xtumlrt/trans/from/uml/UML2xtumlrtSMTranslator.xtend
+++ b/plugins/xtumlrt/trans/org.eclipse.papyrusrt.xtumlrt.trans.from.uml/src/org/eclipse/papyrusrt/xtumlrt/trans/from/uml/UML2xtumlrtSMTranslator.xtend
@@ -395,7 +395,9 @@
                 val triggerPort = uml2xtumlrtTranslator.translateElement(port) as RTPort
                 if (PortKind.RELAY == triggerPort.kind) {
                     CodeGenPlugin.warning("Ignoring replay port from the trigger '" + trigger.qualifiedName + "'")
-                }else{
+                } 
+                else
+                {
                     ports.addIfNotNull(triggerPort)
                 }
             }