Merge branch 'change/45808/2'
diff --git a/features/org.eclipse.etrice.fsm.feature/.project b/features/org.eclipse.etrice.fsm.feature/.project
new file mode 100644
index 0000000..83d4191
--- /dev/null
+++ b/features/org.eclipse.etrice.fsm.feature/.project
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+	<name>org.eclipse.etrice.fsm.feature</name>
+	<comment></comment>
+	<projects>
+	</projects>
+	<buildSpec>
+		<buildCommand>
+			<name>org.eclipse.pde.FeatureBuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+	</buildSpec>
+	<natures>
+		<nature>org.eclipse.pde.FeatureNature</nature>
+	</natures>
+</projectDescription>
diff --git a/features/org.eclipse.etrice.fsm.feature/about.html b/features/org.eclipse.etrice.fsm.feature/about.html
new file mode 100644
index 0000000..d35d5ae
--- /dev/null
+++ b/features/org.eclipse.etrice.fsm.feature/about.html
@@ -0,0 +1,28 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
+    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/>
+<title>About</title>
+</head>
+<body lang="EN-US">
+<h2>About This Content</h2>
+ 
+<p>June 5, 2007</p>	
+<h3>License</h3>
+
+<p>The Eclipse Foundation makes available all content in this plug-in (&quot;Content&quot;).  Unless otherwise 
+indicated below, the Content is provided to you under the terms and conditions of the
+Eclipse Public License Version 1.0 (&quot;EPL&quot;).  A copy of the EPL is available 
+at <a href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a>.
+For purposes of the EPL, &quot;Program&quot; will mean the Content.</p>
+
+<p>If you did not receive this Content directly from the Eclipse Foundation, the Content is 
+being redistributed by another party (&quot;Redistributor&quot;) and different terms and conditions may
+apply to your use of any object code in the Content.  Check the Redistributor's license that was 
+provided with the Content.  If no such license exists, contact the Redistributor.  Unless otherwise
+indicated below, the terms and conditions of the EPL still apply to any source code in the Content
+and such source code may be obtained at <a href="http://www.eclipse.org/">http://www.eclipse.org</a>.</p>
+
+</body>
+</html>
diff --git a/features/org.eclipse.etrice.fsm.feature/about.ini b/features/org.eclipse.etrice.fsm.feature/about.ini
new file mode 100644
index 0000000..a2c20bc
--- /dev/null
+++ b/features/org.eclipse.etrice.fsm.feature/about.ini
@@ -0,0 +1,15 @@
+# about.ini
+# contains information about a feature
+# java.io.Properties file (ISO 8859-1 with "\" escapes)
+# "%key" are externalized strings defined in about.properties
+# This file does not need to be translated.
+
+# Property "aboutText" contains blurb for "About" dialog (translated)
+aboutText=%featureText
+
+# Property "featureImage" contains path to feature image (32x32)
+featureImage=eTrice32.png
+
+# Property "appName" contains name of the application (translated)
+appName=%featureName
+
diff --git a/features/org.eclipse.etrice.fsm.feature/about.mappings b/features/org.eclipse.etrice.fsm.feature/about.mappings
new file mode 100644
index 0000000..bddaab4
--- /dev/null
+++ b/features/org.eclipse.etrice.fsm.feature/about.mappings
@@ -0,0 +1,6 @@
+# about.mappings
+# contains fill-ins for about.properties
+# java.io.Properties file (ISO 8859-1 with "\" escapes)
+# This file does not need to be translated.
+
+0=@build@
\ No newline at end of file
diff --git a/features/org.eclipse.etrice.fsm.feature/about.properties b/features/org.eclipse.etrice.fsm.feature/about.properties
new file mode 100644
index 0000000..2c212b0
--- /dev/null
+++ b/features/org.eclipse.etrice.fsm.feature/about.properties
@@ -0,0 +1,28 @@
+# NLS_MESSAGEFORMAT_VAR
+
+# ==============================================================================
+# Do not change the properties between this line and the last line containing:
+# %%% END OF TRANSLATED PROPERTIES %%%
+# Instead, either redefine an existing property, or create a new property,
+# append it to the end of the file, and change the code to use the new name.
+# ==============================================================================
+
+# about.properties
+# contains externalized strings for about.ini
+# java.io.Properties file (ISO 8859-1 with "\" escapes)
+# fill-ins are supplied by about.mappings
+# This file should be translated.
+
+featureName=eTrice FSM 
+
+featureText=eTrice FSM \n\
+Version: {featureVersion}\n\
+Build id: {0}\n\
+\n\
+(c) Copyright Eclipse contributors and others. 2010, 2011.  All rights reserved.\n\
+Visit http://www.eclipse.org/etrice
+
+# ==============================================================================
+# %%% END OF TRANSLATED PROPERTIES %%%
+# The above properties have been shipped for translation.
+# ==============================================================================
diff --git a/features/org.eclipse.etrice.fsm.feature/build.properties b/features/org.eclipse.etrice.fsm.feature/build.properties
new file mode 100644
index 0000000..1612d86
--- /dev/null
+++ b/features/org.eclipse.etrice.fsm.feature/build.properties
@@ -0,0 +1,6 @@
+bin.includes = feature.xml,\
+               eTrice32.png,\
+               about.properties,\
+               about.mappings,\
+               about.ini,\
+               about.html
diff --git a/features/org.eclipse.etrice.fsm.feature/eTrice32.png b/features/org.eclipse.etrice.fsm.feature/eTrice32.png
new file mode 100644
index 0000000..1670cce
--- /dev/null
+++ b/features/org.eclipse.etrice.fsm.feature/eTrice32.png
Binary files differ
diff --git a/features/org.eclipse.etrice.fsm.feature/feature.properties b/features/org.eclipse.etrice.fsm.feature/feature.properties
new file mode 100644
index 0000000..7a659e1
--- /dev/null
+++ b/features/org.eclipse.etrice.fsm.feature/feature.properties
@@ -0,0 +1,8 @@
+featureName=eTrice FSM
+# "providerName" property - name of the company that provides the feature
+providerName=Eclipse eTrice (Incubation)
+description= eTrice abstract FSM framework
+
+# "license" property - text of the "Feature Update License"
+# should be plain text version of license agreement pointed to be "licenseURL"
+
diff --git a/features/org.eclipse.etrice.fsm.feature/feature.xml b/features/org.eclipse.etrice.fsm.feature/feature.xml
new file mode 100644
index 0000000..5631f52
--- /dev/null
+++ b/features/org.eclipse.etrice.fsm.feature/feature.xml
@@ -0,0 +1,98 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+    <copyright>
+   
+    Copyright (c) 2010 - 2015 Protos Software GmbH.
+    All rights reserved. This program and the accompanying materials
+    are made available under the terms of the Eclipse Public License v1.0
+    which accompanies this distribution, and is available at
+    http://www.eclipse.org/legal/epl-v10.html
+   
+    Contributors:
+       Henrik Rentz-Reichert
+   
+    </copyright>
+   
+ -->
+<feature
+      id="org.eclipse.etrice.fsm.feature"
+      label="eTrice.FSM Feature"
+      version="0.5.0.qualifier"
+      provider-name="eTrice (Incubation)"
+      license-feature="org.eclipse.license"
+      license-feature-version="1.0.1.v20140414-1359">
+
+   <description url="http://www.example.com/description">
+      %description
+   </description>
+
+   <copyright url="http://www.example.com/copyright">
+      (c) 2010 - 2015 Protos Software GmbH.
+All rights reserved.   This program and the accompanying materials
+are made available under the terms of the Eclipse Public License
+v1.0
+which accompanies this distribution, and is available at
+http://www.eclipse.org/legal/epl-v10.html
+   </copyright>
+
+   <license url="http://www.example.com/license">
+      %license
+   </license>
+
+   <plugin
+         id="org.eclipse.etrice.core.common"
+         download-size="0"
+         install-size="0"
+         version="0.0.0"
+         unpack="false"/>
+
+   <plugin
+         id="org.eclipse.etrice.core.common.ui"
+         download-size="0"
+         install-size="0"
+         version="0.0.0"
+         unpack="false"/>
+
+   <plugin
+         id="org.eclipse.etrice.core.fsm"
+         download-size="0"
+         install-size="0"
+         version="0.0.0"
+         unpack="false"/>
+
+   <plugin
+         id="org.eclipse.etrice.core.fsm.ui"
+         download-size="0"
+         install-size="0"
+         version="0.0.0"
+         unpack="false"/>
+
+   <plugin
+         id="org.eclipse.etrice.core.genmodel.fsm"
+         download-size="0"
+         install-size="0"
+         version="0.0.0"
+         unpack="false"/>
+
+   <plugin
+         id="org.eclipse.etrice.generator.fsm"
+         download-size="0"
+         install-size="0"
+         version="0.0.0"
+         unpack="false"/>
+
+   <plugin
+         id="org.eclipse.etrice.ui.behavior.fsm"
+         download-size="0"
+         install-size="0"
+         version="0.0.0"
+         unpack="false"/>
+
+   <plugin
+         id="org.eclipse.etrice.ui.common.base"
+         download-size="0"
+         install-size="0"
+         version="0.0.0"
+         unpack="false"/>
+
+</feature>
diff --git a/plugins/org.eclipse.etrice.core.fsm/META-INF/MANIFEST.MF b/plugins/org.eclipse.etrice.core.fsm/META-INF/MANIFEST.MF
index cc542e5..b4658f6 100644
--- a/plugins/org.eclipse.etrice.core.fsm/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.etrice.core.fsm/META-INF/MANIFEST.MF
@@ -18,7 +18,8 @@
  org.eclipse.emf.ecore,
  org.eclipse.emf.common,
  org.antlr.runtime,
- org.objectweb.asm;bundle-version="[5.0.1,6.0.0)";resolution:=optional
+ org.objectweb.asm;bundle-version="[5.0.1,6.0.0)";resolution:=optional,
+ com.google.guava
 Import-Package: org.apache.log4j,
  org.eclipse.xtext.xbase.lib
 Bundle-RequiredExecutionEnvironment: JavaSE-1.6
diff --git a/plugins/org.eclipse.etrice.core.fsm/model/generated/FSM.ecore b/plugins/org.eclipse.etrice.core.fsm/model/generated/FSM.ecore
index f163179..631bfa5 100644
--- a/plugins/org.eclipse.etrice.core.fsm/model/generated/FSM.ecore
+++ b/plugins/org.eclipse.etrice.core.fsm/model/generated/FSM.ecore
@@ -382,6 +382,11 @@
     <eAnnotations source="http://www.eclipse.org/emf/2002/GenModel">
       <details key="documentation" value="&lt;br>An abstract interface item to be overridden in derived grammars.&#xA;"/>
     </eAnnotations>
+    <eOperations name="getDisplayName" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString">
+      <eAnnotations source="http://www.eclipse.org/emf/2002/GenModel">
+        <details key="body" value="return getName();&#xA;"/>
+      </eAnnotations>
+    </eOperations>
     <eOperations name="getSemantics" eType="#//ProtocolSemantics"/>
     <eOperations name="getAllIncomingAbstractMessages" upperBound="-1" eType="ecore:EClass http://www.eclipse.org/emf/2002/Ecore#//EObject"/>
     <eOperations name="getAllOutgoingAbstractMessages" upperBound="-1" eType="ecore:EClass http://www.eclipse.org/emf/2002/Ecore#//EObject"/>
diff --git a/plugins/org.eclipse.etrice.core.fsm/model/generated/FSM.genmodel b/plugins/org.eclipse.etrice.core.fsm/model/generated/FSM.genmodel
index 059539e..edc632e 100644
--- a/plugins/org.eclipse.etrice.core.fsm/model/generated/FSM.genmodel
+++ b/plugins/org.eclipse.etrice.core.fsm/model/generated/FSM.genmodel
@@ -114,6 +114,7 @@
     </genClasses>
     <genClasses ecoreClass="FSM.ecore#//AbstractInterfaceItem">
       <genFeatures createChild="false" ecoreFeature="ecore:EAttribute FSM.ecore#//AbstractInterfaceItem/name"/>
+      <genOperations ecoreOperation="FSM.ecore#//AbstractInterfaceItem/getDisplayName"/>
       <genOperations ecoreOperation="FSM.ecore#//AbstractInterfaceItem/getSemantics"/>
       <genOperations ecoreOperation="FSM.ecore#//AbstractInterfaceItem/getAllIncomingAbstractMessages"/>
       <genOperations ecoreOperation="FSM.ecore#//AbstractInterfaceItem/getAllOutgoingAbstractMessages"/>
diff --git a/plugins/org.eclipse.etrice.core.fsm/src-gen/org/eclipse/etrice/core/fsm/fSM/AbstractInterfaceItem.java b/plugins/org.eclipse.etrice.core.fsm/src-gen/org/eclipse/etrice/core/fsm/fSM/AbstractInterfaceItem.java
index cbb5877..0c28be6 100644
--- a/plugins/org.eclipse.etrice.core.fsm/src-gen/org/eclipse/etrice/core/fsm/fSM/AbstractInterfaceItem.java
+++ b/plugins/org.eclipse.etrice.core.fsm/src-gen/org/eclipse/etrice/core/fsm/fSM/AbstractInterfaceItem.java
@@ -59,6 +59,15 @@
    * <!-- begin-user-doc -->
    * <!-- end-user-doc -->
    * @model kind="operation"
+   *        annotation="http://www.eclipse.org/emf/2002/GenModel body='return getName();\n'"
+   * @generated
+   */
+  String getDisplayName();
+
+  /**
+   * <!-- begin-user-doc -->
+   * <!-- end-user-doc -->
+   * @model kind="operation"
    * @generated
    */
   ProtocolSemantics getSemantics();
@@ -79,4 +88,13 @@
    */
   EList<EObject> getAllOutgoingAbstractMessages();
 
+  /**
+   * <!-- begin-user-doc -->
+   * <!-- end-user-doc -->
+   * @model kind="operation"
+   *        annotation="http://www.eclipse.org/emf/2002/GenModel body='return true;'"
+   * @generated
+   */
+  boolean isEventDriven();
+
 } // AbstractInterfaceItem
diff --git a/plugins/org.eclipse.etrice.core.fsm/src-gen/org/eclipse/etrice/core/fsm/fSM/impl/AbstractInterfaceItemImpl.java b/plugins/org.eclipse.etrice.core.fsm/src-gen/org/eclipse/etrice/core/fsm/fSM/impl/AbstractInterfaceItemImpl.java
index 55a229c..0bb6193 100644
--- a/plugins/org.eclipse.etrice.core.fsm/src-gen/org/eclipse/etrice/core/fsm/fSM/impl/AbstractInterfaceItemImpl.java
+++ b/plugins/org.eclipse.etrice.core.fsm/src-gen/org/eclipse/etrice/core/fsm/fSM/impl/AbstractInterfaceItemImpl.java
@@ -100,6 +100,17 @@
    * <!-- end-user-doc -->
    * @generated
    */
+  public String getDisplayName()
+  {
+    return getName();
+    
+  }
+
+  /**
+   * <!-- begin-user-doc -->
+   * <!-- end-user-doc -->
+   * @generated
+   */
   public ProtocolSemantics getSemantics()
   {
     // TODO: implement this method
@@ -136,6 +147,16 @@
    * <!-- end-user-doc -->
    * @generated
    */
+  public boolean isEventDriven()
+  {
+    return true;
+  }
+
+  /**
+   * <!-- begin-user-doc -->
+   * <!-- end-user-doc -->
+   * @generated
+   */
   @Override
   public Object eGet(int featureID, boolean resolve, boolean coreType)
   {
diff --git a/plugins/org.eclipse.etrice.core.fsm/src-gen/org/eclipse/etrice/core/fsm/fSM/impl/FSMPackageImpl.java b/plugins/org.eclipse.etrice.core.fsm/src-gen/org/eclipse/etrice/core/fsm/fSM/impl/FSMPackageImpl.java
index e4453e4..62d9d5d 100644
--- a/plugins/org.eclipse.etrice.core.fsm/src-gen/org/eclipse/etrice/core/fsm/fSM/impl/FSMPackageImpl.java
+++ b/plugins/org.eclipse.etrice.core.fsm/src-gen/org/eclipse/etrice/core/fsm/fSM/impl/FSMPackageImpl.java
@@ -1589,12 +1589,16 @@
     initEClass(abstractInterfaceItemEClass, AbstractInterfaceItem.class, "AbstractInterfaceItem", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS);
     initEAttribute(getAbstractInterfaceItem_Name(), ecorePackage.getEString(), "name", null, 0, 1, AbstractInterfaceItem.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
 
+    addEOperation(abstractInterfaceItemEClass, ecorePackage.getEString(), "getDisplayName", 0, 1, IS_UNIQUE, IS_ORDERED);
+
     addEOperation(abstractInterfaceItemEClass, this.getProtocolSemantics(), "getSemantics", 0, 1, IS_UNIQUE, IS_ORDERED);
 
     addEOperation(abstractInterfaceItemEClass, ecorePackage.getEObject(), "getAllIncomingAbstractMessages", 0, -1, IS_UNIQUE, IS_ORDERED);
 
     addEOperation(abstractInterfaceItemEClass, ecorePackage.getEObject(), "getAllOutgoingAbstractMessages", 0, -1, IS_UNIQUE, IS_ORDERED);
 
+    addEOperation(abstractInterfaceItemEClass, ecorePackage.getEBoolean(), "isEventDriven", 0, 1, IS_UNIQUE, IS_ORDERED);
+
     initEClass(guardEClass, Guard.class, "Guard", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS);
     initEReference(getGuard_Guard(), this.getDetailCode(), null, "guard", null, 0, 1, Guard.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
 
diff --git a/plugins/org.eclipse.etrice.core.fsm/src-gen/org/eclipse/etrice/core/fsm/validation/AbstractFSMJavaValidator.java b/plugins/org.eclipse.etrice.core.fsm/src-gen/org/eclipse/etrice/core/fsm/validation/AbstractFSMJavaValidator.java
index dffe9b4..4abc7a5 100644
--- a/plugins/org.eclipse.etrice.core.fsm/src-gen/org/eclipse/etrice/core/fsm/validation/AbstractFSMJavaValidator.java
+++ b/plugins/org.eclipse.etrice.core.fsm/src-gen/org/eclipse/etrice/core/fsm/validation/AbstractFSMJavaValidator.java
@@ -9,7 +9,7 @@
 import org.eclipse.emf.ecore.EPackage;
 import org.eclipse.xtext.validation.ComposedChecks;
 
-@ComposedChecks(validators= {org.eclipse.xtext.validation.ImportUriValidator.class, org.eclipse.xtext.validation.NamesAreUniqueValidator.class})
+@ComposedChecks(validators= {org.eclipse.xtext.validation.ImportUriValidator.class})
 public class AbstractFSMJavaValidator extends org.eclipse.etrice.core.common.validation.BaseJavaValidator {
 
 	@Override
diff --git a/plugins/org.eclipse.etrice.core.fsm/src/org/eclipse/etrice/core/fsm/GenerateFSM.mwe2 b/plugins/org.eclipse.etrice.core.fsm/src/org/eclipse/etrice/core/fsm/GenerateFSM.mwe2
index aecba1b..412df2b 100644
--- a/plugins/org.eclipse.etrice.core.fsm/src/org/eclipse/etrice/core/fsm/GenerateFSM.mwe2
+++ b/plugins/org.eclipse.etrice.core.fsm/src/org/eclipse/etrice/core/fsm/GenerateFSM.mwe2
@@ -87,7 +87,6 @@
     		// Added for compatibility with existing eTrice subgrammars
     		fragment = validation.JavaValidatorFragment auto-inject {
     		    composedCheck = "org.eclipse.xtext.validation.ImportUriValidator"
-    		    composedCheck = "org.eclipse.xtext.validation.NamesAreUniqueValidator"
     		}
     
     		// old scoping and exporting API
diff --git a/plugins/org.eclipse.etrice.core.fsm/src/org/eclipse/etrice/core/fsm/naming/FSMNameProvider.java b/plugins/org.eclipse.etrice.core.fsm/src/org/eclipse/etrice/core/fsm/naming/FSMNameProvider.java
index ced2df9..0313673 100644
--- a/plugins/org.eclipse.etrice.core.fsm/src/org/eclipse/etrice/core/fsm/naming/FSMNameProvider.java
+++ b/plugins/org.eclipse.etrice.core.fsm/src/org/eclipse/etrice/core/fsm/naming/FSMNameProvider.java
@@ -222,11 +222,19 @@
 		return result;
 	}
 
+	public String getTerminalLabel(TransitionTerminal tt) {
+		return getTerminalName(tt, "/");
+	}
+	
 	/**
 	 * @param tt a {@link TransitionTerminal}
 	 * @return a name for the terminal
 	 */
 	private String getTerminalName(TransitionTerminal tt) {
+		return getTerminalName(tt, PATH_SEP);
+	}
+	
+	private String getTerminalName(TransitionTerminal tt, String sep) {
 		if (tt instanceof StateTerminal) {
 			return getStateName(((StateTerminal) tt).getState());
 		}
@@ -234,7 +242,7 @@
 			return ((TrPointTerminal) tt).getTrPoint().getName();
 		}
 		else if (tt instanceof SubStateTrPointTerminal) {
-			return getStatePathName(((SubStateTrPointTerminal) tt).getState())+PATH_SEP+((SubStateTrPointTerminal) tt).getTrPoint().getName();
+			return getStatePathName(((SubStateTrPointTerminal) tt).getState())+sep+((SubStateTrPointTerminal) tt).getTrPoint().getName();
 		}
 		else if (tt instanceof ChoicepointTerminal) {
 			return ((ChoicepointTerminal) tt).getCp().getName();
diff --git a/plugins/org.eclipse.etrice.core.fsm/src/org/eclipse/etrice/core/fsm/postprocessing/ImplPostprocessor.xtend b/plugins/org.eclipse.etrice.core.fsm/src/org/eclipse/etrice/core/fsm/postprocessing/ImplPostprocessor.xtend
index fb2230d..20cb892 100644
--- a/plugins/org.eclipse.etrice.core.fsm/src/org/eclipse/etrice/core/fsm/postprocessing/ImplPostprocessor.xtend
+++ b/plugins/org.eclipse.etrice.core.fsm/src/org/eclipse/etrice/core/fsm/postprocessing/ImplPostprocessor.xtend
@@ -43,9 +43,15 @@
 			''')
 		
 		val ifItem = fsmPackage.getClass("AbstractInterfaceItem")
+        ifItem.addOperation("getDisplayName", EcorePackage::eINSTANCE.getEClassifier("EString"), 1,
+            '''
+                return getName();
+            '''
+        )
 		ifItem.addOperation("getSemantics", fsmPackage.getEClassifier("ProtocolSemantics"))
 		ifItem.addOperation("getAllIncomingAbstractMessages", EcorePackage.Literals.EOBJECT, -1, null)
 		ifItem.addOperation("getAllOutgoingAbstractMessages", EcorePackage.Literals.EOBJECT, -1, null)
+        ifItem.addOperation("isEventDriven", EcorePackage.Literals.EBOOLEAN, 1, "return true;")
 		
 		val itemOwner = fsmPackage.addClass("IInterfaceItemOwner")
 		itemOwner.setAbstract(true)
diff --git a/plugins/org.eclipse.etrice.core.fsm/src/org/eclipse/etrice/core/fsm/util/FSMHelpers.java b/plugins/org.eclipse.etrice.core.fsm/src/org/eclipse/etrice/core/fsm/util/FSMHelpers.java
index 67930ee..55f7920 100644
--- a/plugins/org.eclipse.etrice.core.fsm/src/org/eclipse/etrice/core/fsm/util/FSMHelpers.java
+++ b/plugins/org.eclipse.etrice.core.fsm/src/org/eclipse/etrice/core/fsm/util/FSMHelpers.java
@@ -24,11 +24,14 @@
 import org.eclipse.emf.ecore.EReference;
 import org.eclipse.emf.ecore.EStructuralFeature;
 import org.eclipse.etrice.core.common.base.util.BaseHelpers;
+import org.eclipse.etrice.core.fsm.fSM.AbstractInterfaceItem;
 import org.eclipse.etrice.core.fsm.fSM.ChoicePoint;
 import org.eclipse.etrice.core.fsm.fSM.ChoicepointTerminal;
 import org.eclipse.etrice.core.fsm.fSM.DetailCode;
 import org.eclipse.etrice.core.fsm.fSM.FSMFactory;
 import org.eclipse.etrice.core.fsm.fSM.FSMPackage;
+import org.eclipse.etrice.core.fsm.fSM.InitialTransition;
+import org.eclipse.etrice.core.fsm.fSM.MessageFromIf;
 import org.eclipse.etrice.core.fsm.fSM.ModelComponent;
 import org.eclipse.etrice.core.fsm.fSM.RefinedState;
 import org.eclipse.etrice.core.fsm.fSM.RefinedTransition;
@@ -1085,7 +1088,7 @@
 	 * Returns the complete action code including base class code of a {@link Transition}.
 	 * 
 	 * @param trans the transition
-	 * @param ac the model component
+	 * @param mc the model component
 	 * 
 	 * @return the complete action code including base class code of a {@link Transition}
 	 */
@@ -1122,4 +1125,100 @@
 		return null;
 	}
 
+	/**
+	 * @param mc an {@link ModelComponent}
+	 * @return a list of {@link MessageFromIf} that may come in through one of the
+	 * event driven interface items of this actor class (<i>without</i> inherited ones)
+	 */
+	public List<MessageFromIf> getMessagesFromInterfaces(ModelComponent mc) {
+		ArrayList<MessageFromIf> result = new ArrayList<MessageFromIf>();
+		
+		List<AbstractInterfaceItem> items = mc.getAbstractInterfaceItems();
+		for (AbstractInterfaceItem item : items) {
+			for (EObject msg : item.getAllIncomingAbstractMessages()) {
+				MessageFromIf mif = FSMFactory.eINSTANCE.createMessageFromIf();
+				mif.setMessage(msg);
+				mif.setFrom(item);
+				result.add(mif);
+			}
+		}
+		
+		return result;
+	}
+
+	/**
+	 * @param mc an {@link ModelComponent}
+	 * @return a list of {@link MessageFromIf} that may come in through one of the
+	 * event driven interface items of this actor class (<i>with</i> inherited ones as far as a base class has its own state machine)
+	 */
+	public List<MessageFromIf> getOwnMessagesFromInterfaces(ModelComponent mc) {
+		ArrayList<MessageFromIf> result = new ArrayList<MessageFromIf>();
+		
+		result.addAll(getMessagesFromInterfaces(mc));
+		mc = mc.getBase();
+		while (mc!=null) {
+			if (hasNonEmptyStateMachine(mc))
+				break;
+			
+			List<AbstractInterfaceItem> items = mc.getAbstractInterfaceItems();
+			for (AbstractInterfaceItem item : items) {
+				for (EObject msg : item.getAllIncomingAbstractMessages()) {
+					MessageFromIf mif = FSMFactory.eINSTANCE.createMessageFromIf();
+					mif.setMessage(msg);
+					mif.setFrom(item);
+					result.add(mif);
+				}
+			}
+			
+			mc = mc.getBase();
+		}
+		
+		return result;
+	}
+
+	/**
+	 * @param mc an {@link ModelComponent}
+	 * @return a list of {@link MessageFromIf} that may come in through one of the
+	 * event driven interface items of this actor class(<i>including</i> inherited ones)
+	 */
+	public List<MessageFromIf> getAllMessagesFromInterfaces(ModelComponent mc) {
+		ArrayList<MessageFromIf> result = new ArrayList<MessageFromIf>();
+		
+		while (mc!=null) {
+			List<AbstractInterfaceItem> items = mc.getAbstractInterfaceItems();
+			for (AbstractInterfaceItem item : items) {
+				for (EObject msg : item.getAllIncomingAbstractMessages()) {
+					MessageFromIf mif = FSMFactory.eINSTANCE.createMessageFromIf();
+					mif.setMessage(msg);
+					mif.setFrom(item);
+					result.add(mif);
+				}
+			}
+			
+			mc = mc.getBase();
+		}
+		
+		return result;
+	}
+
+	/**
+	 * @param sg a {@link StateGraph}
+	 * @return the initial transition or <code>null</code> if no such is available
+	 */
+	public Transition getInitTransition(StateGraph sg) {
+		for (Transition tr : sg.getTransitions()) {
+			if (tr instanceof InitialTransition)
+				return tr;
+		}
+		return null;
+	}
+
+	/**
+	 * @param sg a {@link StateGraph}
+	 * @return <code>true</code> if an initial transition is available
+	 */
+	public boolean hasInitTransition(StateGraph sg) {
+		return getInitTransition(sg)!=null;
+	}
+
 }
diff --git a/plugins/org.eclipse.etrice.core.fsm/src/org/eclipse/etrice/core/fsm/validation/FSMJavaValidator.java b/plugins/org.eclipse.etrice.core.fsm/src/org/eclipse/etrice/core/fsm/validation/FSMJavaValidator.java
index 538385c..79326fb 100644
--- a/plugins/org.eclipse.etrice.core.fsm/src/org/eclipse/etrice/core/fsm/validation/FSMJavaValidator.java
+++ b/plugins/org.eclipse.etrice.core.fsm/src/org/eclipse/etrice/core/fsm/validation/FSMJavaValidator.java
@@ -4,9 +4,11 @@
 package org.eclipse.etrice.core.fsm.validation;
 
 import java.util.ArrayList;
+import java.util.Collection;
 
 import org.eclipse.emf.common.util.TreeIterator;
 import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EStructuralFeature;
 import org.eclipse.etrice.core.fsm.fSM.ChoicePoint;
 import org.eclipse.etrice.core.fsm.fSM.DetailCode;
 import org.eclipse.etrice.core.fsm.fSM.FSMPackage;
@@ -17,12 +19,15 @@
 import org.eclipse.etrice.core.fsm.fSM.RefinedTransition;
 import org.eclipse.etrice.core.fsm.fSM.SimpleState;
 import org.eclipse.etrice.core.fsm.fSM.StateGraph;
+import org.eclipse.etrice.core.fsm.fSM.StateGraphItem;
 import org.eclipse.etrice.core.fsm.fSM.TrPoint;
 import org.eclipse.etrice.core.fsm.fSM.Transition;
 import org.eclipse.etrice.core.fsm.validation.FSMValidationUtilXtend.Result;
 import org.eclipse.xtext.util.Strings;
 import org.eclipse.xtext.validation.Check;
 
+import com.google.common.collect.ArrayListMultimap;
+import com.google.common.collect.Multimap;
 import com.google.inject.Inject;
 
 /**
@@ -55,9 +60,9 @@
 	
 	@Check
 	public void checkStateNameUnique(SimpleState s) {
-		Result result = ValidationUtil.isUniqueName(s, s.getName());
-		if (!result.isOk())
-			error(result.getMsg(), FSMPackage.Literals.SIMPLE_STATE__NAME);
+//		Result result = ValidationUtil.isUniqueName(s, s.getName());
+//		if (!result.isOk())
+//			error(result.getMsg(), FSMPackage.Literals.SIMPLE_STATE__NAME);
 	}
 	
 	@Check
@@ -69,8 +74,8 @@
 	
 	@Check
 	public void checkChoicePoint(ChoicePoint cp) {
-		if (!ValidationUtil.isUniqueName(cp, cp.getName()).isOk())
-			error("name is not unique", FSMPackage.Literals.CHOICE_POINT__NAME);
+//		if (!ValidationUtil.isUniqueName(cp, cp.getName()).isOk())
+//			error("name is not unique", FSMPackage.Literals.CHOICE_POINT__NAME);
 	}
 	
 	@Check
@@ -124,7 +129,76 @@
 		}
 	}
 	
-	private void error(Result result) {
+	@Check
+	public void checkUniqueNamesInStateGraph(StateGraph sg) {
+	    Multimap<String, StateGraphItem> names2items = ArrayListMultimap.create();
+	    
+	    // fill the multimap with all objects
+        do {
+            for (org.eclipse.etrice.core.fsm.fSM.State st : sg.getStates()) {
+                // the parent state of refined states is in this scope - so we don't add the name now 
+                if (!(st instanceof RefinedState)) {
+                    names2items.put(st.getName(), st);
+                }
+            }
+            for (TrPoint tp : sg.getTrPoints()) {
+                names2items.put(tp.getName(), tp);
+            }
+            for (ChoicePoint cp : sg.getChPoints()) {
+                names2items.put(cp.getName(), cp);
+            }
+            for (Transition tr : sg.getTransitions()) {
+                names2items.put(tr.getName(), tr);
+            }
+            
+            if (sg.eContainer() instanceof RefinedState) {
+                sg = ((RefinedState)sg.eContainer()).getTarget().getSubgraph();
+            }
+            else if (sg.eContainer() instanceof ModelComponent) {
+                ModelComponent base = ((ModelComponent)sg.eContainer()).getBase();
+                sg = base!=null? base.getStateMachine():null;
+            }
+            else {
+                break;
+            }
+        }
+        while (sg!=null);
+        
+        // check for duplicates
+        for (String key: names2items.keySet()) {
+            Collection<StateGraphItem> list = names2items.get(key);
+            if (list.size()>1) {
+                for (StateGraphItem item: list) {
+                    error("Name is not unique in state graph (including super graph)", item, getNameFeature(item));
+                }
+            }
+        }
+	}
+	
+	/**
+     * @param item
+     * @return
+     */
+    private EStructuralFeature getNameFeature(StateGraphItem item) {
+        if (item instanceof SimpleState) {
+            return FSMPackage.Literals.SIMPLE_STATE__NAME;
+        }
+        else if (item instanceof ChoicePoint) {
+            return FSMPackage.Literals.CHOICE_POINT__NAME;
+        }
+        else if (item instanceof TrPoint) {
+            return FSMPackage.Literals.TR_POINT__NAME;
+        }
+        else if (item instanceof Transition) {
+            return FSMPackage.Literals.TRANSITION__NAME;
+        }
+        else {
+            assert(false): "internal error: unexpected sub type";
+            return null;
+        }
+    }
+
+    private void error(Result result) {
 		error(result.getMsg(), result.getSource(), result.getFeature(), result.getIndex());
 	}
 }
diff --git a/plugins/org.eclipse.etrice.core.fsm/src/org/eclipse/etrice/core/fsm/validation/FSMValidationUtil.java b/plugins/org.eclipse.etrice.core.fsm/src/org/eclipse/etrice/core/fsm/validation/FSMValidationUtil.java
index d17bb19..f818067 100644
--- a/plugins/org.eclipse.etrice.core.fsm/src/org/eclipse/etrice/core/fsm/validation/FSMValidationUtil.java
+++ b/plugins/org.eclipse.etrice.core.fsm/src/org/eclipse/etrice/core/fsm/validation/FSMValidationUtil.java
@@ -174,8 +174,8 @@
 	}
 
 	public Result isValid(TrPoint tp) {
-		if (!isUniqueName(tp, tp.getName()).isOk())
-			return Result.error("name is not unique", tp, FSMPackage.Literals.TR_POINT__NAME);
+//		if (!isUniqueName(tp, tp.getName()).isOk())
+//			return Result.error("name is not unique", tp, FSMPackage.Literals.TR_POINT__NAME);
 		
 		if (tp instanceof TransitionPoint)
 			return Result.ok();
diff --git a/plugins/org.eclipse.etrice.core.fsm/xtend-gen/org/eclipse/etrice/core/fsm/postprocessing/ImplPostprocessor.java b/plugins/org.eclipse.etrice.core.fsm/xtend-gen/org/eclipse/etrice/core/fsm/postprocessing/ImplPostprocessor.java
index ede3a8b..3c6306f 100644
--- a/plugins/org.eclipse.etrice.core.fsm/xtend-gen/org/eclipse/etrice/core/fsm/postprocessing/ImplPostprocessor.java
+++ b/plugins/org.eclipse.etrice.core.fsm/xtend-gen/org/eclipse/etrice/core/fsm/postprocessing/ImplPostprocessor.java
@@ -56,17 +56,23 @@
       _builder_1.newLine();
       PostprocessingHelpers.addOperation(stateGraphItem, "getName", _eClassifier, Integer.valueOf(1), _builder_1.toString());
       final EClass ifItem = PostprocessingHelpers.getClass(fsmPackage, "AbstractInterfaceItem");
-      EClassifier _eClassifier_1 = fsmPackage.getEClassifier("ProtocolSemantics");
-      PostprocessingHelpers.addOperation(ifItem, "getSemantics", _eClassifier_1);
+      EClassifier _eClassifier_1 = EcorePackage.eINSTANCE.getEClassifier("EString");
+      StringConcatenation _builder_2 = new StringConcatenation();
+      _builder_2.append("return getName();");
+      _builder_2.newLine();
+      PostprocessingHelpers.addOperation(ifItem, "getDisplayName", _eClassifier_1, Integer.valueOf(1), _builder_2.toString());
+      EClassifier _eClassifier_2 = fsmPackage.getEClassifier("ProtocolSemantics");
+      PostprocessingHelpers.addOperation(ifItem, "getSemantics", _eClassifier_2);
       PostprocessingHelpers.addOperation(ifItem, "getAllIncomingAbstractMessages", EcorePackage.Literals.EOBJECT, Integer.valueOf((-1)), null);
       PostprocessingHelpers.addOperation(ifItem, "getAllOutgoingAbstractMessages", EcorePackage.Literals.EOBJECT, Integer.valueOf((-1)), null);
+      PostprocessingHelpers.addOperation(ifItem, "isEventDriven", EcorePackage.Literals.EBOOLEAN, Integer.valueOf(1), "return true;");
       final EClass itemOwner = PostprocessingHelpers.addClass(fsmPackage, "IInterfaceItemOwner");
       itemOwner.setAbstract(true);
       itemOwner.setInterface(true);
-      EClassifier _eClassifier_2 = fsmPackage.getEClassifier("AbstractInterfaceItem");
-      PostprocessingHelpers.addOperation(itemOwner, "getAbstractInterfaceItems", _eClassifier_2, Integer.valueOf((-1)), null);
       EClassifier _eClassifier_3 = fsmPackage.getEClassifier("AbstractInterfaceItem");
-      PostprocessingHelpers.addOperation(itemOwner, "getAllAbstractInterfaceItems", _eClassifier_3, Integer.valueOf((-1)), null);
+      PostprocessingHelpers.addOperation(itemOwner, "getAbstractInterfaceItems", _eClassifier_3, Integer.valueOf((-1)), null);
+      EClassifier _eClassifier_4 = fsmPackage.getEClassifier("AbstractInterfaceItem");
+      PostprocessingHelpers.addOperation(itemOwner, "getAllAbstractInterfaceItems", _eClassifier_4, Integer.valueOf((-1)), null);
       final EClass comp = PostprocessingHelpers.getClass(fsmPackage, "ModelComponent");
       EList<EClass> _eSuperTypes = comp.getESuperTypes();
       _xblockexpression = _eSuperTypes.add(itemOwner);
diff --git a/plugins/org.eclipse.etrice.core.genmodel.fsm/model/fsmgen.ecore b/plugins/org.eclipse.etrice.core.genmodel.fsm/model/fsmgen.ecore
index 5ea7ecf..28529c9 100644
--- a/plugins/org.eclipse.etrice.core.genmodel.fsm/model/fsmgen.ecore
+++ b/plugins/org.eclipse.etrice.core.genmodel.fsm/model/fsmgen.ecore
@@ -20,6 +20,9 @@
     <eOperations name="isOwnObject" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EBoolean">
       <eParameters name="obj" eType="ecore:EClass ../../org.eclipse.etrice.core.fsm/model/generated/FSM.ecore#//StateGraphItem"/>
     </eOperations>
+    <eOperations name="hasBaseTransitionDetailCode" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EBoolean">
+      <eParameters name="trans" eType="ecore:EClass ../../org.eclipse.etrice.core.fsm/model/generated/FSM.ecore#//Transition"/>
+    </eOperations>
     <eOperations name="hasStateMachine" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EBoolean"/>
     <eOperations name="getTriggerCodeName" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString">
       <eParameters name="mif" eType="ecore:EClass ../../org.eclipse.etrice.core.fsm/model/generated/FSM.ecore#//MessageFromIf"/>
diff --git a/plugins/org.eclipse.etrice.core.genmodel.fsm/src/org/eclipse/etrice/core/genmodel/fsm/fsmgen/ExpandedModelComponent.java b/plugins/org.eclipse.etrice.core.genmodel.fsm/src/org/eclipse/etrice/core/genmodel/fsm/fsmgen/ExpandedModelComponent.java
index 0c214fc..5b570a9 100644
--- a/plugins/org.eclipse.etrice.core.genmodel.fsm/src/org/eclipse/etrice/core/genmodel/fsm/fsmgen/ExpandedModelComponent.java
+++ b/plugins/org.eclipse.etrice.core.genmodel.fsm/src/org/eclipse/etrice/core/genmodel/fsm/fsmgen/ExpandedModelComponent.java
@@ -129,6 +129,14 @@
 
 	/**
 	 * <!-- begin-user-doc -->
+     * <!-- end-user-doc -->
+	 * @model
+	 * @generated
+	 */
+    boolean hasBaseTransitionDetailCode(Transition trans);
+
+    /**
+	 * <!-- begin-user-doc -->
 	 * <!-- end-user-doc -->
 	 * @model
 	 * @generated
diff --git a/plugins/org.eclipse.etrice.core.genmodel.fsm/src/org/eclipse/etrice/core/genmodel/fsm/fsmgen/impl/ExpandedModelComponentImpl.java b/plugins/org.eclipse.etrice.core.genmodel.fsm/src/org/eclipse/etrice/core/genmodel/fsm/fsmgen/impl/ExpandedModelComponentImpl.java
index 54316ba..757d42f 100644
--- a/plugins/org.eclipse.etrice.core.genmodel.fsm/src/org/eclipse/etrice/core/genmodel/fsm/fsmgen/impl/ExpandedModelComponentImpl.java
+++ b/plugins/org.eclipse.etrice.core.genmodel.fsm/src/org/eclipse/etrice/core/genmodel/fsm/fsmgen/impl/ExpandedModelComponentImpl.java
@@ -204,6 +204,7 @@
 	private boolean prepared = false;
 	private HashSet<StateGraphItem> ownObjects = null;
 	private HashSet<Transition> targetsOfRefinedTransitions = null;
+    private HashSet<Transition> baseTransitionHasDetailCode = null;
 	private HashMap<AbstractInterfaceItem, Integer> ifitem2localId = null;
 	private HashMap<StateGraphNode, NodeData> node2data = null;
 	private HashMap<State, LinkedList<ActiveTrigger>> state2triggers = null;
@@ -379,10 +380,13 @@
 		for (Entry<Transition, DetailCode> entry : trans2refinedAction.entrySet()) {
 			ownObjects.add(entry.getKey());
 			targetsOfRefinedTransitions.add(entry.getKey());
-			if (entry.getKey().getAction()==null)
-				entry.getKey().setAction(entry.getValue());
-			else
-				entry.getKey().getAction().getLines().addAll(entry.getValue().getLines());
+			if (entry.getKey().getAction()==null) {
+			    entry.getKey().setAction(entry.getValue());
+			}
+			else {
+			    baseTransitionHasDetailCode.add(entry.getKey());
+			    entry.getKey().getAction().getLines().addAll(entry.getValue().getLines());
+			}
 		}
 	}
 
@@ -827,6 +831,7 @@
 		ifitem2localId = new HashMap<AbstractInterfaceItem, Integer>();
 		ownObjects = new HashSet<StateGraphItem>();
 		targetsOfRefinedTransitions = new HashSet<Transition>();
+        baseTransitionHasDetailCode = new HashSet<Transition>();
 		node2data = new HashMap<StateGraphNode, NodeData>();
 		state2triggers = new HashMap<State, LinkedList<ActiveTrigger>>();
 		triggerstring2mif = new HashMap<String, MessageFromIf>();
@@ -912,7 +917,16 @@
 		return ownObjects.contains(obj);
 	}
 	
-	private int computeInterfaceItemLocalIds(ModelComponent mc, int offset) {
+	/**
+     * <!-- begin-user-doc -->
+     * <!-- end-user-doc -->
+     * @generated NOT
+     */
+    public boolean hasBaseTransitionDetailCode(Transition trans) {
+        return baseTransitionHasDetailCode.contains(trans);
+    }
+
+    private int computeInterfaceItemLocalIds(ModelComponent mc, int offset) {
 		if (mc.getBase()!=null) {
 			// first recurse into base class
 			offset = computeInterfaceItemLocalIds(mc.getBase(), offset);
diff --git a/plugins/org.eclipse.etrice.core.genmodel.fsm/src/org/eclipse/etrice/core/genmodel/fsm/fsmgen/impl/FsmGenPackageImpl.java b/plugins/org.eclipse.etrice.core.genmodel.fsm/src/org/eclipse/etrice/core/genmodel/fsm/fsmgen/impl/FsmGenPackageImpl.java
index c61c8ef..ccef52d 100644
--- a/plugins/org.eclipse.etrice.core.genmodel.fsm/src/org/eclipse/etrice/core/genmodel/fsm/fsmgen/impl/FsmGenPackageImpl.java
+++ b/plugins/org.eclipse.etrice.core.genmodel.fsm/src/org/eclipse/etrice/core/genmodel/fsm/fsmgen/impl/FsmGenPackageImpl.java
@@ -409,6 +409,9 @@
 		op = addEOperation(expandedModelComponentEClass, ecorePackage.getEBoolean(), "isOwnObject", 0, 1, IS_UNIQUE, IS_ORDERED);
 		addEParameter(op, theFSMPackage.getStateGraphItem(), "obj", 0, 1, IS_UNIQUE, IS_ORDERED);
 
+		op = addEOperation(expandedModelComponentEClass, ecorePackage.getEBoolean(), "hasBaseTransitionDetailCode", 0, 1, IS_UNIQUE, IS_ORDERED);
+		addEParameter(op, theFSMPackage.getTransition(), "trans", 0, 1, IS_UNIQUE, IS_ORDERED);
+
 		addEOperation(expandedModelComponentEClass, ecorePackage.getEBoolean(), "hasStateMachine", 0, 1, IS_UNIQUE, IS_ORDERED);
 
 		op = addEOperation(expandedModelComponentEClass, ecorePackage.getEString(), "getTriggerCodeName", 0, 1, IS_UNIQUE, IS_ORDERED);
diff --git a/plugins/org.eclipse.etrice.core.genmodel/src/org/eclipse/etrice/core/genmodel/etricegen/util/ETriceGenUtil.java b/plugins/org.eclipse.etrice.core.genmodel.fsm/src/org/eclipse/etrice/core/genmodel/fsm/fsmgen/util/FsmGenUtil.java
similarity index 81%
rename from plugins/org.eclipse.etrice.core.genmodel/src/org/eclipse/etrice/core/genmodel/etricegen/util/ETriceGenUtil.java
rename to plugins/org.eclipse.etrice.core.genmodel.fsm/src/org/eclipse/etrice/core/genmodel/fsm/fsmgen/util/FsmGenUtil.java
index 5c84706..dae41c9 100644
--- a/plugins/org.eclipse.etrice.core.genmodel/src/org/eclipse/etrice/core/genmodel/etricegen/util/ETriceGenUtil.java
+++ b/plugins/org.eclipse.etrice.core.genmodel.fsm/src/org/eclipse/etrice/core/genmodel/fsm/fsmgen/util/FsmGenUtil.java
@@ -10,22 +10,21 @@
  * 
  *******************************************************************************/
 
-package org.eclipse.etrice.core.genmodel.etricegen.util;
+package org.eclipse.etrice.core.genmodel.fsm.fsmgen.util;
 
-import org.eclipse.etrice.core.genmodel.etricegen.ETriceGenFactory;
-import org.eclipse.etrice.core.genmodel.fsm.fsmgen.ActiveTrigger;
 import org.eclipse.etrice.core.fsm.fSM.Trigger;
 import org.eclipse.etrice.core.fsm.fSM.TriggeredTransition;
 import org.eclipse.etrice.core.fsm.util.FSMHelpers;
-import org.eclipse.etrice.core.room.util.RoomHelpers;
+import org.eclipse.etrice.core.genmodel.fsm.fsmgen.ActiveTrigger;
+import org.eclipse.etrice.core.genmodel.fsm.fsmgen.FsmGenFactory;
 
 /**
  * @author Henrik Rentz-Reichert
  *
  */
-public class ETriceGenUtil {
+public class FsmGenUtil {
 	
-	private FSMHelpers fsmHelpers = new RoomHelpers();
+	private FSMHelpers fsmHelpers = new FSMHelpers();
 
 	/**
 	 * @param trig the trigger
@@ -35,7 +34,7 @@
 	 * @see org.eclipse.etrice.core.genmodel.etricegen.ExpandedActorClass#isMatching(Trigger, String)
 	 */
 	public boolean isMatching(Trigger trig, String trigstr) {
-		return ETriceGenFactory.eINSTANCE.createExpandedActorClass().isMatching(trig, trigstr);
+		return FsmGenFactory.eINSTANCE.createExpandedModelComponent().isMatching(trig, trigstr);
 	}
 	
 	/**
diff --git a/plugins/org.eclipse.etrice.core.room.ui/.settings/org.eclipse.core.resources.prefs b/plugins/org.eclipse.etrice.core.room.ui/.settings/org.eclipse.core.resources.prefs
new file mode 100644
index 0000000..1a9b29c
--- /dev/null
+++ b/plugins/org.eclipse.etrice.core.room.ui/.settings/org.eclipse.core.resources.prefs
@@ -0,0 +1,2 @@
+eclipse.preferences.version=1
+encoding/<project>=cp1252
diff --git a/plugins/org.eclipse.etrice.core.room/src-gen/org/eclipse/etrice/core/room/InterfaceItem.java b/plugins/org.eclipse.etrice.core.room/src-gen/org/eclipse/etrice/core/room/InterfaceItem.java
index acdc980..b9f8fe0 100644
--- a/plugins/org.eclipse.etrice.core.room/src-gen/org/eclipse/etrice/core/room/InterfaceItem.java
+++ b/plugins/org.eclipse.etrice.core.room/src-gen/org/eclipse/etrice/core/room/InterfaceItem.java
@@ -69,4 +69,13 @@
    */
   EList<EObject> getAllOutgoingAbstractMessages();
 
+  /**
+   * <!-- begin-user-doc -->
+   * <!-- end-user-doc -->
+   * @model kind="operation"
+   *        annotation="http://www.eclipse.org/emf/2002/GenModel body='if (getGeneralProtocol() instanceof ProtocolClass)\n    return ((ProtocolClass) getGeneralProtocol()).getCommType() == <%org.eclipse.etrice.core.room.CommunicationType%>.EVENT_DRIVEN;\nelse\n    return false;\n'"
+   * @generated
+   */
+  boolean isEventDriven();
+
 } // InterfaceItem
diff --git a/plugins/org.eclipse.etrice.core.room/src-gen/org/eclipse/etrice/core/room/impl/InterfaceItemImpl.java b/plugins/org.eclipse.etrice.core.room/src-gen/org/eclipse/etrice/core/room/impl/InterfaceItemImpl.java
index 3cc4c5b..a0be40e 100644
--- a/plugins/org.eclipse.etrice.core.room/src-gen/org/eclipse/etrice/core/room/impl/InterfaceItemImpl.java
+++ b/plugins/org.eclipse.etrice.core.room/src-gen/org/eclipse/etrice/core/room/impl/InterfaceItemImpl.java
@@ -12,6 +12,7 @@
 
 import org.eclipse.etrice.core.fsm.fSM.impl.AbstractInterfaceItemImpl;
 
+import org.eclipse.etrice.core.room.CommunicationType;
 import org.eclipse.etrice.core.room.GeneralProtocolClass;
 import org.eclipse.etrice.core.room.InterfaceItem;
 import org.eclipse.etrice.core.room.Port;
@@ -107,4 +108,18 @@
     
   }
 
+  /**
+   * <!-- begin-user-doc -->
+   * <!-- end-user-doc -->
+   * @generated
+   */
+  public boolean isEventDriven()
+  {
+    if (getGeneralProtocol() instanceof ProtocolClass)
+        return ((ProtocolClass) getGeneralProtocol()).getCommType() == CommunicationType.EVENT_DRIVEN;
+    else
+        return false;
+    
+  }
+
 } //InterfaceItemImpl
diff --git a/plugins/org.eclipse.etrice.core.room/src-gen/org/eclipse/etrice/core/room/impl/RoomPackageImpl.java b/plugins/org.eclipse.etrice.core.room/src-gen/org/eclipse/etrice/core/room/impl/RoomPackageImpl.java
index 5c719e0..8476394 100644
--- a/plugins/org.eclipse.etrice.core.room/src-gen/org/eclipse/etrice/core/room/impl/RoomPackageImpl.java
+++ b/plugins/org.eclipse.etrice.core.room/src-gen/org/eclipse/etrice/core/room/impl/RoomPackageImpl.java
@@ -2767,6 +2767,8 @@
 
     addEOperation(interfaceItemEClass, ecorePackage.getEObject(), "getAllOutgoingAbstractMessages", 0, -1, IS_UNIQUE, IS_ORDERED);
 
+    addEOperation(interfaceItemEClass, ecorePackage.getEBoolean(), "isEventDriven", 0, 1, IS_UNIQUE, IS_ORDERED);
+
     initEClass(portEClass, Port.class, "Port", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS);
     initEAttribute(getPort_Conjugated(), ecorePackage.getEBoolean(), "conjugated", null, 0, 1, Port.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
     initEAttribute(getPort_Multiplicity(), ecorePackage.getEInt(), "multiplicity", "1", 0, 1, Port.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
diff --git a/plugins/org.eclipse.etrice.core.room/src/org/eclipse/etrice/core/RoomRuntimeModule.java b/plugins/org.eclipse.etrice.core.room/src/org/eclipse/etrice/core/RoomRuntimeModule.java
index c2d5664..5508af5 100644
--- a/plugins/org.eclipse.etrice.core.room/src/org/eclipse/etrice/core/RoomRuntimeModule.java
+++ b/plugins/org.eclipse.etrice.core.room/src/org/eclipse/etrice/core/RoomRuntimeModule.java
@@ -37,6 +37,7 @@
 	public void configure(Binder binder) {
 		super.configure(binder);
 		
+		// HOWTO: bind a validator in stand alone mode (usually contributed by extension point)
 		if(!ValidatorExtensionManager.Registry.isAvailable())
 			bindCustomValidator(binder);
 	}
diff --git a/plugins/org.eclipse.etrice.core.room/src/org/eclipse/etrice/core/postprocessing/ImplPostprocessor.xtend b/plugins/org.eclipse.etrice.core.room/src/org/eclipse/etrice/core/postprocessing/ImplPostprocessor.xtend
index 60a5d43..4bc5fa5 100644
--- a/plugins/org.eclipse.etrice.core.room/src/org/eclipse/etrice/core/postprocessing/ImplPostprocessor.xtend
+++ b/plugins/org.eclipse.etrice.core.room/src/org/eclipse/etrice/core/postprocessing/ImplPostprocessor.xtend
@@ -58,7 +58,15 @@
 			return new <%org.eclipse.emf.common.util.BasicEList%><EObject>(new <%org.eclipse.etrice.core.room.util.RoomHelpers%>().getMessageListDeep(this, true));
 			'''
 		)
-			
+        interfaceItem.addOperation("isEventDriven", EcorePackage.Literals.EBOOLEAN, 1, 
+            '''
+            if (getGeneralProtocol() instanceof ProtocolClass)
+                return ((ProtocolClass) getGeneralProtocol()).getCommType() == <%org.eclipse.etrice.core.room.CommunicationType%>.EVENT_DRIVEN;
+            else
+                return false;
+            '''
+        )
+		
 		val actorClass = roomPackage.getClass("ActorClass")
 		actorClass.addOperation("getExternalEndPorts", roomPackage.getEClassifier("Port"), -1,
 			'''
diff --git a/plugins/org.eclipse.etrice.core.room/src/org/eclipse/etrice/core/room/util/RoomHelpers.java b/plugins/org.eclipse.etrice.core.room/src/org/eclipse/etrice/core/room/util/RoomHelpers.java
index 407ad10..d67cb72 100644
--- a/plugins/org.eclipse.etrice.core.room/src/org/eclipse/etrice/core/room/util/RoomHelpers.java
+++ b/plugins/org.eclipse.etrice.core.room/src/org/eclipse/etrice/core/room/util/RoomHelpers.java
@@ -22,12 +22,7 @@
 import org.eclipse.etrice.core.common.base.Annotation;
 import org.eclipse.etrice.core.common.base.KeyValue;
 import org.eclipse.etrice.core.fsm.fSM.DetailCode;
-import org.eclipse.etrice.core.fsm.fSM.FSMFactory;
-import org.eclipse.etrice.core.fsm.fSM.InitialTransition;
-import org.eclipse.etrice.core.fsm.fSM.MessageFromIf;
-import org.eclipse.etrice.core.fsm.fSM.StateGraph;
 import org.eclipse.etrice.core.fsm.fSM.StateGraphItem;
-import org.eclipse.etrice.core.fsm.fSM.Transition;
 import org.eclipse.etrice.core.fsm.util.FSMHelpers;
 import org.eclipse.etrice.core.room.ActorClass;
 import org.eclipse.etrice.core.room.ActorContainerClass;
@@ -686,97 +681,6 @@
 	}
 	
 	/**
-	 * @param ac an {@link ActorClass}
-	 * @return a list of {@link MessageFromIf} that may come in through one of the
-	 * event driven interface items of this actor class (<i>without</i> inherited ones)
-	 */
-	public List<MessageFromIf> getMessagesFromInterfaces(ActorClass ac) {
-		ArrayList<MessageFromIf> result = new ArrayList<MessageFromIf>();
-		
-		List<InterfaceItem> items = getInterfaceItems(ac);
-		for (InterfaceItem item : items) {
-			if (item.getGeneralProtocol() instanceof ProtocolClass) {
-				ProtocolClass pc = (ProtocolClass) item.getGeneralProtocol();
-				if (pc.getCommType()==CommunicationType.EVENT_DRIVEN) {
-					for (Message msg : getIncoming(item)) {
-						MessageFromIf mif = FSMFactory.eINSTANCE.createMessageFromIf();
-						mif.setMessage(msg);
-						mif.setFrom(item);
-						result.add(mif);
-					}
-				}
-			}
-		}
-		
-		return result;
-	}
-	
-	/**
-	 * @param ac an {@link ActorClass}
-	 * @return a list of {@link MessageFromIf} that may come in through one of the
-	 * event driven interface items of this actor class (<i>with</i> inherited ones as far as a base class has its own state machine)
-	 */
-	public List<MessageFromIf> getOwnMessagesFromInterfaces(ActorClass ac) {
-		ArrayList<MessageFromIf> result = new ArrayList<MessageFromIf>();
-		
-		result.addAll(getMessagesFromInterfaces(ac));
-		ac = ac.getActorBase();
-		while (ac!=null) {
-			if (hasNonEmptyStateMachine(ac))
-				break;
-			
-			List<InterfaceItem> items = getInterfaceItems(ac);
-			for (InterfaceItem item : items) {
-				if (item.getGeneralProtocol() instanceof ProtocolClass) {
-					ProtocolClass pc = (ProtocolClass) item.getGeneralProtocol();
-					if (pc.getCommType()==CommunicationType.EVENT_DRIVEN) {
-						for (Message msg : getIncoming(item)) {
-							MessageFromIf mif = FSMFactory.eINSTANCE.createMessageFromIf();
-							mif.setMessage(msg);
-							mif.setFrom(item);
-							result.add(mif);
-						}
-					}
-				}
-			}
-			
-			ac = ac.getActorBase();
-		}
-		
-		return result;
-	}
-	
-	/**
-	 * @param ac an {@link ActorClass}
-	 * @return a list of {@link MessageFromIf} that may come in through one of the
-	 * event driven interface items of this actor class(<i>including</i> inherited ones)
-	 */
-	public List<MessageFromIf> getAllMessagesFromInterfaces(ActorClass ac) {
-		ArrayList<MessageFromIf> result = new ArrayList<MessageFromIf>();
-		
-		while (ac!=null) {
-			List<InterfaceItem> items = getInterfaceItems(ac);
-			for (InterfaceItem item : items) {
-				if (item.getGeneralProtocol() instanceof ProtocolClass) {
-					ProtocolClass pc = (ProtocolClass) item.getGeneralProtocol();
-					if (pc.getCommType()==CommunicationType.EVENT_DRIVEN) {
-						for (Message msg : getIncoming(item)) {
-							MessageFromIf mif = FSMFactory.eINSTANCE.createMessageFromIf();
-							mif.setMessage(msg);
-							mif.setFrom(item);
-							result.add(mif);
-						}
-					}
-				}
-			}
-			
-			ac = ac.getActorBase();
-		}
-		
-		return result;
-	}
-	
-	/**
 	 * @param dc the data class to check
 	 * @return {@code true} if the class hierarchy is circular (i.e. a base class refers to one of its sub classes)
 	 */
@@ -1437,26 +1341,6 @@
 	}
 
 	/**
-	 * @param sg a {@link StateGraph}
-	 * @return the initial transition or <code>null</code> if no such is available
-	 */
-	public Transition getInitTransition(StateGraph sg) {
-		for (Transition tr : sg.getTransitions()) {
-			if (tr instanceof InitialTransition)
-				return tr;
-		}
-		return null;
-	}
-	
-	/**
-	 * @param sg a {@link StateGraph}
-	 * @return <code>true</code> if an initial transition is available
-	 */
-	public boolean hasInitTransition(StateGraph sg) {
-		return getInitTransition(sg)!=null;
-	}
-	
-	/**
 	 * Returns the parent container of an {@link ActorInstanceMapping}.
 	 * 
 	 * @param aim the actor instance mapping
diff --git a/plugins/org.eclipse.etrice.core.room/src/org/eclipse/etrice/core/validation/RoomJavaValidator.java b/plugins/org.eclipse.etrice.core.room/src/org/eclipse/etrice/core/validation/RoomJavaValidator.java
index 70cfb2b..d5b60b7 100644
--- a/plugins/org.eclipse.etrice.core.room/src/org/eclipse/etrice/core/validation/RoomJavaValidator.java
+++ b/plugins/org.eclipse.etrice.core.room/src/org/eclipse/etrice/core/validation/RoomJavaValidator.java
@@ -182,7 +182,7 @@
 				for (Port p : ac.getInterfacePorts()) {
 					if (p.getMultiplicity()<0) {
 						int idx = ((ActorContainerClass)ar.eContainer()).getActorRefs().indexOf(ar);
-						error("replicated actor must not have replicated port with arbitrary multiplicity", RoomPackage.Literals.ACTOR_CONTAINER_CLASS__ACTOR_REFS, idx);
+						error("replicated actor must not have replicated port with arbitrary multiplicity", null);
 					}
 				}
 			}
@@ -192,10 +192,8 @@
 	@Check
 	public void checkLayerConnectiontarget(LayerConnection lc) {
 		if (lc.getTo().getRef() instanceof ActorRef)
-			if (((ActorRef)lc.getTo().getRef()).getMultiplicity()>1) {
-				int idx = ((StructureClass)lc.eContainer()).getConnections().indexOf(lc);
-				error("layer connection must not connect to replicated actor", RoomPackage.Literals.STRUCTURE_CLASS__CONNECTIONS, idx);
-			}
+			if (((ActorRef)lc.getTo().getRef()).getMultiplicity()>1) 
+				error("layer connection must not connect to replicated actor", null);		
 	}
 	
 	@Check
@@ -317,6 +315,8 @@
 			else
 				name2obj.put(ref.getName(), ref);
 		}
+		
+		
 	}
 	
 	@Check
@@ -561,6 +561,10 @@
 
 	@Check
 	public void checkOperation(StandardOperation op) {
+		RoomClass cls = (RoomClass) op.eContainer();
+//		if(cls instanceof RoomClass && !roomHelpers.isCircularClassHierarchy((RoomClass)cls)){
+//			
+//		}
 		if (roomHelpers.isConstructor(op)) {
 			if (!op.getArguments().isEmpty())
 				error("Constructor must have no arguments", RoomPackage.Literals.OPERATION__ARGUMENTS);
@@ -574,11 +578,9 @@
 				error("Destructor must have no return type", RoomPackage.Literals.OPERATION__RETURN_TYPE);
 		}
 		else if (op.isDestructor()) {
-			RoomClass cls = (RoomClass) op.eContainer();
 			error("Destructor must have class name", RoomPackage.Literals.OPERATION__NAME, CHANGE_DESTRUCTOR_NAME, cls.getName());
 		}
 		else if (op.getArguments().isEmpty()) {
-			RoomClass cls = (RoomClass) op.eContainer();
 			
 			// check for method with same name with destructor flag set
 			EList<StandardOperation> ops = null;
diff --git a/plugins/org.eclipse.etrice.core.room/xtend-gen/org/eclipse/etrice/core/postprocessing/ImplPostprocessor.java b/plugins/org.eclipse.etrice.core.room/xtend-gen/org/eclipse/etrice/core/postprocessing/ImplPostprocessor.java
index e7baf7c..63fde61 100644
--- a/plugins/org.eclipse.etrice.core.room/xtend-gen/org/eclipse/etrice/core/postprocessing/ImplPostprocessor.java
+++ b/plugins/org.eclipse.etrice.core.room/xtend-gen/org/eclipse/etrice/core/postprocessing/ImplPostprocessor.java
@@ -77,149 +77,161 @@
       _builder_4.append("return new <%org.eclipse.emf.common.util.BasicEList%><EObject>(new <%org.eclipse.etrice.core.room.util.RoomHelpers%>().getMessageListDeep(this, true));");
       _builder_4.newLine();
       PostprocessingHelpers.addOperation(interfaceItem, "getAllOutgoingAbstractMessages", EcorePackage.Literals.EOBJECT, Integer.valueOf((-1)), _builder_4.toString());
+      StringConcatenation _builder_5 = new StringConcatenation();
+      _builder_5.append("if (getGeneralProtocol() instanceof ProtocolClass)");
+      _builder_5.newLine();
+      _builder_5.append("    ");
+      _builder_5.append("return ((ProtocolClass) getGeneralProtocol()).getCommType() == <%org.eclipse.etrice.core.room.CommunicationType%>.EVENT_DRIVEN;");
+      _builder_5.newLine();
+      _builder_5.append("else");
+      _builder_5.newLine();
+      _builder_5.append("    ");
+      _builder_5.append("return false;");
+      _builder_5.newLine();
+      PostprocessingHelpers.addOperation(interfaceItem, "isEventDriven", EcorePackage.Literals.EBOOLEAN, Integer.valueOf(1), _builder_5.toString());
       final EClass actorClass = PostprocessingHelpers.getClass(roomPackage, "ActorClass");
       EClassifier _eClassifier_2 = roomPackage.getEClassifier("Port");
-      StringConcatenation _builder_5 = new StringConcatenation();
-      _builder_5.append("EList<Port> ports = new BasicEList<Port>();");
-      _builder_5.newLine();
-      _builder_5.append("for (ExternalPort ep : getExternalPorts()) {");
-      _builder_5.newLine();
-      _builder_5.append("\t");
-      _builder_5.append("ports.add(ep.getInterfacePort());");
-      _builder_5.newLine();
-      _builder_5.append("}");
-      _builder_5.newLine();
-      _builder_5.append("return ports;");
-      _builder_5.newLine();
-      PostprocessingHelpers.addOperation(actorClass, "getExternalEndPorts", _eClassifier_2, Integer.valueOf((-1)), _builder_5.toString());
-      EClassifier _eClassifier_3 = roomPackage.getEClassifier("Port");
       StringConcatenation _builder_6 = new StringConcatenation();
-      _builder_6.append("EList<Port> ports = new BasicEList<Port>(getInterfacePorts());");
+      _builder_6.append("EList<Port> ports = new BasicEList<Port>();");
       _builder_6.newLine();
       _builder_6.append("for (ExternalPort ep : getExternalPorts()) {");
       _builder_6.newLine();
       _builder_6.append("\t");
-      _builder_6.append("ports.remove(ep.getInterfacePort());");
+      _builder_6.append("ports.add(ep.getInterfacePort());");
       _builder_6.newLine();
       _builder_6.append("}");
       _builder_6.newLine();
       _builder_6.append("return ports;");
       _builder_6.newLine();
-      PostprocessingHelpers.addOperation(actorClass, "getRelayPorts", _eClassifier_3, Integer.valueOf((-1)), _builder_6.toString());
-      EClassifier _eClassifier_4 = roomPackage.getEClassifier("SPP");
+      PostprocessingHelpers.addOperation(actorClass, "getExternalEndPorts", _eClassifier_2, Integer.valueOf((-1)), _builder_6.toString());
+      EClassifier _eClassifier_3 = roomPackage.getEClassifier("Port");
       StringConcatenation _builder_7 = new StringConcatenation();
-      _builder_7.append("EList<SPP> spps = new BasicEList<SPP>();");
+      _builder_7.append("EList<Port> ports = new BasicEList<Port>(getInterfacePorts());");
       _builder_7.newLine();
-      _builder_7.append("for (ServiceImplementation spp : getServiceImplementations()) {");
+      _builder_7.append("for (ExternalPort ep : getExternalPorts()) {");
       _builder_7.newLine();
       _builder_7.append("\t");
-      _builder_7.append("spps.add(spp.getSpp());");
+      _builder_7.append("ports.remove(ep.getInterfacePort());");
       _builder_7.newLine();
       _builder_7.append("}");
       _builder_7.newLine();
-      _builder_7.append("return spps;");
+      _builder_7.append("return ports;");
       _builder_7.newLine();
-      PostprocessingHelpers.addOperation(actorClass, "getImplementedSPPs", _eClassifier_4, Integer.valueOf((-1)), _builder_7.toString());
-      EClassifier _eClassifier_5 = roomPackage.getEClassifier("ActorClass");
+      PostprocessingHelpers.addOperation(actorClass, "getRelayPorts", _eClassifier_3, Integer.valueOf((-1)), _builder_7.toString());
+      EClassifier _eClassifier_4 = roomPackage.getEClassifier("SPP");
       StringConcatenation _builder_8 = new StringConcatenation();
-      _builder_8.append("return (ActorClass)getBase();");
+      _builder_8.append("EList<SPP> spps = new BasicEList<SPP>();");
       _builder_8.newLine();
-      PostprocessingHelpers.addOperation(actorClass, "getActorBase", _eClassifier_5, Integer.valueOf(1), _builder_8.toString());
-      EClassifier _eClassifier_6 = EcorePackage.eINSTANCE.getEClassifier("EString");
+      _builder_8.append("for (ServiceImplementation spp : getServiceImplementations()) {");
+      _builder_8.newLine();
+      _builder_8.append("\t");
+      _builder_8.append("spps.add(spp.getSpp());");
+      _builder_8.newLine();
+      _builder_8.append("}");
+      _builder_8.newLine();
+      _builder_8.append("return spps;");
+      _builder_8.newLine();
+      PostprocessingHelpers.addOperation(actorClass, "getImplementedSPPs", _eClassifier_4, Integer.valueOf((-1)), _builder_8.toString());
+      EClassifier _eClassifier_5 = roomPackage.getEClassifier("ActorClass");
       StringConcatenation _builder_9 = new StringConcatenation();
-      _builder_9.append("return getName();");
+      _builder_9.append("return (ActorClass)getBase();");
       _builder_9.newLine();
-      PostprocessingHelpers.addOperation(actorClass, "getComponentName", _eClassifier_6, Integer.valueOf(1), _builder_9.toString());
+      PostprocessingHelpers.addOperation(actorClass, "getActorBase", _eClassifier_5, Integer.valueOf(1), _builder_9.toString());
+      EClassifier _eClassifier_6 = EcorePackage.eINSTANCE.getEClassifier("EString");
       StringConcatenation _builder_10 = new StringConcatenation();
-      _builder_10.append("return new <%org.eclipse.emf.common.util.BasicEList%><AbstractInterfaceItem>(new <%org.eclipse.etrice.core.room.util.RoomHelpers%>().getInterfaceItems(this));");
+      _builder_10.append("return getName();");
       _builder_10.newLine();
-      PostprocessingHelpers.addOperation(actorClass, "getAbstractInterfaceItems", FSMPackage.Literals.ABSTRACT_INTERFACE_ITEM, Integer.valueOf((-1)), _builder_10.toString());
+      PostprocessingHelpers.addOperation(actorClass, "getComponentName", _eClassifier_6, Integer.valueOf(1), _builder_10.toString());
       StringConcatenation _builder_11 = new StringConcatenation();
-      _builder_11.append("return new <%org.eclipse.emf.common.util.BasicEList%><AbstractInterfaceItem>(new <%org.eclipse.etrice.core.room.util.RoomHelpers%>().getAllInterfaceItems(this));");
+      _builder_11.append("return new <%org.eclipse.emf.common.util.BasicEList%><AbstractInterfaceItem>(new <%org.eclipse.etrice.core.room.util.RoomHelpers%>().getInterfaceItems(this));");
       _builder_11.newLine();
-      PostprocessingHelpers.addOperation(actorClass, "getAllAbstractInterfaceItems", FSMPackage.Literals.ABSTRACT_INTERFACE_ITEM, Integer.valueOf((-1)), _builder_11.toString());
+      PostprocessingHelpers.addOperation(actorClass, "getAbstractInterfaceItems", FSMPackage.Literals.ABSTRACT_INTERFACE_ITEM, Integer.valueOf((-1)), _builder_11.toString());
+      StringConcatenation _builder_12 = new StringConcatenation();
+      _builder_12.append("return new <%org.eclipse.emf.common.util.BasicEList%><AbstractInterfaceItem>(new <%org.eclipse.etrice.core.room.util.RoomHelpers%>().getAllInterfaceItems(this));");
+      _builder_12.newLine();
+      PostprocessingHelpers.addOperation(actorClass, "getAllAbstractInterfaceItems", FSMPackage.Literals.ABSTRACT_INTERFACE_ITEM, Integer.valueOf((-1)), _builder_12.toString());
       final EClass actorContainerRef = PostprocessingHelpers.getClass(roomPackage, "ActorContainerRef");
       EClassifier _eClassifier_7 = roomPackage.getEClassifier("StructureClass");
-      StringConcatenation _builder_12 = new StringConcatenation();
-      _builder_12.append("if (this instanceof <%org.eclipse.etrice.core.room.ActorRef%>)");
-      _builder_12.newLine();
-      _builder_12.append("\t");
-      _builder_12.append("return ((ActorRef)this).getType();");
-      _builder_12.newLine();
-      _builder_12.append("else if (this instanceof <%org.eclipse.etrice.core.room.SubSystemRef%>)");
-      _builder_12.newLine();
-      _builder_12.append("\t");
-      _builder_12.append("return ((SubSystemRef)this).getType();");
-      _builder_12.newLine();
-      _builder_12.append("else");
-      _builder_12.newLine();
-      _builder_12.append("\t");
-      _builder_12.append("return null;");
-      _builder_12.newLine();
-      PostprocessingHelpers.addOperation(actorContainerRef, "getStructureClass", _eClassifier_7, 
-        Integer.valueOf(1), _builder_12.toString());
-      final EClass refPath = PostprocessingHelpers.getClass(roomPackage, "RefPath");
-      EClassifier _eClassifier_8 = EcorePackage.eINSTANCE.getEClassifier("EString");
       StringConcatenation _builder_13 = new StringConcatenation();
-      _builder_13.append("StringBuilder sb = new StringBuilder();");
-      _builder_13.newLine();
-      _builder_13.append("for (RefSegment ref : getRefs()) {");
+      _builder_13.append("if (this instanceof <%org.eclipse.etrice.core.room.ActorRef%>)");
       _builder_13.newLine();
       _builder_13.append("\t");
-      _builder_13.append("sb.append(\"/\"+ref.toString());");
+      _builder_13.append("return ((ActorRef)this).getType();");
       _builder_13.newLine();
-      _builder_13.append("}");
+      _builder_13.append("else if (this instanceof <%org.eclipse.etrice.core.room.SubSystemRef%>)");
       _builder_13.newLine();
-      _builder_13.append("return sb.toString();");
+      _builder_13.append("\t");
+      _builder_13.append("return ((SubSystemRef)this).getType();");
       _builder_13.newLine();
+      _builder_13.append("else");
+      _builder_13.newLine();
+      _builder_13.append("\t");
+      _builder_13.append("return null;");
+      _builder_13.newLine();
+      PostprocessingHelpers.addOperation(actorContainerRef, "getStructureClass", _eClassifier_7, 
+        Integer.valueOf(1), _builder_13.toString());
+      final EClass refPath = PostprocessingHelpers.getClass(roomPackage, "RefPath");
+      EClassifier _eClassifier_8 = EcorePackage.eINSTANCE.getEClassifier("EString");
+      StringConcatenation _builder_14 = new StringConcatenation();
+      _builder_14.append("StringBuilder sb = new StringBuilder();");
+      _builder_14.newLine();
+      _builder_14.append("for (RefSegment ref : getRefs()) {");
+      _builder_14.newLine();
+      _builder_14.append("\t");
+      _builder_14.append("sb.append(\"/\"+ref.toString());");
+      _builder_14.newLine();
+      _builder_14.append("}");
+      _builder_14.newLine();
+      _builder_14.append("return sb.toString();");
+      _builder_14.newLine();
       PostprocessingHelpers.addOperation(refPath, 
         "toString", _eClassifier_8, 
-        Integer.valueOf(1), _builder_13.toString());
+        Integer.valueOf(1), _builder_14.toString());
       final EClass refSeg = PostprocessingHelpers.getClass(roomPackage, "RefSegment");
       EAttribute _attribute_2 = PostprocessingHelpers.getAttribute(refSeg, "idx");
       _attribute_2.setDefaultValueLiteral("-1");
       EClassifier _eClassifier_9 = EcorePackage.eINSTANCE.getEClassifier("EString");
-      StringConcatenation _builder_14 = new StringConcatenation();
-      _builder_14.append("return getRef() + ((getIdx()>=0)? \":\"+getIdx() : \"\");");
-      _builder_14.newLine();
+      StringConcatenation _builder_15 = new StringConcatenation();
+      _builder_15.append("return getRef() + ((getIdx()>=0)? \":\"+getIdx() : \"\");");
+      _builder_15.newLine();
       PostprocessingHelpers.addOperation(refSeg, 
         "toString", _eClassifier_9, 
-        Integer.valueOf(1), _builder_14.toString());
+        Integer.valueOf(1), _builder_15.toString());
       final EClass enumLiteral = PostprocessingHelpers.getClass(roomPackage, "EnumLiteral");
       EClassifier _eClassifier_10 = EcorePackage.eINSTANCE.getEClassifier("ELong");
-      StringConcatenation _builder_15 = new StringConcatenation();
-      _builder_15.append("if (this.getLiteral() != null)");
-      _builder_15.newLine();
-      _builder_15.append("\t");
-      _builder_15.append("return this.getLiteral().getValue();");
-      _builder_15.newLine();
-      _builder_15.newLine();
-      _builder_15.append("// recursively from predecessor");
-      _builder_15.newLine();
-      _builder_15.append("<%org.eclipse.etrice.core.room.EnumerationType%> et = ((EnumerationType) this.eContainer());");
-      _builder_15.newLine();
-      _builder_15.append("int idx = et.getLiterals().indexOf(this);");
-      _builder_15.newLine();
-      _builder_15.append("if (idx > 0)");
-      _builder_15.newLine();
-      _builder_15.append("\t");
-      _builder_15.append("return et.getLiterals().get(idx - 1).getLiteralValue() + 1;");
-      _builder_15.newLine();
-      _builder_15.newLine();
-      _builder_15.append("return 0;");
-      _builder_15.newLine();
-      PostprocessingHelpers.addOperation(enumLiteral, 
-        "getLiteralValue", _eClassifier_10, 
-        Integer.valueOf(1), _builder_15.toString());
-      EClassifier _eClassifier_11 = EcorePackage.eINSTANCE.getEClassifier("EString");
       StringConcatenation _builder_16 = new StringConcatenation();
+      _builder_16.append("if (this.getLiteral() != null)");
+      _builder_16.newLine();
+      _builder_16.append("\t");
+      _builder_16.append("return this.getLiteral().getValue();");
+      _builder_16.newLine();
+      _builder_16.newLine();
+      _builder_16.append("// recursively from predecessor");
+      _builder_16.newLine();
       _builder_16.append("<%org.eclipse.etrice.core.room.EnumerationType%> et = ((EnumerationType) this.eContainer());");
       _builder_16.newLine();
-      _builder_16.append("return et.getName() + \".\" + this.getName();");
+      _builder_16.append("int idx = et.getLiterals().indexOf(this);");
       _builder_16.newLine();
+      _builder_16.append("if (idx > 0)");
+      _builder_16.newLine();
+      _builder_16.append("\t");
+      _builder_16.append("return et.getLiterals().get(idx - 1).getLiteralValue() + 1;");
+      _builder_16.newLine();
+      _builder_16.newLine();
+      _builder_16.append("return 0;");
+      _builder_16.newLine();
+      PostprocessingHelpers.addOperation(enumLiteral, 
+        "getLiteralValue", _eClassifier_10, 
+        Integer.valueOf(1), _builder_16.toString());
+      EClassifier _eClassifier_11 = EcorePackage.eINSTANCE.getEClassifier("EString");
+      StringConcatenation _builder_17 = new StringConcatenation();
+      _builder_17.append("<%org.eclipse.etrice.core.room.EnumerationType%> et = ((EnumerationType) this.eContainer());");
+      _builder_17.newLine();
+      _builder_17.append("return et.getName() + \".\" + this.getName();");
+      _builder_17.newLine();
       _xblockexpression = PostprocessingHelpers.addOperation(enumLiteral, 
         "getFullName", _eClassifier_11, 
-        Integer.valueOf(1), _builder_16.toString());
+        Integer.valueOf(1), _builder_17.toString());
     }
     return _xblockexpression;
   }
diff --git a/plugins/org.eclipse.etrice.generator.c/.settings/org.eclipse.core.resources.prefs b/plugins/org.eclipse.etrice.generator.c/.settings/org.eclipse.core.resources.prefs
new file mode 100644
index 0000000..1a9b29c
--- /dev/null
+++ b/plugins/org.eclipse.etrice.generator.c/.settings/org.eclipse.core.resources.prefs
@@ -0,0 +1,2 @@
+eclipse.preferences.version=1
+encoding/<project>=cp1252
diff --git a/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/ActorClassGen.xtend b/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/ActorClassGen.xtend
index 7524129..06b43a0 100644
--- a/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/ActorClassGen.xtend
+++ b/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/ActorClassGen.xtend
@@ -205,7 +205,7 @@
 		val replEventPorts = eventPorts.filter[multiplicity!=1]
 		val sendPorts = ac.allEndPorts.filter(p|(p.protocol as ProtocolClass).commType==CommunicationType::DATA_DRIVEN &&  p.conjugated && p.multiplicity==1)
 		val recvPorts = ac.allEndPorts.filter(p|(p.protocol as ProtocolClass).commType==CommunicationType::DATA_DRIVEN && !p.conjugated && p.multiplicity==1)
-		val portsWithOperations = ac.allEndPorts.filter(p|p.portClass!=null && p.portClass.operations.size>0)
+		val portsWithOperations = ac.allInterfaceItems.filter(p|p.portClass!=null && p.portClass.operations.size>0)
 		val filename = (ac.eContainer as RoomModel).name.replaceAll("\\.","_")+"_"+ac.name+"_Utils"
 		
 	'''
@@ -359,8 +359,11 @@
 		void «ac.name»_receiveMessage(void* self, const void* ifitem, const etMessage* msg){
 			ET_MSC_LOGGER_SYNC_ENTRY("«ac.name»", "_receiveMessage")
 			«IF !xpac.stateMachine.empty»
-				
-				«langExt.operationScope(ac.name, false)»receiveEvent(self«IF handleEvents», (etPort*)ifitem, msg->evtID, (void*)(((char*)msg)+MEM_CEIL(sizeof(etMessage)))«ENDIF»);
+				«IF handleEvents»
+					«langExt.operationScope(ac.name, false)»receiveEvent(self, (etPort*)ifitem, msg->evtID, (void*)(((char*)msg)+MEM_CEIL(sizeof(etMessage))));
+				«ELSE»
+					«langExt.operationScope(ac.name, false)»receiveEventInternal(self);
+				«ENDIF»
 			«ENDIF»
 			
 			ET_MSC_LOGGER_SYNC_EXIT
@@ -371,7 +374,11 @@
 				ET_MSC_LOGGER_SYNC_ENTRY("«ac.name»", "_execute")
 				«IF !xpac.stateMachine.empty»
 					
-					«langExt.operationScope(ac.name, false)»receiveEvent(self«IF handleEvents», NULL, 0, NULL«ENDIF»);
+					«IF handleEvents»
+						«langExt.operationScope(ac.name, false)»receiveEvent(self, NULL, 0, NULL);
+					«ELSE»
+						«langExt.operationScope(ac.name, false)»receiveEventInternal(self);
+					«ENDIF»
 				«ENDIF»
 				
 				ET_MSC_LOGGER_SYNC_EXIT
diff --git a/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/CExtensions.xtend b/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/CExtensions.xtend
index e7ee416..fcb2d9d 100644
--- a/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/CExtensions.xtend
+++ b/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/CExtensions.xtend
@@ -40,6 +40,7 @@
 
 import org.eclipse.etrice.core.room.util.RoomHelpers
 import org.eclipse.etrice.core.room.EnumLiteral
+import org.eclipse.emf.ecore.EObject
 
 @Singleton
 class CExtensions implements ILanguageExtension {
@@ -47,8 +48,13 @@
 	@Inject protected IDiagnostician diagnostician
 	@Inject protected extension RoomHelpers
 
-	override String getTypedDataDefinition(Message m) {
-		generateArglistAndTypedData(m.data).get(1)
+	override String getTypedDataDefinition(EObject msg) {
+	    if (msg instanceof Message) {
+    		generateArglistAndTypedData((msg as Message).data).get(1)
+	    }
+	    else {
+	        ""
+	    }
 	}
 
 	// in C no access levels can be defined
@@ -301,7 +307,11 @@
 			att.type.type.initializationWithDefaultValues(att.size)
 	}
 	
-	override generateArglistAndTypedData(VarDecl data) {
+	override generateArglistAndTypedData(EObject d) {
+		if (d==null || !(d instanceof VarDecl))
+			return newArrayList("", "", "")
+			
+		val data = d as VarDecl
 		if (data==null)
 			return newArrayList("", "", "")
 			
diff --git a/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/ProtocolClassGen.xtend b/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/ProtocolClassGen.xtend
index 4cb4b94..a3fde77 100644
--- a/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/ProtocolClassGen.xtend
+++ b/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/ProtocolClassGen.xtend
@@ -230,7 +230,7 @@
 		«ENDFOR»
 		
 		«IF (pc.getPortClass(conj) != null)»	
-			«pc.getPortClass(conj).operations.operationsDeclaration(portClassName)»
+			«pc.getAllOperations(!conj).operationsDeclaration(portClassName)»
 		«ENDIF»
 		
 		«IF pc.handlesReceive(conj)»
@@ -302,50 +302,38 @@
 		'''
 	}
 	
-	def private genDataDrivenPortSources(ProtocolClass pc) {
+	def private genDataDrivenPortSources(ProtocolClass pc){
 		var messages = pc.allIncomingMessages.filter(m|m.data!=null)
-		val enumMsgs = messages.filter(m|m.data.refType.type.isEnumeration)
-		val boolMsgs = messages.filter(m|m.data.refType.type.isBoolean)
-		val usesMSC = Main::settings.generateMSCInstrumentation && !(enumMsgs.empty && boolMsgs.empty)
-		/*
-		 * MSC code is generated for all enumerations and all booleans of the messages of this protocol
-		 */
-	'''
-			«FOR message : messages»
-				«var typeName =message.data.refType.type.typeName»
-				«var refp = if (!(message.data.refType.type.enumerationOrPrimitive)) "*" else ""»
-				«var data = ", "+typeName+refp+" data"»
-				«messageSetterSignature(pc.getPortClassName(true), message.name, data)» {
-					«IF usesMSC && enumMsgs.exists(m|m==message)»
-						#ifdef ET_ASYNC_MSC_LOGGER_ACTIVATE
-							{
-								const char** peerName;
-								for (peerName=self->peerNames; *peerName!=NULL; ++peerName) {
-									ET_MSC_LOGGER_ASYNC_OUT(self->instName, «message.data.refType.type.name»_getLiteralName(data), *peerName)
-									ET_MSC_LOGGER_ASYNC_IN(self->instName, «message.data.refType.type.name»_getLiteralName(data), *peerName)
-								}
-							}
-						#endif
-					«ENDIF»
-					«IF usesMSC && boolMsgs.exists(m|m==message)»
-						#ifdef ET_ASYNC_MSC_LOGGER_ACTIVATE
-							{
-								const char** peerName;
-								for (peerName=self->peerNames; *peerName!=NULL; ++peerName) {
-									ET_MSC_LOGGER_ASYNC_OUT(self->instName, data?"true":"false", *peerName)
-									ET_MSC_LOGGER_ASYNC_IN(self->instName, data?"true":"false", *peerName)
-								}
-							}
-						#endif
-					«ENDIF»
-					self->«message.name» = «refp»data;
-				}
-				«messageGetterSignature(pc.getPortClassName(false), message.name, typeName)» {
-					return self->peer->«message.name»;
-				}
-				
-			«ENDFOR»
-	'''
+		messages.map[message |
+			var type = message.data.refType.type
+			var refp = if (!(type.enumerationOrPrimitive)) "*" else ""
+			// log message name and data in MSC, if feasible
+			var messageLog = switch type {
+				//case type.isEnumeration: '''«type.name»_getLiteralName(data)'''
+				case type.isBoolean: '''data?"«message.name»(true)":"«message.name»(false)"'''
+				default : '''"«message.name»"''' 
+			}
+			'''
+			«messageSetterSignature(pc.getPortClassName(true), message.name, ', '+type.name+refp+' data')» {
+				«IF Main::settings.generateMSCInstrumentation»
+					#ifdef ET_ASYNC_MSC_LOGGER_ACTIVATE
+					{
+						const char** peerName;
+						for (peerName=self->peerNames; *peerName!=NULL; ++peerName) {
+								ET_MSC_LOGGER_ASYNC_OUT(self->instName, «messageLog», *peerName)
+								ET_MSC_LOGGER_ASYNC_IN(self->instName, «messageLog», *peerName)
+						}
+					}
+					#endif
+				«ENDIF»
+				self->«message.name» = «refp»data;
+			}
+			
+			«messageGetterSignature(pc.getPortClassName(false), message.name, type.name)» {
+				return self->peer->«message.name»;
+			}
+			'''
+		].join
 	}
 	
 	def private portClassSource(ProtocolClass pc, Boolean conj) {
@@ -418,7 +406,7 @@
 				/* begin «portClassName» specific */
 				«pclass.userCode.userCode»
 				
-				«pc.getPortClass(conj).operations.operationsImplementation(portClassName)»
+				«pc.getAllOperations(!conj).operationsImplementation(portClassName)»
 				/* end «portClassName» specific */
 				
 			«ENDIF»
diff --git a/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/StateMachineGen.xtend b/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/StateMachineGen.xtend
index 8db32c4..da5b3a8 100644
--- a/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/StateMachineGen.xtend
+++ b/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/StateMachineGen.xtend
@@ -18,6 +18,7 @@
 import org.eclipse.etrice.generator.c.Main
 import org.eclipse.etrice.generator.generic.GenericStateMachineGenerator
 import org.eclipse.etrice.generator.generic.RoomExtensions
+import org.eclipse.etrice.core.genmodel.fsm.fsmgen.ExpandedModelComponent
 
 @Singleton
 class StateMachineGen extends GenericStateMachineGenerator {
@@ -56,9 +57,9 @@
 		'''
 	}
 	
-	override protected genExtra(ExpandedActorClass xpac) {
-		val ac = xpac.actorClass
-		val states = xpac.stateMachine.baseStateList.getLeafStatesLast
+	override public genExtra(ExpandedModelComponent xpmc) {
+		val mc = xpmc.modelComponent
+		val states = xpmc.stateMachine.baseStateList.getLeafStatesLast
 		'''
 			«IF Main::settings.generateMSCInstrumentation»
 				/* state names */
@@ -66,20 +67,20 @@
 				«ENDFOR»};
 			«ENDIF»
 			
-			«langExt.accessLevelPrivate»void setState(«ac.name»* self, «stateType» new_state) {
+			«langExt.accessLevelPrivate»void setState(«mc.componentName»* self, «stateType» new_state) {
 				self->state = new_state;
 				«IF Main::settings.generateMSCInstrumentation»
 					ET_MSC_LOGGER_CHANGE_STATE(self->constData->instName, stateStrings[new_state])
 				«ENDIF»
 			}
 			
-			«langExt.accessLevelPrivate»«stateType» getState(«ac.name»* self) {
+			«langExt.accessLevelPrivate»«stateType» getState(«mc.componentName»* self) {
 				return self->state;
 			}
 		'''
 	}
 	
-	override protected stateType() {
+	override public stateType() {
 		"etInt16"
 	}
 	
@@ -88,7 +89,7 @@
 			((void)trigger__et);	/* avoids unused warning */
 		'''
 	}
-	override protected unreachableReturn() {
+	override public unreachableReturn() {
 		"/* return NO_STATE; // required by CDT but detected as unreachable by JDT because of while (true) */"
 	}
 	
diff --git a/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/ActorClassGen.java b/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/ActorClassGen.java
index 763778b..307b043 100644
--- a/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/ActorClassGen.java
+++ b/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/ActorClassGen.java
@@ -28,6 +28,7 @@
 import org.eclipse.etrice.core.room.DataClass;
 import org.eclipse.etrice.core.room.EnumerationType;
 import org.eclipse.etrice.core.room.GeneralProtocolClass;
+import org.eclipse.etrice.core.room.InterfaceItem;
 import org.eclipse.etrice.core.room.Message;
 import org.eclipse.etrice.core.room.Operation;
 import org.eclipse.etrice.core.room.Port;
@@ -667,9 +668,9 @@
         }
       };
       final Iterable<Port> recvPorts = IterableExtensions.<Port>filter(_allEndPorts_2, _function_3);
-      List<Port> _allEndPorts_3 = this._roomHelpers.getAllEndPorts(ac);
-      final Function1<Port, Boolean> _function_4 = new Function1<Port, Boolean>() {
-        public Boolean apply(final Port p) {
+      List<InterfaceItem> _allInterfaceItems = this._roomHelpers.getAllInterfaceItems(ac);
+      final Function1<InterfaceItem, Boolean> _function_4 = new Function1<InterfaceItem, Boolean>() {
+        public Boolean apply(final InterfaceItem p) {
           boolean _and = false;
           PortClass _portClass = ActorClassGen.this._roomHelpers.getPortClass(p);
           boolean _notEquals = (!Objects.equal(_portClass, null));
@@ -685,7 +686,7 @@
           return Boolean.valueOf(_and);
         }
       };
-      final Iterable<Port> portsWithOperations = IterableExtensions.<Port>filter(_allEndPorts_3, _function_4);
+      final Iterable<InterfaceItem> portsWithOperations = IterableExtensions.<InterfaceItem>filter(_allInterfaceItems, _function_4);
       EObject _eContainer = ac.eContainer();
       String _name = ((RoomModel) _eContainer).getName();
       String _replaceAll = _name.replaceAll("\\.", "_");
@@ -1138,7 +1139,7 @@
       _builder.append("/* port operations */");
       _builder.newLine();
       {
-        for(final Port p : portsWithOperations) {
+        for(final InterfaceItem p : portsWithOperations) {
           {
             PortClass _portClass = this._roomHelpers.getPortClass(p);
             EList<PortOperation> _operations = _portClass.getOperations();
@@ -1348,20 +1349,23 @@
         boolean _isEmpty_2 = this._roomHelpers.isEmpty(_stateMachine_2);
         boolean _not_2 = (!_isEmpty_2);
         if (_not_2) {
-          _builder.append("\t");
-          _builder.newLine();
-          _builder.append("\t");
-          String _name_6 = ac.getName();
-          String _operationScope = this.langExt.operationScope(_name_6, false);
-          _builder.append(_operationScope, "\t");
-          _builder.append("receiveEvent(self");
           {
             if (handleEvents) {
-              _builder.append(", (etPort*)ifitem, msg->evtID, (void*)(((char*)msg)+MEM_CEIL(sizeof(etMessage)))");
+              _builder.append("\t");
+              String _name_6 = ac.getName();
+              String _operationScope = this.langExt.operationScope(_name_6, false);
+              _builder.append(_operationScope, "\t");
+              _builder.append("receiveEvent(self, (etPort*)ifitem, msg->evtID, (void*)(((char*)msg)+MEM_CEIL(sizeof(etMessage))));");
+              _builder.newLineIfNotEmpty();
+            } else {
+              _builder.append("\t");
+              String _name_7 = ac.getName();
+              String _operationScope_1 = this.langExt.operationScope(_name_7, false);
+              _builder.append(_operationScope_1, "\t");
+              _builder.append("receiveEventInternal(self);");
+              _builder.newLineIfNotEmpty();
             }
           }
-          _builder.append(");");
-          _builder.newLineIfNotEmpty();
         }
       }
       _builder.append("\t");
@@ -1381,17 +1385,17 @@
         }
         if (_or_1) {
           _builder.append("void ");
-          String _name_7 = ac.getName();
-          _builder.append(_name_7, "");
-          _builder.append("_execute(");
           String _name_8 = ac.getName();
           _builder.append(_name_8, "");
+          _builder.append("_execute(");
+          String _name_9 = ac.getName();
+          _builder.append(_name_9, "");
           _builder.append("* self) {");
           _builder.newLineIfNotEmpty();
           _builder.append("\t");
           _builder.append("ET_MSC_LOGGER_SYNC_ENTRY(\"");
-          String _name_9 = ac.getName();
-          _builder.append(_name_9, "\t");
+          String _name_10 = ac.getName();
+          _builder.append(_name_10, "\t");
           _builder.append("\", \"_execute\")");
           _builder.newLineIfNotEmpty();
           {
@@ -1401,18 +1405,23 @@
             if (_not_3) {
               _builder.append("\t");
               _builder.newLine();
-              _builder.append("\t");
-              String _name_10 = ac.getName();
-              String _operationScope_1 = this.langExt.operationScope(_name_10, false);
-              _builder.append(_operationScope_1, "\t");
-              _builder.append("receiveEvent(self");
               {
                 if (handleEvents) {
-                  _builder.append(", NULL, 0, NULL");
+                  _builder.append("\t");
+                  String _name_11 = ac.getName();
+                  String _operationScope_2 = this.langExt.operationScope(_name_11, false);
+                  _builder.append(_operationScope_2, "\t");
+                  _builder.append("receiveEvent(self, NULL, 0, NULL);");
+                  _builder.newLineIfNotEmpty();
+                } else {
+                  _builder.append("\t");
+                  String _name_12 = ac.getName();
+                  String _operationScope_3 = this.langExt.operationScope(_name_12, false);
+                  _builder.append(_operationScope_3, "\t");
+                  _builder.append("receiveEventInternal(self);");
+                  _builder.newLineIfNotEmpty();
                 }
               }
-              _builder.append(");");
-              _builder.newLineIfNotEmpty();
             }
           }
           _builder.append("\t");
@@ -1426,8 +1435,8 @@
       }
       _builder.newLine();
       EList<StandardOperation> _operations = ac.getOperations();
-      String _name_11 = ac.getName();
-      CharSequence _operationsImplementation = this._procedureHelpers.operationsImplementation(_operations, _name_11);
+      String _name_13 = ac.getName();
+      CharSequence _operationsImplementation = this._procedureHelpers.operationsImplementation(_operations, _name_13);
       _builder.append(_operationsImplementation, "");
       _builder.newLineIfNotEmpty();
       _builder.newLine();
diff --git a/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/CExtensions.java b/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/CExtensions.java
index de3d3e3..efa0b24 100644
--- a/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/CExtensions.java
+++ b/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/CExtensions.java
@@ -52,10 +52,16 @@
   @Extension
   protected RoomHelpers _roomHelpers;
   
-  public String getTypedDataDefinition(final Message m) {
-    VarDecl _data = m.getData();
-    String[] _generateArglistAndTypedData = this.generateArglistAndTypedData(_data);
-    return _generateArglistAndTypedData[1];
+  public String getTypedDataDefinition(final EObject msg) {
+    String _xifexpression = null;
+    if ((msg instanceof Message)) {
+      VarDecl _data = ((Message) msg).getData();
+      String[] _generateArglistAndTypedData = this.generateArglistAndTypedData(_data);
+      _xifexpression = _generateArglistAndTypedData[1];
+    } else {
+      _xifexpression = "";
+    }
+    return _xifexpression;
   }
   
   public String accessLevelPrivate() {
@@ -626,9 +632,20 @@
     return _xblockexpression;
   }
   
-  public String[] generateArglistAndTypedData(final VarDecl data) {
-    boolean _equals = Objects.equal(data, null);
+  public String[] generateArglistAndTypedData(final EObject d) {
+    boolean _or = false;
+    boolean _equals = Objects.equal(d, null);
     if (_equals) {
+      _or = true;
+    } else {
+      _or = (!(d instanceof VarDecl));
+    }
+    if (_or) {
+      return ((String[])Conversions.unwrapArray(CollectionLiterals.<String>newArrayList("", "", ""), String.class));
+    }
+    final VarDecl data = ((VarDecl) d);
+    boolean _equals_1 = Objects.equal(data, null);
+    if (_equals_1) {
       return ((String[])Conversions.unwrapArray(CollectionLiterals.<String>newArrayList("", "", ""), String.class));
     }
     String _xifexpression = null;
@@ -709,17 +726,17 @@
     String deRef = "*";
     RefableType _refType_10 = data.getRefType();
     final boolean isRef = _refType_10.isRef();
-    boolean _or = false;
+    boolean _or_1 = false;
     RefableType _refType_11 = data.getRefType();
     DataType _type_10 = _refType_11.getType();
     if ((_type_10 instanceof PrimitiveType)) {
-      _or = true;
+      _or_1 = true;
     } else {
       RefableType _refType_12 = data.getRefType();
       DataType _type_11 = _refType_12.getType();
-      _or = (_type_11 instanceof EnumerationType);
+      _or_1 = (_type_11 instanceof EnumerationType);
     }
-    final boolean isPrim = _or;
+    final boolean isPrim = _or_1;
     if (isRef) {
       typeName = (typeName + "*");
       castTypeName = (castTypeName + "*");
diff --git a/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/StateMachineGen.java b/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/StateMachineGen.java
index f3b89e2..1b1579a 100644
--- a/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/StateMachineGen.java
+++ b/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/StateMachineGen.java
@@ -13,9 +13,11 @@
 import com.google.inject.Inject;
 import com.google.inject.Singleton;
 import java.util.List;
+import org.eclipse.etrice.core.fsm.fSM.ModelComponent;
 import org.eclipse.etrice.core.fsm.fSM.State;
 import org.eclipse.etrice.core.fsm.fSM.StateGraph;
 import org.eclipse.etrice.core.genmodel.etricegen.ExpandedActorClass;
+import org.eclipse.etrice.core.genmodel.fsm.fsmgen.ExpandedModelComponent;
 import org.eclipse.etrice.core.room.ActorClass;
 import org.eclipse.etrice.generator.base.GlobalGeneratorSettings;
 import org.eclipse.etrice.generator.c.Main;
@@ -36,10 +38,10 @@
     {
       final ActorClass ac = xpac.getActorClass();
       StateGraph _stateMachine = xpac.getStateMachine();
-      List<State> _baseStateList = this._roomHelpers.getBaseStateList(_stateMachine);
+      List<State> _baseStateList = this._fSMHelpers.getBaseStateList(_stateMachine);
       int _size = _baseStateList.size();
       StateGraph _stateMachine_1 = xpac.getStateMachine();
-      List<State> _leafStateList = this._roomHelpers.getLeafStateList(_stateMachine_1);
+      List<State> _leafStateList = this._fSMHelpers.getLeafStateList(_stateMachine_1);
       int _size_1 = _leafStateList.size();
       int _minus = (_size - _size_1);
       final int historySize = (_minus + 2);
@@ -112,12 +114,12 @@
     return _xblockexpression;
   }
   
-  protected CharSequence genExtra(final ExpandedActorClass xpac) {
+  public CharSequence genExtra(final ExpandedModelComponent xpmc) {
     CharSequence _xblockexpression = null;
     {
-      final ActorClass ac = xpac.getActorClass();
-      StateGraph _stateMachine = xpac.getStateMachine();
-      List<State> _baseStateList = this._roomHelpers.getBaseStateList(_stateMachine);
+      final ModelComponent mc = xpmc.getModelComponent();
+      StateGraph _stateMachine = xpmc.getStateMachine();
+      List<State> _baseStateList = this._fSMHelpers.getBaseStateList(_stateMachine);
       final List<State> states = this._roomExtensions.getLeafStatesLast(_baseStateList);
       StringConcatenation _builder = new StringConcatenation();
       {
@@ -150,8 +152,8 @@
       String _accessLevelPrivate = this.langExt.accessLevelPrivate();
       _builder.append(_accessLevelPrivate, "");
       _builder.append("void setState(");
-      String _name = ac.getName();
-      _builder.append(_name, "");
+      String _componentName = mc.getComponentName();
+      _builder.append(_componentName, "");
       _builder.append("* self, ");
       String _stateType = this.stateType();
       _builder.append(_stateType, "");
@@ -177,8 +179,8 @@
       String _stateType_1 = this.stateType();
       _builder.append(_stateType_1, "");
       _builder.append(" getState(");
-      String _name_1 = ac.getName();
-      _builder.append(_name_1, "");
+      String _componentName_1 = mc.getComponentName();
+      _builder.append(_componentName_1, "");
       _builder.append("* self) {");
       _builder.newLineIfNotEmpty();
       _builder.append("\t");
@@ -191,7 +193,7 @@
     return _xblockexpression;
   }
   
-  protected String stateType() {
+  public String stateType() {
     return "etInt16";
   }
   
@@ -202,7 +204,7 @@
     return _builder;
   }
   
-  protected String unreachableReturn() {
+  public String unreachableReturn() {
     return "/* return NO_STATE; // required by CDT but detected as unreachable by JDT because of while (true) */";
   }
 }
diff --git a/plugins/org.eclipse.etrice.generator.cpp/.settings/org.eclipse.core.resources.prefs b/plugins/org.eclipse.etrice.generator.cpp/.settings/org.eclipse.core.resources.prefs
new file mode 100644
index 0000000..1a9b29c
--- /dev/null
+++ b/plugins/org.eclipse.etrice.generator.cpp/.settings/org.eclipse.core.resources.prefs
@@ -0,0 +1,2 @@
+eclipse.preferences.version=1
+encoding/<project>=cp1252
diff --git a/plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/CppExtensions.xtend b/plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/CppExtensions.xtend
index 1cbbfec..26bce00 100644
--- a/plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/CppExtensions.xtend
+++ b/plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/CppExtensions.xtend
@@ -35,6 +35,7 @@
 import org.eclipse.etrice.core.room.EnumerationType
 
 import org.eclipse.etrice.core.room.EnumLiteral
+import org.eclipse.emf.ecore.EObject
 
 @Singleton
 class CppExtensions implements ILanguageExtension {
@@ -43,8 +44,8 @@
 	@Inject extension TypeHelpers
 	
 
-	override String getTypedDataDefinition(Message m) {
-		generateArglistAndTypedData(m.data).get(1)
+	override String getTypedDataDefinition(EObject msg) {
+		generateArglistAndTypedData((msg as Message).data).get(1)
 	}
 
 
@@ -197,7 +198,8 @@
 			dv
 	}
 	
-	override generateArglistAndTypedData(VarDecl data) {
+	override generateArglistAndTypedData(EObject d) {
+	    val data = d as VarDecl
 		var deref = "*"
 		if (data==null)
 			return newArrayList("", "", "")
diff --git a/plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/StateMachineGen.xtend b/plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/StateMachineGen.xtend
index 55d23f7..f8a84c8 100644
--- a/plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/StateMachineGen.xtend
+++ b/plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/StateMachineGen.xtend
@@ -16,7 +16,8 @@
 import com.google.inject.Inject
 import com.google.inject.Singleton
 import java.util.ArrayList
-import org.eclipse.etrice.core.genmodel.etricegen.ExpandedActorClass
+import org.eclipse.etrice.core.genmodel.fsm.fsmgen.ExpandedModelComponent
+import org.eclipse.etrice.core.room.ActorClass
 import org.eclipse.etrice.generator.generic.GenericStateMachineGenerator
 import org.eclipse.etrice.generator.generic.RoomExtensions
 import org.eclipse.xtext.util.Pair
@@ -33,7 +34,7 @@
 	@Inject extension RoomExtensions
 	@Inject ProtocolClassGen cppProtGen
 	
-	override genExtraDecl(ExpandedActorClass xpac) {
+	override genExtraDecl(ExpandedModelComponent xpac) {
 //		val ac = xpac.actorClass
 	'''
 		protected:
@@ -44,8 +45,8 @@
 			 void setState(int new_state);
 	'''}
 	
-	override genExtra(ExpandedActorClass xpac) {
-		val ac = xpac.actorClass
+	override genExtra(ExpandedModelComponent xpac) {
+		val ac = xpac.modelComponent as ActorClass
 	'''
 		std::string «ac.name»::s_stateStrings[] = {"<no state>","<top>",«FOR state : ac.getAllBaseStatesLeavesLast() SEPARATOR ","»"«state.genStatePathName»"
 		«ENDFOR»};
@@ -61,7 +62,7 @@
 		}
 	'''}
 	
-	override genTriggerConstants(ExpandedActorClass xpac) {
+	override genTriggerConstants(ExpandedModelComponent xpac) {
 		val triggers = if (langExt.usesInheritance)
 			xpac.getOwnTriggers() else xpac.triggers
 
diff --git a/plugins/org.eclipse.etrice.generator.cpp/xtend-gen/org/eclipse/etrice/generator/cpp/gen/CppExtensions.java b/plugins/org.eclipse.etrice.generator.cpp/xtend-gen/org/eclipse/etrice/generator/cpp/gen/CppExtensions.java
index abc0707..155c107 100644
--- a/plugins/org.eclipse.etrice.generator.cpp/xtend-gen/org/eclipse/etrice/generator/cpp/gen/CppExtensions.java
+++ b/plugins/org.eclipse.etrice.generator.cpp/xtend-gen/org/eclipse/etrice/generator/cpp/gen/CppExtensions.java
@@ -48,8 +48,8 @@
   @Extension
   private TypeHelpers _typeHelpers;
   
-  public String getTypedDataDefinition(final Message m) {
-    VarDecl _data = m.getData();
+  public String getTypedDataDefinition(final EObject msg) {
+    VarDecl _data = ((Message) msg).getData();
     String[] _generateArglistAndTypedData = this.generateArglistAndTypedData(_data);
     return _generateArglistAndTypedData[1];
   }
@@ -328,7 +328,8 @@
     return _xblockexpression;
   }
   
-  public String[] generateArglistAndTypedData(final VarDecl data) {
+  public String[] generateArglistAndTypedData(final EObject d) {
+    final VarDecl data = ((VarDecl) d);
     String deref = "*";
     boolean _equals = Objects.equal(data, null);
     if (_equals) {
diff --git a/plugins/org.eclipse.etrice.generator.cpp/xtend-gen/org/eclipse/etrice/generator/cpp/gen/StateMachineGen.java b/plugins/org.eclipse.etrice.generator.cpp/xtend-gen/org/eclipse/etrice/generator/cpp/gen/StateMachineGen.java
index 896671b..5120df4 100644
--- a/plugins/org.eclipse.etrice.generator.cpp/xtend-gen/org/eclipse/etrice/generator/cpp/gen/StateMachineGen.java
+++ b/plugins/org.eclipse.etrice.generator.cpp/xtend-gen/org/eclipse/etrice/generator/cpp/gen/StateMachineGen.java
@@ -18,8 +18,9 @@
 import org.eclipse.emf.common.util.EList;
 import org.eclipse.etrice.core.fsm.fSM.AbstractInterfaceItem;
 import org.eclipse.etrice.core.fsm.fSM.MessageFromIf;
+import org.eclipse.etrice.core.fsm.fSM.ModelComponent;
 import org.eclipse.etrice.core.fsm.fSM.State;
-import org.eclipse.etrice.core.genmodel.etricegen.ExpandedActorClass;
+import org.eclipse.etrice.core.genmodel.fsm.fsmgen.ExpandedModelComponent;
 import org.eclipse.etrice.core.room.ActorClass;
 import org.eclipse.etrice.generator.cpp.gen.ProtocolClassGen;
 import org.eclipse.etrice.generator.generic.GenericStateMachineGenerator;
@@ -42,7 +43,7 @@
   @Inject
   private ProtocolClassGen cppProtGen;
   
-  public CharSequence genExtraDecl(final ExpandedActorClass xpac) {
+  public CharSequence genExtraDecl(final ExpandedModelComponent xpac) {
     StringConcatenation _builder = new StringConcatenation();
     _builder.append("protected:");
     _builder.newLine();
@@ -61,10 +62,11 @@
     return _builder;
   }
   
-  public CharSequence genExtra(final ExpandedActorClass xpac) {
+  public CharSequence genExtra(final ExpandedModelComponent xpac) {
     CharSequence _xblockexpression = null;
     {
-      final ActorClass ac = xpac.getActorClass();
+      ModelComponent _modelComponent = xpac.getModelComponent();
+      final ActorClass ac = ((ActorClass) _modelComponent);
       StringConcatenation _builder = new StringConcatenation();
       _builder.append("std::string ");
       String _name = ac.getName();
@@ -126,7 +128,7 @@
     return _xblockexpression;
   }
   
-  public String genTriggerConstants(final ExpandedActorClass xpac) {
+  public String genTriggerConstants(final ExpandedModelComponent xpac) {
     EList<MessageFromIf> _xifexpression = null;
     boolean _usesInheritance = this.langExt.usesInheritance();
     if (_usesInheritance) {
diff --git a/plugins/org.eclipse.etrice.generator.doc/src/org/eclipse/etrice/generator/doc/gen/DocGen.xtend b/plugins/org.eclipse.etrice.generator.doc/src/org/eclipse/etrice/generator/doc/gen/DocGen.xtend
index 71754a3..4f39be2 100644
--- a/plugins/org.eclipse.etrice.generator.doc/src/org/eclipse/etrice/generator/doc/gen/DocGen.xtend
+++ b/plugins/org.eclipse.etrice.generator.doc/src/org/eclipse/etrice/generator/doc/gen/DocGen.xtend
@@ -16,30 +16,29 @@
 import com.google.inject.Singleton
 import java.io.File
 import java.util.List
-import org.eclipse.etrice.core.genmodel.fsm.base.ILogger
+import java.util.Set
+import org.eclipse.etrice.core.common.base.Documentation
+import org.eclipse.etrice.core.common.base.util.RelativePathHelpers
+import org.eclipse.etrice.core.fsm.fSM.State
 import org.eclipse.etrice.core.genmodel.etricegen.Root
+import org.eclipse.etrice.core.genmodel.fsm.base.ILogger
 import org.eclipse.etrice.core.room.ActorClass
 import org.eclipse.etrice.core.room.Attribute
 import org.eclipse.etrice.core.room.CompoundProtocolClass
 import org.eclipse.etrice.core.room.DataClass
-import org.eclipse.etrice.core.common.base.Documentation
+import org.eclipse.etrice.core.room.EnumerationType
 import org.eclipse.etrice.core.room.LogicalSystem
+import org.eclipse.etrice.core.room.Port
 import org.eclipse.etrice.core.room.ProtocolClass
+import org.eclipse.etrice.core.room.RoomClass
 import org.eclipse.etrice.core.room.RoomModel
 import org.eclipse.etrice.core.room.StandardOperation
-import org.eclipse.etrice.core.fsm.fSM.State
 import org.eclipse.etrice.core.room.SubSystemClass
+import org.eclipse.etrice.core.room.util.RoomHelpers
+import org.eclipse.etrice.generator.fsm.base.CodegenHelpers
 import org.eclipse.etrice.generator.generic.RoomExtensions
 import org.eclipse.xtext.generator.JavaIoFileSystemAccess
 
-import org.eclipse.etrice.core.room.util.RoomHelpers
-import org.eclipse.etrice.generator.base.CodegenHelpers
-import org.eclipse.etrice.core.room.EnumerationType
-import org.eclipse.etrice.core.room.Port
-import org.eclipse.etrice.core.room.RoomClass
-import java.util.Set
-import org.eclipse.etrice.core.common.base.util.RelativePathHelpers
-
 @Singleton
 class DocGen {
 
@@ -65,7 +64,7 @@
 	
 	def doGenerate(Root root) {
 		for (model: root.models) {
-			val ctx = new DocGenContext(root,model)
+			val ctx = new DocGen.DocGenContext(root,model)
 			var path = model.docGenerationTargetPath
 			var file = model.name+".tex"
 			val Set<RoomModel> referencedModels = newHashSet
@@ -109,7 +108,7 @@
 			txt+suffix
 	}
 	
-	def private generateModelDoc(DocGenContext ctx, Set<RoomModel> referencedModels) {
+	def private generateModelDoc(DocGen.DocGenContext ctx, Set<RoomModel> referencedModels) {
 		var model = ctx.model
 		'''
 		\documentclass[titlepage]{article}
@@ -248,7 +247,7 @@
 	'''
 	}
 	
-	def private dispatch generateDoc(LogicalSystem system, DocGenContext ctx) {
+	def private dispatch generateDoc(LogicalSystem system, DocGen.DocGenContext ctx) {
 		val filename = system.name + "_instanceTree.jpg"
 		'''
 		\level{2}{«system.name.escapedString»}
@@ -260,7 +259,7 @@
 		'''
 	}
 	
-	def private dispatch generateDoc(SubSystemClass ssc, DocGenContext ctx) {
+	def private dispatch generateDoc(SubSystemClass ssc, DocGen.DocGenContext ctx) {
 		val filename = ssc.name.escapedString + "_structure.jpg"
 		
 		'''
@@ -273,7 +272,7 @@
 		'''
 	}
 	
-	def private dispatch generateDoc(EnumerationType dc, DocGenContext ctx) {
+	def private dispatch generateDoc(EnumerationType dc, DocGen.DocGenContext ctx) {
 	'''
 		\level{2} {«dc.name.escapedString»}
 		«dc.docu.generateDocText»
@@ -295,7 +294,7 @@
 	'''	
 	}
 	
-	def private dispatch generateDoc(DataClass dc, DocGenContext ctx) {'''
+	def private dispatch generateDoc(DataClass dc, DocGen.DocGenContext ctx) {'''
 		\level{2} {«dc.name.escapedString»}
 		«dc.docu.generateDocText»
 		\level{3}{Attributes}
@@ -306,7 +305,7 @@
 	'''	
 	}
 	
-	def private dispatch generateDoc(ProtocolClass pc, DocGenContext ctx) {'''
+	def private dispatch generateDoc(ProtocolClass pc, DocGen.DocGenContext ctx) {'''
 		\level{2} {«pc.name.escapedString»}
 		«pc.docu.generateDocText»
 		«IF !pc.allIncomingMessages.empty»
@@ -337,7 +336,7 @@
 	'''	
 	}
 	
-	def private dispatch generateDoc(CompoundProtocolClass pc, DocGenContext ctx) {'''
+	def private dispatch generateDoc(CompoundProtocolClass pc, DocGen.DocGenContext ctx) {'''
 		\level{2} {«pc.name.escapedString»}
 		«pc.docu.generateDocText»
 		\level{3}{Sub Protocols}
@@ -354,7 +353,7 @@
 	'''
 	}
 	
-	def dispatch private generateDoc(ActorClass ac, DocGenContext ctx) {
+	def dispatch private generateDoc(ActorClass ac, DocGen.DocGenContext ctx) {
 		val filename = ac.name + "_structure.jpg"
 		'''
 		\level{2}{«ac.name.escapedString»}
@@ -611,4 +610,4 @@
 	
 	def private generateImport(String name, String dir)
 		'''\subimport*{«dir»/}{«name»}'''
-}
\ No newline at end of file
+}
diff --git a/plugins/org.eclipse.etrice.generator.doc/xtend-gen/org/eclipse/etrice/generator/doc/gen/DocGen.java b/plugins/org.eclipse.etrice.generator.doc/xtend-gen/org/eclipse/etrice/generator/doc/gen/DocGen.java
index 9bd95c6..2537e31 100644
--- a/plugins/org.eclipse.etrice.generator.doc/xtend-gen/org/eclipse/etrice/generator/doc/gen/DocGen.java
+++ b/plugins/org.eclipse.etrice.generator.doc/xtend-gen/org/eclipse/etrice/generator/doc/gen/DocGen.java
@@ -48,7 +48,7 @@
 import org.eclipse.etrice.core.room.SubSystemClass;
 import org.eclipse.etrice.core.room.VarDecl;
 import org.eclipse.etrice.core.room.util.RoomHelpers;
-import org.eclipse.etrice.generator.base.CodegenHelpers;
+import org.eclipse.etrice.generator.fsm.base.CodegenHelpers;
 import org.eclipse.etrice.generator.generic.RoomExtensions;
 import org.eclipse.xtend2.lib.StringConcatenation;
 import org.eclipse.xtext.generator.JavaIoFileSystemAccess;
diff --git a/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/base/CodegenHelpers.java b/plugins/org.eclipse.etrice.generator.fsm/src/org/eclipse/etrice/generator/fsm/base/CodegenHelpers.java
similarity index 98%
rename from plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/base/CodegenHelpers.java
rename to plugins/org.eclipse.etrice.generator.fsm/src/org/eclipse/etrice/generator/fsm/base/CodegenHelpers.java
index f892a3b..891c6c7 100644
--- a/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/base/CodegenHelpers.java
+++ b/plugins/org.eclipse.etrice.generator.fsm/src/org/eclipse/etrice/generator/fsm/base/CodegenHelpers.java
@@ -10,7 +10,7 @@
  * 
  *******************************************************************************/
 
-package org.eclipse.etrice.generator.base;
+package org.eclipse.etrice.generator.fsm.base;
 
 import org.eclipse.etrice.core.fsm.fSM.State;
 import org.eclipse.etrice.core.fsm.fSM.StateGraphItem;
diff --git a/plugins/org.eclipse.etrice.generator.fsm/src/org/eclipse/etrice/generator/fsm/generic/AbstractStateMachineGenerator.xtend b/plugins/org.eclipse.etrice.generator.fsm/src/org/eclipse/etrice/generator/fsm/generic/AbstractStateMachineGenerator.xtend
new file mode 100644
index 0000000..2d75f45
--- /dev/null
+++ b/plugins/org.eclipse.etrice.generator.fsm/src/org/eclipse/etrice/generator/fsm/generic/AbstractStateMachineGenerator.xtend
@@ -0,0 +1,672 @@
+/*******************************************************************************
+ * Copyright (c) 2014 protos software gmbh (http://www.protos.de).
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * 
+ * CONTRIBUTORS:
+ * 		Henrik Rentz-Reichert (initial contribution)
+ * 
+ *******************************************************************************/
+
+package org.eclipse.etrice.generator.fsm.generic
+
+import com.google.inject.Inject
+import java.util.ArrayList
+import java.util.List
+import org.eclipse.etrice.core.fsm.fSM.ComponentCommunicationType
+import org.eclipse.etrice.core.fsm.fSM.GuardedTransition
+import org.eclipse.etrice.core.fsm.fSM.ModelComponent
+import org.eclipse.etrice.core.fsm.fSM.State
+import org.eclipse.etrice.core.fsm.fSM.Transition
+import org.eclipse.etrice.core.fsm.fSM.TransitionPoint
+import org.eclipse.etrice.core.fsm.fSM.TriggeredTransition
+import org.eclipse.etrice.core.fsm.util.FSMHelpers
+import org.eclipse.etrice.core.genmodel.fsm.fsmgen.ActiveTrigger
+import org.eclipse.etrice.core.genmodel.fsm.fsmgen.ExpandedModelComponent
+import org.eclipse.etrice.core.genmodel.fsm.fsmgen.util.FsmGenUtil
+import org.eclipse.etrice.generator.fsm.base.CodegenHelpers
+import org.eclipse.xtext.util.Pair
+
+import static org.eclipse.xtext.util.Tuples.*
+
+/**
+ * @author Henrik Rentz-Reichert
+ *
+ */
+abstract class AbstractStateMachineGenerator {
+    
+    @Inject public extension FSMHelpers
+    @Inject public extension FsmGenUtil
+    @Inject public extension CodegenHelpers
+    @Inject public extension FSMExtensions
+    @Inject public ILanguageExtensionBase langExt
+    @Inject public IMessageIdGenerator msgIdGen
+    @Inject public IIfItemIdGenerator itemIdGen
+	@Inject public TransitionChainGenerator transitionChainGenerator
+	@Inject public IDetailCodeTranslator translator
+    
+    /**
+     * generates trigger IDs.
+     * Inheritance (if available) is used for base class IDs.
+     * 
+     * @param xpmc the {@link ExpandedModelComponent}
+     * @return the generated code
+     */
+    def public String genTriggerConstants(ExpandedModelComponent xpmc) {
+        xpmc.genTriggerConstants(langExt.usesInheritance)
+    }
+    
+    /**
+     * generates trigger IDs.
+     * Inheritance (if available) is used for base class IDs.
+     * 
+     * @param xpmc the {@link ExpandedModelComponent}
+     * @param omitBase use <code>true</code> if no base class trigger constants are needed
+     * 
+     * @return the generated code
+     */
+    def public String genTriggerConstants(ExpandedModelComponent xpmc, boolean omitBase) {
+        val triggers = if (omitBase)
+                    xpmc.modelComponent.ownMessagesFromInterfaces
+                    else xpmc.modelComponent.allMessagesFromInterfaces
+        
+        val list = new ArrayList<Pair<String, String>>()
+        list.add(pair("POLLING", "0"));
+        for (mif : triggers) {
+        	if (mif.from.eventDriven) {
+	            list.add(pair(xpmc.getTriggerCodeName(mif), itemIdGen.getIfItemId(mif.from)+" + EVT_SHIFT*"+msgIdGen.getMessageID(mif)))
+        	}
+        }
+        
+        return langExt.genEnumeration("triggers", list)
+    }
+
+    /**
+     * generates state ID constants.
+     * Inheritance (if available) is used for base class IDs.
+     * 
+     * @param xpmc the {@link ExpandedModelComponent}
+     * @return the generated code
+     */
+    def public genStateIdConstants(ExpandedModelComponent xpmc) {
+        xpmc.genStateIdConstants(langExt.usesInheritance)
+    }
+
+    /**
+     * generates state ID constants.
+     * Inheritance (if available) is used for base class IDs.
+     * 
+     * @param xpmc the {@link ExpandedModelComponent}
+     * @param omitBase use <code>true</code> if no base class state constants are needed
+     * 
+     * @return the generated code
+     */
+    def public genStateIdConstants(ExpandedModelComponent xpmc, boolean omitBase) {
+        val mc = xpmc.modelComponent
+        // with inheritance we exclude inherited base states
+        var offset = 2 + if (omitBase)
+            mc.getNumberOfInheritedBaseStates() else 0
+        var baseStates = if (omitBase)
+            mc.stateMachine.getBaseStateList else xpmc.stateMachine.getBaseStateList
+        
+        baseStates = baseStates.leafStatesLast
+        
+        var list = new ArrayList<Pair<String, String>>()
+        if (!omitBase) {
+            list.add(pair("NO_STATE","0"))
+            list.add(pair("STATE_TOP","1"))
+        }
+        for (state : baseStates) {
+            list.add(pair(state.getGenStateId, offset.toString))
+            offset = offset+1;
+        }
+        list.add(pair("STATE_MAX", offset.toString))
+        
+        return langExt.genEnumeration("state_ids", list)
+    }
+    
+    /**
+     * generates transition chain ID constants.
+     * Inheritance (if available) is used for base class IDs.
+     * 
+     * @param xpmc the {@link ExpandedModelComponent}
+     * 
+     * @return the generated code
+     */
+    def public genTransitionChainConstants(ExpandedModelComponent xpmc) {
+        xpmc.genTransitionChainConstants(langExt.usesInheritance)
+    }
+    
+    /**
+     * generates transition chain ID constants.
+     * Inheritance (if available) is used for base class IDs.
+     * 
+     * @param xpmc the {@link ExpandedModelComponent}
+     * @param omitBase use <code>true</code> if no base class transition chain constants are needed
+     * 
+     * @return the generated code
+     */
+    def public genTransitionChainConstants(ExpandedModelComponent xpmc, boolean omitBase) {
+        var chains = if (omitBase)
+            xpmc.getOwnTransitionChains() else xpmc.transitionChains
+        var offset = if (omitBase)
+            xpmc.getTransitionChains().size-chains.size else 0
+
+        var list = new ArrayList<Pair<String, String>>()
+        for (chain : chains) {
+            offset = offset+1;
+            list.add(pair(chain.genChainId, offset.toString))
+        }
+        
+        return langExt.genEnumeration("chain_ids", list)
+    }
+    
+    /**
+     * generates entry and exit code for states
+     * 
+     * @param xpmc the {@link ExpandedModelComponent}
+     * @param generateImplementation if <code>true</code> the implementation is generated, else the declaration
+     * 
+     * @return the generated code
+     */
+    def public String genEntryAndExitCodes(ExpandedModelComponent xpmc, boolean generateImplementation) {
+        xpmc.genEntryAndExitCodes(generateImplementation, langExt.usesInheritance)
+    }
+    
+    /**
+     * generates entry and exit code for states
+     * 
+     * @param xpmc the {@link ExpandedModelComponent}
+     * @param generateImplementation if <code>true</code> the implementation is generated, else the declaration
+     * @param omitBase use <code>true</code> if no base class entry and exit codes are needed
+     * 
+     * @return the generated code
+     */
+    def public String genEntryAndExitCodes(ExpandedModelComponent xpmc, boolean generateImplementation, boolean omitBase) {
+        '''
+        «FOR state : xpmc.stateMachine.getStateList()»
+            «IF !omitBase || xpmc.isOwnObject(state)»
+                «xpmc.genActionCodeMethods(state, generateImplementation)»
+            «ENDIF»
+        «ENDFOR»
+        '''
+    }
+    
+    /**
+     * generates transition action codes
+     * 
+     * @param xpmc the {@link ExpandedModelComponent}
+     * @param generateImplementation if <code>true</code> the implementation is generated, else the declaration
+     * 
+     * @return the generated code
+     */
+    def public String genActionCodes(ExpandedModelComponent xpmc, boolean generateImplementation) {
+        xpmc.genActionCodes(generateImplementation, langExt.usesInheritance)
+    }
+    
+    /**
+     * generates transition action codes
+     * 
+     * @param xpmc the {@link ExpandedModelComponent}
+     * @param generateImplementation if <code>true</code> the implementation is generated, else the declaration
+     * @param omitBase use <code>true</code> if no base class action codes are needed
+     * 
+     * @return the generated code
+     */
+    def public String genActionCodes(ExpandedModelComponent xpmc, boolean generateImplementation, boolean omitBase) {
+        '''
+        «FOR tr : xpmc.stateMachine.allTransitionsRecursive»
+            «IF (!omitBase || xpmc.isOwnObject(tr)) && tr.action.hasDetailCode»
+                «xpmc.genActionCodeMethod(tr, generateImplementation)»
+            «ENDIF»
+        «ENDFOR»
+        '''
+    }
+    
+    def public String genStateSwitchMethods(ExpandedModelComponent xpmc, boolean generateImplementation) {
+		val mc = xpmc.modelComponent
+		val async = mc.commType==ComponentCommunicationType::ASYNCHRONOUS
+		val eventDriven = mc.commType==ComponentCommunicationType::EVENT_DRIVEN
+		val ifItemPtr = interfaceItemType()+langExt.pointerLiteral()
+		val handleEvents = async || eventDriven
+		val opScope = langExt.operationScope(mc.className, false)
+		val opScopePriv = if (langExt.usesInheritance)
+							opScope
+						else
+							""
+		val publicIf = if (langExt.usesInheritance)
+				langExt.accessLevelPublic
+			else
+				langExt.accessLevelPrivate
+		val privAccess = langExt.accessLevelPrivate
+		val selfPtr = langExt.selfPointer(mc.className, true)
+		val selfOnly = langExt.selfPointer(mc.className, false)
+		val getLocalId = 	if (langExt.usesInheritance) {
+								if (langExt.usesPointers)
+									"->getLocalId()"
+								else
+									".getLocalId()"
+							}
+							else
+								"->localId"
+		val constIfItemPtr = if (langExt.usesPointers)
+								"const "+ifItemPtr
+							else
+								ifItemPtr
+		val usesHdlr = usesHandlerTrPoints(xpmc)
+        '''
+		/**
+		 * calls exit codes while exiting from the current state to one of its
+		 * parent states while remembering the history
+		 * @param current__et - the current state
+		 * @param to - the final parent state
+		«IF usesHdlr»
+			 * @param handler__et - entry and exit codes are called only if not handler (for handler TransitionPoints)
+		«ENDIF»
+		 */
+		«IF generateImplementation»
+			«privAccess»void «opScopePriv»exitTo(«selfPtr»«stateType» current__et, «stateType» to«IF usesHdlr», «boolType» handler__et«ENDIF») {
+				while (current__et!=to) {
+					switch (current__et) {
+						«FOR state : xpmc.stateMachine.getBaseStateList()»
+							case «state.getGenStateId()»:
+								«IF state.hasExitCode(true)»«IF usesHdlr»if (!handler__et) «ENDIF»«state.getExitCodeOperationName()»(«langExt.selfPointer(false)»);«ENDIF»
+								«setHistory(state.getParentStateId(), state.getGenStateId())»;
+								current__et = «state.getParentStateId()»;
+								break;
+						«ENDFOR»
+						default:
+							/* should not occur */
+							break;
+					}
+				}
+			}
+		«ELSE»
+			void exitTo(«selfPtr»«stateType» current__et, «stateType» to«IF usesHdlr», «boolType» handler__et«ENDIF»);
+		«ENDIF»
+		
+		/**
+		 * calls action, entry and exit codes along a transition chain. The generic data are cast to typed data
+		 * matching the trigger of this chain. The ID of the final state is returned
+		 * @param chain__et - the chain ID
+		 * @param generic_data__et - the generic data pointer
+		 * @return the +/- ID of the final state either with a positive sign, that indicates to execute the state's entry code, or a negative sign vice versa
+		 */
+		«IF generateImplementation»
+			«privAccess»«stateType» «opScopePriv»executeTransitionChain(«selfPtr»int chain__et«IF handleEvents», «constIfItemPtr» ifitem, «langExt.voidPointer» generic_data__et«ENDIF») {
+				switch (chain__et) {
+					«var allchains = xpmc.getTransitionChains()»
+					«FOR tc : allchains»
+						case «tc.genChainId»:
+						{
+							«transitionChainGenerator.generateExecuteChain(xpmc, tc)»
+						}
+					«ENDFOR»
+						default:
+							/* should not occur */
+							break;
+				}
+				return NO_STATE;
+			}
+		«ELSE»
+			«stateType» executeTransitionChain(«selfPtr»int chain__et«IF handleEvents», «constIfItemPtr» ifitem, «langExt.voidPointer» generic_data__et«ENDIF»);
+		«ENDIF»
+		
+		/**
+		 * calls entry codes while entering a state's history. The ID of the final leaf state is returned
+		 * @param state__et - the state which is entered
+		«IF usesHdlr»
+			 * @param handler__et - entry code is executed if not handler
+		«ENDIF»
+		 * @return - the ID of the final leaf state
+		 */
+		«IF generateImplementation»
+			«privAccess»«stateType» «opScopePriv»enterHistory(«selfPtr»«stateType» state__et«IF usesHdlr», «boolType» handler__et«ENDIF») {
+				«boolType» skip_entry__et = «langExt.booleanConstant(false)»;
+				if (state__et >= STATE_MAX) {
+					state__et = «IF !langExt.usesInheritance»(«stateType»)«ENDIF» (state__et - STATE_MAX);
+					skip_entry__et = «langExt.booleanConstant(true)»;
+				}
+				while («langExt.booleanConstant(true)») {
+					switch (state__et) {
+						«FOR state : xpmc.stateMachine.getBaseStateList()»
+						case «state.getGenStateId()»:
+							«IF state.hasEntryCode(true)»if (!(skip_entry__et«IF usesHdlr» || handler__et«ENDIF»)) «state.getEntryCodeOperationName()»(«langExt.selfPointer(false)»);«ENDIF»
+							«IF state.isLeaf()»
+								/* in leaf state: return state id */
+								return «state.getGenStateId()»;
+							«ELSE»
+								/* state has a sub graph */
+								«IF state.subgraph.hasInitTransition()»
+									/* with init transition */
+									if («getHistory(state.getGenStateId())»==NO_STATE) {
+										«var sub_initt = state.subgraph.getInitTransition()»
+										state__et = executeTransitionChain(«langExt.selfPointer(true)»«xpmc.getChain(sub_initt).genChainId»«IF handleEvents», «langExt.nullPointer», «langExt.nullPointer»«ENDIF»);
+									}
+									else {
+										state__et = «getHistory(state.getGenStateId())»;
+									}
+								«ELSE»
+									/* without init transition */
+									state__et = «getHistory(state.getGenStateId())»;
+								«ENDIF»
+								break;
+							«ENDIF»
+						«ENDFOR»
+						case STATE_TOP:
+							state__et = «getHistory("STATE_TOP")»;
+							break;
+						default:
+							/* should not occur */
+							break;
+					}
+					skip_entry__et = «langExt.booleanConstant(false)»;
+				}
+				«unreachableReturn»
+			}
+		«ELSE»
+			«stateType» enterHistory(«selfPtr»«stateType» state__et«IF usesHdlr», «boolType» handler__et«ENDIF»);
+		«ENDIF»
+		
+		«IF generateImplementation»
+			«publicIf»void «opScope»executeInitTransition(«selfOnly») {
+				«var initt = xpmc.stateMachine.getInitTransition()»
+				int chain__et = «xpmc.getChain(initt).genChainId»;
+				«stateType» next__et = «opScopePriv»executeTransitionChain(«langExt.selfPointer(true)»chain__et«IF handleEvents», «langExt.nullPointer», «langExt.nullPointer»«ENDIF»);
+				next__et = «opScopePriv»enterHistory(«langExt.selfPointer(true)»next__et«IF usesHdlr», «langExt.booleanConstant(false)»«ENDIF»);
+				setState(«langExt.selfPointer(true)»next__et);
+			}
+		«ELSE»
+			void executeInitTransition(«selfOnly»);
+		«ENDIF»
+		
+		/* receiveEvent contains the main implementation of the FSM */
+		«IF generateImplementation»
+			«publicIf»void «opScope»receiveEventInternal(«langExt.selfPointer(mc.className, handleEvents)»«IF handleEvents»«ifItemPtr» ifitem, int localId, int evt, «langExt.voidPointer» generic_data__et«ENDIF») {
+				«IF async»
+					int trigger__et = (ifitem==«langExt.nullPointer»)? POLLING : localId + EVT_SHIFT*evt;
+				«ELSEIF eventDriven»
+					int trigger__et = localId + EVT_SHIFT*evt;
+				«ENDIF»
+				int chain__et = NOT_CAUGHT;
+				«stateType» catching_state__et = NO_STATE;
+				«IF usesHdlr»
+				«boolType» is_handler__et = «langExt.booleanConstant(false)»;
+				«ENDIF»
+				«IF async || eventDriven»
+					«markVariableUsed("trigger__et")»
+				«ENDIF»
+				
+				«IF handleEvents»
+					if (!handleSystemEvent(ifitem, evt, generic_data__et)) {
+						«genStateSwitch(xpmc, usesHdlr)»
+					}
+				«ELSE»
+					«genStateSwitch(xpmc, usesHdlr)»
+				«ENDIF»
+				if (chain__et != NOT_CAUGHT) {
+					«opScopePriv»exitTo(«langExt.selfPointer(true)»getState(«langExt.selfPointer(false)»), catching_state__et«IF usesHdlr», is_handler__et«ENDIF»);
+					{
+						«stateType» next__et = «opScopePriv»executeTransitionChain(«langExt.selfPointer(true)»chain__et«IF handleEvents», ifitem, generic_data__et«ENDIF»);
+						next__et = «opScopePriv»enterHistory(«langExt.selfPointer(true)»next__et«IF usesHdlr», is_handler__et«ENDIF»);
+						setState(«langExt.selfPointer(true)»next__et);
+						«finalAction()»
+					}
+				}
+			}
+		«ELSE»
+			void receiveEventInternal(«langExt.selfPointer(mc.className, handleEvents)»«IF handleEvents»«ifItemPtr» ifitem, int localId, int evt, «langExt.voidPointer» generic_data__et«ENDIF»);
+		«ENDIF»
+		«IF handleEvents»
+			«IF generateImplementation»
+				«publicIf»void «opScope»receiveEvent(«langExt.selfPointer(mc.className, true)»«ifItemPtr» ifitem, int evt, «langExt.voidPointer» generic_data__et) {
+					int localId = (ifitem==«langExt.nullPointer»)? 0 : ifitem«getLocalId»;
+					«opScope»receiveEventInternal(«langExt.selfPointer(true)»ifitem, localId, evt, generic_data__et);
+				}
+			«ELSE»
+				void «opScope»receiveEvent(«langExt.selfPointer(true)»«ifItemPtr» ifitem, int evt, «langExt.voidPointer» generic_data__et);
+			«ENDIF»
+		«ENDIF»
+        '''
+    }
+    
+    /**
+     * generate the do code calls for a given state
+     * 
+     * @param state the {@link State}
+     * @return the generated code
+     */
+    def public String genDoCodes(State state) {'''
+        «IF state.hasDoCode(true)»
+            «state.getDoCodeOperationName()»(«langExt.selfPointer(false)»);
+        «ENDIF»
+        «IF state.eContainer.eContainer instanceof State»
+            «genDoCodes(state.eContainer.eContainer as State)»
+        «ENDIF»
+    '''}
+    
+    /**
+     * helper method which generates the state switch.
+     * Asynchronous, data driven and event driven state machines are distinguished
+     * 
+     * @param xpmc the {@link ExpandedModelComponent}
+     * @param usesHdlr if the state machine uses no handler {@link TransitionPoint}s
+     *      at all then unused variables can be avoided by passing <code>true</code> 
+     * @return the generated code
+     */
+    def public genStateSwitch(ExpandedModelComponent xpmc, boolean usesHdlr) {
+        var async = xpmc.modelComponent.commType==ComponentCommunicationType::ASYNCHRONOUS
+        var eventDriven = xpmc.modelComponent.commType==ComponentCommunicationType::EVENT_DRIVEN
+        var dataDriven = xpmc.modelComponent.commType==ComponentCommunicationType::DATA_DRIVEN
+        '''
+            switch (getState(«langExt.selfPointer(false)»)) {
+                «FOR state : xpmc.stateMachine.getLeafStateList()»
+                case «state.getGenStateId()»:
+                    «IF async»
+                        «var atlist =  xpmc.getActiveTriggers(state)»
+                        «IF !atlist.isEmpty»
+                            switch(trigger__et) {
+                                case POLLING:
+                                    «genDataDrivenTriggers(xpmc, state, usesHdlr)»
+                                    break;
+                                «genEventDrivenTriggers(xpmc, state, atlist, usesHdlr)»
+                            }
+                        «ELSE»
+                                «genDataDrivenTriggers(xpmc, state, usesHdlr)»
+                        «ENDIF»
+                    «ELSEIF dataDriven»
+                            «genDataDrivenTriggers(xpmc, state, usesHdlr)»
+                    «ELSEIF eventDriven»
+                        «var atlist =  xpmc.getActiveTriggers(state)»
+                        «IF !atlist.isEmpty»
+                            switch(trigger__et) {
+                                    «genEventDrivenTriggers(xpmc, state, atlist, usesHdlr)»
+                            }
+                        «ENDIF»
+                    «ENDIF»
+                    break;
+                «ENDFOR»
+                default:
+                    /* should not occur */
+                    break;
+            }
+        '''
+    }
+    
+    /**
+     * helper method which generates the data driven triggers
+     * 
+     * @param xpmc the {@link ExpandedModelComponent}
+     * @param state the {@link State} for which the trigger if-else switch should be generated
+     * @param usesHdlr if the state machine uses no handler {@link TransitionPoints}
+     *      at all then unused variables can be avoided by passing <code>true</code> 
+     * @return the generated code
+     */
+    def public genDataDrivenTriggers(ExpandedModelComponent xpmc, State state, boolean usesHdlr) {
+        '''
+            «genDoCodes(state)»
+            «var transitions = xpmc.getOutgoingTransitionsHierarchical(state).filter(t|t instanceof GuardedTransition)»
+            «FOR tr : transitions»
+                if («guard((tr as GuardedTransition), "", xpmc)»)
+                {
+                    «var chain = xpmc.getChain(tr)»
+                    chain__et = «chain.genChainId»;
+                    catching_state__et = «chain.stateContext.genStateId»;
+                    «IF chain.isHandler() && usesHdlr»
+                        is_handler__et = TRUE;
+                    «ENDIF»
+                }
+                «IF tr!=transitions.last»
+                    else 
+                «ENDIF»
+            «ENDFOR»
+        '''
+    }
+    
+    /**
+     * helper method which generates the event driven triggers
+     * 
+     * @param xpmc the {@link ExpandedModelComponent}
+     * @param state the {@link State} for which the trigger switch should be generated
+     * @param atlist the list of {@link ActiveTrigger}s of this state
+     * @param usesHdlr if the state machine uses no handler {@link TransitionPoints}
+     *      at all then unused variables can be avoided by passing <code>true</code> 
+     * @return the generated code
+     */
+    def public genEventDrivenTriggers(ExpandedModelComponent xpmc, State state, List<ActiveTrigger> atlist, boolean usesHdlr) {
+        '''
+            «FOR at : atlist»
+                case «xpmc.getTriggerCodeName(at)»:
+                    «var needData = at.hasGuard»
+                    «IF needData»{ «langExt.getTypedDataDefinition(at.msg)»«ENDIF»
+                    «FOR tt : at.transitions SEPARATOR " else "»
+                        «var chain = xpmc.getChain(tt)»
+                        «guard(chain.getTransition as TriggeredTransition, at.trigger, xpmc)»
+                        {
+                            chain__et = «chain.genChainId»;
+                            catching_state__et = «chain.stateContext.genStateId»;
+                            «IF chain.isHandler() && usesHdlr»
+                                is_handler__et = «langExt.booleanConstant(true)»;
+                            «ENDIF»
+                        }
+                    «ENDFOR»
+                    «IF needData»}«ENDIF»
+                break;
+            «ENDFOR»
+            default:
+                /* should not occur */
+                break;
+        '''
+    }
+    
+    def public getClassName(ExpandedModelComponent xpmc) {
+        xpmc.modelComponent.className
+    }
+    
+    def public getClassName(ModelComponent mc) {
+        mc.componentName
+    }
+    
+    /**
+     * getter for history array
+     * 
+     * @param state the ID of the history state
+     * @return the generated code
+     */
+    def public getHistory(String state) {
+        langExt.memberAccess+"history["+state+"]"
+    }
+
+    /**
+     * setter for history array
+     * 
+     * @param state the ID of the state whose history should be set
+     * @param historyState the ID of the state that should be assigned
+     * @return the generated code
+     */
+    def public setHistory(String state, String historyState) {
+        langExt.memberAccess+"history["+state+"] = "+historyState
+    }
+    
+    /**
+     * @return the type of (temporary) state variables (defaults to "int")
+     * and has to be signed
+     */
+    def public stateType() {
+        "int"
+    }
+
+    /**
+     * allow target language dependent generation of unreachable return in generated enterHistory method.
+     * The default is just a comment.
+     * @return the generated code
+     */ 
+    def public unreachableReturn() {
+        "/* return NO_STATE; // required by CDT but detected as unreachable by JDT because of while (true) */"
+    }
+
+    /**
+     * type of (temporary) boolean variables (defaults to "boolean")
+     * @return the generated code
+     */
+    def public boolType() {
+        return "boolean"
+    }
+    
+    /**
+     * empty, but may be overridden
+     */
+    def public finalAction() {
+        ''''''
+    }
+    
+    /**
+     * the type of the interface item passed into the receiveEvent() method
+     */
+    def public interfaceItemType() {
+        "InterfaceItemBase"
+    }
+
+    /**
+     * empty, but may be overridden
+     */
+    def markVariableUsed(String varname) {
+        ''''''
+    }
+    
+    /**
+     * let derived class add extra code after definition of constants
+     * 
+     * @param xpmc an expanded actor class
+     * @return the generated code
+     */
+    def public genExtra(ExpandedModelComponent xpmc) {''''''}
+    
+    /**
+     * let derived class add extra code after definition of constants in header (if applicable)
+     * 
+     * @param xpmc an expanded actor class
+     * @return the generated code
+     */
+    def public genExtraDecl(ExpandedModelComponent xpmc) {''''''}
+    
+    /**
+     * helper method to determine whether this state machine uses handler transitions
+     * points at all
+     * 
+     * @param xpax the {@link ExpandedModelComponent}
+     * @return <code>true</code> if the state machine uses handler transition points
+     */
+    def public usesHandlerTrPoints(ExpandedModelComponent xpmc) {
+        if (xpmc.stateMachine.empty)
+            return false
+        !xpmc.stateMachine.allTrPointsRecursive.filter(t|t instanceof TransitionPoint && ((t as TransitionPoint).handler)).empty
+    }
+
+    def public String guard(TriggeredTransition tt, String trigger, ExpandedModelComponent mc)
+    def public String guard(GuardedTransition tt, String trigger, ExpandedModelComponent mc)
+    def public String genActionCodeMethod(ExpandedModelComponent xpmc, Transition tr, boolean generateImplementation)
+    def public String genActionCodeMethods(ExpandedModelComponent xpmc, State state, boolean generateImplementation)
+}
\ No newline at end of file
diff --git a/plugins/org.eclipse.etrice.generator.fsm/src/org/eclipse/etrice/generator/fsm/generic/FSMExtensions.xtend b/plugins/org.eclipse.etrice.generator.fsm/src/org/eclipse/etrice/generator/fsm/generic/FSMExtensions.xtend
index 5127a42..0a88f76 100644
--- a/plugins/org.eclipse.etrice.generator.fsm/src/org/eclipse/etrice/generator/fsm/generic/FSMExtensions.xtend
+++ b/plugins/org.eclipse.etrice.generator.fsm/src/org/eclipse/etrice/generator/fsm/generic/FSMExtensions.xtend
@@ -19,6 +19,12 @@
 import java.util.ArrayList
 import org.eclipse.etrice.core.fsm.fSM.StateGraph
 import org.eclipse.etrice.core.fsm.fSM.TransitionPoint
+import org.eclipse.etrice.core.fsm.fSM.ModelComponent
+import org.eclipse.etrice.core.fsm.util.FSMHelpers
+import com.google.inject.Inject
+import org.eclipse.etrice.core.fsm.fSM.DetailCode
+import org.eclipse.etrice.core.fsm.fSM.Guard
+import org.eclipse.etrice.core.fsm.fSM.CPBranchTransition
 
 /**
  * @author Henrik Rentz-Reichert
@@ -26,6 +32,8 @@
  */
 class FSMExtensions {
 	
+	@Inject protected extension FSMHelpers
+	
 	//-------------------------------------------------------
 	// union methods
 	
@@ -67,6 +75,9 @@
 		return ret;
 	}
 
+    //-------------------------------------------------------
+    // state graph related methods
+
 	/**
 	 * @param ac an {@link ExpandedActorClass}
 	 * @param s a {@link State}
@@ -93,5 +104,63 @@
 		
 		return result;
 	}
+
+    /**
+     * @param states a list of {@link State}s
+     * @return a list ordered such that leaf states are last
+     */
+    def getLeafStatesLast(List<State> states) {
+        val leaf = states.filter(s|s.leaf)
+        val nonLeaf = states.filter(s|!s.leaf)
+        
+        nonLeaf.union(leaf)
+    }
+
+    /**
+     * @param ac an {@link ActorClass}
+     * @return a list of all leaf states
+     */
+    def List<State> getAllLeafStates(ModelComponent mc) {
+        mc.stateMachine.leafStateList
+    }
+
+    /**
+     * @param ac an {@link ActorClass}
+     * @return a list of simple states with leaf states last
+     */
+    def List<State> getAllBaseStatesLeavesLast(ModelComponent mc) {
+        mc.allBaseStates.getLeafStatesLast
+    }
+
+    /**
+     * @param ac an {@link ModelComponent}
+     * @return the number of all inherited states
+     */
+    def int getNumberOfInheritedStates(ModelComponent mc) {
+        if (mc.base==null)
+            return 0
+        else
+            return mc.base.stateMachine.stateList.size+mc.base.numberOfInheritedStates
+    }
+    
+    /**
+     * @param ac an {@link ModelComponent}
+     * @return the number of all inherited base (or simple) states
+     */
+    def int getNumberOfInheritedBaseStates(ModelComponent ac) {
+        if (ac.base==null)
+            return 0
+        else
+            return ac.base.stateMachine.baseStateList.size+ac.base.numberOfInheritedBaseStates
+    }
 	
+	def boolean isConditionOrGuard(DetailCode dc) {
+        val parent = dc.eContainer
+        switch (parent) {
+            Guard: true
+            CPBranchTransition: parent.condition==dc
+            default:
+                false
+        }
+	}
 }
\ No newline at end of file
diff --git a/plugins/org.eclipse.etrice.generator.fsm/src/org/eclipse/etrice/generator/fsm/generic/IDetailCodeTranslator.java b/plugins/org.eclipse.etrice.generator.fsm/src/org/eclipse/etrice/generator/fsm/generic/IDetailCodeTranslator.java
new file mode 100644
index 0000000..e8e4a27
--- /dev/null
+++ b/plugins/org.eclipse.etrice.generator.fsm/src/org/eclipse/etrice/generator/fsm/generic/IDetailCodeTranslator.java
@@ -0,0 +1,24 @@
+/*******************************************************************************
+ * Copyright (c) 2014 protos software gmbh (http://www.protos.de).
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * 
+ * CONTRIBUTORS:
+ * 		Henrik Rentz-Reichert (initial contribution)
+ * 
+ *******************************************************************************/
+
+package org.eclipse.etrice.generator.fsm.generic;
+
+import org.eclipse.etrice.core.fsm.fSM.DetailCode;
+
+/**
+ * @author Henrik Rentz-Reichert
+ *
+ */
+public interface IDetailCodeTranslator {
+
+	String getTranslatedCode(DetailCode dc);
+}
diff --git a/plugins/org.eclipse.etrice.generator.fsm/src/org/eclipse/etrice/generator/fsm/generic/IIfItemIdGenerator.java b/plugins/org.eclipse.etrice.generator.fsm/src/org/eclipse/etrice/generator/fsm/generic/IIfItemIdGenerator.java
new file mode 100644
index 0000000..c903a12
--- /dev/null
+++ b/plugins/org.eclipse.etrice.generator.fsm/src/org/eclipse/etrice/generator/fsm/generic/IIfItemIdGenerator.java
@@ -0,0 +1,25 @@
+/*******************************************************************************
+ * Copyright (c) 2014 protos software gmbh (http://www.protos.de).
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * 
+ * CONTRIBUTORS:
+ * 		Henrik Rentz-Reichert (initial contribution)
+ * 
+ *******************************************************************************/
+
+package org.eclipse.etrice.generator.fsm.generic;
+
+import org.eclipse.etrice.core.fsm.fSM.AbstractInterfaceItem;
+
+/**
+ * an interface for generators of interface item IDs
+ * 
+ * @author Henrik Rentz-Reichert
+ */
+public interface IIfItemIdGenerator {
+
+	String getIfItemId(AbstractInterfaceItem item);
+}
diff --git a/plugins/org.eclipse.etrice.generator.fsm/src/org/eclipse/etrice/generator/fsm/generic/ILanguageExtensionBase.java b/plugins/org.eclipse.etrice.generator.fsm/src/org/eclipse/etrice/generator/fsm/generic/ILanguageExtensionBase.java
new file mode 100644
index 0000000..f922ede
--- /dev/null
+++ b/plugins/org.eclipse.etrice.generator.fsm/src/org/eclipse/etrice/generator/fsm/generic/ILanguageExtensionBase.java
@@ -0,0 +1,217 @@
+/*******************************************************************************
+ * Copyright (c) 2014 protos software gmbh (http://www.protos.de).
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * 
+ * CONTRIBUTORS:
+ * 		Henrik Rentz-Reichert (initial contribution)
+ * 
+ *******************************************************************************/
+
+package org.eclipse.etrice.generator.fsm.generic;
+
+import java.util.List;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.xtext.util.Pair;
+
+import com.google.inject.spi.Message;
+
+/**
+ * @author Henrik Rentz-Reichert
+ *
+ */
+public interface ILanguageExtensionBase {
+
+	/**
+	 * This method is called to get a target language specific piece of
+	 * code that defines a typed local variable holding the data passed with
+	 * the message (if applicable). The name of the local variable should
+	 * be that of the message parameter.
+	 * 
+	 * @param msg the {@link Message}
+	 * @return the variable definition
+	 */
+	String getTypedDataDefinition(EObject msg);
+
+	/** 
+	 * unification of access level for all Languages before each member 
+	 * @return e.g. "private " for Java, nothing for C and C++ (no access level before the individual member) 
+	 */
+	String accessLevelPrivate();
+	
+	/** 
+	 * unification of access level for all Languages before each member 
+	 * @return e.g. "protected " for Java, nothing for C and C++ (no access level before the individual member) 
+	 */
+	String accessLevelProtected();
+	
+	/** 
+	 * unification of access level for all Languages before each member 
+	 * @return e.g. "public " for Java, nothing for C and C++ (no access level before the individual member)
+	 */
+	String accessLevelPublic();
+	
+	
+	// Strings for member access
+	
+	/** 
+	 * unification of member access for different languages
+	 * @return e.g. "this." for Java and C++ or "self->" for C
+	 */
+	String memberAccess(); 	 
+	
+	/** 
+	 * self pointer for building class mechanism in C, 
+	 * e.g. MyClass_function1(MyClass *self, int32 argument1)
+	 * @param classname the class name
+	 * @param hasArgs true if functions has further arguments
+	 * @return "classname *self, " for C / for Java and C++ nothing
+	 */
+	String selfPointer(String classname, boolean hasArgs);
+	
+	/**
+	 * self pointer for function calls
+	 * @param hasArgs true if functions has further arguments
+	 * @return "self, " for C / for Java and C++ nothing
+	 */
+	String selfPointer(boolean hasArgs);
+	
+	/** 
+	 * language specific scoping string for operations
+	 * e.g. nothing in Java (only inside class declaration), nothing and classname:: for C++ and classname_ for C
+	 * @param classname the class name
+	 * @param isDeclaration true if it is a declaration
+	 * @return "classname_" for C / for Java and C++ nothing
+	 */
+	String operationScope(String classname, boolean isDeclaration);
+
+	/**
+	 * member declaration
+	 * 
+	 * @param namespace the namespace or class name
+	 * @param member the member name
+	 * @return for C: namespace_member, for Java namespace.member
+	 */
+	String memberInDeclaration(String namespace, String member);
+	
+	/**
+	 * member usage
+	 * 
+	 * @param namespace the namespace or class name
+	 * @param member the member name
+	 * @return for C: namespace_member, for Java namespace.member
+	 */
+	String memberInUse(String namespace, String member);
+	
+	/**
+	 * does the target language offer inheritance
+	 * 
+	 * @return true for C++ and Java, false for C
+	 */
+	boolean usesInheritance();
+	
+	/**
+	 * does the target language use pointers
+	 * 
+	 * @return true for C++ and C, false for Java
+	 */
+	boolean usesPointers();
+	
+	/**
+	 * generate an enumeration (enum in C, int constants in Java)
+	 * @param name the enumeration name
+	 * @param entries a list of name/value pairs
+	 * @return a string defining the enumeration in the target language
+	 */
+	String genEnumeration(String name, List<Pair<String, String>> entries);
+	
+	/**
+	 * literals for boolean constants
+	 * @param b the boolean value
+	 * @return TRUE/FALSE for C/C++, true/false for Java
+	 */
+	String booleanConstant(boolean b);
+	
+
+	/**
+	 *  literal for pointer
+	 * 
+	 * @return * for C/C++, nothing for Java
+	 */
+	String pointerLiteral();
+	
+	
+	/**
+	 * a literal for the null pointer
+	 * 
+	 * @return NULL for C/C++, null for Java
+	 */
+	String nullPointer();
+	
+	/**
+	 * a generic pointer
+	 * 
+	 * @return void* for C/C++, Object for Java
+	 */
+	String voidPointer();
+	
+	/**
+	 * array declarations differ in Java and C/C++
+	 * @param type
+	 * @param size
+	 * @param name
+	 * @return a string that represents the declaration
+	 */
+	String arrayDeclaration(String type, int size, String name, boolean isRef);
+	
+	/**
+	 * name for the constructor (without namespace if applicable)
+	 * 
+	 * @param cls the class name
+	 * @return the constructor name
+	 */
+	String constructorName(String cls);
+	
+	/**
+	 * name for the destructor (without namespace if applicable)
+	 * 
+	 * @param cls the class name
+	 * @return the destructor name
+	 */
+	String destructorName(String cls);
+	
+	/**
+	 * @return a typename for the return type (might be empty)
+	 */
+	String constructorReturnType();
+	
+	/**
+	 * @return a typename for the return type (might be empty)
+	 */
+	String destructorReturnType();
+	
+	/**
+	 * @param baseClassName the name of the base class
+	 * @param method the method to be called
+	 * @param arguments the argument list
+	 * @return super.method for Java, baseClassName::method for C++, empty for C
+	 */
+	String superCall(String baseClassName, String method, String arguments);
+	
+	/**
+	 * return three strings used by the generator
+	 * 
+	 * @param data the variable declaration
+	 * @return an array of three strings
+	 * <ol>
+	 *  <li>the string that performs the cast from generic_data to the correct type and assigns it to a new variable</li>
+	 *  <li>the data as it appears in a method call</li>
+	 *  <li>the data as it is used in the method declaration</li>
+	 *  </ol>
+	 */
+	String[] generateArglistAndTypedData(EObject data);
+
+}
diff --git a/plugins/org.eclipse.etrice.generator.fsm/src/org/eclipse/etrice/generator/fsm/generic/IMessageIdGenerator.java b/plugins/org.eclipse.etrice.generator.fsm/src/org/eclipse/etrice/generator/fsm/generic/IMessageIdGenerator.java
new file mode 100644
index 0000000..41b2ef0
--- /dev/null
+++ b/plugins/org.eclipse.etrice.generator.fsm/src/org/eclipse/etrice/generator/fsm/generic/IMessageIdGenerator.java
@@ -0,0 +1,24 @@
+/*******************************************************************************
+ * Copyright (c) 2014 protos software gmbh (http://www.protos.de).
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * 
+ * CONTRIBUTORS:
+ * 		Henrik Rentz-Reichert (initial contribution)
+ * 
+ *******************************************************************************/
+
+package org.eclipse.etrice.generator.fsm.generic;
+
+import org.eclipse.etrice.core.fsm.fSM.MessageFromIf;
+
+/**
+ * @author Henrik Rentz-Reichert
+ *
+ */
+public interface IMessageIdGenerator {
+
+	String getMessageID(MessageFromIf mif);
+}
diff --git a/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/generic/TransitionChainGenerator.java b/plugins/org.eclipse.etrice.generator.fsm/src/org/eclipse/etrice/generator/fsm/generic/TransitionChainGenerator.java
similarity index 60%
rename from plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/generic/TransitionChainGenerator.java
rename to plugins/org.eclipse.etrice.generator.fsm/src/org/eclipse/etrice/generator/fsm/generic/TransitionChainGenerator.java
index dc365c3..5d124b2 100644
--- a/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/generic/TransitionChainGenerator.java
+++ b/plugins/org.eclipse.etrice.generator.fsm/src/org/eclipse/etrice/generator/fsm/generic/TransitionChainGenerator.java
@@ -10,15 +10,15 @@
  * 
  *******************************************************************************/
 
-package org.eclipse.etrice.generator.generic;
+package org.eclipse.etrice.generator.fsm.generic;
 
-import org.eclipse.etrice.core.genmodel.etricegen.ExpandedActorClass;
-import org.eclipse.etrice.core.genmodel.fsm.fsmgen.TransitionChain;
+import org.eclipse.emf.ecore.EObject;
 import org.eclipse.etrice.core.fsm.fSM.InitialTransition;
 import org.eclipse.etrice.core.fsm.fSM.Transition;
 import org.eclipse.etrice.core.fsm.fSM.TriggeredTransition;
-import org.eclipse.etrice.core.room.VarDecl;
-import org.eclipse.etrice.generator.base.AbstractGenerator;
+import org.eclipse.etrice.core.genmodel.fsm.fsmgen.ExpandedModelComponent;
+import org.eclipse.etrice.core.genmodel.fsm.fsmgen.TransitionChain;
+import org.eclipse.etrice.generator.fsm.base.CodegenHelpers;
 
 import com.google.inject.Inject;
 
@@ -29,29 +29,30 @@
  */
 public class TransitionChainGenerator {
 
-	@Inject ILanguageExtension languageExt;
+	@Inject private ILanguageExtensionBase languageExt;
+	@Inject private CodegenHelpers codegenHelpers;
+	@Inject private IDetailCodeTranslator translator;
 
-	public String generateExecuteChain(ExpandedActorClass ac, TransitionChain tc) {
-		TransitionChainVisitor tcv = new TransitionChainVisitor(ac);
-		AbstractGenerator.getInjector().injectMembers(tcv);
+	public String generateExecuteChain(ExpandedModelComponent xpmc, TransitionChain tc) {
+		TransitionChainVisitor tcv = new TransitionChainVisitor(xpmc, languageExt, codegenHelpers, translator);
 		tcv.init(tc);
 		
 		return tc.genExecuteChain(tcv);
 	}
 
-	public String generateArgumentList(ExpandedActorClass xpac, Transition t) {
+	public String generateArgumentList(ExpandedModelComponent xpmc, Transition t) {
 		if (t instanceof InitialTransition)
 			// actually is InitialTransition
 			return "";
 		
-		TransitionChain chain = xpac.getChain(t);
+		TransitionChain chain = xpmc.getChain(t);
 		if (!(chain.getTransition() instanceof TriggeredTransition))
 			return "";
 		
-		return generateTypedArgumentList((VarDecl) xpac.getData(t));
+		return generateTypedArgumentList(xpmc.getData(t));
 	}
 
-	public String generateTypedArgumentList(VarDecl data) {
+	public String generateTypedArgumentList(EObject data) {
 		return languageExt.generateArglistAndTypedData(data)[2];
 	}
 }
diff --git a/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/generic/TransitionChainVisitor.java b/plugins/org.eclipse.etrice.generator.fsm/src/org/eclipse/etrice/generator/fsm/generic/TransitionChainVisitor.java
similarity index 73%
rename from plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/generic/TransitionChainVisitor.java
rename to plugins/org.eclipse.etrice.generator.fsm/src/org/eclipse/etrice/generator/fsm/generic/TransitionChainVisitor.java
index 5420be1..b275906 100644
--- a/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/generic/TransitionChainVisitor.java
+++ b/plugins/org.eclipse.etrice.generator.fsm/src/org/eclipse/etrice/generator/fsm/generic/TransitionChainVisitor.java
@@ -10,7 +10,7 @@
  * 
  *******************************************************************************/
 
-package org.eclipse.etrice.generator.generic;
+package org.eclipse.etrice.generator.fsm.generic;
 
 import org.eclipse.etrice.core.fsm.fSM.CPBranchTransition;
 import org.eclipse.etrice.core.fsm.fSM.ContinuationTransition;
@@ -18,14 +18,11 @@
 import org.eclipse.etrice.core.fsm.fSM.InitialTransition;
 import org.eclipse.etrice.core.fsm.fSM.State;
 import org.eclipse.etrice.core.fsm.fSM.Transition;
-import org.eclipse.etrice.core.genmodel.etricegen.ExpandedActorClass;
+import org.eclipse.etrice.core.fsm.util.FSMHelpers;
+import org.eclipse.etrice.core.genmodel.fsm.fsmgen.ExpandedModelComponent;
 import org.eclipse.etrice.core.genmodel.fsm.fsmgen.ITransitionChainVisitor;
 import org.eclipse.etrice.core.genmodel.fsm.fsmgen.TransitionChain;
-import org.eclipse.etrice.core.room.VarDecl;
-import org.eclipse.etrice.generator.base.AbstractGenerator;
-import org.eclipse.etrice.generator.base.CodegenHelpers;
-
-import com.google.inject.Inject;
+import org.eclipse.etrice.generator.fsm.base.CodegenHelpers;
 
 /**
  * Implementation of the {@link org.eclipse.etrice.core.genmodel.fsm.fsmgen.ITransitionChainVisitor ITransitionChainVisitor} interface.
@@ -36,18 +33,32 @@
  */
 public class TransitionChainVisitor implements ITransitionChainVisitor {
 
-	@Inject private ILanguageExtension langExt;
-	@Inject private CodegenHelpers codegenHelpers;
-	private ExpandedActorClass xpac;
+	private FSMHelpers fsmHelpers = new FSMHelpers();
+	
+	// Initialized in constructor
+	private ExpandedModelComponent xpac;
+	private ILanguageExtensionBase langExt;
+	private CodegenHelpers codegenHelpers;
+	private IDetailCodeTranslator translationProvider;
 	private boolean dataDriven;
 
 	/**
 	 * Constructor
 	 * 
-	 * @param xpac an {@link ExpandedActorClass}
+	 * @param xpac an {@link ExpandedModelComponent}
+	 * @param codegenHelpers 
+	 * @param languageExt 
 	 */
-	protected TransitionChainVisitor(ExpandedActorClass xpac) {
+	protected TransitionChainVisitor(
+			ExpandedModelComponent xpac,
+			ILanguageExtensionBase languageExt,
+			CodegenHelpers codegenHelpers,
+			IDetailCodeTranslator translationProvider
+	) {
 		this.xpac = xpac;
+		this.langExt = languageExt;
+		this.codegenHelpers = codegenHelpers;
+		this.translationProvider = translationProvider;
 	}
 	
 	protected void init(TransitionChain tc) {
@@ -65,13 +76,13 @@
 	
 	public String genActionOperationCall(Transition tr) {
 
-		if (tr.getAction()!=null && !tr.getAction().getLines().isEmpty()) {
+		if (fsmHelpers.hasDetailCode(tr.getAction())) {
 			if (tr instanceof InitialTransition)
 				return codegenHelpers.getActionCodeOperationName(tr)+"("+langExt.selfPointer(false)+");\n";
 			else if (dataDriven)
 				return codegenHelpers.getActionCodeOperationName(tr)+"("+langExt.selfPointer(false)+");\n";
 			else {
-				String[] result = langExt.generateArglistAndTypedData((VarDecl) xpac.getData(tr));
+				String[] result = langExt.generateArglistAndTypedData(xpac.getData(tr));
 				String dataArg = result[0];
 				
 				return codegenHelpers.getActionCodeOperationName(tr)+"("+langExt.selfPointer(true)+"ifitem"+dataArg+");\n";
@@ -94,7 +105,7 @@
 		if (!isFirst )
 			result = "}\nelse ";
 
-		result += "if ("+AbstractGenerator.getInstance().getTranslatedCode(tr.getCondition())+") {\n";
+		result += "if ("+translationProvider.getTranslatedCode(tr.getCondition())+") {\n";
 		
 		return result;
 	}
@@ -116,7 +127,7 @@
 	}
 
 	public String genTypedData(TransitionChain tc) {
-		String[] result = langExt.generateArglistAndTypedData((VarDecl) tc.getData());
+		String[] result = langExt.generateArglistAndTypedData(tc.getData());
 		return result[1];
 	}
 
diff --git a/plugins/org.eclipse.etrice.generator.fsm/xtend-gen/org/eclipse/etrice/generator/fsm/generic/AbstractStateMachineGenerator.java b/plugins/org.eclipse.etrice.generator.fsm/xtend-gen/org/eclipse/etrice/generator/fsm/generic/AbstractStateMachineGenerator.java
new file mode 100644
index 0000000..1d21fdb
--- /dev/null
+++ b/plugins/org.eclipse.etrice.generator.fsm/xtend-gen/org/eclipse/etrice/generator/fsm/generic/AbstractStateMachineGenerator.java
@@ -0,0 +1,1778 @@
+/**
+ * Copyright (c) 2014 protos software gmbh (http://www.protos.de).
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * 
+ * CONTRIBUTORS:
+ * 		Henrik Rentz-Reichert (initial contribution)
+ */
+package org.eclipse.etrice.generator.fsm.generic;
+
+import com.google.common.base.Objects;
+import com.google.inject.Inject;
+import java.util.ArrayList;
+import java.util.List;
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.etrice.core.fsm.fSM.AbstractInterfaceItem;
+import org.eclipse.etrice.core.fsm.fSM.ComponentCommunicationType;
+import org.eclipse.etrice.core.fsm.fSM.DetailCode;
+import org.eclipse.etrice.core.fsm.fSM.GuardedTransition;
+import org.eclipse.etrice.core.fsm.fSM.MessageFromIf;
+import org.eclipse.etrice.core.fsm.fSM.ModelComponent;
+import org.eclipse.etrice.core.fsm.fSM.State;
+import org.eclipse.etrice.core.fsm.fSM.StateGraph;
+import org.eclipse.etrice.core.fsm.fSM.TrPoint;
+import org.eclipse.etrice.core.fsm.fSM.Transition;
+import org.eclipse.etrice.core.fsm.fSM.TransitionPoint;
+import org.eclipse.etrice.core.fsm.fSM.TriggeredTransition;
+import org.eclipse.etrice.core.fsm.util.FSMHelpers;
+import org.eclipse.etrice.core.genmodel.fsm.fsmgen.ActiveTrigger;
+import org.eclipse.etrice.core.genmodel.fsm.fsmgen.ExpandedModelComponent;
+import org.eclipse.etrice.core.genmodel.fsm.fsmgen.TransitionChain;
+import org.eclipse.etrice.core.genmodel.fsm.fsmgen.util.FsmGenUtil;
+import org.eclipse.etrice.generator.fsm.base.CodegenHelpers;
+import org.eclipse.etrice.generator.fsm.generic.FSMExtensions;
+import org.eclipse.etrice.generator.fsm.generic.IDetailCodeTranslator;
+import org.eclipse.etrice.generator.fsm.generic.IIfItemIdGenerator;
+import org.eclipse.etrice.generator.fsm.generic.ILanguageExtensionBase;
+import org.eclipse.etrice.generator.fsm.generic.IMessageIdGenerator;
+import org.eclipse.etrice.generator.fsm.generic.TransitionChainGenerator;
+import org.eclipse.xtend2.lib.StringConcatenation;
+import org.eclipse.xtext.util.Pair;
+import org.eclipse.xtext.util.Tuples;
+import org.eclipse.xtext.xbase.lib.Extension;
+import org.eclipse.xtext.xbase.lib.Functions.Function1;
+import org.eclipse.xtext.xbase.lib.IterableExtensions;
+
+/**
+ * @author Henrik Rentz-Reichert
+ */
+@SuppressWarnings("all")
+public abstract class AbstractStateMachineGenerator {
+  @Inject
+  @Extension
+  public FSMHelpers _fSMHelpers;
+  
+  @Inject
+  @Extension
+  public FsmGenUtil _fsmGenUtil;
+  
+  @Inject
+  @Extension
+  public CodegenHelpers _codegenHelpers;
+  
+  @Inject
+  @Extension
+  public FSMExtensions _fSMExtensions;
+  
+  @Inject
+  public ILanguageExtensionBase langExt;
+  
+  @Inject
+  public IMessageIdGenerator msgIdGen;
+  
+  @Inject
+  public IIfItemIdGenerator itemIdGen;
+  
+  @Inject
+  public TransitionChainGenerator transitionChainGenerator;
+  
+  @Inject
+  public IDetailCodeTranslator translator;
+  
+  /**
+   * generates trigger IDs.
+   * Inheritance (if available) is used for base class IDs.
+   * 
+   * @param xpmc the {@link ExpandedModelComponent}
+   * @return the generated code
+   */
+  public String genTriggerConstants(final ExpandedModelComponent xpmc) {
+    boolean _usesInheritance = this.langExt.usesInheritance();
+    return this.genTriggerConstants(xpmc, _usesInheritance);
+  }
+  
+  /**
+   * generates trigger IDs.
+   * Inheritance (if available) is used for base class IDs.
+   * 
+   * @param xpmc the {@link ExpandedModelComponent}
+   * @param omitBase use <code>true</code> if no base class trigger constants are needed
+   * 
+   * @return the generated code
+   */
+  public String genTriggerConstants(final ExpandedModelComponent xpmc, final boolean omitBase) {
+    List<MessageFromIf> _xifexpression = null;
+    if (omitBase) {
+      ModelComponent _modelComponent = xpmc.getModelComponent();
+      _xifexpression = this._fSMHelpers.getOwnMessagesFromInterfaces(_modelComponent);
+    } else {
+      ModelComponent _modelComponent_1 = xpmc.getModelComponent();
+      _xifexpression = this._fSMHelpers.getAllMessagesFromInterfaces(_modelComponent_1);
+    }
+    final List<MessageFromIf> triggers = _xifexpression;
+    final ArrayList<Pair<String, String>> list = new ArrayList<Pair<String, String>>();
+    Pair<String, String> _pair = Tuples.<String, String>pair("POLLING", "0");
+    list.add(_pair);
+    for (final MessageFromIf mif : triggers) {
+      AbstractInterfaceItem _from = mif.getFrom();
+      boolean _isEventDriven = _from.isEventDriven();
+      if (_isEventDriven) {
+        String _triggerCodeName = xpmc.getTriggerCodeName(mif);
+        AbstractInterfaceItem _from_1 = mif.getFrom();
+        String _ifItemId = this.itemIdGen.getIfItemId(_from_1);
+        String _plus = (_ifItemId + " + EVT_SHIFT*");
+        String _messageID = this.msgIdGen.getMessageID(mif);
+        String _plus_1 = (_plus + _messageID);
+        Pair<String, String> _pair_1 = Tuples.<String, String>pair(_triggerCodeName, _plus_1);
+        list.add(_pair_1);
+      }
+    }
+    return this.langExt.genEnumeration("triggers", list);
+  }
+  
+  /**
+   * generates state ID constants.
+   * Inheritance (if available) is used for base class IDs.
+   * 
+   * @param xpmc the {@link ExpandedModelComponent}
+   * @return the generated code
+   */
+  public String genStateIdConstants(final ExpandedModelComponent xpmc) {
+    boolean _usesInheritance = this.langExt.usesInheritance();
+    return this.genStateIdConstants(xpmc, _usesInheritance);
+  }
+  
+  /**
+   * generates state ID constants.
+   * Inheritance (if available) is used for base class IDs.
+   * 
+   * @param xpmc the {@link ExpandedModelComponent}
+   * @param omitBase use <code>true</code> if no base class state constants are needed
+   * 
+   * @return the generated code
+   */
+  public String genStateIdConstants(final ExpandedModelComponent xpmc, final boolean omitBase) {
+    final ModelComponent mc = xpmc.getModelComponent();
+    int _xifexpression = (int) 0;
+    if (omitBase) {
+      _xifexpression = this._fSMExtensions.getNumberOfInheritedBaseStates(mc);
+    } else {
+      _xifexpression = 0;
+    }
+    int offset = (2 + _xifexpression);
+    List<State> _xifexpression_1 = null;
+    if (omitBase) {
+      StateGraph _stateMachine = mc.getStateMachine();
+      _xifexpression_1 = this._fSMHelpers.getBaseStateList(_stateMachine);
+    } else {
+      StateGraph _stateMachine_1 = xpmc.getStateMachine();
+      _xifexpression_1 = this._fSMHelpers.getBaseStateList(_stateMachine_1);
+    }
+    List<State> baseStates = _xifexpression_1;
+    List<State> _leafStatesLast = this._fSMExtensions.getLeafStatesLast(baseStates);
+    baseStates = _leafStatesLast;
+    ArrayList<Pair<String, String>> list = new ArrayList<Pair<String, String>>();
+    if ((!omitBase)) {
+      Pair<String, String> _pair = Tuples.<String, String>pair("NO_STATE", "0");
+      list.add(_pair);
+      Pair<String, String> _pair_1 = Tuples.<String, String>pair("STATE_TOP", "1");
+      list.add(_pair_1);
+    }
+    for (final State state : baseStates) {
+      {
+        String _genStateId = this._codegenHelpers.getGenStateId(state);
+        String _string = Integer.valueOf(offset).toString();
+        Pair<String, String> _pair_2 = Tuples.<String, String>pair(_genStateId, _string);
+        list.add(_pair_2);
+        offset = (offset + 1);
+      }
+    }
+    String _string = Integer.valueOf(offset).toString();
+    Pair<String, String> _pair_2 = Tuples.<String, String>pair("STATE_MAX", _string);
+    list.add(_pair_2);
+    return this.langExt.genEnumeration("state_ids", list);
+  }
+  
+  /**
+   * generates transition chain ID constants.
+   * Inheritance (if available) is used for base class IDs.
+   * 
+   * @param xpmc the {@link ExpandedModelComponent}
+   * 
+   * @return the generated code
+   */
+  public String genTransitionChainConstants(final ExpandedModelComponent xpmc) {
+    boolean _usesInheritance = this.langExt.usesInheritance();
+    return this.genTransitionChainConstants(xpmc, _usesInheritance);
+  }
+  
+  /**
+   * generates transition chain ID constants.
+   * Inheritance (if available) is used for base class IDs.
+   * 
+   * @param xpmc the {@link ExpandedModelComponent}
+   * @param omitBase use <code>true</code> if no base class transition chain constants are needed
+   * 
+   * @return the generated code
+   */
+  public String genTransitionChainConstants(final ExpandedModelComponent xpmc, final boolean omitBase) {
+    EList<TransitionChain> _xifexpression = null;
+    if (omitBase) {
+      _xifexpression = xpmc.getOwnTransitionChains();
+    } else {
+      _xifexpression = xpmc.getTransitionChains();
+    }
+    EList<TransitionChain> chains = _xifexpression;
+    int _xifexpression_1 = (int) 0;
+    if (omitBase) {
+      EList<TransitionChain> _transitionChains = xpmc.getTransitionChains();
+      int _size = _transitionChains.size();
+      int _size_1 = chains.size();
+      _xifexpression_1 = (_size - _size_1);
+    } else {
+      _xifexpression_1 = 0;
+    }
+    int offset = _xifexpression_1;
+    ArrayList<Pair<String, String>> list = new ArrayList<Pair<String, String>>();
+    for (final TransitionChain chain : chains) {
+      {
+        offset = (offset + 1);
+        String _genChainId = this._codegenHelpers.getGenChainId(chain);
+        String _string = Integer.valueOf(offset).toString();
+        Pair<String, String> _pair = Tuples.<String, String>pair(_genChainId, _string);
+        list.add(_pair);
+      }
+    }
+    return this.langExt.genEnumeration("chain_ids", list);
+  }
+  
+  /**
+   * generates entry and exit code for states
+   * 
+   * @param xpmc the {@link ExpandedModelComponent}
+   * @param generateImplementation if <code>true</code> the implementation is generated, else the declaration
+   * 
+   * @return the generated code
+   */
+  public String genEntryAndExitCodes(final ExpandedModelComponent xpmc, final boolean generateImplementation) {
+    boolean _usesInheritance = this.langExt.usesInheritance();
+    return this.genEntryAndExitCodes(xpmc, generateImplementation, _usesInheritance);
+  }
+  
+  /**
+   * generates entry and exit code for states
+   * 
+   * @param xpmc the {@link ExpandedModelComponent}
+   * @param generateImplementation if <code>true</code> the implementation is generated, else the declaration
+   * @param omitBase use <code>true</code> if no base class entry and exit codes are needed
+   * 
+   * @return the generated code
+   */
+  public String genEntryAndExitCodes(final ExpandedModelComponent xpmc, final boolean generateImplementation, final boolean omitBase) {
+    StringConcatenation _builder = new StringConcatenation();
+    {
+      StateGraph _stateMachine = xpmc.getStateMachine();
+      List<State> _stateList = this._fSMHelpers.getStateList(_stateMachine);
+      for(final State state : _stateList) {
+        {
+          boolean _or = false;
+          if ((!omitBase)) {
+            _or = true;
+          } else {
+            boolean _isOwnObject = xpmc.isOwnObject(state);
+            _or = _isOwnObject;
+          }
+          if (_or) {
+            String _genActionCodeMethods = this.genActionCodeMethods(xpmc, state, generateImplementation);
+            _builder.append(_genActionCodeMethods, "");
+            _builder.newLineIfNotEmpty();
+          }
+        }
+      }
+    }
+    return _builder.toString();
+  }
+  
+  /**
+   * generates transition action codes
+   * 
+   * @param xpmc the {@link ExpandedModelComponent}
+   * @param generateImplementation if <code>true</code> the implementation is generated, else the declaration
+   * 
+   * @return the generated code
+   */
+  public String genActionCodes(final ExpandedModelComponent xpmc, final boolean generateImplementation) {
+    boolean _usesInheritance = this.langExt.usesInheritance();
+    return this.genActionCodes(xpmc, generateImplementation, _usesInheritance);
+  }
+  
+  /**
+   * generates transition action codes
+   * 
+   * @param xpmc the {@link ExpandedModelComponent}
+   * @param generateImplementation if <code>true</code> the implementation is generated, else the declaration
+   * @param omitBase use <code>true</code> if no base class action codes are needed
+   * 
+   * @return the generated code
+   */
+  public String genActionCodes(final ExpandedModelComponent xpmc, final boolean generateImplementation, final boolean omitBase) {
+    StringConcatenation _builder = new StringConcatenation();
+    {
+      StateGraph _stateMachine = xpmc.getStateMachine();
+      List<Transition> _allTransitionsRecursive = this._fSMHelpers.getAllTransitionsRecursive(_stateMachine);
+      for(final Transition tr : _allTransitionsRecursive) {
+        {
+          boolean _and = false;
+          boolean _or = false;
+          if ((!omitBase)) {
+            _or = true;
+          } else {
+            boolean _isOwnObject = xpmc.isOwnObject(tr);
+            _or = _isOwnObject;
+          }
+          if (!_or) {
+            _and = false;
+          } else {
+            DetailCode _action = tr.getAction();
+            boolean _hasDetailCode = this._fSMHelpers.hasDetailCode(_action);
+            _and = _hasDetailCode;
+          }
+          if (_and) {
+            String _genActionCodeMethod = this.genActionCodeMethod(xpmc, tr, generateImplementation);
+            _builder.append(_genActionCodeMethod, "");
+            _builder.newLineIfNotEmpty();
+          }
+        }
+      }
+    }
+    return _builder.toString();
+  }
+  
+  public String genStateSwitchMethods(final ExpandedModelComponent xpmc, final boolean generateImplementation) {
+    String _xblockexpression = null;
+    {
+      final ModelComponent mc = xpmc.getModelComponent();
+      ComponentCommunicationType _commType = mc.getCommType();
+      final boolean async = Objects.equal(_commType, ComponentCommunicationType.ASYNCHRONOUS);
+      ComponentCommunicationType _commType_1 = mc.getCommType();
+      final boolean eventDriven = Objects.equal(_commType_1, ComponentCommunicationType.EVENT_DRIVEN);
+      String _interfaceItemType = this.interfaceItemType();
+      String _pointerLiteral = this.langExt.pointerLiteral();
+      final String ifItemPtr = (_interfaceItemType + _pointerLiteral);
+      boolean _or = false;
+      if (async) {
+        _or = true;
+      } else {
+        _or = eventDriven;
+      }
+      final boolean handleEvents = _or;
+      String _className = this.getClassName(mc);
+      final String opScope = this.langExt.operationScope(_className, false);
+      String _xifexpression = null;
+      boolean _usesInheritance = this.langExt.usesInheritance();
+      if (_usesInheritance) {
+        _xifexpression = opScope;
+      } else {
+        _xifexpression = "";
+      }
+      final String opScopePriv = _xifexpression;
+      String _xifexpression_1 = null;
+      boolean _usesInheritance_1 = this.langExt.usesInheritance();
+      if (_usesInheritance_1) {
+        _xifexpression_1 = this.langExt.accessLevelPublic();
+      } else {
+        _xifexpression_1 = this.langExt.accessLevelPrivate();
+      }
+      final String publicIf = _xifexpression_1;
+      final String privAccess = this.langExt.accessLevelPrivate();
+      String _className_1 = this.getClassName(mc);
+      final String selfPtr = this.langExt.selfPointer(_className_1, true);
+      String _className_2 = this.getClassName(mc);
+      final String selfOnly = this.langExt.selfPointer(_className_2, false);
+      String _xifexpression_2 = null;
+      boolean _usesInheritance_2 = this.langExt.usesInheritance();
+      if (_usesInheritance_2) {
+        String _xifexpression_3 = null;
+        boolean _usesPointers = this.langExt.usesPointers();
+        if (_usesPointers) {
+          _xifexpression_3 = "->getLocalId()";
+        } else {
+          _xifexpression_3 = ".getLocalId()";
+        }
+        _xifexpression_2 = _xifexpression_3;
+      } else {
+        _xifexpression_2 = "->localId";
+      }
+      final String getLocalId = _xifexpression_2;
+      String _xifexpression_4 = null;
+      boolean _usesPointers_1 = this.langExt.usesPointers();
+      if (_usesPointers_1) {
+        _xifexpression_4 = ("const " + ifItemPtr);
+      } else {
+        _xifexpression_4 = ifItemPtr;
+      }
+      final String constIfItemPtr = _xifexpression_4;
+      final boolean usesHdlr = this.usesHandlerTrPoints(xpmc);
+      StringConcatenation _builder = new StringConcatenation();
+      _builder.append("/**");
+      _builder.newLine();
+      _builder.append(" ");
+      _builder.append("* calls exit codes while exiting from the current state to one of its");
+      _builder.newLine();
+      _builder.append(" ");
+      _builder.append("* parent states while remembering the history");
+      _builder.newLine();
+      _builder.append(" ");
+      _builder.append("* @param current__et - the current state");
+      _builder.newLine();
+      _builder.append(" ");
+      _builder.append("* @param to - the final parent state");
+      _builder.newLine();
+      {
+        if (usesHdlr) {
+          _builder.append("* @param handler__et - entry and exit codes are called only if not handler (for handler TransitionPoints)");
+          _builder.newLine();
+        }
+      }
+      _builder.append(" ");
+      _builder.append("*/");
+      _builder.newLine();
+      {
+        if (generateImplementation) {
+          _builder.append(privAccess, "");
+          _builder.append("void ");
+          _builder.append(opScopePriv, "");
+          _builder.append("exitTo(");
+          _builder.append(selfPtr, "");
+          String _stateType = this.stateType();
+          _builder.append(_stateType, "");
+          _builder.append(" current__et, ");
+          String _stateType_1 = this.stateType();
+          _builder.append(_stateType_1, "");
+          _builder.append(" to");
+          {
+            if (usesHdlr) {
+              _builder.append(", ");
+              String _boolType = this.boolType();
+              _builder.append(_boolType, "");
+              _builder.append(" handler__et");
+            }
+          }
+          _builder.append(") {");
+          _builder.newLineIfNotEmpty();
+          _builder.append("\t");
+          _builder.append("while (current__et!=to) {");
+          _builder.newLine();
+          _builder.append("\t\t");
+          _builder.append("switch (current__et) {");
+          _builder.newLine();
+          {
+            StateGraph _stateMachine = xpmc.getStateMachine();
+            List<State> _baseStateList = this._fSMHelpers.getBaseStateList(_stateMachine);
+            for(final State state : _baseStateList) {
+              _builder.append("\t\t\t");
+              _builder.append("case ");
+              String _genStateId = this._codegenHelpers.getGenStateId(state);
+              _builder.append(_genStateId, "\t\t\t");
+              _builder.append(":");
+              _builder.newLineIfNotEmpty();
+              _builder.append("\t\t\t");
+              _builder.append("\t");
+              {
+                boolean _hasExitCode = this._fSMHelpers.hasExitCode(state, true);
+                if (_hasExitCode) {
+                  {
+                    if (usesHdlr) {
+                      _builder.append("if (!handler__et) ");
+                    }
+                  }
+                  String _exitCodeOperationName = this._codegenHelpers.getExitCodeOperationName(state);
+                  _builder.append(_exitCodeOperationName, "\t\t\t\t");
+                  _builder.append("(");
+                  String _selfPointer = this.langExt.selfPointer(false);
+                  _builder.append(_selfPointer, "\t\t\t\t");
+                  _builder.append(");");
+                }
+              }
+              _builder.newLineIfNotEmpty();
+              _builder.append("\t\t\t");
+              _builder.append("\t");
+              String _parentStateId = this._codegenHelpers.getParentStateId(state);
+              String _genStateId_1 = this._codegenHelpers.getGenStateId(state);
+              String _setHistory = this.setHistory(_parentStateId, _genStateId_1);
+              _builder.append(_setHistory, "\t\t\t\t");
+              _builder.append(";");
+              _builder.newLineIfNotEmpty();
+              _builder.append("\t\t\t");
+              _builder.append("\t");
+              _builder.append("current__et = ");
+              String _parentStateId_1 = this._codegenHelpers.getParentStateId(state);
+              _builder.append(_parentStateId_1, "\t\t\t\t");
+              _builder.append(";");
+              _builder.newLineIfNotEmpty();
+              _builder.append("\t\t\t");
+              _builder.append("\t");
+              _builder.append("break;");
+              _builder.newLine();
+            }
+          }
+          _builder.append("\t\t\t");
+          _builder.append("default:");
+          _builder.newLine();
+          _builder.append("\t\t\t\t");
+          _builder.append("/* should not occur */");
+          _builder.newLine();
+          _builder.append("\t\t\t\t");
+          _builder.append("break;");
+          _builder.newLine();
+          _builder.append("\t\t");
+          _builder.append("}");
+          _builder.newLine();
+          _builder.append("\t");
+          _builder.append("}");
+          _builder.newLine();
+          _builder.append("}");
+          _builder.newLine();
+        } else {
+          _builder.append("void exitTo(");
+          _builder.append(selfPtr, "");
+          String _stateType_2 = this.stateType();
+          _builder.append(_stateType_2, "");
+          _builder.append(" current__et, ");
+          String _stateType_3 = this.stateType();
+          _builder.append(_stateType_3, "");
+          _builder.append(" to");
+          {
+            if (usesHdlr) {
+              _builder.append(", ");
+              String _boolType_1 = this.boolType();
+              _builder.append(_boolType_1, "");
+              _builder.append(" handler__et");
+            }
+          }
+          _builder.append(");");
+          _builder.newLineIfNotEmpty();
+        }
+      }
+      _builder.newLine();
+      _builder.append("/**");
+      _builder.newLine();
+      _builder.append(" ");
+      _builder.append("* calls action, entry and exit codes along a transition chain. The generic data are cast to typed data");
+      _builder.newLine();
+      _builder.append(" ");
+      _builder.append("* matching the trigger of this chain. The ID of the final state is returned");
+      _builder.newLine();
+      _builder.append(" ");
+      _builder.append("* @param chain__et - the chain ID");
+      _builder.newLine();
+      _builder.append(" ");
+      _builder.append("* @param generic_data__et - the generic data pointer");
+      _builder.newLine();
+      _builder.append(" ");
+      _builder.append("* @return the +/- ID of the final state either with a positive sign, that indicates to execute the state\'s entry code, or a negative sign vice versa");
+      _builder.newLine();
+      _builder.append(" ");
+      _builder.append("*/");
+      _builder.newLine();
+      {
+        if (generateImplementation) {
+          _builder.append(privAccess, "");
+          String _stateType_4 = this.stateType();
+          _builder.append(_stateType_4, "");
+          _builder.append(" ");
+          _builder.append(opScopePriv, "");
+          _builder.append("executeTransitionChain(");
+          _builder.append(selfPtr, "");
+          _builder.append("int chain__et");
+          {
+            if (handleEvents) {
+              _builder.append(", ");
+              _builder.append(constIfItemPtr, "");
+              _builder.append(" ifitem, ");
+              String _voidPointer = this.langExt.voidPointer();
+              _builder.append(_voidPointer, "");
+              _builder.append(" generic_data__et");
+            }
+          }
+          _builder.append(") {");
+          _builder.newLineIfNotEmpty();
+          _builder.append("\t");
+          _builder.append("switch (chain__et) {");
+          _builder.newLine();
+          _builder.append("\t\t");
+          EList<TransitionChain> allchains = xpmc.getTransitionChains();
+          _builder.newLineIfNotEmpty();
+          {
+            for(final TransitionChain tc : allchains) {
+              _builder.append("\t\t");
+              _builder.append("case ");
+              String _genChainId = this._codegenHelpers.getGenChainId(tc);
+              _builder.append(_genChainId, "\t\t");
+              _builder.append(":");
+              _builder.newLineIfNotEmpty();
+              _builder.append("\t\t");
+              _builder.append("{");
+              _builder.newLine();
+              _builder.append("\t\t");
+              _builder.append("\t");
+              String _generateExecuteChain = this.transitionChainGenerator.generateExecuteChain(xpmc, tc);
+              _builder.append(_generateExecuteChain, "\t\t\t");
+              _builder.newLineIfNotEmpty();
+              _builder.append("\t\t");
+              _builder.append("}");
+              _builder.newLine();
+            }
+          }
+          _builder.append("\t\t\t");
+          _builder.append("default:");
+          _builder.newLine();
+          _builder.append("\t\t\t\t");
+          _builder.append("/* should not occur */");
+          _builder.newLine();
+          _builder.append("\t\t\t\t");
+          _builder.append("break;");
+          _builder.newLine();
+          _builder.append("\t");
+          _builder.append("}");
+          _builder.newLine();
+          _builder.append("\t");
+          _builder.append("return NO_STATE;");
+          _builder.newLine();
+          _builder.append("}");
+          _builder.newLine();
+        } else {
+          String _stateType_5 = this.stateType();
+          _builder.append(_stateType_5, "");
+          _builder.append(" executeTransitionChain(");
+          _builder.append(selfPtr, "");
+          _builder.append("int chain__et");
+          {
+            if (handleEvents) {
+              _builder.append(", ");
+              _builder.append(constIfItemPtr, "");
+              _builder.append(" ifitem, ");
+              String _voidPointer_1 = this.langExt.voidPointer();
+              _builder.append(_voidPointer_1, "");
+              _builder.append(" generic_data__et");
+            }
+          }
+          _builder.append(");");
+          _builder.newLineIfNotEmpty();
+        }
+      }
+      _builder.newLine();
+      _builder.append("/**");
+      _builder.newLine();
+      _builder.append(" ");
+      _builder.append("* calls entry codes while entering a state\'s history. The ID of the final leaf state is returned");
+      _builder.newLine();
+      _builder.append(" ");
+      _builder.append("* @param state__et - the state which is entered");
+      _builder.newLine();
+      {
+        if (usesHdlr) {
+          _builder.append("* @param handler__et - entry code is executed if not handler");
+          _builder.newLine();
+        }
+      }
+      _builder.append(" ");
+      _builder.append("* @return - the ID of the final leaf state");
+      _builder.newLine();
+      _builder.append(" ");
+      _builder.append("*/");
+      _builder.newLine();
+      {
+        if (generateImplementation) {
+          _builder.append(privAccess, "");
+          String _stateType_6 = this.stateType();
+          _builder.append(_stateType_6, "");
+          _builder.append(" ");
+          _builder.append(opScopePriv, "");
+          _builder.append("enterHistory(");
+          _builder.append(selfPtr, "");
+          String _stateType_7 = this.stateType();
+          _builder.append(_stateType_7, "");
+          _builder.append(" state__et");
+          {
+            if (usesHdlr) {
+              _builder.append(", ");
+              String _boolType_2 = this.boolType();
+              _builder.append(_boolType_2, "");
+              _builder.append(" handler__et");
+            }
+          }
+          _builder.append(") {");
+          _builder.newLineIfNotEmpty();
+          _builder.append("\t");
+          String _boolType_3 = this.boolType();
+          _builder.append(_boolType_3, "\t");
+          _builder.append(" skip_entry__et = ");
+          String _booleanConstant = this.langExt.booleanConstant(false);
+          _builder.append(_booleanConstant, "\t");
+          _builder.append(";");
+          _builder.newLineIfNotEmpty();
+          _builder.append("\t");
+          _builder.append("if (state__et >= STATE_MAX) {");
+          _builder.newLine();
+          _builder.append("\t\t");
+          _builder.append("state__et = ");
+          {
+            boolean _usesInheritance_3 = this.langExt.usesInheritance();
+            boolean _not = (!_usesInheritance_3);
+            if (_not) {
+              _builder.append("(");
+              String _stateType_8 = this.stateType();
+              _builder.append(_stateType_8, "\t\t");
+              _builder.append(")");
+            }
+          }
+          _builder.append(" (state__et - STATE_MAX);");
+          _builder.newLineIfNotEmpty();
+          _builder.append("\t\t");
+          _builder.append("skip_entry__et = ");
+          String _booleanConstant_1 = this.langExt.booleanConstant(true);
+          _builder.append(_booleanConstant_1, "\t\t");
+          _builder.append(";");
+          _builder.newLineIfNotEmpty();
+          _builder.append("\t");
+          _builder.append("}");
+          _builder.newLine();
+          _builder.append("\t");
+          _builder.append("while (");
+          String _booleanConstant_2 = this.langExt.booleanConstant(true);
+          _builder.append(_booleanConstant_2, "\t");
+          _builder.append(") {");
+          _builder.newLineIfNotEmpty();
+          _builder.append("\t\t");
+          _builder.append("switch (state__et) {");
+          _builder.newLine();
+          {
+            StateGraph _stateMachine_1 = xpmc.getStateMachine();
+            List<State> _baseStateList_1 = this._fSMHelpers.getBaseStateList(_stateMachine_1);
+            for(final State state_1 : _baseStateList_1) {
+              _builder.append("\t\t\t");
+              _builder.append("case ");
+              String _genStateId_2 = this._codegenHelpers.getGenStateId(state_1);
+              _builder.append(_genStateId_2, "\t\t\t");
+              _builder.append(":");
+              _builder.newLineIfNotEmpty();
+              _builder.append("\t\t\t");
+              _builder.append("\t");
+              {
+                boolean _hasEntryCode = this._fSMHelpers.hasEntryCode(state_1, true);
+                if (_hasEntryCode) {
+                  _builder.append("if (!(skip_entry__et");
+                  {
+                    if (usesHdlr) {
+                      _builder.append(" || handler__et");
+                    }
+                  }
+                  _builder.append(")) ");
+                  String _entryCodeOperationName = this._codegenHelpers.getEntryCodeOperationName(state_1);
+                  _builder.append(_entryCodeOperationName, "\t\t\t\t");
+                  _builder.append("(");
+                  String _selfPointer_1 = this.langExt.selfPointer(false);
+                  _builder.append(_selfPointer_1, "\t\t\t\t");
+                  _builder.append(");");
+                }
+              }
+              _builder.newLineIfNotEmpty();
+              {
+                boolean _isLeaf = this._fSMHelpers.isLeaf(state_1);
+                if (_isLeaf) {
+                  _builder.append("\t\t\t");
+                  _builder.append("\t");
+                  _builder.append("/* in leaf state: return state id */");
+                  _builder.newLine();
+                  _builder.append("\t\t\t");
+                  _builder.append("\t");
+                  _builder.append("return ");
+                  String _genStateId_3 = this._codegenHelpers.getGenStateId(state_1);
+                  _builder.append(_genStateId_3, "\t\t\t\t");
+                  _builder.append(";");
+                  _builder.newLineIfNotEmpty();
+                } else {
+                  _builder.append("\t\t\t");
+                  _builder.append("\t");
+                  _builder.append("/* state has a sub graph */");
+                  _builder.newLine();
+                  {
+                    StateGraph _subgraph = state_1.getSubgraph();
+                    boolean _hasInitTransition = this._fSMHelpers.hasInitTransition(_subgraph);
+                    if (_hasInitTransition) {
+                      _builder.append("\t\t\t");
+                      _builder.append("\t");
+                      _builder.append("/* with init transition */");
+                      _builder.newLine();
+                      _builder.append("\t\t\t");
+                      _builder.append("\t");
+                      _builder.append("if (");
+                      String _genStateId_4 = this._codegenHelpers.getGenStateId(state_1);
+                      String _history = this.getHistory(_genStateId_4);
+                      _builder.append(_history, "\t\t\t\t");
+                      _builder.append("==NO_STATE) {");
+                      _builder.newLineIfNotEmpty();
+                      _builder.append("\t\t\t");
+                      _builder.append("\t");
+                      _builder.append("\t");
+                      StateGraph _subgraph_1 = state_1.getSubgraph();
+                      Transition sub_initt = this._fSMHelpers.getInitTransition(_subgraph_1);
+                      _builder.newLineIfNotEmpty();
+                      _builder.append("\t\t\t");
+                      _builder.append("\t");
+                      _builder.append("\t");
+                      _builder.append("state__et = executeTransitionChain(");
+                      String _selfPointer_2 = this.langExt.selfPointer(true);
+                      _builder.append(_selfPointer_2, "\t\t\t\t\t");
+                      TransitionChain _chain = xpmc.getChain(sub_initt);
+                      String _genChainId_1 = this._codegenHelpers.getGenChainId(_chain);
+                      _builder.append(_genChainId_1, "\t\t\t\t\t");
+                      {
+                        if (handleEvents) {
+                          _builder.append(", ");
+                          String _nullPointer = this.langExt.nullPointer();
+                          _builder.append(_nullPointer, "\t\t\t\t\t");
+                          _builder.append(", ");
+                          String _nullPointer_1 = this.langExt.nullPointer();
+                          _builder.append(_nullPointer_1, "\t\t\t\t\t");
+                        }
+                      }
+                      _builder.append(");");
+                      _builder.newLineIfNotEmpty();
+                      _builder.append("\t\t\t");
+                      _builder.append("\t");
+                      _builder.append("}");
+                      _builder.newLine();
+                      _builder.append("\t\t\t");
+                      _builder.append("\t");
+                      _builder.append("else {");
+                      _builder.newLine();
+                      _builder.append("\t\t\t");
+                      _builder.append("\t");
+                      _builder.append("\t");
+                      _builder.append("state__et = ");
+                      String _genStateId_5 = this._codegenHelpers.getGenStateId(state_1);
+                      String _history_1 = this.getHistory(_genStateId_5);
+                      _builder.append(_history_1, "\t\t\t\t\t");
+                      _builder.append(";");
+                      _builder.newLineIfNotEmpty();
+                      _builder.append("\t\t\t");
+                      _builder.append("\t");
+                      _builder.append("}");
+                      _builder.newLine();
+                    } else {
+                      _builder.append("\t\t\t");
+                      _builder.append("\t");
+                      _builder.append("/* without init transition */");
+                      _builder.newLine();
+                      _builder.append("\t\t\t");
+                      _builder.append("\t");
+                      _builder.append("state__et = ");
+                      String _genStateId_6 = this._codegenHelpers.getGenStateId(state_1);
+                      String _history_2 = this.getHistory(_genStateId_6);
+                      _builder.append(_history_2, "\t\t\t\t");
+                      _builder.append(";");
+                      _builder.newLineIfNotEmpty();
+                    }
+                  }
+                  _builder.append("\t\t\t");
+                  _builder.append("\t");
+                  _builder.append("break;");
+                  _builder.newLine();
+                }
+              }
+            }
+          }
+          _builder.append("\t\t\t");
+          _builder.append("case STATE_TOP:");
+          _builder.newLine();
+          _builder.append("\t\t\t\t");
+          _builder.append("state__et = ");
+          String _history_3 = this.getHistory("STATE_TOP");
+          _builder.append(_history_3, "\t\t\t\t");
+          _builder.append(";");
+          _builder.newLineIfNotEmpty();
+          _builder.append("\t\t\t\t");
+          _builder.append("break;");
+          _builder.newLine();
+          _builder.append("\t\t\t");
+          _builder.append("default:");
+          _builder.newLine();
+          _builder.append("\t\t\t\t");
+          _builder.append("/* should not occur */");
+          _builder.newLine();
+          _builder.append("\t\t\t\t");
+          _builder.append("break;");
+          _builder.newLine();
+          _builder.append("\t\t");
+          _builder.append("}");
+          _builder.newLine();
+          _builder.append("\t\t");
+          _builder.append("skip_entry__et = ");
+          String _booleanConstant_3 = this.langExt.booleanConstant(false);
+          _builder.append(_booleanConstant_3, "\t\t");
+          _builder.append(";");
+          _builder.newLineIfNotEmpty();
+          _builder.append("\t");
+          _builder.append("}");
+          _builder.newLine();
+          _builder.append("\t");
+          String _unreachableReturn = this.unreachableReturn();
+          _builder.append(_unreachableReturn, "\t");
+          _builder.newLineIfNotEmpty();
+          _builder.append("}");
+          _builder.newLine();
+        } else {
+          String _stateType_9 = this.stateType();
+          _builder.append(_stateType_9, "");
+          _builder.append(" enterHistory(");
+          _builder.append(selfPtr, "");
+          String _stateType_10 = this.stateType();
+          _builder.append(_stateType_10, "");
+          _builder.append(" state__et");
+          {
+            if (usesHdlr) {
+              _builder.append(", ");
+              String _boolType_4 = this.boolType();
+              _builder.append(_boolType_4, "");
+              _builder.append(" handler__et");
+            }
+          }
+          _builder.append(");");
+          _builder.newLineIfNotEmpty();
+        }
+      }
+      _builder.newLine();
+      {
+        if (generateImplementation) {
+          _builder.append(publicIf, "");
+          _builder.append("void ");
+          _builder.append(opScope, "");
+          _builder.append("executeInitTransition(");
+          _builder.append(selfOnly, "");
+          _builder.append(") {");
+          _builder.newLineIfNotEmpty();
+          _builder.append("\t");
+          StateGraph _stateMachine_2 = xpmc.getStateMachine();
+          Transition initt = this._fSMHelpers.getInitTransition(_stateMachine_2);
+          _builder.newLineIfNotEmpty();
+          _builder.append("\t");
+          _builder.append("int chain__et = ");
+          TransitionChain _chain_1 = xpmc.getChain(initt);
+          String _genChainId_2 = this._codegenHelpers.getGenChainId(_chain_1);
+          _builder.append(_genChainId_2, "\t");
+          _builder.append(";");
+          _builder.newLineIfNotEmpty();
+          _builder.append("\t");
+          String _stateType_11 = this.stateType();
+          _builder.append(_stateType_11, "\t");
+          _builder.append(" next__et = ");
+          _builder.append(opScopePriv, "\t");
+          _builder.append("executeTransitionChain(");
+          String _selfPointer_3 = this.langExt.selfPointer(true);
+          _builder.append(_selfPointer_3, "\t");
+          _builder.append("chain__et");
+          {
+            if (handleEvents) {
+              _builder.append(", ");
+              String _nullPointer_2 = this.langExt.nullPointer();
+              _builder.append(_nullPointer_2, "\t");
+              _builder.append(", ");
+              String _nullPointer_3 = this.langExt.nullPointer();
+              _builder.append(_nullPointer_3, "\t");
+            }
+          }
+          _builder.append(");");
+          _builder.newLineIfNotEmpty();
+          _builder.append("\t");
+          _builder.append("next__et = ");
+          _builder.append(opScopePriv, "\t");
+          _builder.append("enterHistory(");
+          String _selfPointer_4 = this.langExt.selfPointer(true);
+          _builder.append(_selfPointer_4, "\t");
+          _builder.append("next__et");
+          {
+            if (usesHdlr) {
+              _builder.append(", ");
+              String _booleanConstant_4 = this.langExt.booleanConstant(false);
+              _builder.append(_booleanConstant_4, "\t");
+            }
+          }
+          _builder.append(");");
+          _builder.newLineIfNotEmpty();
+          _builder.append("\t");
+          _builder.append("setState(");
+          String _selfPointer_5 = this.langExt.selfPointer(true);
+          _builder.append(_selfPointer_5, "\t");
+          _builder.append("next__et);");
+          _builder.newLineIfNotEmpty();
+          _builder.append("}");
+          _builder.newLine();
+        } else {
+          _builder.append("void executeInitTransition(");
+          _builder.append(selfOnly, "");
+          _builder.append(");");
+          _builder.newLineIfNotEmpty();
+        }
+      }
+      _builder.newLine();
+      _builder.append("/* receiveEvent contains the main implementation of the FSM */");
+      _builder.newLine();
+      {
+        if (generateImplementation) {
+          _builder.append(publicIf, "");
+          _builder.append("void ");
+          _builder.append(opScope, "");
+          _builder.append("receiveEventInternal(");
+          String _className_3 = this.getClassName(mc);
+          String _selfPointer_6 = this.langExt.selfPointer(_className_3, handleEvents);
+          _builder.append(_selfPointer_6, "");
+          {
+            if (handleEvents) {
+              _builder.append(ifItemPtr, "");
+              _builder.append(" ifitem, int localId, int evt, ");
+              String _voidPointer_2 = this.langExt.voidPointer();
+              _builder.append(_voidPointer_2, "");
+              _builder.append(" generic_data__et");
+            }
+          }
+          _builder.append(") {");
+          _builder.newLineIfNotEmpty();
+          {
+            if (async) {
+              _builder.append("\t");
+              _builder.append("int trigger__et = (ifitem==");
+              String _nullPointer_4 = this.langExt.nullPointer();
+              _builder.append(_nullPointer_4, "\t");
+              _builder.append(")? POLLING : localId + EVT_SHIFT*evt;");
+              _builder.newLineIfNotEmpty();
+            } else {
+              if (eventDriven) {
+                _builder.append("\t");
+                _builder.append("int trigger__et = localId + EVT_SHIFT*evt;");
+                _builder.newLine();
+              }
+            }
+          }
+          _builder.append("\t");
+          _builder.append("int chain__et = NOT_CAUGHT;");
+          _builder.newLine();
+          _builder.append("\t");
+          String _stateType_12 = this.stateType();
+          _builder.append(_stateType_12, "\t");
+          _builder.append(" catching_state__et = NO_STATE;");
+          _builder.newLineIfNotEmpty();
+          {
+            if (usesHdlr) {
+              _builder.append("\t");
+              String _boolType_5 = this.boolType();
+              _builder.append(_boolType_5, "\t");
+              _builder.append(" is_handler__et = ");
+              String _booleanConstant_5 = this.langExt.booleanConstant(false);
+              _builder.append(_booleanConstant_5, "\t");
+              _builder.append(";");
+              _builder.newLineIfNotEmpty();
+            }
+          }
+          {
+            boolean _or_1 = false;
+            if (async) {
+              _or_1 = true;
+            } else {
+              _or_1 = eventDriven;
+            }
+            if (_or_1) {
+              _builder.append("\t");
+              CharSequence _markVariableUsed = this.markVariableUsed("trigger__et");
+              _builder.append(_markVariableUsed, "\t");
+              _builder.newLineIfNotEmpty();
+            }
+          }
+          _builder.append("\t");
+          _builder.newLine();
+          {
+            if (handleEvents) {
+              _builder.append("\t");
+              _builder.append("if (!handleSystemEvent(ifitem, evt, generic_data__et)) {");
+              _builder.newLine();
+              _builder.append("\t");
+              _builder.append("\t");
+              CharSequence _genStateSwitch = this.genStateSwitch(xpmc, usesHdlr);
+              _builder.append(_genStateSwitch, "\t\t");
+              _builder.newLineIfNotEmpty();
+              _builder.append("\t");
+              _builder.append("}");
+              _builder.newLine();
+            } else {
+              _builder.append("\t");
+              CharSequence _genStateSwitch_1 = this.genStateSwitch(xpmc, usesHdlr);
+              _builder.append(_genStateSwitch_1, "\t");
+              _builder.newLineIfNotEmpty();
+            }
+          }
+          _builder.append("\t");
+          _builder.append("if (chain__et != NOT_CAUGHT) {");
+          _builder.newLine();
+          _builder.append("\t\t");
+          _builder.append(opScopePriv, "\t\t");
+          _builder.append("exitTo(");
+          String _selfPointer_7 = this.langExt.selfPointer(true);
+          _builder.append(_selfPointer_7, "\t\t");
+          _builder.append("getState(");
+          String _selfPointer_8 = this.langExt.selfPointer(false);
+          _builder.append(_selfPointer_8, "\t\t");
+          _builder.append("), catching_state__et");
+          {
+            if (usesHdlr) {
+              _builder.append(", is_handler__et");
+            }
+          }
+          _builder.append(");");
+          _builder.newLineIfNotEmpty();
+          _builder.append("\t\t");
+          _builder.append("{");
+          _builder.newLine();
+          _builder.append("\t\t\t");
+          String _stateType_13 = this.stateType();
+          _builder.append(_stateType_13, "\t\t\t");
+          _builder.append(" next__et = ");
+          _builder.append(opScopePriv, "\t\t\t");
+          _builder.append("executeTransitionChain(");
+          String _selfPointer_9 = this.langExt.selfPointer(true);
+          _builder.append(_selfPointer_9, "\t\t\t");
+          _builder.append("chain__et");
+          {
+            if (handleEvents) {
+              _builder.append(", ifitem, generic_data__et");
+            }
+          }
+          _builder.append(");");
+          _builder.newLineIfNotEmpty();
+          _builder.append("\t\t\t");
+          _builder.append("next__et = ");
+          _builder.append(opScopePriv, "\t\t\t");
+          _builder.append("enterHistory(");
+          String _selfPointer_10 = this.langExt.selfPointer(true);
+          _builder.append(_selfPointer_10, "\t\t\t");
+          _builder.append("next__et");
+          {
+            if (usesHdlr) {
+              _builder.append(", is_handler__et");
+            }
+          }
+          _builder.append(");");
+          _builder.newLineIfNotEmpty();
+          _builder.append("\t\t\t");
+          _builder.append("setState(");
+          String _selfPointer_11 = this.langExt.selfPointer(true);
+          _builder.append(_selfPointer_11, "\t\t\t");
+          _builder.append("next__et);");
+          _builder.newLineIfNotEmpty();
+          _builder.append("\t\t\t");
+          CharSequence _finalAction = this.finalAction();
+          _builder.append(_finalAction, "\t\t\t");
+          _builder.newLineIfNotEmpty();
+          _builder.append("\t\t");
+          _builder.append("}");
+          _builder.newLine();
+          _builder.append("\t");
+          _builder.append("}");
+          _builder.newLine();
+          _builder.append("}");
+          _builder.newLine();
+        } else {
+          _builder.append("void receiveEventInternal(");
+          String _className_4 = this.getClassName(mc);
+          String _selfPointer_12 = this.langExt.selfPointer(_className_4, handleEvents);
+          _builder.append(_selfPointer_12, "");
+          {
+            if (handleEvents) {
+              _builder.append(ifItemPtr, "");
+              _builder.append(" ifitem, int localId, int evt, ");
+              String _voidPointer_3 = this.langExt.voidPointer();
+              _builder.append(_voidPointer_3, "");
+              _builder.append(" generic_data__et");
+            }
+          }
+          _builder.append(");");
+          _builder.newLineIfNotEmpty();
+        }
+      }
+      {
+        if (handleEvents) {
+          {
+            if (generateImplementation) {
+              _builder.append(publicIf, "");
+              _builder.append("void ");
+              _builder.append(opScope, "");
+              _builder.append("receiveEvent(");
+              String _className_5 = this.getClassName(mc);
+              String _selfPointer_13 = this.langExt.selfPointer(_className_5, true);
+              _builder.append(_selfPointer_13, "");
+              _builder.append(ifItemPtr, "");
+              _builder.append(" ifitem, int evt, ");
+              String _voidPointer_4 = this.langExt.voidPointer();
+              _builder.append(_voidPointer_4, "");
+              _builder.append(" generic_data__et) {");
+              _builder.newLineIfNotEmpty();
+              _builder.append("\t");
+              _builder.append("int localId = (ifitem==");
+              String _nullPointer_5 = this.langExt.nullPointer();
+              _builder.append(_nullPointer_5, "\t");
+              _builder.append(")? 0 : ifitem");
+              _builder.append(getLocalId, "\t");
+              _builder.append(";");
+              _builder.newLineIfNotEmpty();
+              _builder.append("\t");
+              _builder.append(opScope, "\t");
+              _builder.append("receiveEventInternal(");
+              String _selfPointer_14 = this.langExt.selfPointer(true);
+              _builder.append(_selfPointer_14, "\t");
+              _builder.append("ifitem, localId, evt, generic_data__et);");
+              _builder.newLineIfNotEmpty();
+              _builder.append("}");
+              _builder.newLine();
+            } else {
+              _builder.append("void ");
+              _builder.append(opScope, "");
+              _builder.append("receiveEvent(");
+              String _selfPointer_15 = this.langExt.selfPointer(true);
+              _builder.append(_selfPointer_15, "");
+              _builder.append(ifItemPtr, "");
+              _builder.append(" ifitem, int evt, ");
+              String _voidPointer_5 = this.langExt.voidPointer();
+              _builder.append(_voidPointer_5, "");
+              _builder.append(" generic_data__et);");
+              _builder.newLineIfNotEmpty();
+            }
+          }
+        }
+      }
+      _xblockexpression = _builder.toString();
+    }
+    return _xblockexpression;
+  }
+  
+  /**
+   * generate the do code calls for a given state
+   * 
+   * @param state the {@link State}
+   * @return the generated code
+   */
+  public String genDoCodes(final State state) {
+    StringConcatenation _builder = new StringConcatenation();
+    {
+      boolean _hasDoCode = this._fSMHelpers.hasDoCode(state, true);
+      if (_hasDoCode) {
+        String _doCodeOperationName = this._codegenHelpers.getDoCodeOperationName(state);
+        _builder.append(_doCodeOperationName, "");
+        _builder.append("(");
+        String _selfPointer = this.langExt.selfPointer(false);
+        _builder.append(_selfPointer, "");
+        _builder.append(");");
+        _builder.newLineIfNotEmpty();
+      }
+    }
+    {
+      EObject _eContainer = state.eContainer();
+      EObject _eContainer_1 = _eContainer.eContainer();
+      if ((_eContainer_1 instanceof State)) {
+        EObject _eContainer_2 = state.eContainer();
+        EObject _eContainer_3 = _eContainer_2.eContainer();
+        String _genDoCodes = this.genDoCodes(((State) _eContainer_3));
+        _builder.append(_genDoCodes, "");
+        _builder.newLineIfNotEmpty();
+      }
+    }
+    return _builder.toString();
+  }
+  
+  /**
+   * helper method which generates the state switch.
+   * Asynchronous, data driven and event driven state machines are distinguished
+   * 
+   * @param xpmc the {@link ExpandedModelComponent}
+   * @param usesHdlr if the state machine uses no handler {@link TransitionPoint}s
+   *      at all then unused variables can be avoided by passing <code>true</code>
+   * @return the generated code
+   */
+  public CharSequence genStateSwitch(final ExpandedModelComponent xpmc, final boolean usesHdlr) {
+    CharSequence _xblockexpression = null;
+    {
+      ModelComponent _modelComponent = xpmc.getModelComponent();
+      ComponentCommunicationType _commType = _modelComponent.getCommType();
+      boolean async = Objects.equal(_commType, ComponentCommunicationType.ASYNCHRONOUS);
+      ModelComponent _modelComponent_1 = xpmc.getModelComponent();
+      ComponentCommunicationType _commType_1 = _modelComponent_1.getCommType();
+      boolean eventDriven = Objects.equal(_commType_1, ComponentCommunicationType.EVENT_DRIVEN);
+      ModelComponent _modelComponent_2 = xpmc.getModelComponent();
+      ComponentCommunicationType _commType_2 = _modelComponent_2.getCommType();
+      boolean dataDriven = Objects.equal(_commType_2, ComponentCommunicationType.DATA_DRIVEN);
+      StringConcatenation _builder = new StringConcatenation();
+      _builder.append("switch (getState(");
+      String _selfPointer = this.langExt.selfPointer(false);
+      _builder.append(_selfPointer, "");
+      _builder.append(")) {");
+      _builder.newLineIfNotEmpty();
+      {
+        StateGraph _stateMachine = xpmc.getStateMachine();
+        List<State> _leafStateList = this._fSMHelpers.getLeafStateList(_stateMachine);
+        for(final State state : _leafStateList) {
+          _builder.append("    ");
+          _builder.append("case ");
+          String _genStateId = this._codegenHelpers.getGenStateId(state);
+          _builder.append(_genStateId, "    ");
+          _builder.append(":");
+          _builder.newLineIfNotEmpty();
+          {
+            if (async) {
+              _builder.append("    ");
+              _builder.append("    ");
+              EList<ActiveTrigger> atlist = xpmc.getActiveTriggers(state);
+              _builder.newLineIfNotEmpty();
+              {
+                boolean _isEmpty = atlist.isEmpty();
+                boolean _not = (!_isEmpty);
+                if (_not) {
+                  _builder.append("    ");
+                  _builder.append("    ");
+                  _builder.append("switch(trigger__et) {");
+                  _builder.newLine();
+                  _builder.append("    ");
+                  _builder.append("    ");
+                  _builder.append("    ");
+                  _builder.append("case POLLING:");
+                  _builder.newLine();
+                  _builder.append("    ");
+                  _builder.append("    ");
+                  _builder.append("        ");
+                  CharSequence _genDataDrivenTriggers = this.genDataDrivenTriggers(xpmc, state, usesHdlr);
+                  _builder.append(_genDataDrivenTriggers, "                ");
+                  _builder.newLineIfNotEmpty();
+                  _builder.append("    ");
+                  _builder.append("    ");
+                  _builder.append("        ");
+                  _builder.append("break;");
+                  _builder.newLine();
+                  _builder.append("    ");
+                  _builder.append("    ");
+                  _builder.append("    ");
+                  CharSequence _genEventDrivenTriggers = this.genEventDrivenTriggers(xpmc, state, atlist, usesHdlr);
+                  _builder.append(_genEventDrivenTriggers, "            ");
+                  _builder.newLineIfNotEmpty();
+                  _builder.append("    ");
+                  _builder.append("    ");
+                  _builder.append("}");
+                  _builder.newLine();
+                } else {
+                  _builder.append("    ");
+                  _builder.append("    ");
+                  CharSequence _genDataDrivenTriggers_1 = this.genDataDrivenTriggers(xpmc, state, usesHdlr);
+                  _builder.append(_genDataDrivenTriggers_1, "        ");
+                  _builder.newLineIfNotEmpty();
+                }
+              }
+            } else {
+              if (dataDriven) {
+                _builder.append("    ");
+                _builder.append("    ");
+                CharSequence _genDataDrivenTriggers_2 = this.genDataDrivenTriggers(xpmc, state, usesHdlr);
+                _builder.append(_genDataDrivenTriggers_2, "        ");
+                _builder.newLineIfNotEmpty();
+              } else {
+                if (eventDriven) {
+                  _builder.append("    ");
+                  _builder.append("    ");
+                  EList<ActiveTrigger> atlist_1 = xpmc.getActiveTriggers(state);
+                  _builder.newLineIfNotEmpty();
+                  {
+                    boolean _isEmpty_1 = atlist_1.isEmpty();
+                    boolean _not_1 = (!_isEmpty_1);
+                    if (_not_1) {
+                      _builder.append("    ");
+                      _builder.append("    ");
+                      _builder.append("switch(trigger__et) {");
+                      _builder.newLine();
+                      _builder.append("    ");
+                      _builder.append("    ");
+                      _builder.append("        ");
+                      CharSequence _genEventDrivenTriggers_1 = this.genEventDrivenTriggers(xpmc, state, atlist_1, usesHdlr);
+                      _builder.append(_genEventDrivenTriggers_1, "                ");
+                      _builder.newLineIfNotEmpty();
+                      _builder.append("    ");
+                      _builder.append("    ");
+                      _builder.append("}");
+                      _builder.newLine();
+                    }
+                  }
+                }
+              }
+            }
+          }
+          _builder.append("    ");
+          _builder.append("    ");
+          _builder.append("break;");
+          _builder.newLine();
+        }
+      }
+      _builder.append("    ");
+      _builder.append("default:");
+      _builder.newLine();
+      _builder.append("        ");
+      _builder.append("/* should not occur */");
+      _builder.newLine();
+      _builder.append("        ");
+      _builder.append("break;");
+      _builder.newLine();
+      _builder.append("}");
+      _builder.newLine();
+      _xblockexpression = _builder;
+    }
+    return _xblockexpression;
+  }
+  
+  /**
+   * helper method which generates the data driven triggers
+   * 
+   * @param xpmc the {@link ExpandedModelComponent}
+   * @param state the {@link State} for which the trigger if-else switch should be generated
+   * @param usesHdlr if the state machine uses no handler {@link TransitionPoints}
+   *      at all then unused variables can be avoided by passing <code>true</code>
+   * @return the generated code
+   */
+  public CharSequence genDataDrivenTriggers(final ExpandedModelComponent xpmc, final State state, final boolean usesHdlr) {
+    StringConcatenation _builder = new StringConcatenation();
+    String _genDoCodes = this.genDoCodes(state);
+    _builder.append(_genDoCodes, "");
+    _builder.newLineIfNotEmpty();
+    List<Transition> _outgoingTransitionsHierarchical = this._fSMExtensions.getOutgoingTransitionsHierarchical(xpmc, state);
+    final Function1<Transition, Boolean> _function = new Function1<Transition, Boolean>() {
+      public Boolean apply(final Transition t) {
+        return Boolean.valueOf((t instanceof GuardedTransition));
+      }
+    };
+    Iterable<Transition> transitions = IterableExtensions.<Transition>filter(_outgoingTransitionsHierarchical, _function);
+    _builder.newLineIfNotEmpty();
+    {
+      for(final Transition tr : transitions) {
+        _builder.append("if (");
+        String _guard = this.guard(((GuardedTransition) tr), "", xpmc);
+        _builder.append(_guard, "");
+        _builder.append(")");
+        _builder.newLineIfNotEmpty();
+        _builder.append("{");
+        _builder.newLine();
+        _builder.append("    ");
+        TransitionChain chain = xpmc.getChain(tr);
+        _builder.newLineIfNotEmpty();
+        _builder.append("    ");
+        _builder.append("chain__et = ");
+        String _genChainId = this._codegenHelpers.getGenChainId(chain);
+        _builder.append(_genChainId, "    ");
+        _builder.append(";");
+        _builder.newLineIfNotEmpty();
+        _builder.append("    ");
+        _builder.append("catching_state__et = ");
+        State _stateContext = chain.getStateContext();
+        String _genStateId = this._codegenHelpers.getGenStateId(_stateContext);
+        _builder.append(_genStateId, "    ");
+        _builder.append(";");
+        _builder.newLineIfNotEmpty();
+        {
+          boolean _and = false;
+          boolean _isHandler = chain.isHandler();
+          if (!_isHandler) {
+            _and = false;
+          } else {
+            _and = usesHdlr;
+          }
+          if (_and) {
+            _builder.append("    ");
+            _builder.append("is_handler__et = TRUE;");
+            _builder.newLine();
+          }
+        }
+        _builder.append("}");
+        _builder.newLine();
+        {
+          Transition _last = IterableExtensions.<Transition>last(transitions);
+          boolean _notEquals = (!Objects.equal(tr, _last));
+          if (_notEquals) {
+            _builder.append("else ");
+            _builder.newLine();
+          }
+        }
+      }
+    }
+    return _builder;
+  }
+  
+  /**
+   * helper method which generates the event driven triggers
+   * 
+   * @param xpmc the {@link ExpandedModelComponent}
+   * @param state the {@link State} for which the trigger switch should be generated
+   * @param atlist the list of {@link ActiveTrigger}s of this state
+   * @param usesHdlr if the state machine uses no handler {@link TransitionPoints}
+   *      at all then unused variables can be avoided by passing <code>true</code>
+   * @return the generated code
+   */
+  public CharSequence genEventDrivenTriggers(final ExpandedModelComponent xpmc, final State state, final List<ActiveTrigger> atlist, final boolean usesHdlr) {
+    StringConcatenation _builder = new StringConcatenation();
+    {
+      for(final ActiveTrigger at : atlist) {
+        _builder.append("case ");
+        String _triggerCodeName = xpmc.getTriggerCodeName(at);
+        _builder.append(_triggerCodeName, "");
+        _builder.append(":");
+        _builder.newLineIfNotEmpty();
+        _builder.append("    ");
+        boolean needData = this._fsmGenUtil.hasGuard(at);
+        _builder.newLineIfNotEmpty();
+        _builder.append("    ");
+        {
+          if (needData) {
+            _builder.append("{ ");
+            EObject _msg = at.getMsg();
+            String _typedDataDefinition = this.langExt.getTypedDataDefinition(_msg);
+            _builder.append(_typedDataDefinition, "    ");
+          }
+        }
+        _builder.newLineIfNotEmpty();
+        {
+          EList<TriggeredTransition> _transitions = at.getTransitions();
+          boolean _hasElements = false;
+          for(final TriggeredTransition tt : _transitions) {
+            if (!_hasElements) {
+              _hasElements = true;
+            } else {
+              _builder.appendImmediate(" else ", "    ");
+            }
+            _builder.append("    ");
+            TransitionChain chain = xpmc.getChain(tt);
+            _builder.newLineIfNotEmpty();
+            _builder.append("    ");
+            Transition _transition = chain.getTransition();
+            String _trigger = at.getTrigger();
+            String _guard = this.guard(((TriggeredTransition) _transition), _trigger, xpmc);
+            _builder.append(_guard, "    ");
+            _builder.newLineIfNotEmpty();
+            _builder.append("    ");
+            _builder.append("{");
+            _builder.newLine();
+            _builder.append("    ");
+            _builder.append("    ");
+            _builder.append("chain__et = ");
+            String _genChainId = this._codegenHelpers.getGenChainId(chain);
+            _builder.append(_genChainId, "        ");
+            _builder.append(";");
+            _builder.newLineIfNotEmpty();
+            _builder.append("    ");
+            _builder.append("    ");
+            _builder.append("catching_state__et = ");
+            State _stateContext = chain.getStateContext();
+            String _genStateId = this._codegenHelpers.getGenStateId(_stateContext);
+            _builder.append(_genStateId, "        ");
+            _builder.append(";");
+            _builder.newLineIfNotEmpty();
+            {
+              boolean _and = false;
+              boolean _isHandler = chain.isHandler();
+              if (!_isHandler) {
+                _and = false;
+              } else {
+                _and = usesHdlr;
+              }
+              if (_and) {
+                _builder.append("    ");
+                _builder.append("    ");
+                _builder.append("is_handler__et = ");
+                String _booleanConstant = this.langExt.booleanConstant(true);
+                _builder.append(_booleanConstant, "        ");
+                _builder.append(";");
+                _builder.newLineIfNotEmpty();
+              }
+            }
+            _builder.append("    ");
+            _builder.append("}");
+            _builder.newLine();
+          }
+        }
+        _builder.append("    ");
+        {
+          if (needData) {
+            _builder.append("}");
+          }
+        }
+        _builder.newLineIfNotEmpty();
+        _builder.append("break;");
+        _builder.newLine();
+      }
+    }
+    _builder.append("default:");
+    _builder.newLine();
+    _builder.append("    ");
+    _builder.append("/* should not occur */");
+    _builder.newLine();
+    _builder.append("    ");
+    _builder.append("break;");
+    _builder.newLine();
+    return _builder;
+  }
+  
+  public String getClassName(final ExpandedModelComponent xpmc) {
+    ModelComponent _modelComponent = xpmc.getModelComponent();
+    return this.getClassName(_modelComponent);
+  }
+  
+  public String getClassName(final ModelComponent mc) {
+    return mc.getComponentName();
+  }
+  
+  /**
+   * getter for history array
+   * 
+   * @param state the ID of the history state
+   * @return the generated code
+   */
+  public String getHistory(final String state) {
+    String _memberAccess = this.langExt.memberAccess();
+    String _plus = (_memberAccess + "history[");
+    String _plus_1 = (_plus + state);
+    return (_plus_1 + "]");
+  }
+  
+  /**
+   * setter for history array
+   * 
+   * @param state the ID of the state whose history should be set
+   * @param historyState the ID of the state that should be assigned
+   * @return the generated code
+   */
+  public String setHistory(final String state, final String historyState) {
+    String _memberAccess = this.langExt.memberAccess();
+    String _plus = (_memberAccess + "history[");
+    String _plus_1 = (_plus + state);
+    String _plus_2 = (_plus_1 + "] = ");
+    return (_plus_2 + historyState);
+  }
+  
+  /**
+   * @return the type of (temporary) state variables (defaults to "int")
+   * and has to be signed
+   */
+  public String stateType() {
+    return "int";
+  }
+  
+  /**
+   * allow target language dependent generation of unreachable return in generated enterHistory method.
+   * The default is just a comment.
+   * @return the generated code
+   */
+  public String unreachableReturn() {
+    return "/* return NO_STATE; // required by CDT but detected as unreachable by JDT because of while (true) */";
+  }
+  
+  /**
+   * type of (temporary) boolean variables (defaults to "boolean")
+   * @return the generated code
+   */
+  public String boolType() {
+    return "boolean";
+  }
+  
+  /**
+   * empty, but may be overridden
+   */
+  public CharSequence finalAction() {
+    StringConcatenation _builder = new StringConcatenation();
+    return _builder;
+  }
+  
+  /**
+   * the type of the interface item passed into the receiveEvent() method
+   */
+  public String interfaceItemType() {
+    return "InterfaceItemBase";
+  }
+  
+  /**
+   * empty, but may be overridden
+   */
+  public CharSequence markVariableUsed(final String varname) {
+    StringConcatenation _builder = new StringConcatenation();
+    return _builder;
+  }
+  
+  /**
+   * let derived class add extra code after definition of constants
+   * 
+   * @param xpmc an expanded actor class
+   * @return the generated code
+   */
+  public CharSequence genExtra(final ExpandedModelComponent xpmc) {
+    StringConcatenation _builder = new StringConcatenation();
+    return _builder;
+  }
+  
+  /**
+   * let derived class add extra code after definition of constants in header (if applicable)
+   * 
+   * @param xpmc an expanded actor class
+   * @return the generated code
+   */
+  public CharSequence genExtraDecl(final ExpandedModelComponent xpmc) {
+    StringConcatenation _builder = new StringConcatenation();
+    return _builder;
+  }
+  
+  /**
+   * helper method to determine whether this state machine uses handler transitions
+   * points at all
+   * 
+   * @param xpax the {@link ExpandedModelComponent}
+   * @return <code>true</code> if the state machine uses handler transition points
+   */
+  public boolean usesHandlerTrPoints(final ExpandedModelComponent xpmc) {
+    boolean _xblockexpression = false;
+    {
+      StateGraph _stateMachine = xpmc.getStateMachine();
+      boolean _isEmpty = this._fSMHelpers.isEmpty(_stateMachine);
+      if (_isEmpty) {
+        return false;
+      }
+      StateGraph _stateMachine_1 = xpmc.getStateMachine();
+      List<TrPoint> _allTrPointsRecursive = this._fSMHelpers.getAllTrPointsRecursive(_stateMachine_1);
+      final Function1<TrPoint, Boolean> _function = new Function1<TrPoint, Boolean>() {
+        public Boolean apply(final TrPoint t) {
+          boolean _and = false;
+          if (!(t instanceof TransitionPoint)) {
+            _and = false;
+          } else {
+            boolean _isHandler = ((TransitionPoint) t).isHandler();
+            _and = _isHandler;
+          }
+          return Boolean.valueOf(_and);
+        }
+      };
+      Iterable<TrPoint> _filter = IterableExtensions.<TrPoint>filter(_allTrPointsRecursive, _function);
+      boolean _isEmpty_1 = IterableExtensions.isEmpty(_filter);
+      _xblockexpression = (!_isEmpty_1);
+    }
+    return _xblockexpression;
+  }
+  
+  public abstract String guard(final TriggeredTransition tt, final String trigger, final ExpandedModelComponent mc);
+  
+  public abstract String guard(final GuardedTransition tt, final String trigger, final ExpandedModelComponent mc);
+  
+  public abstract String genActionCodeMethod(final ExpandedModelComponent xpmc, final Transition tr, final boolean generateImplementation);
+  
+  public abstract String genActionCodeMethods(final ExpandedModelComponent xpmc, final State state, final boolean generateImplementation);
+}
diff --git a/plugins/org.eclipse.etrice.generator.fsm/xtend-gen/org/eclipse/etrice/generator/fsm/generic/FSMExtensions.java b/plugins/org.eclipse.etrice.generator.fsm/xtend-gen/org/eclipse/etrice/generator/fsm/generic/FSMExtensions.java
index 792f218..703743c 100644
--- a/plugins/org.eclipse.etrice.generator.fsm/xtend-gen/org/eclipse/etrice/generator/fsm/generic/FSMExtensions.java
+++ b/plugins/org.eclipse.etrice.generator.fsm/xtend-gen/org/eclipse/etrice/generator/fsm/generic/FSMExtensions.java
@@ -10,23 +10,37 @@
  */
 package org.eclipse.etrice.generator.fsm.generic;
 
+import com.google.common.base.Objects;
 import com.google.common.collect.Iterables;
+import com.google.inject.Inject;
 import java.util.ArrayList;
 import java.util.List;
 import org.eclipse.emf.common.util.EList;
 import org.eclipse.emf.ecore.EObject;
+import org.eclipse.etrice.core.fsm.fSM.CPBranchTransition;
+import org.eclipse.etrice.core.fsm.fSM.DetailCode;
+import org.eclipse.etrice.core.fsm.fSM.Guard;
+import org.eclipse.etrice.core.fsm.fSM.ModelComponent;
 import org.eclipse.etrice.core.fsm.fSM.State;
 import org.eclipse.etrice.core.fsm.fSM.StateGraph;
 import org.eclipse.etrice.core.fsm.fSM.TrPoint;
 import org.eclipse.etrice.core.fsm.fSM.Transition;
 import org.eclipse.etrice.core.fsm.fSM.TransitionPoint;
+import org.eclipse.etrice.core.fsm.util.FSMHelpers;
 import org.eclipse.etrice.core.genmodel.fsm.fsmgen.ExpandedModelComponent;
+import org.eclipse.xtext.xbase.lib.Extension;
+import org.eclipse.xtext.xbase.lib.Functions.Function1;
+import org.eclipse.xtext.xbase.lib.IterableExtensions;
 
 /**
  * @author Henrik Rentz-Reichert
  */
 @SuppressWarnings("all")
 public class FSMExtensions {
+  @Inject
+  @Extension
+  protected FSMHelpers _fSMHelpers;
+  
   /**
    * the template type is T
    * @param l an iterable of type T
@@ -92,4 +106,114 @@
     }
     return result;
   }
+  
+  /**
+   * @param states a list of {@link State}s
+   * @return a list ordered such that leaf states are last
+   */
+  public List<State> getLeafStatesLast(final List<State> states) {
+    List<State> _xblockexpression = null;
+    {
+      final Function1<State, Boolean> _function = new Function1<State, Boolean>() {
+        public Boolean apply(final State s) {
+          return Boolean.valueOf(FSMExtensions.this._fSMHelpers.isLeaf(s));
+        }
+      };
+      final Iterable<State> leaf = IterableExtensions.<State>filter(states, _function);
+      final Function1<State, Boolean> _function_1 = new Function1<State, Boolean>() {
+        public Boolean apply(final State s) {
+          boolean _isLeaf = FSMExtensions.this._fSMHelpers.isLeaf(s);
+          return Boolean.valueOf((!_isLeaf));
+        }
+      };
+      final Iterable<State> nonLeaf = IterableExtensions.<State>filter(states, _function_1);
+      _xblockexpression = this.<State>union(nonLeaf, leaf);
+    }
+    return _xblockexpression;
+  }
+  
+  /**
+   * @param ac an {@link ActorClass}
+   * @return a list of all leaf states
+   */
+  public List<State> getAllLeafStates(final ModelComponent mc) {
+    StateGraph _stateMachine = mc.getStateMachine();
+    return this._fSMHelpers.getLeafStateList(_stateMachine);
+  }
+  
+  /**
+   * @param ac an {@link ActorClass}
+   * @return a list of simple states with leaf states last
+   */
+  public List<State> getAllBaseStatesLeavesLast(final ModelComponent mc) {
+    List<State> _allBaseStates = this._fSMHelpers.getAllBaseStates(mc);
+    return this.getLeafStatesLast(_allBaseStates);
+  }
+  
+  /**
+   * @param ac an {@link ModelComponent}
+   * @return the number of all inherited states
+   */
+  public int getNumberOfInheritedStates(final ModelComponent mc) {
+    ModelComponent _base = mc.getBase();
+    boolean _equals = Objects.equal(_base, null);
+    if (_equals) {
+      return 0;
+    } else {
+      ModelComponent _base_1 = mc.getBase();
+      StateGraph _stateMachine = _base_1.getStateMachine();
+      List<State> _stateList = this._fSMHelpers.getStateList(_stateMachine);
+      int _size = _stateList.size();
+      ModelComponent _base_2 = mc.getBase();
+      int _numberOfInheritedStates = this.getNumberOfInheritedStates(_base_2);
+      return (_size + _numberOfInheritedStates);
+    }
+  }
+  
+  /**
+   * @param ac an {@link ModelComponent}
+   * @return the number of all inherited base (or simple) states
+   */
+  public int getNumberOfInheritedBaseStates(final ModelComponent ac) {
+    ModelComponent _base = ac.getBase();
+    boolean _equals = Objects.equal(_base, null);
+    if (_equals) {
+      return 0;
+    } else {
+      ModelComponent _base_1 = ac.getBase();
+      StateGraph _stateMachine = _base_1.getStateMachine();
+      List<State> _baseStateList = this._fSMHelpers.getBaseStateList(_stateMachine);
+      int _size = _baseStateList.size();
+      ModelComponent _base_2 = ac.getBase();
+      int _numberOfInheritedBaseStates = this.getNumberOfInheritedBaseStates(_base_2);
+      return (_size + _numberOfInheritedBaseStates);
+    }
+  }
+  
+  public boolean isConditionOrGuard(final DetailCode dc) {
+    boolean _xblockexpression = false;
+    {
+      final EObject parent = dc.eContainer();
+      boolean _switchResult = false;
+      boolean _matched = false;
+      if (!_matched) {
+        if (parent instanceof Guard) {
+          _matched=true;
+          _switchResult = true;
+        }
+      }
+      if (!_matched) {
+        if (parent instanceof CPBranchTransition) {
+          _matched=true;
+          DetailCode _condition = ((CPBranchTransition)parent).getCondition();
+          _switchResult = Objects.equal(_condition, dc);
+        }
+      }
+      if (!_matched) {
+        _switchResult = false;
+      }
+      _xblockexpression = _switchResult;
+    }
+    return _xblockexpression;
+  }
 }
diff --git a/plugins/org.eclipse.etrice.generator.fsmtest/META-INF/MANIFEST.MF b/plugins/org.eclipse.etrice.generator.fsmtest/META-INF/MANIFEST.MF
index 37a80da..21c3c70 100644
--- a/plugins/org.eclipse.etrice.generator.fsmtest/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.etrice.generator.fsmtest/META-INF/MANIFEST.MF
@@ -16,7 +16,7 @@
  org.eclipse.emf.ecore,
  org.eclipse.emf.common,
  org.antlr.runtime,
- org.eclipse.xtext.common.types
+ org.eclipse.xtext.common.types;bundle-version="2.6.0"
 Import-Package: org.apache.log4j,
  org.eclipse.xtext.xbase.lib
 Bundle-RequiredExecutionEnvironment: JavaSE-1.6
diff --git a/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/Main.java b/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/Main.java
index 240d021..fb70a68 100644
--- a/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/Main.java
+++ b/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/Main.java
@@ -28,7 +28,9 @@
 import org.eclipse.xtext.scoping.impl.ImportUriResolver;
 
 import com.google.inject.Inject;
+import com.google.inject.Singleton;
 
+@Singleton
 public class Main extends AbstractGenerator {
 	
 	public static final String OPTION_GEN_PERSIST = "-persistable";
diff --git a/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/ActorClassGen.xtend b/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/ActorClassGen.xtend
index 6784d6d..cb5ee8d 100644
--- a/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/ActorClassGen.xtend
+++ b/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/ActorClassGen.xtend
@@ -159,17 +159,17 @@
 		
 				// own ports
 				«FOR ep : ac.getEndPorts()»
-					«ep.name» = new «ep.getPortClassName()»(this, "«ep.name»", IFITEM_«ep.name»);
+					«ep.name» = new «ep.getPortClassName()»(this, "«ep.name»", «ep.ifItemId»);
 				«ENDFOR»
 				
 				// own saps
 				«FOR sap : ac.serviceAccessPoints»
-					«sap.name» = new «sap.getPortClassName()»(this, "«sap.name»", IFITEM_«sap.name», 0);
+					«sap.name» = new «sap.getPortClassName()»(this, "«sap.name»", «sap.ifItemId», 0);
 				«ENDFOR»
 				
 				// own service implementations
 				«FOR svc : ac.serviceImplementations»
-					«svc.spp.name» = new «svc.getPortClassName()»(this, "«svc.spp.name»", IFITEM_«svc.spp.name»);
+					«svc.spp.name» = new «svc.getPortClassName()»(this, "«svc.spp.name»", «svc.spp.ifItemId»);
 				«ENDFOR»
 				
 				// sub actors
@@ -314,7 +314,11 @@
 			«IF ac.commType == ComponentCommunicationType::ASYNCHRONOUS || ac.commType == ComponentCommunicationType::DATA_DRIVEN»
 				@Override
 				public void receive(Message msg) {
-					receiveEvent(«IF ac.commType == ComponentCommunicationType::ASYNCHRONOUS»null, -1, null«ENDIF»);
+					«IF ac.commType == ComponentCommunicationType::ASYNCHRONOUS»
+						receiveEvent(null, -1, null);
+					«ELSE»
+						receiveEventInternal();
+					«ENDIF»
 				}
 			«ENDIF»
 			
diff --git a/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/JavaExtensions.xtend b/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/JavaExtensions.xtend
index c14b479..7354161 100644
--- a/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/JavaExtensions.xtend
+++ b/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/JavaExtensions.xtend
@@ -36,14 +36,20 @@
 import org.eclipse.etrice.core.room.EnumerationType
 
 import org.eclipse.etrice.core.room.EnumLiteral
+import org.eclipse.emf.ecore.EObject
 
 @Singleton
 class JavaExtensions implements ILanguageExtension {
 
 	@Inject TypeHelpers typeHelpers
 
-	override String getTypedDataDefinition(Message m) {
-		generateArglistAndTypedData(m.data).get(1)
+	override String getTypedDataDefinition(EObject msg) {
+	    if (msg instanceof Message) {
+    		generateArglistAndTypedData((msg as Message).data).get(1)
+	    }
+	    else {
+	        ""
+	    }
 	}
 
 	def String getJavaFileName(RoomClass rc) {rc.name+".java"}
@@ -243,10 +249,11 @@
 			dv
 	}
 
-	override generateArglistAndTypedData(VarDecl data) {
-		if (data==null)
+	override generateArglistAndTypedData(EObject d) {
+		if (d==null || !(d instanceof VarDecl))
 			return newArrayList("", "", "")
 		
+		val data = d as VarDecl
 		var typeName = data.refType.type.getName();
 		var castTypeName = typeName;
 		if (data.refType.type instanceof PrimitiveType) {
diff --git a/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/OptionalActorInterfaceGen.xtend b/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/OptionalActorInterfaceGen.xtend
index ac3824d..95a8bc9 100644
--- a/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/OptionalActorInterfaceGen.xtend
+++ b/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/OptionalActorInterfaceGen.xtend
@@ -69,9 +69,9 @@
 					
 					«FOR ep : ac.allInterfacePorts»
 						«IF ep.replicated»
-							«ep.name» = new ReplicatedInterfaceItemBroker(this, "«ep.name»", IFITEM_«ep.name»);
+							«ep.name» = new ReplicatedInterfaceItemBroker(this, "«ep.name»", «ep.ifItemId»);
 						«ELSE»
-							«ep.name» = new InterfaceItemBroker(this, "«ep.name»", IFITEM_«ep.name»);
+							«ep.name» = new InterfaceItemBroker(this, "«ep.name»", «ep.ifItemId»);
 						«ENDIF»
 					«ENDFOR»
 				}
diff --git a/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/StateMachineGen.xtend b/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/StateMachineGen.xtend
index 46497c5..ca73c56 100644
--- a/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/StateMachineGen.xtend
+++ b/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/StateMachineGen.xtend
@@ -18,19 +18,20 @@
 import org.eclipse.etrice.core.fsm.fSM.State
 import org.eclipse.etrice.generator.generic.GenericStateMachineGenerator
 import org.eclipse.etrice.generator.java.Main
+import org.eclipse.etrice.core.genmodel.fsm.fsmgen.ExpandedModelComponent
 
 @Singleton
 class StateMachineGen extends GenericStateMachineGenerator {
 	
-	override genExtra(ExpandedActorClass xpac) {
+	override genExtra(ExpandedModelComponent xpac) {
 		val states = new ArrayList<State>()
-		var ac = xpac.actorClass
+		var ac = xpac.modelComponent
 		
 //		it is crucial that we obey the order that is used for state IDs
 //		that means we have to collect base classes first and each base class list with leaf states last
 		while (ac!=null) {
 			states.addAll(0, ac.allBaseStates.leafStatesLast)
-			ac = ac.actorBase
+			ac = ac.base
 		}
 	'''
 		«IF Main::settings.generateMSCInstrumentation || Main::settings.generateWithVerboseOutput»
diff --git a/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/ActorClassGen.java b/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/ActorClassGen.java
index e58acfc..72a2bfd 100644
--- a/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/ActorClassGen.java
+++ b/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/ActorClassGen.java
@@ -518,9 +518,9 @@
           _builder.append("(this, \"");
           String _name_13 = ep_1.getName();
           _builder.append(_name_13, "\t\t");
-          _builder.append("\", IFITEM_");
-          String _name_14 = ep_1.getName();
-          _builder.append(_name_14, "\t\t");
+          _builder.append("\", ");
+          String _ifItemId = this.getIfItemId(ep_1);
+          _builder.append(_ifItemId, "\t\t");
           _builder.append(");");
           _builder.newLineIfNotEmpty();
         }
@@ -534,17 +534,17 @@
         EList<SAP> _serviceAccessPoints_1 = ac.getServiceAccessPoints();
         for(final SAP sap_1 : _serviceAccessPoints_1) {
           _builder.append("\t\t");
-          String _name_15 = sap_1.getName();
-          _builder.append(_name_15, "\t\t");
+          String _name_14 = sap_1.getName();
+          _builder.append(_name_14, "\t\t");
           _builder.append(" = new ");
           String _portClassName_4 = this._roomExtensions.getPortClassName(sap_1);
           _builder.append(_portClassName_4, "\t\t");
           _builder.append("(this, \"");
-          String _name_16 = sap_1.getName();
-          _builder.append(_name_16, "\t\t");
-          _builder.append("\", IFITEM_");
-          String _name_17 = sap_1.getName();
-          _builder.append(_name_17, "\t\t");
+          String _name_15 = sap_1.getName();
+          _builder.append(_name_15, "\t\t");
+          _builder.append("\", ");
+          String _ifItemId_1 = this.getIfItemId(sap_1);
+          _builder.append(_ifItemId_1, "\t\t");
           _builder.append(", 0);");
           _builder.newLineIfNotEmpty();
         }
@@ -559,19 +559,19 @@
         for(final ServiceImplementation svc_1 : _serviceImplementations_1) {
           _builder.append("\t\t");
           SPP _spp_1 = svc_1.getSpp();
-          String _name_18 = _spp_1.getName();
-          _builder.append(_name_18, "\t\t");
+          String _name_16 = _spp_1.getName();
+          _builder.append(_name_16, "\t\t");
           _builder.append(" = new ");
           String _portClassName_5 = this._roomExtensions.getPortClassName(svc_1);
           _builder.append(_portClassName_5, "\t\t");
           _builder.append("(this, \"");
           SPP _spp_2 = svc_1.getSpp();
-          String _name_19 = _spp_2.getName();
-          _builder.append(_name_19, "\t\t");
-          _builder.append("\", IFITEM_");
+          String _name_17 = _spp_2.getName();
+          _builder.append(_name_17, "\t\t");
+          _builder.append("\", ");
           SPP _spp_3 = svc_1.getSpp();
-          String _name_20 = _spp_3.getName();
-          _builder.append(_name_20, "\t\t");
+          String _ifItemId_2 = this.getIfItemId(_spp_3);
+          _builder.append(_ifItemId_2, "\t\t");
           _builder.append(");");
           _builder.newLineIfNotEmpty();
         }
@@ -589,12 +589,12 @@
             boolean _equals = Objects.equal(_refType, ReferenceType.OPTIONAL);
             if (_equals) {
               _builder.append("\t\t");
-              String _name_21 = sub_2.getName();
-              _builder.append(_name_21, "\t\t");
+              String _name_18 = sub_2.getName();
+              _builder.append(_name_18, "\t\t");
               _builder.append(" = new ");
               ActorClass _type_3 = sub_2.getType();
-              String _name_22 = _type_3.getName();
-              _builder.append(_name_22, "\t\t");
+              String _name_19 = _type_3.getName();
+              _builder.append(_name_19, "\t\t");
               {
                 int _multiplicity_1 = sub_2.getMultiplicity();
                 boolean _notEquals_2 = (_multiplicity_1 != 1);
@@ -603,8 +603,8 @@
                 }
               }
               _builder.append("Interface(this, \"");
-              String _name_23 = sub_2.getName();
-              _builder.append(_name_23, "\t\t");
+              String _name_20 = sub_2.getName();
+              _builder.append(_name_20, "\t\t");
               _builder.append("\");");
               _builder.newLineIfNotEmpty();
             } else {
@@ -624,8 +624,8 @@
                     _builder.append("\t\t");
                     _builder.append("\t");
                     _builder.append("DebuggingService.getInstance().addMessageActorCreate(this, \"");
-                    String _name_24 = sub_2.getName();
-                    _builder.append(_name_24, "\t\t\t");
+                    String _name_21 = sub_2.getName();
+                    _builder.append(_name_21, "\t\t\t");
                     _builder.append(GenmodelConstants.INDEX_SEP, "\t\t\t");
                     _builder.append("\"+i);");
                     _builder.newLineIfNotEmpty();
@@ -635,11 +635,11 @@
                 _builder.append("\t");
                 _builder.append("new ");
                 ActorClass _type_4 = sub_2.getType();
-                String _name_25 = _type_4.getName();
-                _builder.append(_name_25, "\t\t\t");
+                String _name_22 = _type_4.getName();
+                _builder.append(_name_22, "\t\t\t");
                 _builder.append("(this, \"");
-                String _name_26 = sub_2.getName();
-                _builder.append(_name_26, "\t\t\t");
+                String _name_23 = sub_2.getName();
+                _builder.append(_name_23, "\t\t\t");
                 _builder.append(GenmodelConstants.INDEX_SEP, "\t\t\t");
                 _builder.append("\"+i);");
                 _builder.newLineIfNotEmpty();
@@ -653,8 +653,8 @@
                   if (_generateMSCInstrumentation_1) {
                     _builder.append("\t\t");
                     _builder.append("DebuggingService.getInstance().addMessageActorCreate(this, \"");
-                    String _name_27 = sub_2.getName();
-                    _builder.append(_name_27, "\t\t");
+                    String _name_24 = sub_2.getName();
+                    _builder.append(_name_24, "\t\t");
                     _builder.append("\");");
                     _builder.newLineIfNotEmpty();
                   }
@@ -662,11 +662,11 @@
                 _builder.append("\t\t");
                 _builder.append("new ");
                 ActorClass _type_5 = sub_2.getType();
-                String _name_28 = _type_5.getName();
-                _builder.append(_name_28, "\t\t");
+                String _name_25 = _type_5.getName();
+                _builder.append(_name_25, "\t\t");
                 _builder.append("(this, \"");
-                String _name_29 = sub_2.getName();
-                _builder.append(_name_29, "\t\t");
+                String _name_26 = sub_2.getName();
+                _builder.append(_name_26, "\t\t");
                 _builder.append("\");");
                 _builder.newLineIfNotEmpty();
               }
@@ -771,8 +771,8 @@
             for(final Attribute a_1 : _dynConfigReadAttributes_3) {
               _builder.append("\t\t");
               _builder.append("lock_");
-              String _name_30 = a_1.getName();
-              _builder.append(_name_30, "\t\t");
+              String _name_27 = a_1.getName();
+              _builder.append(_name_27, "\t\t");
               _builder.append(" = new DynConfigLock();");
               _builder.newLineIfNotEmpty();
             }
@@ -788,8 +788,8 @@
       EList<Attribute> _attributes_3 = ac.getAttributes();
       List<Attribute> _dynConfigReadAttributes_4 = this.dataConfigExt.getDynConfigReadAttributes(ac);
       List<Attribute> _minus = this._roomExtensions.<Attribute>minus(_attributes_3, _dynConfigReadAttributes_4);
-      String _name_31 = ac.getName();
-      CharSequence _attributeSettersGettersImplementation = this._procedureHelpers.attributeSettersGettersImplementation(_minus, _name_31);
+      String _name_28 = ac.getName();
+      CharSequence _attributeSettersGettersImplementation = this._procedureHelpers.attributeSettersGettersImplementation(_minus, _name_28);
       _builder.append(_attributeSettersGettersImplementation, "\t");
       _builder.newLineIfNotEmpty();
       _builder.append("\t");
@@ -808,9 +808,9 @@
         for(final Port ep_2 : _endPorts_2) {
           _builder.append("\t");
           String _portClassName_6 = this._roomExtensions.getPortClassName(ep_2);
-          String _name_32 = ep_2.getName();
-          String _name_33 = ac.getName();
-          CharSequence _terImplementation = this._procedureHelpers.getterImplementation(_portClassName_6, _name_32, _name_33);
+          String _name_29 = ep_2.getName();
+          String _name_30 = ac.getName();
+          CharSequence _terImplementation = this._procedureHelpers.getterImplementation(_portClassName_6, _name_29, _name_30);
           _builder.append(_terImplementation, "\t");
           _builder.newLineIfNotEmpty();
         }
@@ -820,9 +820,9 @@
         for(final SAP sap_2 : _serviceAccessPoints_2) {
           _builder.append("\t");
           String _portClassName_7 = this._roomExtensions.getPortClassName(sap_2);
-          String _name_34 = sap_2.getName();
-          String _name_35 = ac.getName();
-          CharSequence _terImplementation_1 = this._procedureHelpers.getterImplementation(_portClassName_7, _name_34, _name_35);
+          String _name_31 = sap_2.getName();
+          String _name_32 = ac.getName();
+          CharSequence _terImplementation_1 = this._procedureHelpers.getterImplementation(_portClassName_7, _name_31, _name_32);
           _builder.append(_terImplementation_1, "\t");
           _builder.newLineIfNotEmpty();
         }
@@ -833,9 +833,9 @@
           _builder.append("\t");
           String _portClassName_8 = this._roomExtensions.getPortClassName(svc_2);
           SPP _spp_4 = svc_2.getSpp();
-          String _name_36 = _spp_4.getName();
-          String _name_37 = ac.getName();
-          CharSequence _terImplementation_2 = this._procedureHelpers.getterImplementation(_portClassName_8, _name_36, _name_37);
+          String _name_33 = _spp_4.getName();
+          String _name_34 = ac.getName();
+          CharSequence _terImplementation_2 = this._procedureHelpers.getterImplementation(_portClassName_8, _name_33, _name_34);
           _builder.append(_terImplementation_2, "\t");
           _builder.newLineIfNotEmpty();
         }
@@ -888,8 +888,8 @@
               _builder.newLine();
               _builder.append("\t");
               _builder.append("\t");
-              String _name_38 = ac.getName();
-              String _destructorCall = this._procedureHelpers.destructorCall(_name_38);
+              String _name_35 = ac.getName();
+              String _destructorCall = this._procedureHelpers.destructorCall(_name_35);
               _builder.append(_destructorCall, "\t\t");
               _builder.append(";");
               _builder.newLineIfNotEmpty();
@@ -969,8 +969,8 @@
               _builder.append("\t");
               _builder.append("\t");
               _builder.append("if (ifitem==");
-              String _name_39 = ifitem.getName();
-              _builder.append(_name_39, "\t\t");
+              String _name_36 = ifitem.getName();
+              _builder.append(_name_36, "\t\t");
               _builder.append(") {");
               _builder.newLineIfNotEmpty();
               _builder.append("\t");
@@ -986,8 +986,8 @@
                   _builder.append("\t\t");
                   _builder.append("case ");
                   ProtocolClass _protocolClass = this._roomHelpers.getProtocolClass(msg);
-                  String _name_40 = _protocolClass.getName();
-                  _builder.append(_name_40, "\t\t\t\t");
+                  String _name_37 = _protocolClass.getName();
+                  _builder.append(_name_37, "\t\t\t\t");
                   _builder.append(".");
                   String _xifexpression_6 = null;
                   boolean _isIncoming = this._roomExtensions.isIncoming(msg);
@@ -997,8 +997,8 @@
                     _xifexpression_6 = "OUT_";
                   }
                   _builder.append(_xifexpression_6, "\t\t\t\t");
-                  String _name_41 = msg.getName();
-                  _builder.append(_name_41, "\t\t\t\t");
+                  String _name_38 = msg.getName();
+                  _builder.append(_name_38, "\t\t\t\t");
                   _builder.append(":");
                   _builder.newLineIfNotEmpty();
                   {
@@ -1020,11 +1020,11 @@
                   _builder.append("\t\t");
                   _builder.append("\t");
                   _builder.append("on_");
-                  String _name_42 = ifitem.getName();
-                  _builder.append(_name_42, "\t\t\t\t\t");
+                  String _name_39 = ifitem.getName();
+                  _builder.append(_name_39, "\t\t\t\t\t");
                   _builder.append("_");
-                  String _name_43 = msg.getName();
-                  _builder.append(_name_43, "\t\t\t\t\t");
+                  String _name_40 = msg.getName();
+                  _builder.append(_name_40, "\t\t\t\t\t");
                   _builder.append("(ifitem");
                   {
                     VarDecl _data_1 = msg.getData();
@@ -1032,8 +1032,8 @@
                     if (_notEquals_6) {
                       _builder.append(", ");
                       VarDecl _data_2 = msg.getData();
-                      String _name_44 = _data_2.getName();
-                      _builder.append(_name_44, "\t\t\t\t\t");
+                      String _name_41 = _data_2.getName();
+                      _builder.append(_name_41, "\t\t\t\t\t");
                     }
                   }
                   _builder.append(");");
@@ -1080,11 +1080,11 @@
                 for(final Message msg_1 : _incoming_1) {
                   _builder.append("\t");
                   _builder.append("protected void on_");
-                  String _name_45 = ifitem_1.getName();
-                  _builder.append(_name_45, "\t");
+                  String _name_42 = ifitem_1.getName();
+                  _builder.append(_name_42, "\t");
                   _builder.append("_");
-                  String _name_46 = msg_1.getName();
-                  _builder.append(_name_46, "\t");
+                  String _name_43 = msg_1.getName();
+                  _builder.append(_name_43, "\t");
                   _builder.append("(InterfaceItemBase ifitem");
                   {
                     VarDecl _data_4 = msg_1.getData();
@@ -1178,18 +1178,21 @@
           _builder.append("\t");
           _builder.append("public void receive(Message msg) {");
           _builder.newLine();
-          _builder.append("\t");
-          _builder.append("\t");
-          _builder.append("receiveEvent(");
           {
             ComponentCommunicationType _commType_7 = ac.getCommType();
             boolean _equals_8 = Objects.equal(_commType_7, ComponentCommunicationType.ASYNCHRONOUS);
             if (_equals_8) {
-              _builder.append("null, -1, null");
+              _builder.append("\t");
+              _builder.append("\t");
+              _builder.append("receiveEvent(null, -1, null);");
+              _builder.newLine();
+            } else {
+              _builder.append("\t");
+              _builder.append("\t");
+              _builder.append("receiveEventInternal();");
+              _builder.newLine();
             }
           }
-          _builder.append(");");
-          _builder.newLineIfNotEmpty();
           _builder.append("\t");
           _builder.append("}");
           _builder.newLine();
@@ -1380,27 +1383,27 @@
                           _builder.append("\t");
                           _builder.append("\t");
                           _builder.append("dataObject.set");
-                          String _name_47 = att.getName();
-                          String _firstUpper = StringExtensions.toFirstUpper(_name_47);
+                          String _name_44 = att.getName();
+                          String _firstUpper = StringExtensions.toFirstUpper(_name_44);
                           _builder.append(_firstUpper, "\t\t");
                           _builder.append("(Arrays.copyOf(");
-                          String _name_48 = att.getName();
-                          _builder.append(_name_48, "\t\t");
+                          String _name_45 = att.getName();
+                          _builder.append(_name_45, "\t\t");
                           _builder.append(", ");
-                          String _name_49 = att.getName();
-                          _builder.append(_name_49, "\t\t");
+                          String _name_46 = att.getName();
+                          _builder.append(_name_46, "\t\t");
                           _builder.append(".length));");
                           _builder.newLineIfNotEmpty();
                         } else {
                           _builder.append("\t");
                           _builder.append("\t");
                           _builder.append("dataObject.set");
-                          String _name_50 = att.getName();
-                          String _firstUpper_1 = StringExtensions.toFirstUpper(_name_50);
+                          String _name_47 = att.getName();
+                          String _firstUpper_1 = StringExtensions.toFirstUpper(_name_47);
                           _builder.append(_firstUpper_1, "\t\t");
                           _builder.append("(");
-                          String _name_51 = att.getName();
-                          _builder.append(_name_51, "\t\t");
+                          String _name_48 = att.getName();
+                          _builder.append(_name_48, "\t\t");
                           _builder.append(");");
                           _builder.newLineIfNotEmpty();
                         }
@@ -1419,14 +1422,14 @@
                           _builder.append("\t");
                           RefableType _type_8 = att.getType();
                           DataType _type_9 = _type_8.getType();
-                          String _name_52 = _type_9.getName();
-                          _builder.append(_name_52, "\t\t\t");
+                          String _name_49 = _type_9.getName();
+                          _builder.append(_name_49, "\t\t\t");
                           _builder.append("[] arr = Arrays.copyOf(");
-                          String _name_53 = att.getName();
-                          _builder.append(_name_53, "\t\t\t");
+                          String _name_50 = att.getName();
+                          _builder.append(_name_50, "\t\t\t");
                           _builder.append(", ");
-                          String _name_54 = att.getName();
-                          _builder.append(_name_54, "\t\t\t");
+                          String _name_51 = att.getName();
+                          _builder.append(_name_51, "\t\t\t");
                           _builder.append(".length);");
                           _builder.newLineIfNotEmpty();
                           _builder.append("\t");
@@ -1438,8 +1441,8 @@
                           _builder.append("\t");
                           _builder.append("\t");
                           _builder.append("dataObject.set");
-                          String _name_55 = att.getName();
-                          String _firstUpper_2 = StringExtensions.toFirstUpper(_name_55);
+                          String _name_52 = att.getName();
+                          String _firstUpper_2 = StringExtensions.toFirstUpper(_name_52);
                           _builder.append(_firstUpper_2, "\t\t\t");
                           _builder.append("(arr);");
                           _builder.newLineIfNotEmpty();
@@ -1451,12 +1454,12 @@
                           _builder.append("\t");
                           _builder.append("\t");
                           _builder.append("dataObject.set");
-                          String _name_56 = att.getName();
-                          String _firstUpper_3 = StringExtensions.toFirstUpper(_name_56);
+                          String _name_53 = att.getName();
+                          String _firstUpper_3 = StringExtensions.toFirstUpper(_name_53);
                           _builder.append(_firstUpper_3, "\t\t");
                           _builder.append("(");
-                          String _name_57 = att.getName();
-                          _builder.append(_name_57, "\t\t");
+                          String _name_54 = att.getName();
+                          _builder.append(_name_54, "\t\t");
                           _builder.append(".deepCopy());");
                           _builder.newLineIfNotEmpty();
                         }
@@ -1547,28 +1550,28 @@
                           _builder.append("\t");
                           _builder.append("\t");
                           _builder.append("set");
-                          String _name_58 = att_1.getName();
-                          String _firstUpper_4 = StringExtensions.toFirstUpper(_name_58);
+                          String _name_55 = att_1.getName();
+                          String _firstUpper_4 = StringExtensions.toFirstUpper(_name_55);
                           _builder.append(_firstUpper_4, "\t\t");
                           _builder.append("(Arrays.copyOf(dataObject.get");
-                          String _name_59 = att_1.getName();
-                          String _firstUpper_5 = StringExtensions.toFirstUpper(_name_59);
+                          String _name_56 = att_1.getName();
+                          String _firstUpper_5 = StringExtensions.toFirstUpper(_name_56);
                           _builder.append(_firstUpper_5, "\t\t");
                           _builder.append("(), ");
-                          String _name_60 = att_1.getName();
-                          _builder.append(_name_60, "\t\t");
+                          String _name_57 = att_1.getName();
+                          _builder.append(_name_57, "\t\t");
                           _builder.append(".length));");
                           _builder.newLineIfNotEmpty();
                         } else {
                           _builder.append("\t");
                           _builder.append("\t");
                           _builder.append("set");
-                          String _name_61 = att_1.getName();
-                          String _firstUpper_6 = StringExtensions.toFirstUpper(_name_61);
+                          String _name_58 = att_1.getName();
+                          String _firstUpper_6 = StringExtensions.toFirstUpper(_name_58);
                           _builder.append(_firstUpper_6, "\t\t");
                           _builder.append("(dataObject.get");
-                          String _name_62 = att_1.getName();
-                          String _firstUpper_7 = StringExtensions.toFirstUpper(_name_62);
+                          String _name_59 = att_1.getName();
+                          String _firstUpper_7 = StringExtensions.toFirstUpper(_name_59);
                           _builder.append(_firstUpper_7, "\t\t");
                           _builder.append("());");
                           _builder.newLineIfNotEmpty();
@@ -1588,15 +1591,15 @@
                           _builder.append("\t");
                           RefableType _type_12 = att_1.getType();
                           DataType _type_13 = _type_12.getType();
-                          String _name_63 = _type_13.getName();
-                          _builder.append(_name_63, "\t\t\t");
+                          String _name_60 = _type_13.getName();
+                          _builder.append(_name_60, "\t\t\t");
                           _builder.append("[] arr = Arrays.copyOf(dataObject.get");
-                          String _name_64 = att_1.getName();
-                          String _firstUpper_8 = StringExtensions.toFirstUpper(_name_64);
+                          String _name_61 = att_1.getName();
+                          String _firstUpper_8 = StringExtensions.toFirstUpper(_name_61);
                           _builder.append(_firstUpper_8, "\t\t\t");
                           _builder.append("(), ");
-                          String _name_65 = att_1.getName();
-                          _builder.append(_name_65, "\t\t\t");
+                          String _name_62 = att_1.getName();
+                          _builder.append(_name_62, "\t\t\t");
                           _builder.append(".length);");
                           _builder.newLineIfNotEmpty();
                           _builder.append("\t");
@@ -1608,8 +1611,8 @@
                           _builder.append("\t");
                           _builder.append("\t");
                           _builder.append("set");
-                          String _name_66 = att_1.getName();
-                          String _firstUpper_9 = StringExtensions.toFirstUpper(_name_66);
+                          String _name_63 = att_1.getName();
+                          String _firstUpper_9 = StringExtensions.toFirstUpper(_name_63);
                           _builder.append(_firstUpper_9, "\t\t\t");
                           _builder.append("(arr);");
                           _builder.newLineIfNotEmpty();
@@ -1621,12 +1624,12 @@
                           _builder.append("\t");
                           _builder.append("\t");
                           _builder.append("set");
-                          String _name_67 = att_1.getName();
-                          String _firstUpper_10 = StringExtensions.toFirstUpper(_name_67);
+                          String _name_64 = att_1.getName();
+                          String _firstUpper_10 = StringExtensions.toFirstUpper(_name_64);
                           _builder.append(_firstUpper_10, "\t\t");
                           _builder.append("(dataObject.get");
-                          String _name_68 = att_1.getName();
-                          String _firstUpper_11 = StringExtensions.toFirstUpper(_name_68);
+                          String _name_65 = att_1.getName();
+                          String _firstUpper_11 = StringExtensions.toFirstUpper(_name_65);
                           _builder.append(_firstUpper_11, "\t\t");
                           _builder.append("().deepCopy());");
                           _builder.newLineIfNotEmpty();
diff --git a/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/JavaExtensions.java b/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/JavaExtensions.java
index eaed766..badf8c9 100644
--- a/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/JavaExtensions.java
+++ b/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/JavaExtensions.java
@@ -43,10 +43,16 @@
   @Inject
   private TypeHelpers typeHelpers;
   
-  public String getTypedDataDefinition(final Message m) {
-    VarDecl _data = m.getData();
-    String[] _generateArglistAndTypedData = this.generateArglistAndTypedData(_data);
-    return _generateArglistAndTypedData[1];
+  public String getTypedDataDefinition(final EObject msg) {
+    String _xifexpression = null;
+    if ((msg instanceof Message)) {
+      VarDecl _data = ((Message) msg).getData();
+      String[] _generateArglistAndTypedData = this.generateArglistAndTypedData(_data);
+      _xifexpression = _generateArglistAndTypedData[1];
+    } else {
+      _xifexpression = "";
+    }
+    return _xifexpression;
   }
   
   public String getJavaFileName(final RoomClass rc) {
@@ -548,11 +554,18 @@
     return _xblockexpression;
   }
   
-  public String[] generateArglistAndTypedData(final VarDecl data) {
-    boolean _equals = Objects.equal(data, null);
+  public String[] generateArglistAndTypedData(final EObject d) {
+    boolean _or = false;
+    boolean _equals = Objects.equal(d, null);
     if (_equals) {
+      _or = true;
+    } else {
+      _or = (!(d instanceof VarDecl));
+    }
+    if (_or) {
       return ((String[])Conversions.unwrapArray(CollectionLiterals.<String>newArrayList("", "", ""), String.class));
     }
+    final VarDecl data = ((VarDecl) d);
     RefableType _refType = data.getRefType();
     DataType _type = _refType.getType();
     String typeName = _type.getName();
diff --git a/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/OptionalActorInterfaceGen.java b/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/OptionalActorInterfaceGen.java
index 077fdad..59db7ab 100644
--- a/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/OptionalActorInterfaceGen.java
+++ b/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/OptionalActorInterfaceGen.java
@@ -168,21 +168,21 @@
               _builder.append(" = new ReplicatedInterfaceItemBroker(this, \"");
               String _name_3 = ep_1.getName();
               _builder.append(_name_3, "\t\t");
-              _builder.append("\", IFITEM_");
-              String _name_4 = ep_1.getName();
-              _builder.append(_name_4, "\t\t");
+              _builder.append("\", ");
+              String _ifItemId = this.getIfItemId(ep_1);
+              _builder.append(_ifItemId, "\t\t");
               _builder.append(");");
               _builder.newLineIfNotEmpty();
             } else {
               _builder.append("\t\t");
+              String _name_4 = ep_1.getName();
+              _builder.append(_name_4, "\t\t");
+              _builder.append(" = new InterfaceItemBroker(this, \"");
               String _name_5 = ep_1.getName();
               _builder.append(_name_5, "\t\t");
-              _builder.append(" = new InterfaceItemBroker(this, \"");
-              String _name_6 = ep_1.getName();
-              _builder.append(_name_6, "\t\t");
-              _builder.append("\", IFITEM_");
-              String _name_7 = ep_1.getName();
-              _builder.append(_name_7, "\t\t");
+              _builder.append("\", ");
+              String _ifItemId_1 = this.getIfItemId(ep_1);
+              _builder.append(_ifItemId_1, "\t\t");
               _builder.append(");");
               _builder.newLineIfNotEmpty();
             }
diff --git a/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/StateMachineGen.java b/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/StateMachineGen.java
index b3c107f..a1c6dcf 100644
--- a/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/StateMachineGen.java
+++ b/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/StateMachineGen.java
@@ -14,8 +14,10 @@
 import com.google.inject.Singleton;
 import java.util.ArrayList;
 import java.util.List;
+import org.eclipse.etrice.core.fsm.fSM.ModelComponent;
 import org.eclipse.etrice.core.fsm.fSM.State;
 import org.eclipse.etrice.core.genmodel.etricegen.ExpandedActorClass;
+import org.eclipse.etrice.core.genmodel.fsm.fsmgen.ExpandedModelComponent;
 import org.eclipse.etrice.core.room.ActorClass;
 import org.eclipse.etrice.generator.generic.GenericStateMachineGenerator;
 import org.eclipse.etrice.generator.java.Main;
@@ -25,20 +27,20 @@
 @Singleton
 @SuppressWarnings("all")
 public class StateMachineGen extends GenericStateMachineGenerator {
-  public CharSequence genExtra(final ExpandedActorClass xpac) {
+  public CharSequence genExtra(final ExpandedModelComponent xpac) {
     CharSequence _xblockexpression = null;
     {
       final ArrayList<State> states = new ArrayList<State>();
-      ActorClass ac = xpac.getActorClass();
+      ModelComponent ac = xpac.getModelComponent();
       boolean _notEquals = (!Objects.equal(ac, null));
       boolean _while = _notEquals;
       while (_while) {
         {
-          List<State> _allBaseStates = this._roomHelpers.getAllBaseStates(ac);
-          List<State> _leafStatesLast = this._roomExtensions.getLeafStatesLast(_allBaseStates);
+          List<State> _allBaseStates = this._fSMHelpers.getAllBaseStates(ac);
+          List<State> _leafStatesLast = this._fSMExtensions.getLeafStatesLast(_allBaseStates);
           states.addAll(0, _leafStatesLast);
-          ActorClass _actorBase = ac.getActorBase();
-          ac = _actorBase;
+          ModelComponent _base = ac.getBase();
+          ac = _base;
         }
         boolean _notEquals_1 = (!Objects.equal(ac, null));
         _while = _notEquals_1;
@@ -158,7 +160,7 @@
   
   public int getHistorySize(final ExpandedActorClass xpac) {
     ActorClass _actorClass = xpac.getActorClass();
-    List<State> _allBaseStates = this._roomHelpers.getAllBaseStates(_actorClass);
+    List<State> _allBaseStates = this._fSMHelpers.getAllBaseStates(_actorClass);
     int _size = _allBaseStates.size();
     return (_size + 2);
   }
diff --git a/plugins/org.eclipse.etrice.generator.ui/.settings/org.eclipse.core.resources.prefs b/plugins/org.eclipse.etrice.generator.ui/.settings/org.eclipse.core.resources.prefs
new file mode 100644
index 0000000..1a9b29c
--- /dev/null
+++ b/plugins/org.eclipse.etrice.generator.ui/.settings/org.eclipse.core.resources.prefs
@@ -0,0 +1,2 @@
+eclipse.preferences.version=1
+encoding/<project>=cp1252
diff --git a/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/base/AbstractGenerator.java b/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/base/AbstractGenerator.java
index caa3a3a..77a4bc3 100644
--- a/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/base/AbstractGenerator.java
+++ b/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/base/AbstractGenerator.java
@@ -39,6 +39,7 @@
 import org.eclipse.etrice.generator.fsm.base.ILineOutputLogger;
 import org.eclipse.etrice.generator.fsm.base.IncrementalGenerationFileIo;
 import org.eclipse.etrice.generator.fsm.base.StdLineOutput;
+import org.eclipse.etrice.generator.fsm.generic.IDetailCodeTranslator;
 import org.eclipse.etrice.generator.generic.RoomExtensions;
 import org.eclipse.xtext.diagnostics.Severity;
 import org.eclipse.xtext.util.CancelIndicator;
@@ -67,7 +68,7 @@
  * @author Henrik Rentz-Reichert
  *
  */
-public abstract class AbstractGenerator {
+public abstract class AbstractGenerator implements IDetailCodeTranslator {
 	
 	public static final String OPTION_LIB = "-lib";
 	public static final String OPTION_NOEXIT = "-noexit";
diff --git a/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/base/AbstractGeneratorBaseModule.java b/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/base/AbstractGeneratorBaseModule.java
index 1baa336..95e9f10 100644
--- a/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/base/AbstractGeneratorBaseModule.java
+++ b/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/base/AbstractGeneratorBaseModule.java
@@ -19,6 +19,12 @@
 import org.eclipse.etrice.generator.fsm.base.Diagnostician;
 import org.eclipse.etrice.generator.fsm.base.ILineOutputLogger;
 import org.eclipse.etrice.generator.fsm.base.Logger;
+import org.eclipse.etrice.generator.fsm.generic.IDetailCodeTranslator;
+import org.eclipse.etrice.generator.fsm.generic.IIfItemIdGenerator;
+import org.eclipse.etrice.generator.fsm.generic.ILanguageExtensionBase;
+import org.eclipse.etrice.generator.fsm.generic.IMessageIdGenerator;
+import org.eclipse.etrice.generator.generic.GenericActorClassGenerator;
+import org.eclipse.etrice.generator.generic.GenericProtocolClassGenerator;
 import org.eclipse.etrice.generator.generic.ILanguageExtension;
 import org.eclipse.xtext.parser.IEncodingProvider;
 import org.eclipse.xtext.resource.XtextResourceSet;
@@ -61,6 +67,13 @@
 		
 		binder.bind(IEncodingProvider.class).to(IEncodingProvider.Runtime.class);
 
+		binder.bind(IMessageIdGenerator.class).to(GenericProtocolClassGenerator.class);
+		binder.bind(IIfItemIdGenerator.class).to(GenericActorClassGenerator.class);
+		
+		binder.bind(IDetailCodeTranslator.class).to(AbstractGenerator.class);
+		
+		binder.bind(ILanguageExtensionBase.class).to(ILanguageExtension.class);
+		
 		if (bindILanguageExtension()!=null)
 			binder.bind(ILanguageExtension.class).to(bindILanguageExtension());
 		if (bindITranslationProvider()!=null)
diff --git a/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/generic/GenericActorClassGenerator.xtend b/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/generic/GenericActorClassGenerator.xtend
index ca16152..4e89493 100644
--- a/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/generic/GenericActorClassGenerator.xtend
+++ b/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/generic/GenericActorClassGenerator.xtend
@@ -21,12 +21,14 @@
 import org.eclipse.etrice.core.room.util.RoomHelpers
 import static extension org.eclipse.etrice.generator.fsm.base.Indexed.*
 import org.eclipse.etrice.core.room.ActorClass
+import org.eclipse.etrice.generator.fsm.generic.IIfItemIdGenerator
+import org.eclipse.etrice.core.fsm.fSM.AbstractInterfaceItem
 
 /**
  * Target language independent part of an actor class generator.
  * It uses the {@link ILanguageExtension}.
  */
-class GenericActorClassGenerator {
+class GenericActorClassGenerator implements IIfItemIdGenerator {
 
 	@Inject protected extension RoomHelpers
 	@Inject protected extension RoomExtensions
@@ -50,13 +52,13 @@
 			
 		val list = new ArrayList<Pair<String, String>>()
 		for (ep : endPorts) {
-			list.add(pair("IFITEM_"+ep.name, (1+xpac.getInterfaceItemLocalId(ep)).toString))
+			list.add(pair(ep.ifItemId, (1+xpac.getInterfaceItemLocalId(ep)).toString))
 		}
 		for (sap : strSAPs) {
-			list.add(pair("IFITEM_"+sap.name, (1+xpac.getInterfaceItemLocalId(sap)).toString))
+			list.add(pair(sap.ifItemId, (1+xpac.getInterfaceItemLocalId(sap)).toString))
 		}
 		for (svc : svcImpls) {
-			list.add(pair("IFITEM_"+svc.spp.name, (1+xpac.getInterfaceItemLocalId(svc.spp)).toString))
+			list.add(pair(svc.spp.ifItemId, (1+xpac.getInterfaceItemLocalId(svc.spp)).toString))
 		}
 		
 		return langExt.genEnumeration("interface_items", list)
@@ -66,9 +68,14 @@
 		val ports = ac.allInterfacePorts
 		val list = new ArrayList<Pair<String, String>>()
 		for (ep : ports.indexed) {
-			list.add(pair("IFITEM_"+ep.value.name, ep.index1.toString))
+			list.add(pair(ep.value.ifItemId, ep.index1.toString))
 		}
 		
 		return langExt.genEnumeration("interface_items", list)
 	}
+    
+    override getIfItemId(AbstractInterfaceItem item) {
+        "IFITEM_"+item.name
+    }
+
 }
\ No newline at end of file
diff --git a/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/generic/GenericProtocolClassGenerator.xtend b/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/generic/GenericProtocolClassGenerator.xtend
index 119e78b..5a69fda 100644
--- a/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/generic/GenericProtocolClassGenerator.xtend
+++ b/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/generic/GenericProtocolClassGenerator.xtend
@@ -25,11 +25,12 @@
 import org.eclipse.xtext.util.Pair
 import static org.eclipse.xtext.util.Tuples.*
 import org.eclipse.etrice.core.room.util.RoomHelpers
+import org.eclipse.etrice.generator.fsm.generic.IMessageIdGenerator
 
 /**
  * Target language independent protocol class generator.
  */
-class GenericProtocolClassGenerator {
+class GenericProtocolClassGenerator implements IMessageIdGenerator {
 
 	@Inject protected extension RoomHelpers
 	@Inject protected extension ILanguageExtension
@@ -64,7 +65,7 @@
 	 * @param mif a {@link MessageFromIf}
 	 * @return an identifier for the message
 	 */
-	def getMessageID(MessageFromIf mif) {
+	override getMessageID(MessageFromIf mif) {
 		return getMessageID(mif.message as Message, mif.from as InterfaceItem)
 	}
 	
diff --git a/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/generic/GenericStateMachineGenerator.xtend b/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/generic/GenericStateMachineGenerator.xtend
index 3749793..3ddb025 100644
--- a/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/generic/GenericStateMachineGenerator.xtend
+++ b/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/generic/GenericStateMachineGenerator.xtend
@@ -12,597 +12,130 @@
 
 package org.eclipse.etrice.generator.generic
 
-import com.google.inject.Inject
-import java.util.ArrayList
-import java.util.List
-import org.eclipse.etrice.core.genmodel.fsm.fsmgen.ActiveTrigger
-import org.eclipse.etrice.core.genmodel.etricegen.ExpandedActorClass
-import org.eclipse.etrice.core.genmodel.fsm.fsmgen.ExpandedRefinedState
-import org.eclipse.etrice.core.genmodel.etricegen.util.ETriceGenUtil
 import org.eclipse.etrice.core.fsm.fSM.ComponentCommunicationType
 import org.eclipse.etrice.core.fsm.fSM.GuardedTransition
 import org.eclipse.etrice.core.fsm.fSM.NonInitialTransition
 import org.eclipse.etrice.core.fsm.fSM.State
 import org.eclipse.etrice.core.fsm.fSM.Transition
-import org.eclipse.etrice.core.fsm.fSM.TransitionPoint
 import org.eclipse.etrice.core.fsm.fSM.TriggeredTransition
-import org.eclipse.etrice.core.room.util.RoomHelpers
-import org.eclipse.etrice.generator.base.AbstractGenerator
-import org.eclipse.etrice.generator.base.CodegenHelpers
-import org.eclipse.xtext.util.Pair
-
-import static org.eclipse.xtext.util.Tuples.*
-import org.eclipse.etrice.core.room.Message
+import org.eclipse.etrice.core.genmodel.fsm.fsmgen.ExpandedModelComponent
+import org.eclipse.etrice.core.genmodel.fsm.fsmgen.ExpandedRefinedState
+import org.eclipse.etrice.generator.fsm.generic.AbstractStateMachineGenerator
 
 /**
  * A target language independent generator of the state machine implementation-
  */
-class GenericStateMachineGenerator {
-
-	@Inject protected extension RoomHelpers
-	@Inject protected extension ETriceGenUtil
-	@Inject protected extension CodegenHelpers
-	@Inject protected extension RoomExtensions
-	@Inject protected ILanguageExtension langExt
-	@Inject protected GenericProtocolClassGenerator pcGen
-	@Inject protected TransitionChainGenerator transitionChainGenerator
-
-	/**
-	 * generates state ID constants.
-	 * Inheritance (if available) is used for base class IDs.
-	 * 
-	 * @param xpac the {@link ExpandedActorClass}
-	 * @return the generated code
-	 */
-	def protected genStateIdConstants(ExpandedActorClass xpac) {
-		val ac = xpac.actorClass
-		// with inheritance we exclude inherited base states
-		var offset = 2 + if (langExt.usesInheritance)
-			ac.getNumberOfInheritedBaseStates() else 0
-		var baseStates = if (langExt.usesInheritance)
-			ac.stateMachine.getBaseStateList else xpac.stateMachine.getBaseStateList
-		
-		baseStates = baseStates.leafStatesLast
-		
-		var list = new ArrayList<Pair<String, String>>()
-		if (!langExt.usesInheritance) {
-			list.add(pair("NO_STATE","0"))
-			list.add(pair("STATE_TOP","1"))
-		}
-		for (state : baseStates) {
-			list.add(pair(state.getGenStateId, offset.toString))
-			offset = offset+1;
-		}
-		list.add(pair("STATE_MAX", offset.toString))
-		
-		return langExt.genEnumeration("state_ids", list)
-	}
-	
-	/**
-	 * generates transition chain ID constants.
-	 * Inheritance (if available) is used for base class IDs.
-	 * 
-	 * @param xpac the {@link ExpandedActorClass}
-	 * @return the generated code
-	 */
-	def protected genTransitionChainConstants(ExpandedActorClass xpac) {
-		var chains = if (langExt.usesInheritance)
-			xpac.getOwnTransitionChains() else xpac.transitionChains
-		var offset = if (langExt.usesInheritance)
-			xpac.getTransitionChains().size-chains.size else 0
-
-		var list = new ArrayList<Pair<String, String>>()
-		for (chain : chains) {
-			offset = offset+1;
-			list.add(pair(chain.genChainId, offset.toString))
-		}
-		
-		return langExt.genEnumeration("chain_ids", list)
-	}
-	
-	/**
-	 * generates trigger IDs.
-	 * Inheritance (if available) is used for base class IDs.
-	 * 
-	 * @param xpac the {@link ExpandedActorClass}
-	 * @return the generated code
-	 */
-	def protected genTriggerConstants(ExpandedActorClass xpac) {
-		val triggers = if (langExt.usesInheritance)
-					xpac.actorClass.ownMessagesFromInterfaces
-					else xpac.actorClass.allMessagesFromInterfaces
-		
-		val list = new ArrayList<Pair<String, String>>()
-		list.add(pair("POLLING", "0"));
-		for (mif : triggers) {
-			list.add(pair(xpac.getTriggerCodeName(mif), "IFITEM_"+mif.from.name+" + EVT_SHIFT*"+pcGen.getMessageID(mif)))
-		}
-		
-		return langExt.genEnumeration("triggers", list)
-	}
+class GenericStateMachineGenerator extends AbstractStateMachineGenerator {
 	
 	/**
 	 * generates the code of the whole state machine
 	 * 
-	 * @param xpac the {@link ExpandedActorClass}
+	 * @param xpmc the {@link ExpandedModelComponent}
 	 * @return the generated code
 	 * 
 	 * @see #genStateMachine
 	 */
-	def genStateMachine(ExpandedActorClass xpac) {
-		xpac.genStateMachine(true)
+	def genStateMachine(ExpandedModelComponent xpmc) {
+		xpmc.genStateMachine(true)
 	}
 	
 	/**
 	 * generates the code of the whole state machine
 	 * 
-	 * @param xpac the {@link ExpandedActorClass}
+	 * @param xpmc the {@link ExpandedModelComponent}
 	 * @param shallGenerateOneFile if <code>true</code> the generation of state IDs and
 	 * 		other constants is skipped (and left for the header file)
 	 * @return the generated code
 	 */
-	def genStateMachine(ExpandedActorClass xpac, boolean shallGenerateOneFile) {
-		val ac = xpac.actorClass
-		val async = ac.commType==ComponentCommunicationType::ASYNCHRONOUS
-		val eventDriven = ac.commType==ComponentCommunicationType::EVENT_DRIVEN
-		val handleEvents = async || eventDriven
-		val opScope = langExt.operationScope(ac.name, false)
-		val opScopePriv = if (langExt.usesInheritance)
-							opScope
-						else
-							""
-		val publicIf = if (langExt.usesInheritance)
-				langExt.accessLevelPublic
-			else
-				langExt.accessLevelPrivate
-		val privAccess = langExt.accessLevelPrivate
-		val selfPtr = langExt.selfPointer(ac.name, true)
-		val selfOnly = langExt.selfPointer(ac.name, false)
-		val getLocalId = 	if (langExt.usesInheritance) {
-								if (langExt.usesPointers)
-									"->getLocalId()"
-								else
-									".getLocalId()"
-							}
-							else
-								"->localId"
-		val ifItemPtr = "InterfaceItemBase"+langExt.pointerLiteral()
-		val constIfItemPtr = if (langExt.usesPointers)
-								"const "+ifItemPtr
-							else
-								ifItemPtr
-		val usesHdlr = usesHandlerTrPoints(xpac)
+	def genStateMachine(ExpandedModelComponent xpmc, boolean shallGenerateOneFile) {
 		
 	'''
 		«IF shallGenerateOneFile»
-		/* state IDs */
-		«xpac.genStateIdConstants»
-		
-		/* transition chains */
-		«xpac.genTransitionChainConstants»
-		
-		/* triggers */
-		«xpac.genTriggerConstants»
+			/* state IDs */
+			«xpmc.genStateIdConstants»
+			
+			/* transition chains */
+			«xpmc.genTransitionChainConstants»
+			
+			/* triggers */
+			«xpmc.genTriggerConstants»
 		«ENDIF»
 
-		«genExtra(xpac)»
+		«genExtra(xpmc)»
 		
 		/* Entry and Exit Codes */
-		«FOR state : xpac.stateMachine.getStateList()»
-			«IF !langExt.usesInheritance || xpac.isOwnObject(state)»
-				«xpac.genActionCodeMethods(state)»
-			«ENDIF»
-		«ENDFOR»
+        «xpmc.genEntryAndExitCodes(true)»
 		
 		/* Action Codes */
-		«FOR tr : xpac.stateMachine.allTransitionsRecursive»
-			«IF (!langExt.usesInheritance || xpac.isOwnObject(tr)) && tr.action.hasDetailCode»
-				«var start = xpac.getChain(tr)?.getTransition»
-				«var hasArgs = start instanceof NonInitialTransition && !(start instanceof GuardedTransition)»
-				«langExt.accessLevelProtected»void «opScopePriv»«tr.getActionCodeOperationName()»(«langExt.selfPointer(ac.name, hasArgs)»«IF hasArgs»«constIfItemPtr» ifitem«transitionChainGenerator.generateArgumentList(xpac, tr)»«ENDIF») {
-					«AbstractGenerator::getInstance().getTranslatedCode(tr.action)»
-				}
-			«ENDIF»
-		«ENDFOR»
+        «xpmc.genActionCodes(true)»
 		
-		/**
-		 * calls exit codes while exiting from the current state to one of its
-		 * parent states while remembering the history
-		 * @param current__et - the current state
-		 * @param to - the final parent state
-		 «IF usesHdlr»
-		 * @param handler__et - entry and exit codes are called only if not handler (for handler TransitionPoints)
-		 «ENDIF»
-		 */
-		«privAccess»void «opScopePriv»exitTo(«selfPtr»«stateType» current__et, «stateType» to«IF usesHdlr», «boolType» handler__et«ENDIF») {
-			while (current__et!=to) {
-				switch (current__et) {
-					«FOR state : xpac.stateMachine.getBaseStateList()»
-						case «state.getGenStateId()»:
-							«IF state.hasExitCode(true)»«IF usesHdlr»if (!handler__et) «ENDIF»«state.getExitCodeOperationName()»(«langExt.selfPointer(false)»);«ENDIF»
-							«setHistory(state.getParentStateId(), state.getGenStateId())»;
-							current__et = «state.getParentStateId()»;
-							break;
-					«ENDFOR»
-					default:
-						/* should not occur */
-						break;
-				}
-			}
-		}
-		
-		/**
-		 * calls action, entry and exit codes along a transition chain. The generic data are cast to typed data
-		 * matching the trigger of this chain. The ID of the final state is returned
-		 * @param chain__et - the chain ID
-		 * @param generic_data__et - the generic data pointer
-		 * @return the +/- ID of the final state either with a positive sign, that indicates to execute the state's entry code, or a negative sign vice versa
-		 */
-		«privAccess»«stateType» «opScopePriv»executeTransitionChain(«selfPtr»int chain__et«IF handleEvents», «constIfItemPtr» ifitem, «langExt.voidPointer» generic_data__et«ENDIF») {
-			switch (chain__et) {
-				«var allchains = xpac.getTransitionChains()»
-				«FOR tc : allchains»
-					case «tc.genChainId»:
-					{
-						«transitionChainGenerator.generateExecuteChain(xpac, tc)»
-					}
-				«ENDFOR»
-					default:
-						/* should not occur */
-						break;
-			}
-			return NO_STATE;
-		}
-		
-		/**
-		 * calls entry codes while entering a state's history. The ID of the final leaf state is returned
-		 * @param state__et - the state which is entered
-		 «IF usesHdlr»
-		 * @param handler__et - entry code is executed if not handler
-		 «ENDIF»
-		 * @return - the ID of the final leaf state
-		 */
-		«privAccess»«stateType» «opScopePriv»enterHistory(«selfPtr»«stateType» state__et«IF usesHdlr», «boolType» handler__et«ENDIF») {
-			«boolType» skip_entry__et = «langExt.booleanConstant(false)»;
-			if (state__et >= STATE_MAX) {
-				state__et = «IF !langExt.usesInheritance»(«stateType»)«ENDIF» (state__et - STATE_MAX);
-				skip_entry__et = «langExt.booleanConstant(true)»;
-			}
-			while («langExt.booleanConstant(true)») {
-				switch (state__et) {
-					«FOR state : xpac.stateMachine.getBaseStateList()»
-					case «state.getGenStateId()»:
-						«IF state.hasEntryCode(true)»if (!(skip_entry__et«IF usesHdlr» || handler__et«ENDIF»)) «state.getEntryCodeOperationName()»(«langExt.selfPointer(false)»);«ENDIF»
-						«IF state.isLeaf()»
-							/* in leaf state: return state id */
-							return «state.getGenStateId()»;
-						«ELSE»
-							/* state has a sub graph */
-							«IF state.subgraph.hasInitTransition()»
-								/* with init transition */
-								if («getHistory(state.getGenStateId())»==NO_STATE) {
-									«var sub_initt = state.subgraph.getInitTransition()»
-									state__et = executeTransitionChain(«langExt.selfPointer(true)»«xpac.getChain(sub_initt).genChainId»«IF handleEvents», «langExt.nullPointer», «langExt.nullPointer»«ENDIF»);
-								}
-								else {
-									state__et = «getHistory(state.getGenStateId())»;
-								}
-							«ELSE»
-								/* without init transition */
-								state__et = «getHistory(state.getGenStateId())»;
-							«ENDIF»
-							break;
-						«ENDIF»
-					«ENDFOR»
-					case STATE_TOP:
-						state__et = «getHistory("STATE_TOP")»;
-						break;
-					default:
-						/* should not occur */
-						break;
-				}
-				skip_entry__et = «langExt.booleanConstant(false)»;
-			}
-			«unreachableReturn»
-		}
-		
-		«publicIf»void «opScope»executeInitTransition(«selfOnly») {
-			«var initt = xpac.stateMachine.getInitTransition()»
-			int chain__et = «xpac.getChain(initt).genChainId»;
-			«stateType» next__et = «opScopePriv»executeTransitionChain(«langExt.selfPointer(true)»chain__et«IF handleEvents», «langExt.nullPointer», «langExt.nullPointer»«ENDIF»);
-			next__et = «opScopePriv»enterHistory(«langExt.selfPointer(true)»next__et«IF usesHdlr», «langExt.booleanConstant(false)»«ENDIF»);
-			setState(«langExt.selfPointer(true)»next__et);
-		}
-		
-		/* receiveEvent contains the main implementation of the FSM */
-		«publicIf»void «opScope»receiveEvent(«langExt.selfPointer(ac.name, handleEvents)»«IF handleEvents»«ifItemPtr» ifitem, int evt, «langExt.voidPointer» generic_data__et«ENDIF») {
-			«IF async»
-				int trigger__et = (ifitem==«langExt.nullPointer»)? POLLING : ifitem«getLocalId» + EVT_SHIFT*evt;
-			«ELSEIF eventDriven»
-				int trigger__et = ifitem«getLocalId» + EVT_SHIFT*evt;
-			«ENDIF»
-			int chain__et = NOT_CAUGHT;
-			«stateType» catching_state__et = NO_STATE;
-			«IF usesHdlr»
-			«boolType» is_handler__et = «langExt.booleanConstant(false)»;
-			«ENDIF»
-			«IF async || eventDriven»
-				«markVariableUsed("trigger__et")»
-			«ENDIF»
-			
-			«IF handleEvents»
-				if (!handleSystemEvent(ifitem, evt, generic_data__et)) {
-					«genStateSwitch(xpac, usesHdlr)»
-				}
-			«ELSE»
-				«genStateSwitch(xpac, usesHdlr)»
-			«ENDIF»
-			if (chain__et != NOT_CAUGHT) {
-				«opScopePriv»exitTo(«langExt.selfPointer(true)»getState(«langExt.selfPointer(false)»), catching_state__et«IF usesHdlr», is_handler__et«ENDIF»);
-				{
-					«stateType» next__et = «opScopePriv»executeTransitionChain(«langExt.selfPointer(true)»chain__et«IF handleEvents», ifitem, generic_data__et«ENDIF»);
-					next__et = «opScopePriv»enterHistory(«langExt.selfPointer(true)»next__et«IF usesHdlr», is_handler__et«ENDIF»);
-					setState(«langExt.selfPointer(true)»next__et);
-					«finalAction()»
-				}
-			}
-		}
+		/* State Switch Methods */
+		«xpmc.genStateSwitchMethods(true)»
 	'''}
-	
-	/**
-	 * empty, but may be overridden
-	 */
-	def finalAction() {
-		''''''
-	}
-
-	/**
-	 * empty, but may be overridden
-	 */
-	def markVariableUsed(String varname) {
-		''''''
-	}
-	
-	/**
-	 * helper method which generates the state switch.
-	 * Asynchronous, data driven and event driven state machines are distinguished
-	 * 
-	 * @param xpac the {@link ExpandedActorClass}
-	 * @param usesHdlr if the state machine uses no handler {@link TransitionPoint}s
-	 * 		at all then unused variables can be avoided by passing <code>true</code> 
-	 * @return the generated code
-	 */
-	def protected genStateSwitch(ExpandedActorClass xpac, boolean usesHdlr) {
-		var async = xpac.actorClass.commType==ComponentCommunicationType::ASYNCHRONOUS
-		var eventDriven = xpac.actorClass.commType==ComponentCommunicationType::EVENT_DRIVEN
-		var dataDriven = xpac.actorClass.commType==ComponentCommunicationType::DATA_DRIVEN
-		'''
-			switch (getState(«langExt.selfPointer(false)»)) {
-				«FOR state : xpac.stateMachine.getLeafStateList()»
-				case «state.getGenStateId()»:
-					«IF async»
-						«var atlist =  xpac.getActiveTriggers(state)»
-						«IF !atlist.isEmpty»
-							switch(trigger__et) {
-								case POLLING:
-									«genDataDrivenTriggers(xpac, state, usesHdlr)»
-									break;
-								«genEventDrivenTriggers(xpac, state, atlist, usesHdlr)»
-							}
-						«ELSE»
-								«genDataDrivenTriggers(xpac, state, usesHdlr)»
-						«ENDIF»
-					«ELSEIF dataDriven»
-							«genDataDrivenTriggers(xpac, state, usesHdlr)»
-					«ELSEIF eventDriven»
-						«var atlist =  xpac.getActiveTriggers(state)»
-						«IF !atlist.isEmpty»
-							switch(trigger__et) {
-									«genEventDrivenTriggers(xpac, state, atlist, usesHdlr)»
-							}
-						«ENDIF»
-					«ENDIF»
-					break;
-				«ENDFOR»
-				default:
-					/* should not occur */
-					break;
-			}
-		'''
-	}
-	
-	/**
-	 * helper method which generates the data driven triggers
-	 * 
-	 * @param xpac the {@link ExpandedActorClass}
-	 * @param state the {@link State} for which the trigger if-else switch should be generated
-	 * @param usesHdlr if the state machine uses no handler {@link TransitionPoints}
-	 * 		at all then unused variables can be avoided by passing <code>true</code> 
-	 * @return the generated code
-	 */
-	def protected genDataDrivenTriggers(ExpandedActorClass xpac, State state, boolean usesHdlr) {
-		'''
-			«genDoCodes(state)»
-			«var transitions = xpac.getOutgoingTransitionsHierarchical(state).filter(t|t instanceof GuardedTransition)»
-			«FOR tr : transitions»
-				if («AbstractGenerator::getInstance().getTranslatedCode((tr as GuardedTransition).guard)»)
-				{
-					«var chain = xpac.getChain(tr)»
-					chain__et = «chain.genChainId»;
-					catching_state__et = «chain.stateContext.genStateId»;
-					«IF chain.isHandler() && usesHdlr»
-						is_handler__et = ET_TRUE;
-					«ENDIF»
-				}
-				«IF tr!=transitions.last»
-					else 
-				«ENDIF»
-			«ENDFOR»
-		'''
-	}
-	
-	/**
-	 * helper method which generates the event driven triggers
-	 * 
-	 * @param xpac the {@link ExpandedActorClass}
-	 * @param state the {@link State} for which the trigger switch should be generated
-	 * @param atlist the list of {@link ActiveTrigger}s of this state
-	 * @param usesHdlr if the state machine uses no handler {@link TransitionPoints}
-	 * 		at all then unused variables can be avoided by passing <code>true</code> 
-	 * @return the generated code
-	 */
-	def protected genEventDrivenTriggers(ExpandedActorClass xpac, State state, List<ActiveTrigger> atlist, boolean usesHdlr) {
-		'''
-			«FOR at : atlist»
-				case «xpac.getTriggerCodeName(at)»:
-					«var needData = at.hasGuard»
-					«IF needData»{ «langExt.getTypedDataDefinition(at.msg as Message)»«ENDIF»
-					«FOR tt : at.transitions SEPARATOR " else "»
-						«var chain = xpac.getChain(tt)»
-						«guard(chain.getTransition, at.trigger, xpac)»
-						{
-							chain__et = «chain.genChainId»;
-							catching_state__et = «chain.stateContext.genStateId»;
-							«IF chain.isHandler() && usesHdlr»
-								is_handler__et = «langExt.booleanConstant(true)»;
-							«ENDIF»
-						}
-					«ENDFOR»
-					«IF needData»}«ENDIF»
-				break;
-			«ENDFOR»
-			default:
-				/* should not occur */
-				break;
-		'''
-	}
-	
-	/**
-	 * getter for history array
-	 * 
-	 * @param state the ID of the history state
-	 * @return the generated code
-	 */
-	def protected getHistory(String state) {
-		langExt.memberAccess+"history["+state+"]"
-	}
-
-	/**
-	 * setter for history array
-	 * 
-	 * @param state the ID of the state whose history should be set
-	 * @param historyState the ID of the state that should be assigned
-	 * @return the generated code
-	 */
-	def protected setHistory(String state, String historyState) {
-		langExt.memberAccess+"history["+state+"] = "+historyState
-	}
-	
-	/**
-	 * @return the type of (temporary) state variables (defaults to "int")
-	 * and has to be signed
-	 */
-	def protected stateType() {
-		"int"
-	}
-
-	/**
-	 * allow target language dependent generation of unreachable return in generated enterHistory method.
-	 * The default is just a comment.
-	 * @return the generated code
-	 */	
-	def protected unreachableReturn() {
-		"/* return NO_STATE; // required by CDT but detected as unreachable by JDT because of while (true) */"
-	}
-
-	/**
-	 * type of (temporary) boolean variables (defaults to "boolean")
-	 * @return the generated code
-	 */
-	def protected boolType() {
-		return "boolean"
-	}
-	
-	/**
-	 * let derived class add extra code after definition of constants
-	 * 
-	 * @param xpac an expanded actor class
-	 * @return the generated code
-	 */
-	def protected genExtra(ExpandedActorClass xpac) {''''''}
-	
-	/**
-	 * let derived class add extra code after definition of constants in header (if applicable)
-	 * 
-	 * @param xpac an expanded actor class
-	 * @return the generated code
-	 */
-	def protected genExtraDecl(ExpandedActorClass xpac) {''''''}
 
 	/**
 	 * generate a transition guard if applicable
 	 * 
 	 * @param tt a {@link TriggeredTransition}
 	 * @param trigger a trigger string
-	 * @param xpac an expanded actor class
+	 * @param xpmc an expanded actor class
 	 * @return the generated code
 	 */	
-	def protected dispatch guard(TriggeredTransition tt, String trigger, ExpandedActorClass ac) {
-		val tr = tt.triggers.findFirst(e|ac.isMatching(e, trigger))
+	override String guard(TriggeredTransition tt, String trigger, ExpandedModelComponent mc) {
+		val tr = tt.triggers.findFirst(e|mc.isMatching(e, trigger))
 	'''
 		«IF tr.hasGuard()»
-			if («AbstractGenerator::getInstance().getTranslatedCode(tr.guard.guard)»)
+			if («translator.getTranslatedCode(tr.guard.guard)»)
 		«ENDIF»
 	'''
 	}
-
-	/**
-	 * (necessary for completeness of the dispatching, never called)
-	 */
-	def protected dispatch guard(Transition t, String trigger, ExpandedActorClass ac) {
-	'''
-		/* error */
-	'''
-	}
 	
-	/**
-	 * generate the do code calls for a given state
-	 * 
-	 * @param state the {@link State}
-	 * @return the generated code
-	 */
-	def protected String genDoCodes(State state) {'''
-		«IF state.hasDoCode(true)»
-			«state.getDoCodeOperationName()»(«langExt.selfPointer(false)»);
-		«ENDIF»
-		«IF state.eContainer.eContainer instanceof State»
-			«genDoCodes(state.eContainer.eContainer as State)»
-		«ENDIF»
-	'''}
+    override String guard(GuardedTransition tt, String trigger, ExpandedModelComponent mc) {
+        '''
+            «translator.getTranslatedCode(tt.guard)»
+        '''
+    }
 	
-	/**
-	 * generate action code method implementations
-	 * 
-	 * @param xpac the {@link ExpandedActorClass}
-	 * @param state the {@link State}
-	 * @return the generated code
-	 */
-	def protected genActionCodeMethods(ExpandedActorClass xpac, State state) {
-		genActionCodeMethods(xpac, state, true);
+	override String genActionCodeMethod(ExpandedModelComponent xpmc, Transition tr, boolean generateImplementation) {
+        var start = xpmc.getChain(tr)?.getTransition
+        var hasArgs = start instanceof NonInitialTransition && !(start instanceof GuardedTransition)
+        val opScope = langExt.operationScope(xpmc.getClassName, false)
+        val opScopePriv = if (langExt.usesInheritance)
+                            opScope
+                        else
+                            ""
+        val ifItemPtr = "InterfaceItemBase"+langExt.pointerLiteral()
+        val constIfItemPtr = if (langExt.usesPointers)
+                                "const "+ifItemPtr
+                            else
+                                ifItemPtr
+                            
+        if (generateImplementation) {
+    	    '''
+                «langExt.accessLevelProtected»void «opScopePriv»«tr.getActionCodeOperationName()»(«langExt.selfPointer(xpmc.className, hasArgs)»«IF hasArgs»«constIfItemPtr» ifitem«transitionChainGenerator.generateArgumentList(xpmc, tr)»«ENDIF») {
+                    «translator.getTranslatedCode(tr.action)»
+                }
+    	    '''
+        }
+        else {
+            '''
+                «langExt.accessLevelProtected»void «tr.getActionCodeOperationName()»(«langExt.selfPointer(xpmc.className, hasArgs)»«IF hasArgs»«constIfItemPtr» ifitem«transitionChainGenerator.generateArgumentList(xpmc, tr)»«ENDIF»);
+            '''
+        }
 	}
 
 	/**
 	 * generate action code method implementations or declarations
 	 * 
-	 * @param xpax the {@link ExpandedActorClass}
+	 * @param xpax the {@link ExpandedModelComponent}
 	 * @param state the {@link State}
 	 * @param generateImplementation if only declarations should be generated then <code>false</code> has to be passed
 	 * @return the generated code
 	 */
-	def protected genActionCodeMethods(ExpandedActorClass xpac, State state, boolean generateImplementation) {
-		val ac = xpac.actorClass
-		val selfPtr = langExt.selfPointer(xpac.actorClass.name, false)
-		val opScope = langExt.operationScope(ac.name, false)
+	override String genActionCodeMethods(ExpandedModelComponent xpmc, State state, boolean generateImplementation) {
+		val mc = xpmc.modelComponent
+		val selfPtr = langExt.selfPointer(mc.className, false)
+		val opScope = langExt.operationScope(mc.className, false)
 		val opScopePriv = if (langExt.usesInheritance)
 							opScope
 						else
@@ -610,17 +143,17 @@
 		val entryOp = state.getEntryCodeOperationName()
 		val exitOp = state.getExitCodeOperationName()
 		val doOp = state.getDoCodeOperationName()
-		var entry = AbstractGenerator::getInstance().getTranslatedCode(state.entryCode)
-		var exit = AbstractGenerator::getInstance().getTranslatedCode(state.exitCode)
-		var docode = AbstractGenerator::getInstance().getTranslatedCode(state.doCode)
+		var entry = translator.getTranslatedCode(state.entryCode)
+		var exit = translator.getTranslatedCode(state.exitCode)
+		var docode = translator.getTranslatedCode(state.doCode)
 		if (state instanceof ExpandedRefinedState) {
 			val rs = state as ExpandedRefinedState
-			val inhEntry = AbstractGenerator::getInstance().getTranslatedCode(rs.inheritedEntry)
-			val inhExit = AbstractGenerator::getInstance().getTranslatedCode(rs.inheritedExit)
-			val inhDo = AbstractGenerator::getInstance().getTranslatedCode(rs.inheritedDo)
+			val inhEntry = translator.getTranslatedCode(rs.inheritedEntry)
+			val inhExit = translator.getTranslatedCode(rs.inheritedExit)
+			val inhDo = translator.getTranslatedCode(rs.inheritedDo)
 			if (langExt.usesInheritance) {
 				// we call the super method in the generated code
-				val baseName = xpac.actorClass.actorBase.name
+				val baseName = mc.base.className
 				if (rs.inheritedEntry.hasDetailCode)
 					entry = langExt.superCall(baseName, entryOp, "") + entry
 				if (rs.inheritedExit.hasDetailCode)
@@ -638,29 +171,29 @@
 		'''
 		«IF !entry.empty»
 			«IF generateImplementation»
-			«langExt.accessLevelProtected»void «opScopePriv»«entryOp»(«selfPtr») {
-				«entry»
-			}
+				«langExt.accessLevelProtected»void «opScopePriv»«entryOp»(«selfPtr») {
+					«entry»
+				}
 			«ELSE»
-			«langExt.accessLevelProtected»void «entryOp»(«selfPtr»);
+				«langExt.accessLevelProtected»void «entryOp»(«selfPtr»);
 			«ENDIF»
 		«ENDIF»
 		«IF !exit.empty»
 			«IF generateImplementation»
-			«langExt.accessLevelProtected»void «opScopePriv»«exitOp»(«selfPtr») {
-				«exit»
-			}
+				«langExt.accessLevelProtected»void «opScopePriv»«exitOp»(«selfPtr») {
+					«exit»
+				}
 			«ELSE»
-			«langExt.accessLevelProtected»void «exitOp»(«selfPtr»);
+				«langExt.accessLevelProtected»void «exitOp»(«selfPtr»);
 			«ENDIF»
 		«ENDIF»
 		«IF !docode.empty»
 			«IF generateImplementation»
-			«langExt.accessLevelProtected» void «opScopePriv»«doOp»(«selfPtr») {
-				«docode»
-			}
+				«langExt.accessLevelProtected» void «opScopePriv»«doOp»(«selfPtr») {
+					«docode»
+				}
 			«ELSE»
-			«langExt.accessLevelProtected»void «doOp»(«selfPtr»);
+				«langExt.accessLevelProtected»void «doOp»(«selfPtr»);
 			«ENDIF»
 		«ENDIF»
 		'''
@@ -672,53 +205,43 @@
 	 * @param classname the name of the type
 	 * @return the type name for a constant pointer
 	 */
-	def protected constPointer(String classname) {
+	def constPointer(String classname) {
 		return classname	
 	}
 
 	/**
 	 * generate all method declarations
 	 * 
-	 * @param xpax the {@link ExpandedActorClass}
+	 * @param xpax the {@link ExpandedModelComponent}
 	 * @return the generated code
 	 */
-	def genStateMachineMethodDeclarations(ExpandedActorClass xpac)
+	def genStateMachineMethodDeclarations(ExpandedModelComponent xpmc)
 	{
-		val ac = xpac.actorClass
-		val async = ac.commType==ComponentCommunicationType::ASYNCHRONOUS
-		val eventDriven = ac.commType==ComponentCommunicationType::EVENT_DRIVEN
+		val mc = xpmc.modelComponent
+		val async = mc.commType==ComponentCommunicationType::ASYNCHRONOUS
+		val eventDriven = mc.commType==ComponentCommunicationType::EVENT_DRIVEN
 		val handleEvents = async || eventDriven
-		val selfPtr = langExt.selfPointer(ac.name, true)
-		val usesHdlr = usesHandlerTrPoints(xpac)
+		val selfPtr = langExt.selfPointer(mc.className, true)
+		val usesHdlr = usesHandlerTrPoints(xpmc)
 		
 	'''
 		
 		/* state IDs */
-		«xpac.genStateIdConstants»
+		«xpmc.genStateIdConstants»
 		
 		/* transition chains */
-		«xpac.genTransitionChainConstants»
+		«xpmc.genTransitionChainConstants»
 		
 		/* triggers */
-		«xpac.genTriggerConstants»
+		«xpmc.genTriggerConstants»
 
-		«genExtraDecl(xpac)»
+		«genExtraDecl(xpmc)»
 		
 		/* Entry and Exit Codes */
-		«FOR state : xpac.stateMachine.getStateList()»
-			«IF !langExt.usesInheritance || xpac.isOwnObject(state)»
-				«xpac.genActionCodeMethods(state, false)»
-			«ENDIF»
-		«ENDFOR»
+        «xpmc.genEntryAndExitCodes(false)»
 		
 		/* Action Codes */
-		«FOR tr : xpac.stateMachine.allTransitionsRecursive»
-			«IF (!langExt.usesInheritance || xpac.isOwnObject(tr)) && tr.action.hasDetailCode»
-				«var start = xpac.getChain(tr).getTransition»
-				«var hasArgs = start instanceof NonInitialTransition && !(start instanceof GuardedTransition)»
-				«langExt.accessLevelProtected»void «tr.getActionCodeOperationName()»(«langExt.selfPointer(ac.name, hasArgs)»«IF hasArgs»«constPointer("etRuntime::InterfaceItemBase")» ifitem«transitionChainGenerator.generateArgumentList(xpac, tr)»«ENDIF»);
-			«ENDIF»
-		«ENDFOR»
+        «xpmc.genActionCodes(false)»
 		
 		private:
 			/**
@@ -753,23 +276,10 @@
 		
 		public:
 
-			void executeInitTransition(«langExt.selfPointer(ac.name, false)»);
+			void executeInitTransition(«langExt.selfPointer(mc.className, false)»);
 			
 			/* receiveEvent contains the main implementation of the FSM */
-			void receiveEvent(«langExt.selfPointer(ac.name, handleEvents)»«IF handleEvents»etRuntime::InterfaceItemBase* ifitem, int evt, «langExt.voidPointer» generic_data__et«ENDIF»);
+			void receiveEvent(«langExt.selfPointer(mc.className, handleEvents)»«IF handleEvents»etRuntime::InterfaceItemBase* ifitem, int evt, «langExt.voidPointer» generic_data__et«ENDIF»);
 	'''
 	}
-	
-	/**
-	 * helper method to determine whether this state machine uses handler transitions
-	 * points at all
-	 * 
-	 * @param xpax the {@link ExpandedActorClass}
-	 * @return <code>true</code> if the state machine uses handler transition points
-	 */
-	def private usesHandlerTrPoints(ExpandedActorClass xpac) {
-		if (xpac.stateMachine.empty)
-			return false
-		!xpac.stateMachine.allTrPointsRecursive.filter(t|t instanceof TransitionPoint && ((t as TransitionPoint).handler)).empty
-	}
 }
diff --git a/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/generic/ILanguageExtension.java b/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/generic/ILanguageExtension.java
index b32b597..ad1d53a 100644
--- a/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/generic/ILanguageExtension.java
+++ b/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/generic/ILanguageExtension.java
@@ -12,15 +12,11 @@
 
 package org.eclipse.etrice.generator.generic;
 
-import java.util.List;
-
 import org.eclipse.etrice.core.room.DataType;
 import org.eclipse.etrice.core.room.EnumLiteral;
 import org.eclipse.etrice.core.room.EnumerationType;
-import org.eclipse.etrice.core.room.Message;
 import org.eclipse.etrice.core.room.PrimitiveType;
-import org.eclipse.etrice.core.room.VarDecl;
-import org.eclipse.xtext.util.Pair;
+import org.eclipse.etrice.generator.fsm.generic.ILanguageExtensionBase;
 
 
 /**
@@ -31,183 +27,7 @@
  * @author Thomas Schuetz
  * @author Henrik Rentz-Reichert
  */
-public interface ILanguageExtension {
-
-	/**
-	 * This method is called to get a target language specific piece of
-	 * code that defines a typed local variable holding the data passed with
-	 * the message (if applicable). The name of the local variable should
-	 * be that of the message parameter.
-	 * 
-	 * @param m the {@link Message}
-	 * @return the variable definition
-	 */
-	String getTypedDataDefinition(Message m);
-
-	/** 
-	 * unification of access level for all Languages before each member 
-	 * @return e.g. "private " for Java, nothing for C and C++ (no access level before the individual member) 
-	 */
-	String accessLevelPrivate();
-	
-	/** 
-	 * unification of access level for all Languages before each member 
-	 * @return e.g. "protected " for Java, nothing for C and C++ (no access level before the individual member) 
-	 */
-	String accessLevelProtected();
-	
-	/** 
-	 * unification of access level for all Languages before each member 
-	 * @return e.g. "public " for Java, nothing for C and C++ (no access level before the individual member)
-	 */
-	String accessLevelPublic();
-	
-	
-	// Strings for member access
-	
-	/** 
-	 * unification of member access for different languages
-	 * @return e.g. "this." for Java and C++ or "self->" for C
-	 */
-	String memberAccess(); 	 
-	
-	/** 
-	 * self pointer for building class mechanism in C, 
-	 * e.g. MyClass_function1(MyClass *self, int32 argument1)
-	 * @param classname the class name
-	 * @param hasArgs true if functions has further arguments
-	 * @return "classname *self, " for C / for Java and C++ nothing
-	 */
-	String selfPointer(String classname, boolean hasArgs);
-	
-	/**
-	 * self pointer for function calls
-	 * @param hasArgs true if functions has further arguments
-	 * @return "self, " for C / for Java and C++ nothing
-	 */
-	String selfPointer(boolean hasArgs);
-	
-	/** 
-	 * language specific scoping string for operations
-	 * e.g. nothing in Java (only inside class declaration), nothing and classname:: for C++ and classname_ for C
-	 * @param classname the class name
-	 * @param isDeclaration true if it is a declaration
-	 * @return "classname_" for C / for Java and C++ nothing
-	 */
-	String operationScope(String classname, boolean isDeclaration);
-
-	/**
-	 * member declaration
-	 * 
-	 * @param namespace the namespace or class name
-	 * @param member the member name
-	 * @return for C: namespace_member, for Java namespace.member
-	 */
-	String memberInDeclaration(String namespace, String member);
-	
-	/**
-	 * member usage
-	 * 
-	 * @param namespace the namespace or class name
-	 * @param member the member name
-	 * @return for C: namespace_member, for Java namespace.member
-	 */
-	String memberInUse(String namespace, String member);
-	
-	/**
-	 * does the target language offer inheritance
-	 * 
-	 * @return true for C++ and Java, false for C
-	 */
-	boolean usesInheritance();
-	
-	/**
-	 * does the target language use pointers
-	 * 
-	 * @return true for C++ and C, false for Java
-	 */
-	boolean usesPointers();
-	
-	/**
-	 * generate an enumeration (enum in C, int constants in Java)
-	 * @param name the enumeration name
-	 * @param entries a list of name/value pairs
-	 * @return a string defining the enumeration in the target language
-	 */
-	String genEnumeration(String name, List<Pair<String, String>> entries);
-	
-	/**
-	 * literals for boolean constants
-	 * @param b the boolean value
-	 * @return TRUE/FALSE for C/C++, true/false for Java
-	 */
-	String booleanConstant(boolean b);
-	
-
-	/**
-	 *  literal for pointer
-	 * 
-	 * @return * for C/C++, nothing for Java
-	 */
-	String pointerLiteral();
-	
-	
-	/**
-	 * a literal for the null pointer
-	 * 
-	 * @return NULL for C/C++, null for Java
-	 */
-	String nullPointer();
-	
-	/**
-	 * a generic pointer
-	 * 
-	 * @return void* for C/C++, Object for Java
-	 */
-	String voidPointer();
-	
-	/**
-	 * array declarations differ in Java and C/C++
-	 * @param type
-	 * @param size
-	 * @param name
-	 * @return a string that represents the declaration
-	 */
-	String arrayDeclaration(String type, int size, String name, boolean isRef);
-	
-	/**
-	 * name for the constructor (without namespace if applicable)
-	 * 
-	 * @param cls the class name
-	 * @return the constructor name
-	 */
-	String constructorName(String cls);
-	
-	/**
-	 * name for the destructor (without namespace if applicable)
-	 * 
-	 * @param cls the class name
-	 * @return the destructor name
-	 */
-	String destructorName(String cls);
-	
-	/**
-	 * @return a typename for the return type (might be empty)
-	 */
-	String constructorReturnType();
-	
-	/**
-	 * @return a typename for the return type (might be empty)
-	 */
-	String destructorReturnType();
-	
-	/**
-	 * @param baseClassName the name of the base class
-	 * @param method the method to be called
-	 * @param arguments the argument list
-	 * @return super.method for Java, baseClassName::method for C++, empty for C
-	 */
-	String superCall(String baseClassName, String method, String arguments);
+public interface ILanguageExtension extends ILanguageExtensionBase {
 	
 	/**
 	 * Produces necessary casts or data type keys for an attribute (array) value statement
@@ -228,19 +48,6 @@
 	String toEnumLiteral(EnumerationType type, String value);
 	
 	/**
-	 * return three strings used by the generator
-	 * 
-	 * @param data the variable declaration
-	 * @return an array of three strings
-	 * <ol>
-	 *  <li>the string that performs the cast from generic_data to the correct type and assigns it to a new variable</li>
-	 *  <li>the data as it appears in a method call</li>
-	 *  <li>the data as it is used in the method declaration</li>
-	 *  </ol>
-	 */
-	String[] generateArglistAndTypedData(VarDecl data);
-	
-	/**
 	 * returns a default value for a type
 	 * @param dt the data type
 	 * @return the default value string
diff --git a/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/generic/RoomExtensions.xtend b/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/generic/RoomExtensions.xtend
index b4fcec5..3ca104e 100644
--- a/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/generic/RoomExtensions.xtend
+++ b/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/generic/RoomExtensions.xtend
@@ -19,7 +19,6 @@
 import org.eclipse.emf.common.util.BasicEList
 import org.eclipse.emf.common.util.TreeIterator
 import org.eclipse.emf.ecore.EObject
-import org.eclipse.etrice.core.fsm.fSM.State
 import org.eclipse.etrice.core.genmodel.etricegen.AbstractInstance
 import org.eclipse.etrice.core.genmodel.etricegen.InterfaceItemInstance
 import org.eclipse.etrice.core.genmodel.etricegen.PortInstance
@@ -410,36 +409,6 @@
 			return "OUT_"+m.name
 	}
 
-	//-------------------------------------------------------
-	// state graph related methods
-
-	/**
-	 * @param states a list of {@link State}s
-	 * @return a list ordered such that leaf states are last
-	 */
-	def getLeafStatesLast(List<State> states) {
-		val leaf = states.filter(s|s.leaf)
-		val nonLeaf = states.filter(s|!s.leaf)
-		
-		nonLeaf.union(leaf)
-	}
-
-	/**
-	 * @param ac an {@link ActorClass}
-	 * @return a list of all leaf states
-	 */
-	def List<State> getAllLeafStates(ActorClass ac) {
-		ac.stateMachine.leafStateList
-	}
-
-	/**
-	 * @param ac an {@link ActorClass}
-	 * @return a list of simple states with leaf states last
-	 */
-	def List<State> getAllBaseStatesLeavesLast(ActorClass ac) {
-		ac.allBaseStates.getLeafStatesLast
-	}
-
 	/**
 	 * @param ac an {@link ActorClass}
 	 * @return <code>true</code> if an operation named 'stop' is defined with a void argument list and
@@ -449,28 +418,6 @@
 		ac.operations.exists(e|e.name=="stop" && e.arguments.isEmpty && e.returnType==null)
 			|| (ac.actorBase!=null && ac.actorBase.overridesStop())
 	}
-
-	/**
-	 * @param ac an {@link ActorClass}
-	 * @return the number of all inherited states
-	 */
-	def int getNumberOfInheritedStates(ActorClass ac) {
-		if (ac.actorBase==null)
-			return 0
-		else
-			return ac.base.stateMachine.getStateList().size+ac.actorBase.getNumberOfInheritedStates()
-	}
-	
-	/**
-	 * @param ac an {@link ActorClass}
-	 * @return the number of all inherited base (or simple) states
-	 */
-	def int getNumberOfInheritedBaseStates(ActorClass ac) {
-		if (ac.actorBase==null)
-			return 0
-		else
-			return ac.base.stateMachine.getBaseStateList().size+ac.actorBase.getNumberOfInheritedBaseStates()
-	}
 	
 	def getAllSubInstances(StructureInstance ssi) {
 		val BasicEList<AbstractInstance> result = new BasicEList<AbstractInstance>();
diff --git a/plugins/org.eclipse.etrice.generator/xtend-gen/org/eclipse/etrice/generator/generic/GenericActorClassGenerator.java b/plugins/org.eclipse.etrice.generator/xtend-gen/org/eclipse/etrice/generator/generic/GenericActorClassGenerator.java
index 9499033..f183748 100644
--- a/plugins/org.eclipse.etrice.generator/xtend-gen/org/eclipse/etrice/generator/generic/GenericActorClassGenerator.java
+++ b/plugins/org.eclipse.etrice.generator/xtend-gen/org/eclipse/etrice/generator/generic/GenericActorClassGenerator.java
@@ -13,6 +13,7 @@
 import com.google.inject.Inject;
 import java.util.ArrayList;
 import java.util.List;
+import org.eclipse.etrice.core.fsm.fSM.AbstractInterfaceItem;
 import org.eclipse.etrice.core.genmodel.etricegen.ExpandedActorClass;
 import org.eclipse.etrice.core.room.ActorClass;
 import org.eclipse.etrice.core.room.Port;
@@ -21,6 +22,7 @@
 import org.eclipse.etrice.core.room.ServiceImplementation;
 import org.eclipse.etrice.core.room.util.RoomHelpers;
 import org.eclipse.etrice.generator.fsm.base.Indexed;
+import org.eclipse.etrice.generator.fsm.generic.IIfItemIdGenerator;
 import org.eclipse.etrice.generator.generic.ILanguageExtension;
 import org.eclipse.etrice.generator.generic.RoomExtensions;
 import org.eclipse.xtext.util.Pair;
@@ -32,7 +34,7 @@
  * It uses the {@link ILanguageExtension}.
  */
 @SuppressWarnings("all")
-public class GenericActorClassGenerator {
+public class GenericActorClassGenerator implements IIfItemIdGenerator {
   @Inject
   @Extension
   protected RoomHelpers _roomHelpers;
@@ -79,32 +81,29 @@
     final List<ServiceImplementation> svcImpls = _xifexpression_2;
     final ArrayList<Pair<String, String>> list = new ArrayList<Pair<String, String>>();
     for (final Port ep : endPorts) {
-      String _name = ep.getName();
-      String _plus = ("IFITEM_" + _name);
+      String _ifItemId = this.getIfItemId(ep);
       int _interfaceItemLocalId = xpac.getInterfaceItemLocalId(ep);
-      int _plus_1 = (1 + _interfaceItemLocalId);
-      String _string = Integer.valueOf(_plus_1).toString();
-      Pair<String, String> _pair = Tuples.<String, String>pair(_plus, _string);
+      int _plus = (1 + _interfaceItemLocalId);
+      String _string = Integer.valueOf(_plus).toString();
+      Pair<String, String> _pair = Tuples.<String, String>pair(_ifItemId, _string);
       list.add(_pair);
     }
     for (final SAP sap : strSAPs) {
-      String _name_1 = sap.getName();
-      String _plus_2 = ("IFITEM_" + _name_1);
+      String _ifItemId_1 = this.getIfItemId(sap);
       int _interfaceItemLocalId_1 = xpac.getInterfaceItemLocalId(sap);
-      int _plus_3 = (1 + _interfaceItemLocalId_1);
-      String _string_1 = Integer.valueOf(_plus_3).toString();
-      Pair<String, String> _pair_1 = Tuples.<String, String>pair(_plus_2, _string_1);
+      int _plus_1 = (1 + _interfaceItemLocalId_1);
+      String _string_1 = Integer.valueOf(_plus_1).toString();
+      Pair<String, String> _pair_1 = Tuples.<String, String>pair(_ifItemId_1, _string_1);
       list.add(_pair_1);
     }
     for (final ServiceImplementation svc : svcImpls) {
       SPP _spp = svc.getSpp();
-      String _name_2 = _spp.getName();
-      String _plus_4 = ("IFITEM_" + _name_2);
+      String _ifItemId_2 = this.getIfItemId(_spp);
       SPP _spp_1 = svc.getSpp();
       int _interfaceItemLocalId_2 = xpac.getInterfaceItemLocalId(_spp_1);
-      int _plus_5 = (1 + _interfaceItemLocalId_2);
-      String _string_2 = Integer.valueOf(_plus_5).toString();
-      Pair<String, String> _pair_2 = Tuples.<String, String>pair(_plus_4, _string_2);
+      int _plus_2 = (1 + _interfaceItemLocalId_2);
+      String _string_2 = Integer.valueOf(_plus_2).toString();
+      Pair<String, String> _pair_2 = Tuples.<String, String>pair(_ifItemId_2, _string_2);
       list.add(_pair_2);
     }
     return this.langExt.genEnumeration("interface_items", list);
@@ -116,13 +115,17 @@
     Iterable<Indexed<Port>> _indexed = Indexed.<Port>indexed(ports);
     for (final Indexed<Port> ep : _indexed) {
       Port _value = ep.getValue();
-      String _name = _value.getName();
-      String _plus = ("IFITEM_" + _name);
+      String _ifItemId = this.getIfItemId(_value);
       int _index1 = ep.getIndex1();
       String _string = Integer.valueOf(_index1).toString();
-      Pair<String, String> _pair = Tuples.<String, String>pair(_plus, _string);
+      Pair<String, String> _pair = Tuples.<String, String>pair(_ifItemId, _string);
       list.add(_pair);
     }
     return this.langExt.genEnumeration("interface_items", list);
   }
+  
+  public String getIfItemId(final AbstractInterfaceItem item) {
+    String _name = item.getName();
+    return ("IFITEM_" + _name);
+  }
 }
diff --git a/plugins/org.eclipse.etrice.generator/xtend-gen/org/eclipse/etrice/generator/generic/GenericProtocolClassGenerator.java b/plugins/org.eclipse.etrice.generator/xtend-gen/org/eclipse/etrice/generator/generic/GenericProtocolClassGenerator.java
index d343bee..392458c 100644
--- a/plugins/org.eclipse.etrice.generator/xtend-gen/org/eclipse/etrice/generator/generic/GenericProtocolClassGenerator.java
+++ b/plugins/org.eclipse.etrice.generator/xtend-gen/org/eclipse/etrice/generator/generic/GenericProtocolClassGenerator.java
@@ -24,6 +24,7 @@
 import org.eclipse.etrice.core.room.SAP;
 import org.eclipse.etrice.core.room.SPP;
 import org.eclipse.etrice.core.room.util.RoomHelpers;
+import org.eclipse.etrice.generator.fsm.generic.IMessageIdGenerator;
 import org.eclipse.etrice.generator.generic.ILanguageExtension;
 import org.eclipse.etrice.generator.generic.RoomExtensions;
 import org.eclipse.xtext.util.Pair;
@@ -34,7 +35,7 @@
  * Target language independent protocol class generator.
  */
 @SuppressWarnings("all")
-public class GenericProtocolClassGenerator {
+public class GenericProtocolClassGenerator implements IMessageIdGenerator {
   @Inject
   @Extension
   protected RoomHelpers _roomHelpers;
diff --git a/plugins/org.eclipse.etrice.generator/xtend-gen/org/eclipse/etrice/generator/generic/GenericStateMachineGenerator.java b/plugins/org.eclipse.etrice.generator/xtend-gen/org/eclipse/etrice/generator/generic/GenericStateMachineGenerator.java
index ae98387..ef6f7b7 100644
--- a/plugins/org.eclipse.etrice.generator/xtend-gen/org/eclipse/etrice/generator/generic/GenericStateMachineGenerator.java
+++ b/plugins/org.eclipse.etrice.generator/xtend-gen/org/eclipse/etrice/generator/generic/GenericStateMachineGenerator.java
@@ -11,44 +11,22 @@
 package org.eclipse.etrice.generator.generic;
 
 import com.google.common.base.Objects;
-import com.google.inject.Inject;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
 import org.eclipse.emf.common.util.EList;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.etrice.core.fsm.fSM.AbstractInterfaceItem;
 import org.eclipse.etrice.core.fsm.fSM.ComponentCommunicationType;
 import org.eclipse.etrice.core.fsm.fSM.DetailCode;
 import org.eclipse.etrice.core.fsm.fSM.Guard;
 import org.eclipse.etrice.core.fsm.fSM.GuardedTransition;
-import org.eclipse.etrice.core.fsm.fSM.MessageFromIf;
+import org.eclipse.etrice.core.fsm.fSM.ModelComponent;
 import org.eclipse.etrice.core.fsm.fSM.NonInitialTransition;
 import org.eclipse.etrice.core.fsm.fSM.State;
-import org.eclipse.etrice.core.fsm.fSM.StateGraph;
-import org.eclipse.etrice.core.fsm.fSM.TrPoint;
 import org.eclipse.etrice.core.fsm.fSM.Transition;
-import org.eclipse.etrice.core.fsm.fSM.TransitionPoint;
 import org.eclipse.etrice.core.fsm.fSM.Trigger;
 import org.eclipse.etrice.core.fsm.fSM.TriggeredTransition;
-import org.eclipse.etrice.core.genmodel.etricegen.ExpandedActorClass;
-import org.eclipse.etrice.core.genmodel.etricegen.util.ETriceGenUtil;
-import org.eclipse.etrice.core.genmodel.fsm.fsmgen.ActiveTrigger;
+import org.eclipse.etrice.core.genmodel.fsm.fsmgen.ExpandedModelComponent;
 import org.eclipse.etrice.core.genmodel.fsm.fsmgen.ExpandedRefinedState;
 import org.eclipse.etrice.core.genmodel.fsm.fsmgen.TransitionChain;
-import org.eclipse.etrice.core.room.ActorClass;
-import org.eclipse.etrice.core.room.Message;
-import org.eclipse.etrice.core.room.util.RoomHelpers;
-import org.eclipse.etrice.generator.base.AbstractGenerator;
-import org.eclipse.etrice.generator.base.CodegenHelpers;
-import org.eclipse.etrice.generator.generic.GenericProtocolClassGenerator;
-import org.eclipse.etrice.generator.generic.ILanguageExtension;
-import org.eclipse.etrice.generator.generic.RoomExtensions;
-import org.eclipse.etrice.generator.generic.TransitionChainGenerator;
+import org.eclipse.etrice.generator.fsm.generic.AbstractStateMachineGenerator;
 import org.eclipse.xtend2.lib.StringConcatenation;
-import org.eclipse.xtext.util.Pair;
-import org.eclipse.xtext.util.Tuples;
-import org.eclipse.xtext.xbase.lib.Extension;
 import org.eclipse.xtext.xbase.lib.Functions.Function1;
 import org.eclipse.xtext.xbase.lib.IterableExtensions;
 
@@ -56,1492 +34,74 @@
  * A target language independent generator of the state machine implementation-
  */
 @SuppressWarnings("all")
-public class GenericStateMachineGenerator {
-  @Inject
-  @Extension
-  protected RoomHelpers _roomHelpers;
-  
-  @Inject
-  @Extension
-  protected ETriceGenUtil _eTriceGenUtil;
-  
-  @Inject
-  @Extension
-  protected CodegenHelpers _codegenHelpers;
-  
-  @Inject
-  @Extension
-  protected RoomExtensions _roomExtensions;
-  
-  @Inject
-  protected ILanguageExtension langExt;
-  
-  @Inject
-  protected GenericProtocolClassGenerator pcGen;
-  
-  @Inject
-  protected TransitionChainGenerator transitionChainGenerator;
-  
-  /**
-   * generates state ID constants.
-   * Inheritance (if available) is used for base class IDs.
-   * 
-   * @param xpac the {@link ExpandedActorClass}
-   * @return the generated code
-   */
-  protected String genStateIdConstants(final ExpandedActorClass xpac) {
-    final ActorClass ac = xpac.getActorClass();
-    int _xifexpression = (int) 0;
-    boolean _usesInheritance = this.langExt.usesInheritance();
-    if (_usesInheritance) {
-      _xifexpression = this._roomExtensions.getNumberOfInheritedBaseStates(ac);
-    } else {
-      _xifexpression = 0;
-    }
-    int offset = (2 + _xifexpression);
-    List<State> _xifexpression_1 = null;
-    boolean _usesInheritance_1 = this.langExt.usesInheritance();
-    if (_usesInheritance_1) {
-      StateGraph _stateMachine = ac.getStateMachine();
-      _xifexpression_1 = this._roomHelpers.getBaseStateList(_stateMachine);
-    } else {
-      StateGraph _stateMachine_1 = xpac.getStateMachine();
-      _xifexpression_1 = this._roomHelpers.getBaseStateList(_stateMachine_1);
-    }
-    List<State> baseStates = _xifexpression_1;
-    List<State> _leafStatesLast = this._roomExtensions.getLeafStatesLast(baseStates);
-    baseStates = _leafStatesLast;
-    ArrayList<Pair<String, String>> list = new ArrayList<Pair<String, String>>();
-    boolean _usesInheritance_2 = this.langExt.usesInheritance();
-    boolean _not = (!_usesInheritance_2);
-    if (_not) {
-      Pair<String, String> _pair = Tuples.<String, String>pair("NO_STATE", "0");
-      list.add(_pair);
-      Pair<String, String> _pair_1 = Tuples.<String, String>pair("STATE_TOP", "1");
-      list.add(_pair_1);
-    }
-    for (final State state : baseStates) {
-      {
-        String _genStateId = this._codegenHelpers.getGenStateId(state);
-        String _string = Integer.valueOf(offset).toString();
-        Pair<String, String> _pair_2 = Tuples.<String, String>pair(_genStateId, _string);
-        list.add(_pair_2);
-        offset = (offset + 1);
-      }
-    }
-    String _string = Integer.valueOf(offset).toString();
-    Pair<String, String> _pair_2 = Tuples.<String, String>pair("STATE_MAX", _string);
-    list.add(_pair_2);
-    return this.langExt.genEnumeration("state_ids", list);
-  }
-  
-  /**
-   * generates transition chain ID constants.
-   * Inheritance (if available) is used for base class IDs.
-   * 
-   * @param xpac the {@link ExpandedActorClass}
-   * @return the generated code
-   */
-  protected String genTransitionChainConstants(final ExpandedActorClass xpac) {
-    EList<TransitionChain> _xifexpression = null;
-    boolean _usesInheritance = this.langExt.usesInheritance();
-    if (_usesInheritance) {
-      _xifexpression = xpac.getOwnTransitionChains();
-    } else {
-      _xifexpression = xpac.getTransitionChains();
-    }
-    EList<TransitionChain> chains = _xifexpression;
-    int _xifexpression_1 = (int) 0;
-    boolean _usesInheritance_1 = this.langExt.usesInheritance();
-    if (_usesInheritance_1) {
-      EList<TransitionChain> _transitionChains = xpac.getTransitionChains();
-      int _size = _transitionChains.size();
-      int _size_1 = chains.size();
-      _xifexpression_1 = (_size - _size_1);
-    } else {
-      _xifexpression_1 = 0;
-    }
-    int offset = _xifexpression_1;
-    ArrayList<Pair<String, String>> list = new ArrayList<Pair<String, String>>();
-    for (final TransitionChain chain : chains) {
-      {
-        offset = (offset + 1);
-        String _genChainId = this._codegenHelpers.getGenChainId(chain);
-        String _string = Integer.valueOf(offset).toString();
-        Pair<String, String> _pair = Tuples.<String, String>pair(_genChainId, _string);
-        list.add(_pair);
-      }
-    }
-    return this.langExt.genEnumeration("chain_ids", list);
-  }
-  
-  /**
-   * generates trigger IDs.
-   * Inheritance (if available) is used for base class IDs.
-   * 
-   * @param xpac the {@link ExpandedActorClass}
-   * @return the generated code
-   */
-  protected String genTriggerConstants(final ExpandedActorClass xpac) {
-    List<MessageFromIf> _xifexpression = null;
-    boolean _usesInheritance = this.langExt.usesInheritance();
-    if (_usesInheritance) {
-      ActorClass _actorClass = xpac.getActorClass();
-      _xifexpression = this._roomHelpers.getOwnMessagesFromInterfaces(_actorClass);
-    } else {
-      ActorClass _actorClass_1 = xpac.getActorClass();
-      _xifexpression = this._roomHelpers.getAllMessagesFromInterfaces(_actorClass_1);
-    }
-    final List<MessageFromIf> triggers = _xifexpression;
-    final ArrayList<Pair<String, String>> list = new ArrayList<Pair<String, String>>();
-    Pair<String, String> _pair = Tuples.<String, String>pair("POLLING", "0");
-    list.add(_pair);
-    for (final MessageFromIf mif : triggers) {
-      String _triggerCodeName = xpac.getTriggerCodeName(mif);
-      AbstractInterfaceItem _from = mif.getFrom();
-      String _name = _from.getName();
-      String _plus = ("IFITEM_" + _name);
-      String _plus_1 = (_plus + " + EVT_SHIFT*");
-      String _messageID = this.pcGen.getMessageID(mif);
-      String _plus_2 = (_plus_1 + _messageID);
-      Pair<String, String> _pair_1 = Tuples.<String, String>pair(_triggerCodeName, _plus_2);
-      list.add(_pair_1);
-    }
-    return this.langExt.genEnumeration("triggers", list);
-  }
-  
+public class GenericStateMachineGenerator extends AbstractStateMachineGenerator {
   /**
    * generates the code of the whole state machine
    * 
-   * @param xpac the {@link ExpandedActorClass}
+   * @param xpmc the {@link ExpandedModelComponent}
    * @return the generated code
    * 
    * @see #genStateMachine
    */
-  public CharSequence genStateMachine(final ExpandedActorClass xpac) {
-    return this.genStateMachine(xpac, true);
+  public CharSequence genStateMachine(final ExpandedModelComponent xpmc) {
+    return this.genStateMachine(xpmc, true);
   }
   
   /**
    * generates the code of the whole state machine
    * 
-   * @param xpac the {@link ExpandedActorClass}
+   * @param xpmc the {@link ExpandedModelComponent}
    * @param shallGenerateOneFile if <code>true</code> the generation of state IDs and
    * 		other constants is skipped (and left for the header file)
    * @return the generated code
    */
-  public CharSequence genStateMachine(final ExpandedActorClass xpac, final boolean shallGenerateOneFile) {
-    CharSequence _xblockexpression = null;
+  public CharSequence genStateMachine(final ExpandedModelComponent xpmc, final boolean shallGenerateOneFile) {
+    StringConcatenation _builder = new StringConcatenation();
     {
-      final ActorClass ac = xpac.getActorClass();
-      ComponentCommunicationType _commType = ac.getCommType();
-      final boolean async = Objects.equal(_commType, ComponentCommunicationType.ASYNCHRONOUS);
-      ComponentCommunicationType _commType_1 = ac.getCommType();
-      final boolean eventDriven = Objects.equal(_commType_1, ComponentCommunicationType.EVENT_DRIVEN);
-      boolean _or = false;
-      if (async) {
-        _or = true;
-      } else {
-        _or = eventDriven;
+      if (shallGenerateOneFile) {
+        _builder.append("/* state IDs */");
+        _builder.newLine();
+        String _genStateIdConstants = this.genStateIdConstants(xpmc);
+        _builder.append(_genStateIdConstants, "");
+        _builder.newLineIfNotEmpty();
+        _builder.newLine();
+        _builder.append("/* transition chains */");
+        _builder.newLine();
+        String _genTransitionChainConstants = this.genTransitionChainConstants(xpmc);
+        _builder.append(_genTransitionChainConstants, "");
+        _builder.newLineIfNotEmpty();
+        _builder.newLine();
+        _builder.append("/* triggers */");
+        _builder.newLine();
+        String _genTriggerConstants = this.genTriggerConstants(xpmc);
+        _builder.append(_genTriggerConstants, "");
+        _builder.newLineIfNotEmpty();
       }
-      final boolean handleEvents = _or;
-      String _name = ac.getName();
-      final String opScope = this.langExt.operationScope(_name, false);
-      String _xifexpression = null;
-      boolean _usesInheritance = this.langExt.usesInheritance();
-      if (_usesInheritance) {
-        _xifexpression = opScope;
-      } else {
-        _xifexpression = "";
-      }
-      final String opScopePriv = _xifexpression;
-      String _xifexpression_1 = null;
-      boolean _usesInheritance_1 = this.langExt.usesInheritance();
-      if (_usesInheritance_1) {
-        _xifexpression_1 = this.langExt.accessLevelPublic();
-      } else {
-        _xifexpression_1 = this.langExt.accessLevelPrivate();
-      }
-      final String publicIf = _xifexpression_1;
-      final String privAccess = this.langExt.accessLevelPrivate();
-      String _name_1 = ac.getName();
-      final String selfPtr = this.langExt.selfPointer(_name_1, true);
-      String _name_2 = ac.getName();
-      final String selfOnly = this.langExt.selfPointer(_name_2, false);
-      String _xifexpression_2 = null;
-      boolean _usesInheritance_2 = this.langExt.usesInheritance();
-      if (_usesInheritance_2) {
-        String _xifexpression_3 = null;
-        boolean _usesPointers = this.langExt.usesPointers();
-        if (_usesPointers) {
-          _xifexpression_3 = "->getLocalId()";
-        } else {
-          _xifexpression_3 = ".getLocalId()";
-        }
-        _xifexpression_2 = _xifexpression_3;
-      } else {
-        _xifexpression_2 = "->localId";
-      }
-      final String getLocalId = _xifexpression_2;
-      String _pointerLiteral = this.langExt.pointerLiteral();
-      final String ifItemPtr = ("InterfaceItemBase" + _pointerLiteral);
-      String _xifexpression_4 = null;
-      boolean _usesPointers_1 = this.langExt.usesPointers();
-      if (_usesPointers_1) {
-        _xifexpression_4 = ("const " + ifItemPtr);
-      } else {
-        _xifexpression_4 = ifItemPtr;
-      }
-      final String constIfItemPtr = _xifexpression_4;
-      final boolean usesHdlr = this.usesHandlerTrPoints(xpac);
-      StringConcatenation _builder = new StringConcatenation();
-      {
-        if (shallGenerateOneFile) {
-          _builder.append("/* state IDs */");
-          _builder.newLine();
-          String _genStateIdConstants = this.genStateIdConstants(xpac);
-          _builder.append(_genStateIdConstants, "");
-          _builder.newLineIfNotEmpty();
-          _builder.newLine();
-          _builder.append("/* transition chains */");
-          _builder.newLine();
-          String _genTransitionChainConstants = this.genTransitionChainConstants(xpac);
-          _builder.append(_genTransitionChainConstants, "");
-          _builder.newLineIfNotEmpty();
-          _builder.newLine();
-          _builder.append("/* triggers */");
-          _builder.newLine();
-          String _genTriggerConstants = this.genTriggerConstants(xpac);
-          _builder.append(_genTriggerConstants, "");
-          _builder.newLineIfNotEmpty();
-        }
-      }
-      _builder.newLine();
-      CharSequence _genExtra = this.genExtra(xpac);
-      _builder.append(_genExtra, "");
-      _builder.newLineIfNotEmpty();
-      _builder.newLine();
-      _builder.append("/* Entry and Exit Codes */");
-      _builder.newLine();
-      {
-        StateGraph _stateMachine = xpac.getStateMachine();
-        List<State> _stateList = this._roomHelpers.getStateList(_stateMachine);
-        for(final State state : _stateList) {
-          {
-            boolean _or_1 = false;
-            boolean _usesInheritance_3 = this.langExt.usesInheritance();
-            boolean _not = (!_usesInheritance_3);
-            if (_not) {
-              _or_1 = true;
-            } else {
-              boolean _isOwnObject = xpac.isOwnObject(state);
-              _or_1 = _isOwnObject;
-            }
-            if (_or_1) {
-              CharSequence _genActionCodeMethods = this.genActionCodeMethods(xpac, state);
-              _builder.append(_genActionCodeMethods, "");
-              _builder.newLineIfNotEmpty();
-            }
-          }
-        }
-      }
-      _builder.newLine();
-      _builder.append("/* Action Codes */");
-      _builder.newLine();
-      {
-        StateGraph _stateMachine_1 = xpac.getStateMachine();
-        List<Transition> _allTransitionsRecursive = this._roomHelpers.getAllTransitionsRecursive(_stateMachine_1);
-        for(final Transition tr : _allTransitionsRecursive) {
-          {
-            boolean _and = false;
-            boolean _or_2 = false;
-            boolean _usesInheritance_4 = this.langExt.usesInheritance();
-            boolean _not_1 = (!_usesInheritance_4);
-            if (_not_1) {
-              _or_2 = true;
-            } else {
-              boolean _isOwnObject_1 = xpac.isOwnObject(tr);
-              _or_2 = _isOwnObject_1;
-            }
-            if (!_or_2) {
-              _and = false;
-            } else {
-              DetailCode _action = tr.getAction();
-              boolean _hasDetailCode = this._roomHelpers.hasDetailCode(_action);
-              _and = _hasDetailCode;
-            }
-            if (_and) {
-              TransitionChain _chain = xpac.getChain(tr);
-              Transition _transition = null;
-              if (_chain!=null) {
-                _transition=_chain.getTransition();
-              }
-              Transition start = _transition;
-              _builder.newLineIfNotEmpty();
-              boolean _and_1 = false;
-              if (!(start instanceof NonInitialTransition)) {
-                _and_1 = false;
-              } else {
-                _and_1 = (!(start instanceof GuardedTransition));
-              }
-              boolean hasArgs = _and_1;
-              _builder.newLineIfNotEmpty();
-              String _accessLevelProtected = this.langExt.accessLevelProtected();
-              _builder.append(_accessLevelProtected, "");
-              _builder.append("void ");
-              _builder.append(opScopePriv, "");
-              String _actionCodeOperationName = this._codegenHelpers.getActionCodeOperationName(tr);
-              _builder.append(_actionCodeOperationName, "");
-              _builder.append("(");
-              String _name_3 = ac.getName();
-              String _selfPointer = this.langExt.selfPointer(_name_3, hasArgs);
-              _builder.append(_selfPointer, "");
-              {
-                if (hasArgs) {
-                  _builder.append(constIfItemPtr, "");
-                  _builder.append(" ifitem");
-                  String _generateArgumentList = this.transitionChainGenerator.generateArgumentList(xpac, tr);
-                  _builder.append(_generateArgumentList, "");
-                }
-              }
-              _builder.append(") {");
-              _builder.newLineIfNotEmpty();
-              _builder.append("\t");
-              AbstractGenerator _instance = AbstractGenerator.getInstance();
-              DetailCode _action_1 = tr.getAction();
-              String _translatedCode = _instance.getTranslatedCode(_action_1);
-              _builder.append(_translatedCode, "\t");
-              _builder.newLineIfNotEmpty();
-              _builder.append("}");
-              _builder.newLine();
-            }
-          }
-        }
-      }
-      _builder.newLine();
-      _builder.append("/**");
-      _builder.newLine();
-      _builder.append(" ");
-      _builder.append("* calls exit codes while exiting from the current state to one of its");
-      _builder.newLine();
-      _builder.append(" ");
-      _builder.append("* parent states while remembering the history");
-      _builder.newLine();
-      _builder.append(" ");
-      _builder.append("* @param current__et - the current state");
-      _builder.newLine();
-      _builder.append(" ");
-      _builder.append("* @param to - the final parent state");
-      _builder.newLine();
-      {
-        if (usesHdlr) {
-          _builder.append(" ");
-          _builder.append("* @param handler__et - entry and exit codes are called only if not handler (for handler TransitionPoints)");
-          _builder.newLine();
-        }
-      }
-      _builder.append(" ");
-      _builder.append("*/");
-      _builder.newLine();
-      _builder.append(privAccess, "");
-      _builder.append("void ");
-      _builder.append(opScopePriv, "");
-      _builder.append("exitTo(");
-      _builder.append(selfPtr, "");
-      String _stateType = this.stateType();
-      _builder.append(_stateType, "");
-      _builder.append(" current__et, ");
-      String _stateType_1 = this.stateType();
-      _builder.append(_stateType_1, "");
-      _builder.append(" to");
-      {
-        if (usesHdlr) {
-          _builder.append(", ");
-          String _boolType = this.boolType();
-          _builder.append(_boolType, "");
-          _builder.append(" handler__et");
-        }
-      }
-      _builder.append(") {");
-      _builder.newLineIfNotEmpty();
-      _builder.append("\t");
-      _builder.append("while (current__et!=to) {");
-      _builder.newLine();
-      _builder.append("\t\t");
-      _builder.append("switch (current__et) {");
-      _builder.newLine();
-      {
-        StateGraph _stateMachine_2 = xpac.getStateMachine();
-        List<State> _baseStateList = this._roomHelpers.getBaseStateList(_stateMachine_2);
-        for(final State state_1 : _baseStateList) {
-          _builder.append("\t\t\t");
-          _builder.append("case ");
-          String _genStateId = this._codegenHelpers.getGenStateId(state_1);
-          _builder.append(_genStateId, "\t\t\t");
-          _builder.append(":");
-          _builder.newLineIfNotEmpty();
-          _builder.append("\t\t\t");
-          _builder.append("\t");
-          {
-            boolean _hasExitCode = this._roomHelpers.hasExitCode(state_1, true);
-            if (_hasExitCode) {
-              {
-                if (usesHdlr) {
-                  _builder.append("if (!handler__et) ");
-                }
-              }
-              String _exitCodeOperationName = this._codegenHelpers.getExitCodeOperationName(state_1);
-              _builder.append(_exitCodeOperationName, "\t\t\t\t");
-              _builder.append("(");
-              String _selfPointer_1 = this.langExt.selfPointer(false);
-              _builder.append(_selfPointer_1, "\t\t\t\t");
-              _builder.append(");");
-            }
-          }
-          _builder.newLineIfNotEmpty();
-          _builder.append("\t\t\t");
-          _builder.append("\t");
-          String _parentStateId = this._codegenHelpers.getParentStateId(state_1);
-          String _genStateId_1 = this._codegenHelpers.getGenStateId(state_1);
-          String _setHistory = this.setHistory(_parentStateId, _genStateId_1);
-          _builder.append(_setHistory, "\t\t\t\t");
-          _builder.append(";");
-          _builder.newLineIfNotEmpty();
-          _builder.append("\t\t\t");
-          _builder.append("\t");
-          _builder.append("current__et = ");
-          String _parentStateId_1 = this._codegenHelpers.getParentStateId(state_1);
-          _builder.append(_parentStateId_1, "\t\t\t\t");
-          _builder.append(";");
-          _builder.newLineIfNotEmpty();
-          _builder.append("\t\t\t");
-          _builder.append("\t");
-          _builder.append("break;");
-          _builder.newLine();
-        }
-      }
-      _builder.append("\t\t\t");
-      _builder.append("default:");
-      _builder.newLine();
-      _builder.append("\t\t\t\t");
-      _builder.append("/* should not occur */");
-      _builder.newLine();
-      _builder.append("\t\t\t\t");
-      _builder.append("break;");
-      _builder.newLine();
-      _builder.append("\t\t");
-      _builder.append("}");
-      _builder.newLine();
-      _builder.append("\t");
-      _builder.append("}");
-      _builder.newLine();
-      _builder.append("}");
-      _builder.newLine();
-      _builder.newLine();
-      _builder.append("/**");
-      _builder.newLine();
-      _builder.append(" ");
-      _builder.append("* calls action, entry and exit codes along a transition chain. The generic data are cast to typed data");
-      _builder.newLine();
-      _builder.append(" ");
-      _builder.append("* matching the trigger of this chain. The ID of the final state is returned");
-      _builder.newLine();
-      _builder.append(" ");
-      _builder.append("* @param chain__et - the chain ID");
-      _builder.newLine();
-      _builder.append(" ");
-      _builder.append("* @param generic_data__et - the generic data pointer");
-      _builder.newLine();
-      _builder.append(" ");
-      _builder.append("* @return the +/- ID of the final state either with a positive sign, that indicates to execute the state\'s entry code, or a negative sign vice versa");
-      _builder.newLine();
-      _builder.append(" ");
-      _builder.append("*/");
-      _builder.newLine();
-      _builder.append(privAccess, "");
-      String _stateType_2 = this.stateType();
-      _builder.append(_stateType_2, "");
-      _builder.append(" ");
-      _builder.append(opScopePriv, "");
-      _builder.append("executeTransitionChain(");
-      _builder.append(selfPtr, "");
-      _builder.append("int chain__et");
-      {
-        if (handleEvents) {
-          _builder.append(", ");
-          _builder.append(constIfItemPtr, "");
-          _builder.append(" ifitem, ");
-          String _voidPointer = this.langExt.voidPointer();
-          _builder.append(_voidPointer, "");
-          _builder.append(" generic_data__et");
-        }
-      }
-      _builder.append(") {");
-      _builder.newLineIfNotEmpty();
-      _builder.append("\t");
-      _builder.append("switch (chain__et) {");
-      _builder.newLine();
-      _builder.append("\t\t");
-      EList<TransitionChain> allchains = xpac.getTransitionChains();
-      _builder.newLineIfNotEmpty();
-      {
-        for(final TransitionChain tc : allchains) {
-          _builder.append("\t\t");
-          _builder.append("case ");
-          String _genChainId = this._codegenHelpers.getGenChainId(tc);
-          _builder.append(_genChainId, "\t\t");
-          _builder.append(":");
-          _builder.newLineIfNotEmpty();
-          _builder.append("\t\t");
-          _builder.append("{");
-          _builder.newLine();
-          _builder.append("\t\t");
-          _builder.append("\t");
-          String _generateExecuteChain = this.transitionChainGenerator.generateExecuteChain(xpac, tc);
-          _builder.append(_generateExecuteChain, "\t\t\t");
-          _builder.newLineIfNotEmpty();
-          _builder.append("\t\t");
-          _builder.append("}");
-          _builder.newLine();
-        }
-      }
-      _builder.append("\t\t\t");
-      _builder.append("default:");
-      _builder.newLine();
-      _builder.append("\t\t\t\t");
-      _builder.append("/* should not occur */");
-      _builder.newLine();
-      _builder.append("\t\t\t\t");
-      _builder.append("break;");
-      _builder.newLine();
-      _builder.append("\t");
-      _builder.append("}");
-      _builder.newLine();
-      _builder.append("\t");
-      _builder.append("return NO_STATE;");
-      _builder.newLine();
-      _builder.append("}");
-      _builder.newLine();
-      _builder.newLine();
-      _builder.append("/**");
-      _builder.newLine();
-      _builder.append(" ");
-      _builder.append("* calls entry codes while entering a state\'s history. The ID of the final leaf state is returned");
-      _builder.newLine();
-      _builder.append(" ");
-      _builder.append("* @param state__et - the state which is entered");
-      _builder.newLine();
-      {
-        if (usesHdlr) {
-          _builder.append(" ");
-          _builder.append("* @param handler__et - entry code is executed if not handler");
-          _builder.newLine();
-        }
-      }
-      _builder.append(" ");
-      _builder.append("* @return - the ID of the final leaf state");
-      _builder.newLine();
-      _builder.append(" ");
-      _builder.append("*/");
-      _builder.newLine();
-      _builder.append(privAccess, "");
-      String _stateType_3 = this.stateType();
-      _builder.append(_stateType_3, "");
-      _builder.append(" ");
-      _builder.append(opScopePriv, "");
-      _builder.append("enterHistory(");
-      _builder.append(selfPtr, "");
-      String _stateType_4 = this.stateType();
-      _builder.append(_stateType_4, "");
-      _builder.append(" state__et");
-      {
-        if (usesHdlr) {
-          _builder.append(", ");
-          String _boolType_1 = this.boolType();
-          _builder.append(_boolType_1, "");
-          _builder.append(" handler__et");
-        }
-      }
-      _builder.append(") {");
-      _builder.newLineIfNotEmpty();
-      _builder.append("\t");
-      String _boolType_2 = this.boolType();
-      _builder.append(_boolType_2, "\t");
-      _builder.append(" skip_entry__et = ");
-      String _booleanConstant = this.langExt.booleanConstant(false);
-      _builder.append(_booleanConstant, "\t");
-      _builder.append(";");
-      _builder.newLineIfNotEmpty();
-      _builder.append("\t");
-      _builder.append("if (state__et >= STATE_MAX) {");
-      _builder.newLine();
-      _builder.append("\t\t");
-      _builder.append("state__et = ");
-      {
-        boolean _usesInheritance_5 = this.langExt.usesInheritance();
-        boolean _not_2 = (!_usesInheritance_5);
-        if (_not_2) {
-          _builder.append("(");
-          String _stateType_5 = this.stateType();
-          _builder.append(_stateType_5, "\t\t");
-          _builder.append(")");
-        }
-      }
-      _builder.append(" (state__et - STATE_MAX);");
-      _builder.newLineIfNotEmpty();
-      _builder.append("\t\t");
-      _builder.append("skip_entry__et = ");
-      String _booleanConstant_1 = this.langExt.booleanConstant(true);
-      _builder.append(_booleanConstant_1, "\t\t");
-      _builder.append(";");
-      _builder.newLineIfNotEmpty();
-      _builder.append("\t");
-      _builder.append("}");
-      _builder.newLine();
-      _builder.append("\t");
-      _builder.append("while (");
-      String _booleanConstant_2 = this.langExt.booleanConstant(true);
-      _builder.append(_booleanConstant_2, "\t");
-      _builder.append(") {");
-      _builder.newLineIfNotEmpty();
-      _builder.append("\t\t");
-      _builder.append("switch (state__et) {");
-      _builder.newLine();
-      {
-        StateGraph _stateMachine_3 = xpac.getStateMachine();
-        List<State> _baseStateList_1 = this._roomHelpers.getBaseStateList(_stateMachine_3);
-        for(final State state_2 : _baseStateList_1) {
-          _builder.append("\t\t\t");
-          _builder.append("case ");
-          String _genStateId_2 = this._codegenHelpers.getGenStateId(state_2);
-          _builder.append(_genStateId_2, "\t\t\t");
-          _builder.append(":");
-          _builder.newLineIfNotEmpty();
-          _builder.append("\t\t\t");
-          _builder.append("\t");
-          {
-            boolean _hasEntryCode = this._roomHelpers.hasEntryCode(state_2, true);
-            if (_hasEntryCode) {
-              _builder.append("if (!(skip_entry__et");
-              {
-                if (usesHdlr) {
-                  _builder.append(" || handler__et");
-                }
-              }
-              _builder.append(")) ");
-              String _entryCodeOperationName = this._codegenHelpers.getEntryCodeOperationName(state_2);
-              _builder.append(_entryCodeOperationName, "\t\t\t\t");
-              _builder.append("(");
-              String _selfPointer_2 = this.langExt.selfPointer(false);
-              _builder.append(_selfPointer_2, "\t\t\t\t");
-              _builder.append(");");
-            }
-          }
-          _builder.newLineIfNotEmpty();
-          {
-            boolean _isLeaf = this._roomHelpers.isLeaf(state_2);
-            if (_isLeaf) {
-              _builder.append("\t\t\t");
-              _builder.append("\t");
-              _builder.append("/* in leaf state: return state id */");
-              _builder.newLine();
-              _builder.append("\t\t\t");
-              _builder.append("\t");
-              _builder.append("return ");
-              String _genStateId_3 = this._codegenHelpers.getGenStateId(state_2);
-              _builder.append(_genStateId_3, "\t\t\t\t");
-              _builder.append(";");
-              _builder.newLineIfNotEmpty();
-            } else {
-              _builder.append("\t\t\t");
-              _builder.append("\t");
-              _builder.append("/* state has a sub graph */");
-              _builder.newLine();
-              {
-                StateGraph _subgraph = state_2.getSubgraph();
-                boolean _hasInitTransition = this._roomHelpers.hasInitTransition(_subgraph);
-                if (_hasInitTransition) {
-                  _builder.append("\t\t\t");
-                  _builder.append("\t");
-                  _builder.append("/* with init transition */");
-                  _builder.newLine();
-                  _builder.append("\t\t\t");
-                  _builder.append("\t");
-                  _builder.append("if (");
-                  String _genStateId_4 = this._codegenHelpers.getGenStateId(state_2);
-                  String _history = this.getHistory(_genStateId_4);
-                  _builder.append(_history, "\t\t\t\t");
-                  _builder.append("==NO_STATE) {");
-                  _builder.newLineIfNotEmpty();
-                  _builder.append("\t\t\t");
-                  _builder.append("\t");
-                  _builder.append("\t");
-                  StateGraph _subgraph_1 = state_2.getSubgraph();
-                  Transition sub_initt = this._roomHelpers.getInitTransition(_subgraph_1);
-                  _builder.newLineIfNotEmpty();
-                  _builder.append("\t\t\t");
-                  _builder.append("\t");
-                  _builder.append("\t");
-                  _builder.append("state__et = executeTransitionChain(");
-                  String _selfPointer_3 = this.langExt.selfPointer(true);
-                  _builder.append(_selfPointer_3, "\t\t\t\t\t");
-                  TransitionChain _chain_1 = xpac.getChain(sub_initt);
-                  String _genChainId_1 = this._codegenHelpers.getGenChainId(_chain_1);
-                  _builder.append(_genChainId_1, "\t\t\t\t\t");
-                  {
-                    if (handleEvents) {
-                      _builder.append(", ");
-                      String _nullPointer = this.langExt.nullPointer();
-                      _builder.append(_nullPointer, "\t\t\t\t\t");
-                      _builder.append(", ");
-                      String _nullPointer_1 = this.langExt.nullPointer();
-                      _builder.append(_nullPointer_1, "\t\t\t\t\t");
-                    }
-                  }
-                  _builder.append(");");
-                  _builder.newLineIfNotEmpty();
-                  _builder.append("\t\t\t");
-                  _builder.append("\t");
-                  _builder.append("}");
-                  _builder.newLine();
-                  _builder.append("\t\t\t");
-                  _builder.append("\t");
-                  _builder.append("else {");
-                  _builder.newLine();
-                  _builder.append("\t\t\t");
-                  _builder.append("\t");
-                  _builder.append("\t");
-                  _builder.append("state__et = ");
-                  String _genStateId_5 = this._codegenHelpers.getGenStateId(state_2);
-                  String _history_1 = this.getHistory(_genStateId_5);
-                  _builder.append(_history_1, "\t\t\t\t\t");
-                  _builder.append(";");
-                  _builder.newLineIfNotEmpty();
-                  _builder.append("\t\t\t");
-                  _builder.append("\t");
-                  _builder.append("}");
-                  _builder.newLine();
-                } else {
-                  _builder.append("\t\t\t");
-                  _builder.append("\t");
-                  _builder.append("/* without init transition */");
-                  _builder.newLine();
-                  _builder.append("\t\t\t");
-                  _builder.append("\t");
-                  _builder.append("state__et = ");
-                  String _genStateId_6 = this._codegenHelpers.getGenStateId(state_2);
-                  String _history_2 = this.getHistory(_genStateId_6);
-                  _builder.append(_history_2, "\t\t\t\t");
-                  _builder.append(";");
-                  _builder.newLineIfNotEmpty();
-                }
-              }
-              _builder.append("\t\t\t");
-              _builder.append("\t");
-              _builder.append("break;");
-              _builder.newLine();
-            }
-          }
-        }
-      }
-      _builder.append("\t\t\t");
-      _builder.append("case STATE_TOP:");
-      _builder.newLine();
-      _builder.append("\t\t\t\t");
-      _builder.append("state__et = ");
-      String _history_3 = this.getHistory("STATE_TOP");
-      _builder.append(_history_3, "\t\t\t\t");
-      _builder.append(";");
-      _builder.newLineIfNotEmpty();
-      _builder.append("\t\t\t\t");
-      _builder.append("break;");
-      _builder.newLine();
-      _builder.append("\t\t\t");
-      _builder.append("default:");
-      _builder.newLine();
-      _builder.append("\t\t\t\t");
-      _builder.append("/* should not occur */");
-      _builder.newLine();
-      _builder.append("\t\t\t\t");
-      _builder.append("break;");
-      _builder.newLine();
-      _builder.append("\t\t");
-      _builder.append("}");
-      _builder.newLine();
-      _builder.append("\t\t");
-      _builder.append("skip_entry__et = ");
-      String _booleanConstant_3 = this.langExt.booleanConstant(false);
-      _builder.append(_booleanConstant_3, "\t\t");
-      _builder.append(";");
-      _builder.newLineIfNotEmpty();
-      _builder.append("\t");
-      _builder.append("}");
-      _builder.newLine();
-      _builder.append("\t");
-      String _unreachableReturn = this.unreachableReturn();
-      _builder.append(_unreachableReturn, "\t");
-      _builder.newLineIfNotEmpty();
-      _builder.append("}");
-      _builder.newLine();
-      _builder.newLine();
-      _builder.append(publicIf, "");
-      _builder.append("void ");
-      _builder.append(opScope, "");
-      _builder.append("executeInitTransition(");
-      _builder.append(selfOnly, "");
-      _builder.append(") {");
-      _builder.newLineIfNotEmpty();
-      _builder.append("\t");
-      StateGraph _stateMachine_4 = xpac.getStateMachine();
-      Transition initt = this._roomHelpers.getInitTransition(_stateMachine_4);
-      _builder.newLineIfNotEmpty();
-      _builder.append("\t");
-      _builder.append("int chain__et = ");
-      TransitionChain _chain_2 = xpac.getChain(initt);
-      String _genChainId_2 = this._codegenHelpers.getGenChainId(_chain_2);
-      _builder.append(_genChainId_2, "\t");
-      _builder.append(";");
-      _builder.newLineIfNotEmpty();
-      _builder.append("\t");
-      String _stateType_6 = this.stateType();
-      _builder.append(_stateType_6, "\t");
-      _builder.append(" next__et = ");
-      _builder.append(opScopePriv, "\t");
-      _builder.append("executeTransitionChain(");
-      String _selfPointer_4 = this.langExt.selfPointer(true);
-      _builder.append(_selfPointer_4, "\t");
-      _builder.append("chain__et");
-      {
-        if (handleEvents) {
-          _builder.append(", ");
-          String _nullPointer_2 = this.langExt.nullPointer();
-          _builder.append(_nullPointer_2, "\t");
-          _builder.append(", ");
-          String _nullPointer_3 = this.langExt.nullPointer();
-          _builder.append(_nullPointer_3, "\t");
-        }
-      }
-      _builder.append(");");
-      _builder.newLineIfNotEmpty();
-      _builder.append("\t");
-      _builder.append("next__et = ");
-      _builder.append(opScopePriv, "\t");
-      _builder.append("enterHistory(");
-      String _selfPointer_5 = this.langExt.selfPointer(true);
-      _builder.append(_selfPointer_5, "\t");
-      _builder.append("next__et");
-      {
-        if (usesHdlr) {
-          _builder.append(", ");
-          String _booleanConstant_4 = this.langExt.booleanConstant(false);
-          _builder.append(_booleanConstant_4, "\t");
-        }
-      }
-      _builder.append(");");
-      _builder.newLineIfNotEmpty();
-      _builder.append("\t");
-      _builder.append("setState(");
-      String _selfPointer_6 = this.langExt.selfPointer(true);
-      _builder.append(_selfPointer_6, "\t");
-      _builder.append("next__et);");
-      _builder.newLineIfNotEmpty();
-      _builder.append("}");
-      _builder.newLine();
-      _builder.newLine();
-      _builder.append("/* receiveEvent contains the main implementation of the FSM */");
-      _builder.newLine();
-      _builder.append(publicIf, "");
-      _builder.append("void ");
-      _builder.append(opScope, "");
-      _builder.append("receiveEvent(");
-      String _name_4 = ac.getName();
-      String _selfPointer_7 = this.langExt.selfPointer(_name_4, handleEvents);
-      _builder.append(_selfPointer_7, "");
-      {
-        if (handleEvents) {
-          _builder.append(ifItemPtr, "");
-          _builder.append(" ifitem, int evt, ");
-          String _voidPointer_1 = this.langExt.voidPointer();
-          _builder.append(_voidPointer_1, "");
-          _builder.append(" generic_data__et");
-        }
-      }
-      _builder.append(") {");
-      _builder.newLineIfNotEmpty();
-      {
-        if (async) {
-          _builder.append("\t");
-          _builder.append("int trigger__et = (ifitem==");
-          String _nullPointer_4 = this.langExt.nullPointer();
-          _builder.append(_nullPointer_4, "\t");
-          _builder.append(")? POLLING : ifitem");
-          _builder.append(getLocalId, "\t");
-          _builder.append(" + EVT_SHIFT*evt;");
-          _builder.newLineIfNotEmpty();
-        } else {
-          if (eventDriven) {
-            _builder.append("\t");
-            _builder.append("int trigger__et = ifitem");
-            _builder.append(getLocalId, "\t");
-            _builder.append(" + EVT_SHIFT*evt;");
-            _builder.newLineIfNotEmpty();
-          }
-        }
-      }
-      _builder.append("\t");
-      _builder.append("int chain__et = NOT_CAUGHT;");
-      _builder.newLine();
-      _builder.append("\t");
-      String _stateType_7 = this.stateType();
-      _builder.append(_stateType_7, "\t");
-      _builder.append(" catching_state__et = NO_STATE;");
-      _builder.newLineIfNotEmpty();
-      {
-        if (usesHdlr) {
-          _builder.append("\t");
-          String _boolType_3 = this.boolType();
-          _builder.append(_boolType_3, "\t");
-          _builder.append(" is_handler__et = ");
-          String _booleanConstant_5 = this.langExt.booleanConstant(false);
-          _builder.append(_booleanConstant_5, "\t");
-          _builder.append(";");
-          _builder.newLineIfNotEmpty();
-        }
-      }
-      {
-        boolean _or_3 = false;
-        if (async) {
-          _or_3 = true;
-        } else {
-          _or_3 = eventDriven;
-        }
-        if (_or_3) {
-          _builder.append("\t");
-          CharSequence _markVariableUsed = this.markVariableUsed("trigger__et");
-          _builder.append(_markVariableUsed, "\t");
-          _builder.newLineIfNotEmpty();
-        }
-      }
-      _builder.append("\t");
-      _builder.newLine();
-      {
-        if (handleEvents) {
-          _builder.append("\t");
-          _builder.append("if (!handleSystemEvent(ifitem, evt, generic_data__et)) {");
-          _builder.newLine();
-          _builder.append("\t");
-          _builder.append("\t");
-          CharSequence _genStateSwitch = this.genStateSwitch(xpac, usesHdlr);
-          _builder.append(_genStateSwitch, "\t\t");
-          _builder.newLineIfNotEmpty();
-          _builder.append("\t");
-          _builder.append("}");
-          _builder.newLine();
-        } else {
-          _builder.append("\t");
-          CharSequence _genStateSwitch_1 = this.genStateSwitch(xpac, usesHdlr);
-          _builder.append(_genStateSwitch_1, "\t");
-          _builder.newLineIfNotEmpty();
-        }
-      }
-      _builder.append("\t");
-      _builder.append("if (chain__et != NOT_CAUGHT) {");
-      _builder.newLine();
-      _builder.append("\t\t");
-      _builder.append(opScopePriv, "\t\t");
-      _builder.append("exitTo(");
-      String _selfPointer_8 = this.langExt.selfPointer(true);
-      _builder.append(_selfPointer_8, "\t\t");
-      _builder.append("getState(");
-      String _selfPointer_9 = this.langExt.selfPointer(false);
-      _builder.append(_selfPointer_9, "\t\t");
-      _builder.append("), catching_state__et");
-      {
-        if (usesHdlr) {
-          _builder.append(", is_handler__et");
-        }
-      }
-      _builder.append(");");
-      _builder.newLineIfNotEmpty();
-      _builder.append("\t\t");
-      _builder.append("{");
-      _builder.newLine();
-      _builder.append("\t\t\t");
-      String _stateType_8 = this.stateType();
-      _builder.append(_stateType_8, "\t\t\t");
-      _builder.append(" next__et = ");
-      _builder.append(opScopePriv, "\t\t\t");
-      _builder.append("executeTransitionChain(");
-      String _selfPointer_10 = this.langExt.selfPointer(true);
-      _builder.append(_selfPointer_10, "\t\t\t");
-      _builder.append("chain__et");
-      {
-        if (handleEvents) {
-          _builder.append(", ifitem, generic_data__et");
-        }
-      }
-      _builder.append(");");
-      _builder.newLineIfNotEmpty();
-      _builder.append("\t\t\t");
-      _builder.append("next__et = ");
-      _builder.append(opScopePriv, "\t\t\t");
-      _builder.append("enterHistory(");
-      String _selfPointer_11 = this.langExt.selfPointer(true);
-      _builder.append(_selfPointer_11, "\t\t\t");
-      _builder.append("next__et");
-      {
-        if (usesHdlr) {
-          _builder.append(", is_handler__et");
-        }
-      }
-      _builder.append(");");
-      _builder.newLineIfNotEmpty();
-      _builder.append("\t\t\t");
-      _builder.append("setState(");
-      String _selfPointer_12 = this.langExt.selfPointer(true);
-      _builder.append(_selfPointer_12, "\t\t\t");
-      _builder.append("next__et);");
-      _builder.newLineIfNotEmpty();
-      _builder.append("\t\t\t");
-      CharSequence _finalAction = this.finalAction();
-      _builder.append(_finalAction, "\t\t\t");
-      _builder.newLineIfNotEmpty();
-      _builder.append("\t\t");
-      _builder.append("}");
-      _builder.newLine();
-      _builder.append("\t");
-      _builder.append("}");
-      _builder.newLine();
-      _builder.append("}");
-      _builder.newLine();
-      _xblockexpression = _builder;
     }
-    return _xblockexpression;
-  }
-  
-  /**
-   * empty, but may be overridden
-   */
-  public CharSequence finalAction() {
-    StringConcatenation _builder = new StringConcatenation();
-    return _builder;
-  }
-  
-  /**
-   * empty, but may be overridden
-   */
-  public CharSequence markVariableUsed(final String varname) {
-    StringConcatenation _builder = new StringConcatenation();
-    return _builder;
-  }
-  
-  /**
-   * helper method which generates the state switch.
-   * Asynchronous, data driven and event driven state machines are distinguished
-   * 
-   * @param xpac the {@link ExpandedActorClass}
-   * @param usesHdlr if the state machine uses no handler {@link TransitionPoint}s
-   * 		at all then unused variables can be avoided by passing <code>true</code>
-   * @return the generated code
-   */
-  protected CharSequence genStateSwitch(final ExpandedActorClass xpac, final boolean usesHdlr) {
-    CharSequence _xblockexpression = null;
-    {
-      ActorClass _actorClass = xpac.getActorClass();
-      ComponentCommunicationType _commType = _actorClass.getCommType();
-      boolean async = Objects.equal(_commType, ComponentCommunicationType.ASYNCHRONOUS);
-      ActorClass _actorClass_1 = xpac.getActorClass();
-      ComponentCommunicationType _commType_1 = _actorClass_1.getCommType();
-      boolean eventDriven = Objects.equal(_commType_1, ComponentCommunicationType.EVENT_DRIVEN);
-      ActorClass _actorClass_2 = xpac.getActorClass();
-      ComponentCommunicationType _commType_2 = _actorClass_2.getCommType();
-      boolean dataDriven = Objects.equal(_commType_2, ComponentCommunicationType.DATA_DRIVEN);
-      StringConcatenation _builder = new StringConcatenation();
-      _builder.append("switch (getState(");
-      String _selfPointer = this.langExt.selfPointer(false);
-      _builder.append(_selfPointer, "");
-      _builder.append(")) {");
-      _builder.newLineIfNotEmpty();
-      {
-        StateGraph _stateMachine = xpac.getStateMachine();
-        List<State> _leafStateList = this._roomHelpers.getLeafStateList(_stateMachine);
-        for(final State state : _leafStateList) {
-          _builder.append("\t");
-          _builder.append("case ");
-          String _genStateId = this._codegenHelpers.getGenStateId(state);
-          _builder.append(_genStateId, "\t");
-          _builder.append(":");
-          _builder.newLineIfNotEmpty();
-          {
-            if (async) {
-              _builder.append("\t");
-              _builder.append("\t");
-              EList<ActiveTrigger> atlist = xpac.getActiveTriggers(state);
-              _builder.newLineIfNotEmpty();
-              {
-                boolean _isEmpty = atlist.isEmpty();
-                boolean _not = (!_isEmpty);
-                if (_not) {
-                  _builder.append("\t");
-                  _builder.append("\t");
-                  _builder.append("switch(trigger__et) {");
-                  _builder.newLine();
-                  _builder.append("\t");
-                  _builder.append("\t");
-                  _builder.append("\t");
-                  _builder.append("case POLLING:");
-                  _builder.newLine();
-                  _builder.append("\t");
-                  _builder.append("\t");
-                  _builder.append("\t\t");
-                  CharSequence _genDataDrivenTriggers = this.genDataDrivenTriggers(xpac, state, usesHdlr);
-                  _builder.append(_genDataDrivenTriggers, "\t\t\t\t");
-                  _builder.newLineIfNotEmpty();
-                  _builder.append("\t");
-                  _builder.append("\t");
-                  _builder.append("\t\t");
-                  _builder.append("break;");
-                  _builder.newLine();
-                  _builder.append("\t");
-                  _builder.append("\t");
-                  _builder.append("\t");
-                  CharSequence _genEventDrivenTriggers = this.genEventDrivenTriggers(xpac, state, atlist, usesHdlr);
-                  _builder.append(_genEventDrivenTriggers, "\t\t\t");
-                  _builder.newLineIfNotEmpty();
-                  _builder.append("\t");
-                  _builder.append("\t");
-                  _builder.append("}");
-                  _builder.newLine();
-                } else {
-                  _builder.append("\t");
-                  _builder.append("\t");
-                  CharSequence _genDataDrivenTriggers_1 = this.genDataDrivenTriggers(xpac, state, usesHdlr);
-                  _builder.append(_genDataDrivenTriggers_1, "\t\t");
-                  _builder.newLineIfNotEmpty();
-                }
-              }
-            } else {
-              if (dataDriven) {
-                _builder.append("\t");
-                _builder.append("\t");
-                CharSequence _genDataDrivenTriggers_2 = this.genDataDrivenTriggers(xpac, state, usesHdlr);
-                _builder.append(_genDataDrivenTriggers_2, "\t\t");
-                _builder.newLineIfNotEmpty();
-              } else {
-                if (eventDriven) {
-                  _builder.append("\t");
-                  _builder.append("\t");
-                  EList<ActiveTrigger> atlist_1 = xpac.getActiveTriggers(state);
-                  _builder.newLineIfNotEmpty();
-                  {
-                    boolean _isEmpty_1 = atlist_1.isEmpty();
-                    boolean _not_1 = (!_isEmpty_1);
-                    if (_not_1) {
-                      _builder.append("\t");
-                      _builder.append("\t");
-                      _builder.append("switch(trigger__et) {");
-                      _builder.newLine();
-                      _builder.append("\t");
-                      _builder.append("\t");
-                      _builder.append("\t\t");
-                      CharSequence _genEventDrivenTriggers_1 = this.genEventDrivenTriggers(xpac, state, atlist_1, usesHdlr);
-                      _builder.append(_genEventDrivenTriggers_1, "\t\t\t\t");
-                      _builder.newLineIfNotEmpty();
-                      _builder.append("\t");
-                      _builder.append("\t");
-                      _builder.append("}");
-                      _builder.newLine();
-                    }
-                  }
-                }
-              }
-            }
-          }
-          _builder.append("\t");
-          _builder.append("\t");
-          _builder.append("break;");
-          _builder.newLine();
-        }
-      }
-      _builder.append("\t");
-      _builder.append("default:");
-      _builder.newLine();
-      _builder.append("\t\t");
-      _builder.append("/* should not occur */");
-      _builder.newLine();
-      _builder.append("\t\t");
-      _builder.append("break;");
-      _builder.newLine();
-      _builder.append("}");
-      _builder.newLine();
-      _xblockexpression = _builder;
-    }
-    return _xblockexpression;
-  }
-  
-  /**
-   * helper method which generates the data driven triggers
-   * 
-   * @param xpac the {@link ExpandedActorClass}
-   * @param state the {@link State} for which the trigger if-else switch should be generated
-   * @param usesHdlr if the state machine uses no handler {@link TransitionPoints}
-   * 		at all then unused variables can be avoided by passing <code>true</code>
-   * @return the generated code
-   */
-  protected CharSequence genDataDrivenTriggers(final ExpandedActorClass xpac, final State state, final boolean usesHdlr) {
-    StringConcatenation _builder = new StringConcatenation();
-    String _genDoCodes = this.genDoCodes(state);
-    _builder.append(_genDoCodes, "");
+    _builder.newLine();
+    CharSequence _genExtra = this.genExtra(xpmc);
+    _builder.append(_genExtra, "");
     _builder.newLineIfNotEmpty();
-    List<Transition> _outgoingTransitionsHierarchical = this._roomExtensions.getOutgoingTransitionsHierarchical(xpac, state);
-    final Function1<Transition, Boolean> _function = new Function1<Transition, Boolean>() {
-      public Boolean apply(final Transition t) {
-        return Boolean.valueOf((t instanceof GuardedTransition));
-      }
-    };
-    Iterable<Transition> transitions = IterableExtensions.<Transition>filter(_outgoingTransitionsHierarchical, _function);
+    _builder.newLine();
+    _builder.append("/* Entry and Exit Codes */");
+    _builder.newLine();
+    _builder.append("        ");
+    String _genEntryAndExitCodes = this.genEntryAndExitCodes(xpmc, true);
+    _builder.append(_genEntryAndExitCodes, "        ");
     _builder.newLineIfNotEmpty();
-    {
-      for(final Transition tr : transitions) {
-        _builder.append("if (");
-        AbstractGenerator _instance = AbstractGenerator.getInstance();
-        DetailCode _guard = ((GuardedTransition) tr).getGuard();
-        String _translatedCode = _instance.getTranslatedCode(_guard);
-        _builder.append(_translatedCode, "");
-        _builder.append(")");
-        _builder.newLineIfNotEmpty();
-        _builder.append("{");
-        _builder.newLine();
-        _builder.append("\t");
-        TransitionChain chain = xpac.getChain(tr);
-        _builder.newLineIfNotEmpty();
-        _builder.append("\t");
-        _builder.append("chain__et = ");
-        String _genChainId = this._codegenHelpers.getGenChainId(chain);
-        _builder.append(_genChainId, "\t");
-        _builder.append(";");
-        _builder.newLineIfNotEmpty();
-        _builder.append("\t");
-        _builder.append("catching_state__et = ");
-        State _stateContext = chain.getStateContext();
-        String _genStateId = this._codegenHelpers.getGenStateId(_stateContext);
-        _builder.append(_genStateId, "\t");
-        _builder.append(";");
-        _builder.newLineIfNotEmpty();
-        {
-          boolean _and = false;
-          boolean _isHandler = chain.isHandler();
-          if (!_isHandler) {
-            _and = false;
-          } else {
-            _and = usesHdlr;
-          }
-          if (_and) {
-            _builder.append("\t");
-            _builder.append("is_handler__et = ET_TRUE;");
-            _builder.newLine();
-          }
-        }
-        _builder.append("}");
-        _builder.newLine();
-        {
-          Transition _last = IterableExtensions.<Transition>last(transitions);
-          boolean _notEquals = (!Objects.equal(tr, _last));
-          if (_notEquals) {
-            _builder.append("else ");
-            _builder.newLine();
-          }
-        }
-      }
-    }
-    return _builder;
-  }
-  
-  /**
-   * helper method which generates the event driven triggers
-   * 
-   * @param xpac the {@link ExpandedActorClass}
-   * @param state the {@link State} for which the trigger switch should be generated
-   * @param atlist the list of {@link ActiveTrigger}s of this state
-   * @param usesHdlr if the state machine uses no handler {@link TransitionPoints}
-   * 		at all then unused variables can be avoided by passing <code>true</code>
-   * @return the generated code
-   */
-  protected CharSequence genEventDrivenTriggers(final ExpandedActorClass xpac, final State state, final List<ActiveTrigger> atlist, final boolean usesHdlr) {
-    StringConcatenation _builder = new StringConcatenation();
-    {
-      for(final ActiveTrigger at : atlist) {
-        _builder.append("case ");
-        String _triggerCodeName = xpac.getTriggerCodeName(at);
-        _builder.append(_triggerCodeName, "");
-        _builder.append(":");
-        _builder.newLineIfNotEmpty();
-        _builder.append("\t");
-        boolean needData = this._eTriceGenUtil.hasGuard(at);
-        _builder.newLineIfNotEmpty();
-        _builder.append("\t");
-        {
-          if (needData) {
-            _builder.append("{ ");
-            EObject _msg = at.getMsg();
-            String _typedDataDefinition = this.langExt.getTypedDataDefinition(((Message) _msg));
-            _builder.append(_typedDataDefinition, "\t");
-          }
-        }
-        _builder.newLineIfNotEmpty();
-        {
-          EList<TriggeredTransition> _transitions = at.getTransitions();
-          boolean _hasElements = false;
-          for(final TriggeredTransition tt : _transitions) {
-            if (!_hasElements) {
-              _hasElements = true;
-            } else {
-              _builder.appendImmediate(" else ", "\t");
-            }
-            _builder.append("\t");
-            TransitionChain chain = xpac.getChain(tt);
-            _builder.newLineIfNotEmpty();
-            _builder.append("\t");
-            Transition _transition = chain.getTransition();
-            String _trigger = at.getTrigger();
-            CharSequence _guard = this.guard(_transition, _trigger, xpac);
-            _builder.append(_guard, "\t");
-            _builder.newLineIfNotEmpty();
-            _builder.append("\t");
-            _builder.append("{");
-            _builder.newLine();
-            _builder.append("\t");
-            _builder.append("\t");
-            _builder.append("chain__et = ");
-            String _genChainId = this._codegenHelpers.getGenChainId(chain);
-            _builder.append(_genChainId, "\t\t");
-            _builder.append(";");
-            _builder.newLineIfNotEmpty();
-            _builder.append("\t");
-            _builder.append("\t");
-            _builder.append("catching_state__et = ");
-            State _stateContext = chain.getStateContext();
-            String _genStateId = this._codegenHelpers.getGenStateId(_stateContext);
-            _builder.append(_genStateId, "\t\t");
-            _builder.append(";");
-            _builder.newLineIfNotEmpty();
-            {
-              boolean _and = false;
-              boolean _isHandler = chain.isHandler();
-              if (!_isHandler) {
-                _and = false;
-              } else {
-                _and = usesHdlr;
-              }
-              if (_and) {
-                _builder.append("\t");
-                _builder.append("\t");
-                _builder.append("is_handler__et = ");
-                String _booleanConstant = this.langExt.booleanConstant(true);
-                _builder.append(_booleanConstant, "\t\t");
-                _builder.append(";");
-                _builder.newLineIfNotEmpty();
-              }
-            }
-            _builder.append("\t");
-            _builder.append("}");
-            _builder.newLine();
-          }
-        }
-        _builder.append("\t");
-        {
-          if (needData) {
-            _builder.append("}");
-          }
-        }
-        _builder.newLineIfNotEmpty();
-        _builder.append("break;");
-        _builder.newLine();
-      }
-    }
-    _builder.append("default:");
     _builder.newLine();
-    _builder.append("\t");
-    _builder.append("/* should not occur */");
+    _builder.append("/* Action Codes */");
     _builder.newLine();
-    _builder.append("\t");
-    _builder.append("break;");
+    _builder.append("        ");
+    String _genActionCodes = this.genActionCodes(xpmc, true);
+    _builder.append(_genActionCodes, "        ");
+    _builder.newLineIfNotEmpty();
     _builder.newLine();
-    return _builder;
-  }
-  
-  /**
-   * getter for history array
-   * 
-   * @param state the ID of the history state
-   * @return the generated code
-   */
-  protected String getHistory(final String state) {
-    String _memberAccess = this.langExt.memberAccess();
-    String _plus = (_memberAccess + "history[");
-    String _plus_1 = (_plus + state);
-    return (_plus_1 + "]");
-  }
-  
-  /**
-   * setter for history array
-   * 
-   * @param state the ID of the state whose history should be set
-   * @param historyState the ID of the state that should be assigned
-   * @return the generated code
-   */
-  protected String setHistory(final String state, final String historyState) {
-    String _memberAccess = this.langExt.memberAccess();
-    String _plus = (_memberAccess + "history[");
-    String _plus_1 = (_plus + state);
-    String _plus_2 = (_plus_1 + "] = ");
-    return (_plus_2 + historyState);
-  }
-  
-  /**
-   * @return the type of (temporary) state variables (defaults to "int")
-   * and has to be signed
-   */
-  protected String stateType() {
-    return "int";
-  }
-  
-  /**
-   * allow target language dependent generation of unreachable return in generated enterHistory method.
-   * The default is just a comment.
-   * @return the generated code
-   */
-  protected String unreachableReturn() {
-    return "/* return NO_STATE; // required by CDT but detected as unreachable by JDT because of while (true) */";
-  }
-  
-  /**
-   * type of (temporary) boolean variables (defaults to "boolean")
-   * @return the generated code
-   */
-  protected String boolType() {
-    return "boolean";
-  }
-  
-  /**
-   * let derived class add extra code after definition of constants
-   * 
-   * @param xpac an expanded actor class
-   * @return the generated code
-   */
-  protected CharSequence genExtra(final ExpandedActorClass xpac) {
-    StringConcatenation _builder = new StringConcatenation();
-    return _builder;
-  }
-  
-  /**
-   * let derived class add extra code after definition of constants in header (if applicable)
-   * 
-   * @param xpac an expanded actor class
-   * @return the generated code
-   */
-  protected CharSequence genExtraDecl(final ExpandedActorClass xpac) {
-    StringConcatenation _builder = new StringConcatenation();
+    _builder.append("/* State Switch Methods */");
+    _builder.newLine();
+    String _genStateSwitchMethods = this.genStateSwitchMethods(xpmc, true);
+    _builder.append(_genStateSwitchMethods, "");
+    _builder.newLineIfNotEmpty();
     return _builder;
   }
   
@@ -1550,110 +110,157 @@
    * 
    * @param tt a {@link TriggeredTransition}
    * @param trigger a trigger string
-   * @param xpac an expanded actor class
+   * @param xpmc an expanded actor class
    * @return the generated code
    */
-  protected CharSequence _guard(final TriggeredTransition tt, final String trigger, final ExpandedActorClass ac) {
-    CharSequence _xblockexpression = null;
+  public String guard(final TriggeredTransition tt, final String trigger, final ExpandedModelComponent mc) {
+    String _xblockexpression = null;
     {
       EList<Trigger> _triggers = tt.getTriggers();
       final Function1<Trigger, Boolean> _function = new Function1<Trigger, Boolean>() {
         public Boolean apply(final Trigger e) {
-          return Boolean.valueOf(ac.isMatching(e, trigger));
+          return Boolean.valueOf(mc.isMatching(e, trigger));
         }
       };
       final Trigger tr = IterableExtensions.<Trigger>findFirst(_triggers, _function);
       StringConcatenation _builder = new StringConcatenation();
       {
-        boolean _hasGuard = this._roomHelpers.hasGuard(tr);
+        boolean _hasGuard = this._fSMHelpers.hasGuard(tr);
         if (_hasGuard) {
           _builder.append("if (");
-          AbstractGenerator _instance = AbstractGenerator.getInstance();
           Guard _guard = tr.getGuard();
           DetailCode _guard_1 = _guard.getGuard();
-          String _translatedCode = _instance.getTranslatedCode(_guard_1);
+          String _translatedCode = this.translator.getTranslatedCode(_guard_1);
           _builder.append(_translatedCode, "");
           _builder.append(")");
           _builder.newLineIfNotEmpty();
         }
       }
-      _xblockexpression = _builder;
+      _xblockexpression = _builder.toString();
+    }
+    return _xblockexpression;
+  }
+  
+  public String guard(final GuardedTransition tt, final String trigger, final ExpandedModelComponent mc) {
+    StringConcatenation _builder = new StringConcatenation();
+    DetailCode _guard = tt.getGuard();
+    String _translatedCode = this.translator.getTranslatedCode(_guard);
+    _builder.append(_translatedCode, "");
+    _builder.newLineIfNotEmpty();
+    return _builder.toString();
+  }
+  
+  public String genActionCodeMethod(final ExpandedModelComponent xpmc, final Transition tr, final boolean generateImplementation) {
+    String _xblockexpression = null;
+    {
+      TransitionChain _chain = xpmc.getChain(tr);
+      Transition _transition = null;
+      if (_chain!=null) {
+        _transition=_chain.getTransition();
+      }
+      Transition start = _transition;
+      boolean _and = false;
+      if (!(start instanceof NonInitialTransition)) {
+        _and = false;
+      } else {
+        _and = (!(start instanceof GuardedTransition));
+      }
+      boolean hasArgs = _and;
+      String _className = this.getClassName(xpmc);
+      final String opScope = this.langExt.operationScope(_className, false);
+      String _xifexpression = null;
+      boolean _usesInheritance = this.langExt.usesInheritance();
+      if (_usesInheritance) {
+        _xifexpression = opScope;
+      } else {
+        _xifexpression = "";
+      }
+      final String opScopePriv = _xifexpression;
+      String _pointerLiteral = this.langExt.pointerLiteral();
+      final String ifItemPtr = ("InterfaceItemBase" + _pointerLiteral);
+      String _xifexpression_1 = null;
+      boolean _usesPointers = this.langExt.usesPointers();
+      if (_usesPointers) {
+        _xifexpression_1 = ("const " + ifItemPtr);
+      } else {
+        _xifexpression_1 = ifItemPtr;
+      }
+      final String constIfItemPtr = _xifexpression_1;
+      String _xifexpression_2 = null;
+      if (generateImplementation) {
+        StringConcatenation _builder = new StringConcatenation();
+        String _accessLevelProtected = this.langExt.accessLevelProtected();
+        _builder.append(_accessLevelProtected, "");
+        _builder.append("void ");
+        _builder.append(opScopePriv, "");
+        String _actionCodeOperationName = this._codegenHelpers.getActionCodeOperationName(tr);
+        _builder.append(_actionCodeOperationName, "");
+        _builder.append("(");
+        String _className_1 = this.getClassName(xpmc);
+        String _selfPointer = this.langExt.selfPointer(_className_1, hasArgs);
+        _builder.append(_selfPointer, "");
+        {
+          if (hasArgs) {
+            _builder.append(constIfItemPtr, "");
+            _builder.append(" ifitem");
+            String _generateArgumentList = this.transitionChainGenerator.generateArgumentList(xpmc, tr);
+            _builder.append(_generateArgumentList, "");
+          }
+        }
+        _builder.append(") {");
+        _builder.newLineIfNotEmpty();
+        _builder.append("    ");
+        DetailCode _action = tr.getAction();
+        String _translatedCode = this.translator.getTranslatedCode(_action);
+        _builder.append(_translatedCode, "    ");
+        _builder.newLineIfNotEmpty();
+        _builder.append("}");
+        _builder.newLine();
+        _xifexpression_2 = _builder.toString();
+      } else {
+        StringConcatenation _builder_1 = new StringConcatenation();
+        String _accessLevelProtected_1 = this.langExt.accessLevelProtected();
+        _builder_1.append(_accessLevelProtected_1, "");
+        _builder_1.append("void ");
+        String _actionCodeOperationName_1 = this._codegenHelpers.getActionCodeOperationName(tr);
+        _builder_1.append(_actionCodeOperationName_1, "");
+        _builder_1.append("(");
+        String _className_2 = this.getClassName(xpmc);
+        String _selfPointer_1 = this.langExt.selfPointer(_className_2, hasArgs);
+        _builder_1.append(_selfPointer_1, "");
+        {
+          if (hasArgs) {
+            _builder_1.append(constIfItemPtr, "");
+            _builder_1.append(" ifitem");
+            String _generateArgumentList_1 = this.transitionChainGenerator.generateArgumentList(xpmc, tr);
+            _builder_1.append(_generateArgumentList_1, "");
+          }
+        }
+        _builder_1.append(");");
+        _builder_1.newLineIfNotEmpty();
+        _xifexpression_2 = _builder_1.toString();
+      }
+      _xblockexpression = _xifexpression_2;
     }
     return _xblockexpression;
   }
   
   /**
-   * (necessary for completeness of the dispatching, never called)
-   */
-  protected CharSequence _guard(final Transition t, final String trigger, final ExpandedActorClass ac) {
-    StringConcatenation _builder = new StringConcatenation();
-    _builder.append("/* error */");
-    _builder.newLine();
-    return _builder;
-  }
-  
-  /**
-   * generate the do code calls for a given state
-   * 
-   * @param state the {@link State}
-   * @return the generated code
-   */
-  protected String genDoCodes(final State state) {
-    StringConcatenation _builder = new StringConcatenation();
-    {
-      boolean _hasDoCode = this._roomHelpers.hasDoCode(state, true);
-      if (_hasDoCode) {
-        String _doCodeOperationName = this._codegenHelpers.getDoCodeOperationName(state);
-        _builder.append(_doCodeOperationName, "");
-        _builder.append("(");
-        String _selfPointer = this.langExt.selfPointer(false);
-        _builder.append(_selfPointer, "");
-        _builder.append(");");
-        _builder.newLineIfNotEmpty();
-      }
-    }
-    {
-      EObject _eContainer = state.eContainer();
-      EObject _eContainer_1 = _eContainer.eContainer();
-      if ((_eContainer_1 instanceof State)) {
-        EObject _eContainer_2 = state.eContainer();
-        EObject _eContainer_3 = _eContainer_2.eContainer();
-        String _genDoCodes = this.genDoCodes(((State) _eContainer_3));
-        _builder.append(_genDoCodes, "");
-        _builder.newLineIfNotEmpty();
-      }
-    }
-    return _builder.toString();
-  }
-  
-  /**
-   * generate action code method implementations
-   * 
-   * @param xpac the {@link ExpandedActorClass}
-   * @param state the {@link State}
-   * @return the generated code
-   */
-  protected CharSequence genActionCodeMethods(final ExpandedActorClass xpac, final State state) {
-    return this.genActionCodeMethods(xpac, state, true);
-  }
-  
-  /**
    * generate action code method implementations or declarations
    * 
-   * @param xpax the {@link ExpandedActorClass}
+   * @param xpax the {@link ExpandedModelComponent}
    * @param state the {@link State}
    * @param generateImplementation if only declarations should be generated then <code>false</code> has to be passed
    * @return the generated code
    */
-  protected CharSequence genActionCodeMethods(final ExpandedActorClass xpac, final State state, final boolean generateImplementation) {
-    CharSequence _xblockexpression = null;
+  public String genActionCodeMethods(final ExpandedModelComponent xpmc, final State state, final boolean generateImplementation) {
+    String _xblockexpression = null;
     {
-      final ActorClass ac = xpac.getActorClass();
-      ActorClass _actorClass = xpac.getActorClass();
-      String _name = _actorClass.getName();
-      final String selfPtr = this.langExt.selfPointer(_name, false);
-      String _name_1 = ac.getName();
-      final String opScope = this.langExt.operationScope(_name_1, false);
+      final ModelComponent mc = xpmc.getModelComponent();
+      String _className = this.getClassName(mc);
+      final String selfPtr = this.langExt.selfPointer(_className, false);
+      String _className_1 = this.getClassName(mc);
+      final String opScope = this.langExt.operationScope(_className_1, false);
       String _xifexpression = null;
       boolean _usesInheritance = this.langExt.usesInheritance();
       if (_usesInheritance) {
@@ -1665,47 +272,40 @@
       final String entryOp = this._codegenHelpers.getEntryCodeOperationName(state);
       final String exitOp = this._codegenHelpers.getExitCodeOperationName(state);
       final String doOp = this._codegenHelpers.getDoCodeOperationName(state);
-      AbstractGenerator _instance = AbstractGenerator.getInstance();
       DetailCode _entryCode = state.getEntryCode();
-      String entry = _instance.getTranslatedCode(_entryCode);
-      AbstractGenerator _instance_1 = AbstractGenerator.getInstance();
+      String entry = this.translator.getTranslatedCode(_entryCode);
       DetailCode _exitCode = state.getExitCode();
-      String exit = _instance_1.getTranslatedCode(_exitCode);
-      AbstractGenerator _instance_2 = AbstractGenerator.getInstance();
+      String exit = this.translator.getTranslatedCode(_exitCode);
       DetailCode _doCode = state.getDoCode();
-      String docode = _instance_2.getTranslatedCode(_doCode);
+      String docode = this.translator.getTranslatedCode(_doCode);
       if ((state instanceof ExpandedRefinedState)) {
         final ExpandedRefinedState rs = ((ExpandedRefinedState) state);
-        AbstractGenerator _instance_3 = AbstractGenerator.getInstance();
         DetailCode _inheritedEntry = rs.getInheritedEntry();
-        final String inhEntry = _instance_3.getTranslatedCode(_inheritedEntry);
-        AbstractGenerator _instance_4 = AbstractGenerator.getInstance();
+        final String inhEntry = this.translator.getTranslatedCode(_inheritedEntry);
         DetailCode _inheritedExit = rs.getInheritedExit();
-        final String inhExit = _instance_4.getTranslatedCode(_inheritedExit);
-        AbstractGenerator _instance_5 = AbstractGenerator.getInstance();
+        final String inhExit = this.translator.getTranslatedCode(_inheritedExit);
         DetailCode _inheritedDo = rs.getInheritedDo();
-        final String inhDo = _instance_5.getTranslatedCode(_inheritedDo);
+        final String inhDo = this.translator.getTranslatedCode(_inheritedDo);
         boolean _usesInheritance_1 = this.langExt.usesInheritance();
         if (_usesInheritance_1) {
-          ActorClass _actorClass_1 = xpac.getActorClass();
-          ActorClass _actorBase = _actorClass_1.getActorBase();
-          final String baseName = _actorBase.getName();
+          ModelComponent _base = mc.getBase();
+          final String baseName = this.getClassName(_base);
           DetailCode _inheritedEntry_1 = rs.getInheritedEntry();
-          boolean _hasDetailCode = this._roomHelpers.hasDetailCode(_inheritedEntry_1);
+          boolean _hasDetailCode = this._fSMHelpers.hasDetailCode(_inheritedEntry_1);
           if (_hasDetailCode) {
             String _superCall = this.langExt.superCall(baseName, entryOp, "");
             String _plus = (_superCall + entry);
             entry = _plus;
           }
           DetailCode _inheritedExit_1 = rs.getInheritedExit();
-          boolean _hasDetailCode_1 = this._roomHelpers.hasDetailCode(_inheritedExit_1);
+          boolean _hasDetailCode_1 = this._fSMHelpers.hasDetailCode(_inheritedExit_1);
           if (_hasDetailCode_1) {
             String _superCall_1 = this.langExt.superCall(baseName, exitOp, "");
             String _plus_1 = (exit + _superCall_1);
             exit = _plus_1;
           }
           DetailCode _inheritedDo_1 = rs.getInheritedDo();
-          boolean _hasDetailCode_2 = this._roomHelpers.hasDetailCode(_inheritedDo_1);
+          boolean _hasDetailCode_2 = this._fSMHelpers.hasDetailCode(_inheritedDo_1);
           if (_hasDetailCode_2) {
             String _superCall_2 = this.langExt.superCall(baseName, doOp, "");
             String _plus_2 = (_superCall_2 + docode);
@@ -1817,7 +417,7 @@
           }
         }
       }
-      _xblockexpression = _builder;
+      _xblockexpression = _builder.toString();
     }
     return _xblockexpression;
   }
@@ -1826,23 +426,23 @@
    * @param classname the name of the type
    * @return the type name for a constant pointer
    */
-  protected String constPointer(final String classname) {
+  public String constPointer(final String classname) {
     return classname;
   }
   
   /**
    * generate all method declarations
    * 
-   * @param xpax the {@link ExpandedActorClass}
+   * @param xpax the {@link ExpandedModelComponent}
    * @return the generated code
    */
-  public CharSequence genStateMachineMethodDeclarations(final ExpandedActorClass xpac) {
+  public CharSequence genStateMachineMethodDeclarations(final ExpandedModelComponent xpmc) {
     CharSequence _xblockexpression = null;
     {
-      final ActorClass ac = xpac.getActorClass();
-      ComponentCommunicationType _commType = ac.getCommType();
+      final ModelComponent mc = xpmc.getModelComponent();
+      ComponentCommunicationType _commType = mc.getCommType();
       final boolean async = Objects.equal(_commType, ComponentCommunicationType.ASYNCHRONOUS);
-      ComponentCommunicationType _commType_1 = ac.getCommType();
+      ComponentCommunicationType _commType_1 = mc.getCommType();
       final boolean eventDriven = Objects.equal(_commType_1, ComponentCommunicationType.EVENT_DRIVEN);
       boolean _or = false;
       if (async) {
@@ -1851,118 +451,46 @@
         _or = eventDriven;
       }
       final boolean handleEvents = _or;
-      String _name = ac.getName();
-      final String selfPtr = this.langExt.selfPointer(_name, true);
-      final boolean usesHdlr = this.usesHandlerTrPoints(xpac);
+      String _className = this.getClassName(mc);
+      final String selfPtr = this.langExt.selfPointer(_className, true);
+      final boolean usesHdlr = this.usesHandlerTrPoints(xpmc);
       StringConcatenation _builder = new StringConcatenation();
       _builder.newLine();
       _builder.append("/* state IDs */");
       _builder.newLine();
-      String _genStateIdConstants = this.genStateIdConstants(xpac);
+      String _genStateIdConstants = this.genStateIdConstants(xpmc);
       _builder.append(_genStateIdConstants, "");
       _builder.newLineIfNotEmpty();
       _builder.newLine();
       _builder.append("/* transition chains */");
       _builder.newLine();
-      String _genTransitionChainConstants = this.genTransitionChainConstants(xpac);
+      String _genTransitionChainConstants = this.genTransitionChainConstants(xpmc);
       _builder.append(_genTransitionChainConstants, "");
       _builder.newLineIfNotEmpty();
       _builder.newLine();
       _builder.append("/* triggers */");
       _builder.newLine();
-      String _genTriggerConstants = this.genTriggerConstants(xpac);
+      String _genTriggerConstants = this.genTriggerConstants(xpmc);
       _builder.append(_genTriggerConstants, "");
       _builder.newLineIfNotEmpty();
       _builder.newLine();
-      CharSequence _genExtraDecl = this.genExtraDecl(xpac);
+      CharSequence _genExtraDecl = this.genExtraDecl(xpmc);
       _builder.append(_genExtraDecl, "");
       _builder.newLineIfNotEmpty();
       _builder.newLine();
       _builder.append("/* Entry and Exit Codes */");
       _builder.newLine();
-      {
-        StateGraph _stateMachine = xpac.getStateMachine();
-        List<State> _stateList = this._roomHelpers.getStateList(_stateMachine);
-        for(final State state : _stateList) {
-          {
-            boolean _or_1 = false;
-            boolean _usesInheritance = this.langExt.usesInheritance();
-            boolean _not = (!_usesInheritance);
-            if (_not) {
-              _or_1 = true;
-            } else {
-              boolean _isOwnObject = xpac.isOwnObject(state);
-              _or_1 = _isOwnObject;
-            }
-            if (_or_1) {
-              CharSequence _genActionCodeMethods = this.genActionCodeMethods(xpac, state, false);
-              _builder.append(_genActionCodeMethods, "");
-              _builder.newLineIfNotEmpty();
-            }
-          }
-        }
-      }
+      _builder.append("        ");
+      String _genEntryAndExitCodes = this.genEntryAndExitCodes(xpmc, false);
+      _builder.append(_genEntryAndExitCodes, "        ");
+      _builder.newLineIfNotEmpty();
       _builder.newLine();
       _builder.append("/* Action Codes */");
       _builder.newLine();
-      {
-        StateGraph _stateMachine_1 = xpac.getStateMachine();
-        List<Transition> _allTransitionsRecursive = this._roomHelpers.getAllTransitionsRecursive(_stateMachine_1);
-        for(final Transition tr : _allTransitionsRecursive) {
-          {
-            boolean _and = false;
-            boolean _or_2 = false;
-            boolean _usesInheritance_1 = this.langExt.usesInheritance();
-            boolean _not_1 = (!_usesInheritance_1);
-            if (_not_1) {
-              _or_2 = true;
-            } else {
-              boolean _isOwnObject_1 = xpac.isOwnObject(tr);
-              _or_2 = _isOwnObject_1;
-            }
-            if (!_or_2) {
-              _and = false;
-            } else {
-              DetailCode _action = tr.getAction();
-              boolean _hasDetailCode = this._roomHelpers.hasDetailCode(_action);
-              _and = _hasDetailCode;
-            }
-            if (_and) {
-              TransitionChain _chain = xpac.getChain(tr);
-              Transition start = _chain.getTransition();
-              _builder.newLineIfNotEmpty();
-              boolean _and_1 = false;
-              if (!(start instanceof NonInitialTransition)) {
-                _and_1 = false;
-              } else {
-                _and_1 = (!(start instanceof GuardedTransition));
-              }
-              boolean hasArgs = _and_1;
-              _builder.newLineIfNotEmpty();
-              String _accessLevelProtected = this.langExt.accessLevelProtected();
-              _builder.append(_accessLevelProtected, "");
-              _builder.append("void ");
-              String _actionCodeOperationName = this._codegenHelpers.getActionCodeOperationName(tr);
-              _builder.append(_actionCodeOperationName, "");
-              _builder.append("(");
-              String _name_1 = ac.getName();
-              String _selfPointer = this.langExt.selfPointer(_name_1, hasArgs);
-              _builder.append(_selfPointer, "");
-              {
-                if (hasArgs) {
-                  String _constPointer = this.constPointer("etRuntime::InterfaceItemBase");
-                  _builder.append(_constPointer, "");
-                  _builder.append(" ifitem");
-                  String _generateArgumentList = this.transitionChainGenerator.generateArgumentList(xpac, tr);
-                  _builder.append(_generateArgumentList, "");
-                }
-              }
-              _builder.append(");");
-              _builder.newLineIfNotEmpty();
-            }
-          }
-        }
-      }
+      _builder.append("        ");
+      String _genActionCodes = this.genActionCodes(xpmc, false);
+      _builder.append(_genActionCodes, "        ");
+      _builder.newLineIfNotEmpty();
       _builder.newLine();
       _builder.append("private:");
       _builder.newLine();
@@ -2035,8 +563,8 @@
       {
         if (handleEvents) {
           _builder.append(", ");
-          String _constPointer_1 = this.constPointer("etRuntime::InterfaceItemBase");
-          _builder.append(_constPointer_1, "\t");
+          String _constPointer = this.constPointer("etRuntime::InterfaceItemBase");
+          _builder.append(_constPointer, "\t");
           _builder.append(" ifitem, ");
           String _voidPointer = this.langExt.voidPointer();
           _builder.append(_voidPointer, "\t");
@@ -2089,9 +617,9 @@
       _builder.newLine();
       _builder.append("\t");
       _builder.append("void executeInitTransition(");
-      String _name_2 = ac.getName();
-      String _selfPointer_1 = this.langExt.selfPointer(_name_2, false);
-      _builder.append(_selfPointer_1, "\t");
+      String _className_1 = this.getClassName(mc);
+      String _selfPointer = this.langExt.selfPointer(_className_1, false);
+      _builder.append(_selfPointer, "\t");
       _builder.append(");");
       _builder.newLineIfNotEmpty();
       _builder.append("\t");
@@ -2101,9 +629,9 @@
       _builder.newLine();
       _builder.append("\t");
       _builder.append("void receiveEvent(");
-      String _name_3 = ac.getName();
-      String _selfPointer_2 = this.langExt.selfPointer(_name_3, handleEvents);
-      _builder.append(_selfPointer_2, "\t");
+      String _className_2 = this.getClassName(mc);
+      String _selfPointer_1 = this.langExt.selfPointer(_className_2, handleEvents);
+      _builder.append(_selfPointer_1, "\t");
       {
         if (handleEvents) {
           _builder.append("etRuntime::InterfaceItemBase* ifitem, int evt, ");
@@ -2118,51 +646,4 @@
     }
     return _xblockexpression;
   }
-  
-  /**
-   * helper method to determine whether this state machine uses handler transitions
-   * points at all
-   * 
-   * @param xpax the {@link ExpandedActorClass}
-   * @return <code>true</code> if the state machine uses handler transition points
-   */
-  private boolean usesHandlerTrPoints(final ExpandedActorClass xpac) {
-    boolean _xblockexpression = false;
-    {
-      StateGraph _stateMachine = xpac.getStateMachine();
-      boolean _isEmpty = this._roomHelpers.isEmpty(_stateMachine);
-      if (_isEmpty) {
-        return false;
-      }
-      StateGraph _stateMachine_1 = xpac.getStateMachine();
-      List<TrPoint> _allTrPointsRecursive = this._roomHelpers.getAllTrPointsRecursive(_stateMachine_1);
-      final Function1<TrPoint, Boolean> _function = new Function1<TrPoint, Boolean>() {
-        public Boolean apply(final TrPoint t) {
-          boolean _and = false;
-          if (!(t instanceof TransitionPoint)) {
-            _and = false;
-          } else {
-            boolean _isHandler = ((TransitionPoint) t).isHandler();
-            _and = _isHandler;
-          }
-          return Boolean.valueOf(_and);
-        }
-      };
-      Iterable<TrPoint> _filter = IterableExtensions.<TrPoint>filter(_allTrPointsRecursive, _function);
-      boolean _isEmpty_1 = IterableExtensions.isEmpty(_filter);
-      _xblockexpression = (!_isEmpty_1);
-    }
-    return _xblockexpression;
-  }
-  
-  protected CharSequence guard(final Transition tt, final String trigger, final ExpandedActorClass ac) {
-    if (tt instanceof TriggeredTransition) {
-      return _guard((TriggeredTransition)tt, trigger, ac);
-    } else if (tt != null) {
-      return _guard(tt, trigger, ac);
-    } else {
-      throw new IllegalArgumentException("Unhandled parameter types: " +
-        Arrays.<Object>asList(tt, trigger, ac).toString());
-    }
-  }
 }
diff --git a/plugins/org.eclipse.etrice.generator/xtend-gen/org/eclipse/etrice/generator/generic/RoomExtensions.java b/plugins/org.eclipse.etrice.generator/xtend-gen/org/eclipse/etrice/generator/generic/RoomExtensions.java
index b98991f..8ded2b1 100644
--- a/plugins/org.eclipse.etrice.generator/xtend-gen/org/eclipse/etrice/generator/generic/RoomExtensions.java
+++ b/plugins/org.eclipse.etrice.generator/xtend-gen/org/eclipse/etrice/generator/generic/RoomExtensions.java
@@ -23,9 +23,6 @@
 import org.eclipse.emf.common.util.URI;
 import org.eclipse.emf.ecore.EObject;
 import org.eclipse.emf.ecore.resource.Resource;
-import org.eclipse.etrice.core.fsm.fSM.ModelComponent;
-import org.eclipse.etrice.core.fsm.fSM.State;
-import org.eclipse.etrice.core.fsm.fSM.StateGraph;
 import org.eclipse.etrice.core.genmodel.etricegen.AbstractInstance;
 import org.eclipse.etrice.core.genmodel.etricegen.InterfaceItemInstance;
 import org.eclipse.etrice.core.genmodel.etricegen.PortInstance;
@@ -518,49 +515,6 @@
   }
   
   /**
-   * @param states a list of {@link State}s
-   * @return a list ordered such that leaf states are last
-   */
-  public List<State> getLeafStatesLast(final List<State> states) {
-    List<State> _xblockexpression = null;
-    {
-      final Function1<State, Boolean> _function = new Function1<State, Boolean>() {
-        public Boolean apply(final State s) {
-          return Boolean.valueOf(RoomExtensions.this._roomHelpers.isLeaf(s));
-        }
-      };
-      final Iterable<State> leaf = IterableExtensions.<State>filter(states, _function);
-      final Function1<State, Boolean> _function_1 = new Function1<State, Boolean>() {
-        public Boolean apply(final State s) {
-          boolean _isLeaf = RoomExtensions.this._roomHelpers.isLeaf(s);
-          return Boolean.valueOf((!_isLeaf));
-        }
-      };
-      final Iterable<State> nonLeaf = IterableExtensions.<State>filter(states, _function_1);
-      _xblockexpression = this.<State>union(nonLeaf, leaf);
-    }
-    return _xblockexpression;
-  }
-  
-  /**
-   * @param ac an {@link ActorClass}
-   * @return a list of all leaf states
-   */
-  public List<State> getAllLeafStates(final ActorClass ac) {
-    StateGraph _stateMachine = ac.getStateMachine();
-    return this._roomHelpers.getLeafStateList(_stateMachine);
-  }
-  
-  /**
-   * @param ac an {@link ActorClass}
-   * @return a list of simple states with leaf states last
-   */
-  public List<State> getAllBaseStatesLeavesLast(final ActorClass ac) {
-    List<State> _allBaseStates = this._roomHelpers.getAllBaseStates(ac);
-    return this.getLeafStatesLast(_allBaseStates);
-  }
-  
-  /**
    * @param ac an {@link ActorClass}
    * @return <code>true</code> if an operation named 'stop' is defined with a void argument list and
    * 		void return type
@@ -610,46 +564,6 @@
     return _or;
   }
   
-  /**
-   * @param ac an {@link ActorClass}
-   * @return the number of all inherited states
-   */
-  public int getNumberOfInheritedStates(final ActorClass ac) {
-    ActorClass _actorBase = ac.getActorBase();
-    boolean _equals = Objects.equal(_actorBase, null);
-    if (_equals) {
-      return 0;
-    } else {
-      ModelComponent _base = ac.getBase();
-      StateGraph _stateMachine = _base.getStateMachine();
-      List<State> _stateList = this._roomHelpers.getStateList(_stateMachine);
-      int _size = _stateList.size();
-      ActorClass _actorBase_1 = ac.getActorBase();
-      int _numberOfInheritedStates = this.getNumberOfInheritedStates(_actorBase_1);
-      return (_size + _numberOfInheritedStates);
-    }
-  }
-  
-  /**
-   * @param ac an {@link ActorClass}
-   * @return the number of all inherited base (or simple) states
-   */
-  public int getNumberOfInheritedBaseStates(final ActorClass ac) {
-    ActorClass _actorBase = ac.getActorBase();
-    boolean _equals = Objects.equal(_actorBase, null);
-    if (_equals) {
-      return 0;
-    } else {
-      ModelComponent _base = ac.getBase();
-      StateGraph _stateMachine = _base.getStateMachine();
-      List<State> _baseStateList = this._roomHelpers.getBaseStateList(_stateMachine);
-      int _size = _baseStateList.size();
-      ActorClass _actorBase_1 = ac.getActorBase();
-      int _numberOfInheritedBaseStates = this.getNumberOfInheritedBaseStates(_actorBase_1);
-      return (_size + _numberOfInheritedBaseStates);
-    }
-  }
-  
   public BasicEList<AbstractInstance> getAllSubInstances(final StructureInstance ssi) {
     final BasicEList<AbstractInstance> result = new BasicEList<AbstractInstance>();
     final TreeIterator<EObject> it = ssi.eAllContents();
diff --git a/plugins/org.eclipse.etrice.ui.behavior.fsm/src/org/eclipse/etrice/ui/behavior/fsm/commands/PopulateDiagramCommand.java b/plugins/org.eclipse.etrice.ui.behavior.fsm/src/org/eclipse/etrice/ui/behavior/fsm/commands/PopulateDiagramCommand.java
index 0984e89..28d00f9 100644
--- a/plugins/org.eclipse.etrice.ui.behavior.fsm/src/org/eclipse/etrice/ui/behavior/fsm/commands/PopulateDiagramCommand.java
+++ b/plugins/org.eclipse.etrice.ui.behavior.fsm/src/org/eclipse/etrice/ui/behavior/fsm/commands/PopulateDiagramCommand.java
@@ -32,13 +32,13 @@
 	private IFeatureProvider fp;
 	private Injector injector;
 
-	public PopulateDiagramCommand(Diagram diag, ModelComponent mc, Injector injector, TransactionalEditingDomain domain) {
+	public PopulateDiagramCommand(String providerId, Diagram diag, ModelComponent mc, Injector injector, TransactionalEditingDomain domain) {
 		super(domain);
 		this.diagram = diag;
 		this.mc = mc;
 		this.injector = injector;
 
-		IDiagramTypeProvider dtp = GraphitiUi.getExtensionManager().createDiagramTypeProvider(diagram, "org.eclipse.etrice.ui.behavior.diagramTypeProvider"); //$NON-NLS-1$
+		IDiagramTypeProvider dtp = GraphitiUi.getExtensionManager().createDiagramTypeProvider(diagram, providerId); //$NON-NLS-1$
 		fp = dtp.getFeatureProvider();
 	}
 
diff --git a/plugins/org.eclipse.etrice.ui.behavior.fsm/src/org/eclipse/etrice/ui/behavior/fsm/dialogs/IMemberAwareConfiguration.java b/plugins/org.eclipse.etrice.ui.behavior.fsm/src/org/eclipse/etrice/ui/behavior/fsm/dialogs/IMemberAwareConfiguration.java
index 3871f4a..d49b674 100644
--- a/plugins/org.eclipse.etrice.ui.behavior.fsm/src/org/eclipse/etrice/ui/behavior/fsm/dialogs/IMemberAwareConfiguration.java
+++ b/plugins/org.eclipse.etrice.ui.behavior.fsm/src/org/eclipse/etrice/ui/behavior/fsm/dialogs/IMemberAwareConfiguration.java
@@ -15,7 +15,7 @@
 import org.eclipse.swt.widgets.Control;
 
 /**
- * @author jci
+ * @author Henrik Rentz-Reichert
  *
  */
 public interface IMemberAwareConfiguration {
diff --git a/plugins/org.eclipse.etrice.ui.behavior.fsm/src/org/eclipse/etrice/ui/behavior/fsm/dialogs/TransitionTriggerCompartment.java b/plugins/org.eclipse.etrice.ui.behavior.fsm/src/org/eclipse/etrice/ui/behavior/fsm/dialogs/TransitionTriggerCompartment.java
index 9c22458..7ff1866 100644
--- a/plugins/org.eclipse.etrice.ui.behavior.fsm/src/org/eclipse/etrice/ui/behavior/fsm/dialogs/TransitionTriggerCompartment.java
+++ b/plugins/org.eclipse.etrice.ui.behavior.fsm/src/org/eclipse/etrice/ui/behavior/fsm/dialogs/TransitionTriggerCompartment.java
@@ -53,7 +53,7 @@
 import org.eclipse.ui.forms.widgets.FormToolkit;
 
 /**
- * @author jci
+ * @author Henrik Rentz-Reichert
  *
  */
 public class TransitionTriggerCompartment {
@@ -364,7 +364,7 @@
 		memberAwareConfiguration.configureMemberAwareness(interfaceCombo);
 		
 		for (AbstractInterfaceItem item : interfaceItems) {
-			interfaceCombo.add(item.getName());
+			interfaceCombo.add(item.getDisplayName());
 		}
 	}
 
@@ -443,7 +443,7 @@
 	private void updateInterfaceItem() {
 		String ifName = interfaceCombo.getItem(interfaceCombo.getSelectionIndex());
 		for (AbstractInterfaceItem item : interfaceItems) {
-			if (item.getName().equals(ifName)) {
+			if (item.getDisplayName().equals(ifName)) {
 				MessageFromIf mif = (MessageFromIf) ((IStructuredSelection)mifViewer.getSelection()).getFirstElement();
 				mif.setFrom(item);
 				updateCombos();
@@ -464,7 +464,7 @@
 				MessageFromIf mif = (MessageFromIf) sel;
 				String[] items = interfaceCombo.getItems();
 				for (int i = 0; i < items.length; i++) {
-					if (items[i].equals(mif.getFrom().getName())) {
+					if (items[i].equals(mif.getFrom().getDisplayName())) {
 						interfaceCombo.select(i);
 						currentMsgs = mif.getFrom().getAllIncomingAbstractMessages();
 						int pos = 0;
diff --git a/plugins/org.eclipse.etrice.ui.behavior.fsm/src/org/eclipse/etrice/ui/behavior/fsm/editor/AbstractFSMEditor.java b/plugins/org.eclipse.etrice.ui.behavior.fsm/src/org/eclipse/etrice/ui/behavior/fsm/editor/AbstractFSMEditor.java
index f619e73..389a9ff 100644
--- a/plugins/org.eclipse.etrice.ui.behavior.fsm/src/org/eclipse/etrice/ui/behavior/fsm/editor/AbstractFSMEditor.java
+++ b/plugins/org.eclipse.etrice.ui.behavior.fsm/src/org/eclipse/etrice/ui/behavior/fsm/editor/AbstractFSMEditor.java
@@ -141,9 +141,7 @@
 	public void doSave(IProgressMonitor monitor) {
 		getEditingDomain().getCommandStack().execute(new RecordingCommand(getEditingDomain()) {
 			protected void doExecute() {
-				removeEmptySubgraphs();
-				rebaseRefinedStates();
-				removeUnusedRefinedStates();
+				cleanupBeforeSave();
 			}
 		});
 		
@@ -151,7 +149,16 @@
 	}
 
 	/**
-	 * 
+	 * is called before actually saving the model
+	 */
+	protected void cleanupBeforeSave() {
+		removeEmptySubgraphs();
+		rebaseRefinedStates();
+		removeUnusedRefinedStates();
+	}
+	
+	/**
+	 * removes dangling refined states
 	 */
 	protected void removeUnusedRefinedStates() {
 		Diagram diagram = getDiagramTypeProvider().getDiagram();
@@ -171,8 +178,16 @@
 	}
 
 	/**
+	 * determines whether a refined state is actually used.
+	 * I.e. it has at least one of
+	 * <ul>
+	 * <li>direct substructure</li>
+	 * <li>entry code</li>
+	 * <li>exit code</li>
+	 * </ul>
+	 * 
 	 * @param s
-	 * @return
+	 * @return whether a refined state is actually used
 	 */
 	private boolean isUnused(RefinedState s) {
 		FSMHelpers fsmHelpers = FSMSupportUtil.getInstance().getFSMHelpers();
@@ -186,6 +201,9 @@
 		return true;
 	}
 
+	/**
+	 * removes empty subgraphs
+	 */
 	protected void removeEmptySubgraphs() {
 		Diagram diagram = getDiagramTypeProvider().getDiagram();
 		FSMHelpers fsmHelpers = FSMSupportUtil.getInstance().getFSMHelpers();
diff --git a/plugins/org.eclipse.etrice.ui.behavior/src/org/eclipse/etrice/ui/behavior/DiagramAccess.java b/plugins/org.eclipse.etrice.ui.behavior/src/org/eclipse/etrice/ui/behavior/DiagramAccess.java
index 75a2a9b..2d6c2d8 100644
--- a/plugins/org.eclipse.etrice.ui.behavior/src/org/eclipse/etrice/ui/behavior/DiagramAccess.java
+++ b/plugins/org.eclipse.etrice.ui.behavior/src/org/eclipse/etrice/ui/behavior/DiagramAccess.java
@@ -90,7 +90,7 @@
 	@Override
 	protected Command getInitialCommand(EObject rootObject, Diagram diagram, TransactionalEditingDomain editingDomain) {
 		if (rootObject instanceof ModelComponent) {
-			return new PopulateDiagramCommand(diagram, (ModelComponent) rootObject, Activator.getDefault().getInjector(), editingDomain);
+			return new PopulateDiagramCommand("org.eclipse.etrice.ui.behavior.diagramTypeProvider", diagram, (ModelComponent) rootObject, Activator.getDefault().getInjector(), editingDomain);
 		}
 		return null;
 	}
diff --git a/plugins/org.eclipse.etrice.ui.common.base/src/org/eclipse/etrice/ui/common/base/concurrency/ConcurrentModificationObserver.java b/plugins/org.eclipse.etrice.ui.common.base/src/org/eclipse/etrice/ui/common/base/concurrency/ConcurrentModificationObserver.java
deleted file mode 100644
index bd4f0ad..0000000
--- a/plugins/org.eclipse.etrice.ui.common.base/src/org/eclipse/etrice/ui/common/base/concurrency/ConcurrentModificationObserver.java
+++ /dev/null
@@ -1,95 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010 protos software gmbh (http://www.protos.de).
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- * 
- * CONTRIBUTORS:
- * 		Jan Koehnlein (Itemis, initially from org.eclipse.xtext.gmf.glue)
- * 
- *******************************************************************************/
-
-package org.eclipse.etrice.ui.common.base.concurrency;
-
-import org.eclipse.emf.edit.domain.EditingDomain;
-import org.eclipse.emf.edit.domain.IEditingDomainProvider;
-import org.eclipse.emf.transaction.TransactionalEditingDomain;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.IEditorReference;
-import org.eclipse.ui.IPartListener;
-import org.eclipse.ui.IStartup;
-import org.eclipse.ui.IWorkbenchPage;
-import org.eclipse.ui.IWorkbenchPart;
-import org.eclipse.ui.PlatformUI;
-
-/**
- * Detects concurrent modifications of Graphiti (eTrice structure and behavior)
- * and Xtext editors based on Xtext's dirty state management.
- * 
- * @author Jan Koehnlein
- * @author Henrik Rentz-Reichert
- * 
- */
-public class ConcurrentModificationObserver implements IPartListener {
-
-	private EditingDomainAdapter.Factory factory;
-
-	public ConcurrentModificationObserver(IWorkbenchPage activePage) {
-		factory = new EditingDomainAdapter.Factory();
-		for (IEditorReference editorRef : activePage.getEditorReferences()) {
-			IEditorPart editor = editorRef.getEditor(false);
-			if (editor != null) {
-				partOpened(editor);
-			}
-		}
-	}
-
-	public void partOpened(IWorkbenchPart part) {
-		Object adapter = part.getAdapter(IEditingDomainProvider.class);
-		if (adapter instanceof IEditingDomainProvider) {
-			EditingDomain editingDomain = ((IEditingDomainProvider) adapter).getEditingDomain();
-			if (editingDomain instanceof TransactionalEditingDomain)
-				factory.adapt(editingDomain, EditingDomainAdapter.class);
-		}
-	}
-
-	public void partClosed(IWorkbenchPart part) {
-		Object adapter = part.getAdapter(IEditingDomainProvider.class);
-		if (adapter instanceof IEditingDomainProvider) {
-			EditingDomain editingDomain = ((IEditingDomainProvider) adapter).getEditingDomain();
-			if (editingDomain instanceof TransactionalEditingDomain) {
-				EditingDomainAdapter editingDomainAdapter = (EditingDomainAdapter) factory.adapt(editingDomain,
-						EditingDomainAdapter.class);
-				if (editingDomainAdapter != null) {
-					editingDomainAdapter.dispose();
-				}
-			}
-		}
-	}
-
-	public void partActivated(IWorkbenchPart part) {
-		// do nothing
-	}
-
-	public void partDeactivated(IWorkbenchPart part) {
-		// do nothing
-	}
-
-	public void partBroughtToTop(IWorkbenchPart part) {
-		// do nothing
-	}
-
-	public static class Initializer implements IStartup {
-		public void earlyStartup() {
-			Display.getDefault().asyncExec(new Runnable() {
-				public void run() {
-					IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
-					activePage.addPartListener(new ConcurrentModificationObserver(activePage));
-				}
-			});
-		}
-	}
-
-}
diff --git a/plugins/org.eclipse.etrice.ui.common.base/src/org/eclipse/etrice/ui/common/base/concurrency/DirtyResourceTracker.java b/plugins/org.eclipse.etrice.ui.common.base/src/org/eclipse/etrice/ui/common/base/concurrency/DirtyResourceTracker.java
new file mode 100644
index 0000000..501cb8f
--- /dev/null
+++ b/plugins/org.eclipse.etrice.ui.common.base/src/org/eclipse/etrice/ui/common/base/concurrency/DirtyResourceTracker.java
@@ -0,0 +1,325 @@
+/*******************************************************************************

+ * Copyright (c) 2015 protos software gmbh (http://www.protos.de).

+ * All rights reserved. This program and the accompanying materials

+ * are made available under the terms of the Eclipse Public License v1.0

+ * which accompanies this distribution, and is available at

+ * http://www.eclipse.org/legal/epl-v10.html

+ * 

+ * CONTRIBUTORS:

+ * 		Jan Koehnlein (Itemis, initially from org.eclipse.xtext.gmf.glue)

+ * 		Henrik Rentz-Reichert

+ * 		Juergen Haug (initial contribution)

+ * 

+ *******************************************************************************/

+

+package org.eclipse.etrice.ui.common.base.concurrency;

+

+import java.util.HashMap;

+import java.util.List;

+import java.util.Map;

+

+import org.eclipse.core.runtime.IStatus;

+import org.eclipse.core.runtime.Status;

+import org.eclipse.emf.common.command.Command;

+import org.eclipse.emf.common.util.URI;

+import org.eclipse.emf.ecore.resource.Resource;

+import org.eclipse.emf.transaction.NotificationFilter;

+import org.eclipse.emf.transaction.ResourceSetChangeEvent;

+import org.eclipse.emf.transaction.ResourceSetListener;

+import org.eclipse.emf.transaction.RollbackException;

+import org.eclipse.emf.transaction.TransactionalEditingDomain;

+import org.eclipse.emf.transaction.TransactionalEditingDomain.Lifecycle;

+import org.eclipse.emf.transaction.TransactionalEditingDomainEvent;

+import org.eclipse.emf.transaction.TransactionalEditingDomainListener;

+import org.eclipse.emf.transaction.util.TransactionUtil;

+import org.eclipse.etrice.ui.common.base.UIBaseActivator;

+import org.eclipse.etrice.ui.common.base.editor.DiagramEditorBase;

+import org.eclipse.jface.dialogs.MessageDialog;

+import org.eclipse.swt.SWT;

+import org.eclipse.swt.widgets.Display;

+import org.eclipse.swt.widgets.Shell;

+import org.eclipse.ui.IPartListener;

+import org.eclipse.ui.IWorkbenchPart;

+import org.eclipse.ui.PlatformUI;

+import org.eclipse.xtext.resource.IResourceServiceProvider;

+import org.eclipse.xtext.resource.XtextResource;

+import org.eclipse.xtext.ui.editor.IDirtyResource;

+import org.eclipse.xtext.ui.editor.IDirtyStateManager;

+import org.eclipse.xtext.ui.shared.Access;

+

+import com.google.common.collect.Lists;

+

+/**

+ * Detects concurrent modifications of eTrice structure and behavior

+ * and Xtext editors based on Xtext's dirty state management.

+ * <p>

+ * Based on former ConcurrentModificationObserver and EditingDomainAdapter

+ */

+public class DirtyResourceTracker {

+

+	public static void register(DiagramEditorBase diagramEditor){

+		new DirtyResourceTracker(diagramEditor);

+	}

+	

+	protected class DialogPrompter implements Runnable {

+

+		private boolean isYesResult;

+

+		public boolean isYesResult() {

+			return isYesResult;

+		}

+

+		public void run() {

+			Shell shell = Display.getDefault().getActiveShell();

+			isYesResult = MessageDialog.open(MessageDialog.QUESTION, shell, "Concurrent Modification",

+					"Other editors have a modified version of models you are going to change.\n"

+							+ "If you apply your changes you are loosing the possibility to save the others.\n"

+							+ "Apply changes anyway?", SWT.NONE);

+		}

+	}

+

+	protected class ResourceSetListenerImpl implements ResourceSetListener {

+

+		@Override

+		public NotificationFilter getFilter() {

+			return null;

+		}

+

+		@Override

+		public Command transactionAboutToCommit(ResourceSetChangeEvent event) throws RollbackException {

+			checkConcurrentModificationOnTransaction();

+

+			return null;

+		}

+

+		@Override

+		public void resourceSetChanged(ResourceSetChangeEvent event) {

+		}

+

+		@Override

+		public boolean isAggregatePrecommitListener() {

+			return false;

+		}

+

+		@Override

+		public boolean isPrecommitOnly() {

+			return false;

+		}

+

+		@Override

+		public boolean isPostcommitOnly() {

+			return false;

+		}

+

+	}

+

+	protected class PartListenerImpl implements IPartListener {

+

+		@Override

+		public void partActivated(IWorkbenchPart part) {

+

+		}

+

+		@Override

+		public void partBroughtToTop(IWorkbenchPart part) {

+

+		}

+

+		@Override

+		public void partClosed(IWorkbenchPart part) {

+			dispose();

+		}

+

+		@Override

+		public void partDeactivated(IWorkbenchPart part) {

+			updateDirtyStateOnEditorDeactivation();

+		}

+

+		@Override

+		public void partOpened(IWorkbenchPart part) {

+

+		}

+

+	}

+

+	protected class TransactionalEditingDomainListenerImpl implements TransactionalEditingDomainListener {

+

+		@Override

+		public void transactionStarting(TransactionalEditingDomainEvent event) {

+

+		}

+

+		@Override

+		public void transactionInterrupted(TransactionalEditingDomainEvent event) {

+

+		}

+

+		@Override

+		public void transactionStarted(TransactionalEditingDomainEvent event) {

+

+		}

+

+		@Override

+		public void transactionClosing(TransactionalEditingDomainEvent event) {

+

+		}

+

+		@Override

+		public void transactionClosed(TransactionalEditingDomainEvent event) {

+

+		}

+

+		@Override

+		public void editingDomainDisposing(TransactionalEditingDomainEvent event) {

+			dispose();

+		}

+

+	}

+

+	private DiagramEditorBase diagramEditor;

+	private TransactionalEditingDomain editingDomain;

+	private IDirtyStateManager dirtyStateManager;

+	private Map<URI, IDirtyResource> uri2dirtyResource;

+	private TransactionalEditingDomainListenerImpl editingDomainListener;

+	private IPartListener uiPartListener;

+

+	public DirtyResourceTracker(DiagramEditorBase diagramEditor) {

+		this.diagramEditor = diagramEditor;

+		this.editingDomain = diagramEditor.getEditingDomain();

+		this.dirtyStateManager = Access.getIDirtyStateManager().get();

+		this.uri2dirtyResource = new HashMap<URI, IDirtyResource>();

+		this.editingDomainListener = new TransactionalEditingDomainListenerImpl();

+

+		Lifecycle lifecycle = TransactionUtil.getAdapter(editingDomain, Lifecycle.class);

+		lifecycle.addTransactionalEditingDomainListener(editingDomainListener);

+		editingDomain.addResourceSetListener(new ResourceSetListenerImpl());

+

+		uiPartListener = new PartListenerImpl();

+		diagramEditor.getSite().getWorkbenchWindow().getPartService().addPartListener(uiPartListener);

+	}

+

+	/**

+	 * If execution of command is about to complete, check concurrent modification and prompt dialog

+	 * @throws RollbackException

+	 */

+	public void checkConcurrentModificationOnTransaction() throws RollbackException {

+		List<XtextResource> resourcesWithConflicts = null;

+		for (Resource resource : editingDomain.getResourceSet().getResources()) {

+			if (resource instanceof XtextResource && resource.isModified()) {

+				XtextResource xtextResource = (XtextResource) resource;

+				IDirtyResource dirtyResource = uri2dirtyResource.get(xtextResource.getURI());

+				if (dirtyResource == null) {

+					if (!createAndRegisterDirtyState(xtextResource)) {

+						if (resourcesWithConflicts == null) {

+							resourcesWithConflicts = Lists.newArrayList();

+						}

+						resourcesWithConflicts.add(xtextResource);

+					}

+				}

+			}

+		}

+		if (resourcesWithConflicts != null) {

+			if (userApplyChanges()) {

+				for (XtextResource resourceWithConflicts : resourcesWithConflicts) {

+					try {

+						IDirtyResource dirtyResource = createDirtyResource(resourceWithConflicts);

+						// assert resource is serializable

+						dirtyResource.getContents();

+						dirtyStateManager.announceDirtyStateChanged(dirtyResource);

+					}

+					catch (Exception exc) {

+						System.err.println("Error serializing resource: " + exc);

+					}

+				}

+			}

+			else {

+				throw new RollbackException(new Status(IStatus.ERROR, UIBaseActivator.PLUGIN_ID,

+						"Transaction aborted by user"));

+			}

+		}

+	}

+

+	/**

+	 * Issue: Undo changes via change recording look like resource changes.<br>

+	 * Thus resource gets dirty state if {@link DiagramEditorBase#isDirty()} and {@link Resource#isModified()}.

+	 */

+	public void updateDirtyStateOnEditorDeactivation() {

+		if (!diagramEditor.isDirty()) {

+			for (URI uri : uri2dirtyResource.keySet())

+				dirtyStateManager.discardDirtyState(uri2dirtyResource.get(uri));

+			uri2dirtyResource.clear();

+		} else

+			setResourcesDirtyState();

+	}

+

+	protected void setResourcesDirtyState() {

+		List<URI> remainingURIs = Lists.newArrayList(uri2dirtyResource.keySet());

+		for (Resource resource : editingDomain.getResourceSet().getResources()) {

+			if (resource instanceof XtextResource) {

+				XtextResource xtextResource = (XtextResource) resource;

+				remainingURIs.remove(xtextResource.getURI());

+				IDirtyResource dirtyResource = uri2dirtyResource.get(xtextResource.getURI());

+				if (xtextResource.isModified()) {

+					if (dirtyResource == null) {

+						createAndRegisterDirtyState(xtextResource);

+					}

+				}

+				else {

+					if (dirtyResource != null) {

+						uri2dirtyResource.remove(xtextResource.getURI());

+						dirtyStateManager.discardDirtyState(dirtyResource);

+					}

+				}

+			}

+		}

+		// removed resources

+		for (URI remainingURI : remainingURIs) {

+			IDirtyResource dirtyResource = uri2dirtyResource.get(remainingURI);

+			dirtyStateManager.discardDirtyState(dirtyResource);

+			uri2dirtyResource.remove(remainingURI);

+		}

+	}

+

+	protected boolean createAndRegisterDirtyState(XtextResource xtextResource) {

+		IDirtyResource dirtyResource = createDirtyResource(xtextResource);

+		if (dirtyResource == null) {

+			return true;

+		}

+		else {

+			boolean isSuccess = dirtyStateManager.manageDirtyState(dirtyResource);

+			if (isSuccess) {

+				uri2dirtyResource.put(xtextResource.getURI(), dirtyResource);

+			}

+			return isSuccess;

+		}

+	}

+

+	protected IDirtyResource createDirtyResource(XtextResource xtextResource) {

+		IResourceServiceProvider resourceServiceProvider = IResourceServiceProvider.Registry.INSTANCE

+				.getResourceServiceProvider(xtextResource.getURI());

+		if (resourceServiceProvider == null) {

+			return null;

+		}

+		return new SimpleDirtyResource(xtextResource, resourceServiceProvider);

+	}

+

+	protected boolean userApplyChanges() {

+		DialogPrompter dialogPrompter = new DialogPrompter();

+		Display.getDefault().syncExec(dialogPrompter);

+		boolean yesResult = dialogPrompter.isYesResult();

+		return yesResult;

+	}

+

+	public void dispose() {

+		PlatformUI.getWorkbench().getActiveWorkbenchWindow().getPartService().removePartListener(uiPartListener);

+

+		for (IDirtyResource dirtyResource : uri2dirtyResource.values()) 

+			dirtyStateManager.discardDirtyState(dirtyResource);

+		uri2dirtyResource.clear();

+		

+		Lifecycle lifecycle = TransactionUtil.getAdapter(editingDomain, Lifecycle.class);

+		if (lifecycle != null)

+			lifecycle.removeTransactionalEditingDomainListener(editingDomainListener);

+	}

+

+}

diff --git a/plugins/org.eclipse.etrice.ui.common.base/src/org/eclipse/etrice/ui/common/base/concurrency/EditingDomainAdapter.java b/plugins/org.eclipse.etrice.ui.common.base/src/org/eclipse/etrice/ui/common/base/concurrency/EditingDomainAdapter.java
deleted file mode 100644
index f27099d..0000000
--- a/plugins/org.eclipse.etrice.ui.common.base/src/org/eclipse/etrice/ui/common/base/concurrency/EditingDomainAdapter.java
+++ /dev/null
@@ -1,256 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010 protos software gmbh (http://www.protos.de).
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- * 
- * CONTRIBUTORS:
- * 		Jan Koehnlein (Itemis, initially from org.eclipse.xtext.gmf.glue)
- * 
- *******************************************************************************/
-
-package org.eclipse.etrice.ui.common.base.concurrency;
-
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.emf.common.command.Command;
-import org.eclipse.emf.common.notify.Adapter;
-import org.eclipse.emf.common.notify.Notifier;
-import org.eclipse.emf.common.notify.impl.AdapterFactoryImpl;
-import org.eclipse.emf.common.notify.impl.AdapterImpl;
-import org.eclipse.emf.common.util.URI;
-import org.eclipse.emf.ecore.resource.Resource;
-import org.eclipse.emf.ecore.resource.ResourceSet;
-import org.eclipse.emf.transaction.NotificationFilter;
-import org.eclipse.emf.transaction.ResourceSetChangeEvent;
-import org.eclipse.emf.transaction.ResourceSetListener;
-import org.eclipse.emf.transaction.RollbackException;
-import org.eclipse.emf.transaction.TransactionalEditingDomain;
-import org.eclipse.emf.transaction.TransactionalEditingDomain.Lifecycle;
-import org.eclipse.emf.transaction.TransactionalEditingDomainEvent;
-import org.eclipse.emf.transaction.TransactionalEditingDomainListener;
-import org.eclipse.emf.transaction.util.TransactionUtil;
-import org.eclipse.etrice.ui.common.base.UIBaseActivator;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.xtext.resource.IResourceServiceProvider;
-import org.eclipse.xtext.resource.XtextResource;
-import org.eclipse.xtext.ui.editor.IDirtyResource;
-import org.eclipse.xtext.ui.editor.IDirtyStateManager;
-import org.eclipse.xtext.ui.shared.Access;
-
-import com.google.common.collect.Lists;
-
-public class EditingDomainAdapter extends AdapterImpl implements ResourceSetListener,
-		TransactionalEditingDomainListener {
-
-	public static class Factory extends AdapterFactoryImpl {
-		@Override
-		public boolean isFactoryForType(Object type) {
-			return super.isFactoryForType(type == EditingDomainAdapter.class);
-		}
-
-		@Override
-		protected Object resolve(Object object, Object type) {
-			if (object instanceof TransactionalEditingDomain) {
-				return adapt(((TransactionalEditingDomain) object).getResourceSet(), type);
-			}
-			return super.resolve(object, type);
-		}
-
-		@Override
-		protected Adapter createAdapter(Notifier target) {
-			if (target instanceof ResourceSet) {
-				return new EditingDomainAdapter(TransactionUtil.getEditingDomain(target));
-			} else {
-				return null;
-			}
-		}
-	}
-
-	private final TransactionalEditingDomain editingDomain;
-
-	private IDirtyStateManager dirtyStateManager;
-
-	private Map<URI, IDirtyResource> uri2dirtyResource;
-
-	protected EditingDomainAdapter(TransactionalEditingDomain editingDomain) {
-		this.editingDomain = editingDomain;
-		editingDomain.addResourceSetListener(this);
-		dirtyStateManager = Access.getIDirtyStateManager().get();
-		uri2dirtyResource = new HashMap<URI, IDirtyResource>();
-		Lifecycle lifecycle = TransactionUtil.getAdapter(editingDomain, Lifecycle.class);
-		lifecycle.addTransactionalEditingDomainListener(this);
-	}
-
-	public NotificationFilter getFilter() {
-		return null;
-	}
-
-	public boolean isAggregatePrecommitListener() {
-		return true;
-	}
-
-	public boolean isPostcommitOnly() {
-		return false;
-	}
-
-	public boolean isPrecommitOnly() {
-		return false;
-	}
-
-	public void resourceSetChanged(ResourceSetChangeEvent event) {
-		List<URI> remainingURIs = Lists.newArrayList(uri2dirtyResource.keySet());
-		for (Resource resource : editingDomain.getResourceSet().getResources()) {
-			if (resource instanceof XtextResource) {
-				XtextResource xtextResource = (XtextResource) resource;
-				remainingURIs.remove(xtextResource.getURI());
-				IDirtyResource dirtyResource = uri2dirtyResource.get(xtextResource.getURI());
-				if (xtextResource.isModified()) {
-					if (dirtyResource == null) {
-						createAndRegisterDirtyState(xtextResource);
-					}
-				} else {
-					if (dirtyResource != null) {
-						uri2dirtyResource.remove(xtextResource.getURI());
-						dirtyStateManager.discardDirtyState(dirtyResource);
-					}
-				}
-			}
-		}
-		// removed resources
-		for (URI remainingURI : remainingURIs) {
-			IDirtyResource dirtyResource = uri2dirtyResource.get(remainingURI);
-			dirtyStateManager.discardDirtyState(dirtyResource);
-			uri2dirtyResource.remove(remainingURI);
-		}
-	}
-
-	public Command transactionAboutToCommit(ResourceSetChangeEvent event) throws RollbackException {
-		List<XtextResource> resourcesWithConflicts = null;
-		for (Resource resource : editingDomain.getResourceSet().getResources()) {
-			if (resource instanceof XtextResource && resource.isModified()) {
-				XtextResource xtextResource = (XtextResource) resource;
-				IDirtyResource dirtyResource = uri2dirtyResource.get(xtextResource.getURI());
-				if (dirtyResource == null) {
-					if (!createAndRegisterDirtyState(xtextResource)) {
-						if (resourcesWithConflicts == null) {
-							resourcesWithConflicts = Lists.newArrayList();
-						}
-						resourcesWithConflicts.add(xtextResource);
-					}
-				}
-			}
-		}
-		if (resourcesWithConflicts != null) {
-			if (queryApplyChanges()) {
-				for (XtextResource resourceWithConflicts : resourcesWithConflicts) {
-					try {
-						IDirtyResource dirtyResource = createDirtyResource(resourceWithConflicts);
-						// assert resource is serializable
-						dirtyResource.getContents();
-						dirtyStateManager.announceDirtyStateChanged(dirtyResource);
-					} catch (Exception exc) {
-						System.err.println("Error serializing resource: "+exc);
-					}
-				}
-			} else {
-				throw new RollbackException(new Status(IStatus.ERROR, UIBaseActivator.PLUGIN_ID,
-						"Transaction aborted by user"));
-			}
-		}
-		return null;
-	}
-
-	protected boolean createAndRegisterDirtyState(XtextResource xtextResource) {
-		IDirtyResource dirtyResource = createDirtyResource(xtextResource);
-		if (dirtyResource == null) {
-			return true;
-		} else {
-			boolean isSuccess = dirtyStateManager.manageDirtyState(dirtyResource);
-			if (isSuccess) {
-				uri2dirtyResource.put(xtextResource.getURI(), dirtyResource);
-			}
-			return isSuccess;
-		}
-	}
-
-	protected IDirtyResource createDirtyResource(XtextResource xtextResource) {
-		IResourceServiceProvider resourceServiceProvider = IResourceServiceProvider.Registry.INSTANCE
-				.getResourceServiceProvider(xtextResource.getURI());
-		if (resourceServiceProvider == null) {
-			return null;
-		}
-		return new SimpleDirtyResource(xtextResource, resourceServiceProvider);
-	}
-
-	public void editingDomainDisposing(TransactionalEditingDomainEvent event) {
-		dispose();
-	}
-
-	public void dispose() {
-		if (uri2dirtyResource != null) {
-			for (IDirtyResource dirtyResource : uri2dirtyResource.values()) {
-				dirtyStateManager.discardDirtyState(dirtyResource);
-			}
-			uri2dirtyResource = null;
-		}
-		Lifecycle lifecycle = TransactionUtil.getAdapter(editingDomain, Lifecycle.class);
-		if (lifecycle != null) {
-			lifecycle.removeTransactionalEditingDomainListener(this);
-		}
-		editingDomain.removeResourceSetListener(this);
-	}
-
-	protected boolean queryApplyChanges() {
-		DialogPrompter dialogPrompter = new DialogPrompter();
-		Display.getDefault().syncExec(dialogPrompter);
-		boolean yesResult = dialogPrompter.isYesResult();
-		return yesResult;
-	}
-
-	protected class DialogPrompter implements Runnable {
-
-		private boolean isYesResult;
-
-		public boolean isYesResult() {
-			return isYesResult;
-		}
-
-		public void run() {
-			Shell shell = Display.getDefault().getActiveShell();
-			isYesResult = MessageDialog.open(MessageDialog.QUESTION, shell, "Concurrent Modification",
-					"Other editors have a modified version of models you are going to change.\n"
-							+ "If you apply your changes you are loosing the possibility to save the others.\n"
-							+ "Apply changes anyway?", SWT.NONE);
-		}
-	}
-
-	public void transactionClosed(TransactionalEditingDomainEvent event) {
-		// do nothing
-	}
-
-	public void transactionClosing(TransactionalEditingDomainEvent event) {
-		// do nothing
-	}
-
-	public void transactionInterrupted(TransactionalEditingDomainEvent event) {
-		// do nothing
-	}
-
-	public void transactionStarted(TransactionalEditingDomainEvent event) {
-		// do nothing
-	}
-
-	public void transactionStarting(TransactionalEditingDomainEvent event) {
-		// do nothing
-	}
-
-}
diff --git a/plugins/org.eclipse.etrice.ui.common.base/src/org/eclipse/etrice/ui/common/base/editor/DiagramEditorBase.java b/plugins/org.eclipse.etrice.ui.common.base/src/org/eclipse/etrice/ui/common/base/editor/DiagramEditorBase.java
index 5977892..4db4463 100644
--- a/plugins/org.eclipse.etrice.ui.common.base/src/org/eclipse/etrice/ui/common/base/editor/DiagramEditorBase.java
+++ b/plugins/org.eclipse.etrice.ui.common.base/src/org/eclipse/etrice/ui/common/base/editor/DiagramEditorBase.java
@@ -33,6 +33,7 @@
 import org.eclipse.etrice.core.fsm.fSM.ModelComponent;
 import org.eclipse.etrice.core.fsm.ui.FSMUiModule;
 import org.eclipse.etrice.ui.common.base.UIBaseActivator;
+import org.eclipse.etrice.ui.common.base.concurrency.DirtyResourceTracker;
 import org.eclipse.graphiti.mm.pictograms.Diagram;
 import org.eclipse.graphiti.services.Graphiti;
 import org.eclipse.graphiti.ui.editor.DiagramBehavior;
@@ -135,30 +136,37 @@
 						return;
 					}
 	
-					// HOWTO: call serializer to validate the concrete syntax
-					// this throws an exception which is caught further up the stack
-					// and a dialog will be displayed
-					serializer.serialize(xres.getContents().get(0));
-					
-					List<Issue> result = resourceValidator.validate(res, CheckMode.NORMAL_AND_FAST, new CancelIndicator() {
-						public boolean isCanceled() {
-							return monitor.isCanceled();
-						}
-					});
-					if (!result.isEmpty()) {
-						boolean error = false;
-						MultiStatus ms = new MultiStatus(UIBaseActivator.PLUGIN_ID, Status.ERROR, "validation errors during diagram save", null);
-						for (Issue issue : result) {
-							if (issue.isSyntaxError() || issue.getSeverity()==Severity.ERROR) {
-								ms.add(new Status(Status.ERROR, UIBaseActivator.PLUGIN_ID, issue.getMessage()));
-								error = true;
+					try {
+						// HOWTO: call serializer to validate the concrete syntax
+						// this throws an exception which is caught further up the stack
+						// and a dialog will be displayed
+						serializer.serialize(xres.getContents().get(0));
+						
+						List<Issue> result = resourceValidator.validate(res, CheckMode.NORMAL_AND_FAST, new CancelIndicator() {
+							public boolean isCanceled() {
+								return monitor.isCanceled();
+							}
+						});
+						if (!result.isEmpty()) {
+							boolean error = false;
+							MultiStatus ms = new MultiStatus(UIBaseActivator.PLUGIN_ID, Status.ERROR, "validation errors during diagram save", null);
+							for (Issue issue : result) {
+								if (issue.isSyntaxError() || issue.getSeverity()==Severity.ERROR) {
+									ms.add(new Status(Status.ERROR, UIBaseActivator.PLUGIN_ID, issue.getMessage()));
+									error = true;
+								}
+							}
+							if (error) {
+								MessageDialog.openError(Display.getDefault().getActiveShell(), "ERROR", "Internal error: model is invalid, can't save");
+								UIBaseActivator.getDefault().getLog().log(ms);
+								return;
 							}
 						}
-						if (error) {
-							MessageDialog.openError(Display.getDefault().getActiveShell(), "ERROR", "Internal error: model is invalid, can't save");
-							UIBaseActivator.getDefault().getLog().log(ms);
-							return;
-						}
+					}
+					catch (RuntimeException e) {
+						MessageDialog.openError(Display.getDefault().getActiveShell(), "ERROR", "Internal error: model is invalid, can't save:\n\n"+e.getMessage());
+						UIBaseActivator.getDefault().getLog().log(new Status(Status.ERROR, UIBaseActivator.PLUGIN_ID, e.getMessage()));
+						return;
 					}
 				}
 			}
@@ -227,6 +235,8 @@
 			 */
 	//		if (AutoUpdateFeature.isLastDoneChanges())
 				doSave(new NullProgressMonitor());
+				
+			DirtyResourceTracker.register(this);
 		}
 
 	/**
diff --git a/plugins/org.eclipse.etrice.ui.structure/src/org/eclipse/etrice/ui/structure/support/SPPSupport.java b/plugins/org.eclipse.etrice.ui.structure/src/org/eclipse/etrice/ui/structure/support/SPPSupport.java
index 9013b9e..edf2e85 100644
--- a/plugins/org.eclipse.etrice.ui.structure/src/org/eclipse/etrice/ui/structure/support/SPPSupport.java
+++ b/plugins/org.eclipse.etrice.ui.structure/src/org/eclipse/etrice/ui/structure/support/SPPSupport.java
@@ -381,7 +381,7 @@
 			}
 			else {
 				// we just set the referenced GA
-				//containerShape.getAnchors().get(0).setReferencedGraphicsAlgorithm(rect);
+				containerShape.getAnchors().get(0).setReferencedGraphicsAlgorithm(rect);
 			}
 		}
 
diff --git a/plugins/org.eclipse.etrice.ui.structure/src/org/eclipse/etrice/ui/structure/support/StructureClassUpdate.java b/plugins/org.eclipse.etrice.ui.structure/src/org/eclipse/etrice/ui/structure/support/StructureClassUpdate.java
index 528f8df..ce645a7 100644
--- a/plugins/org.eclipse.etrice.ui.structure/src/org/eclipse/etrice/ui/structure/support/StructureClassUpdate.java
+++ b/plugins/org.eclipse.etrice.ui.structure/src/org/eclipse/etrice/ui/structure/support/StructureClassUpdate.java
@@ -19,7 +19,6 @@
 
 import org.eclipse.emf.ecore.EObject;
 import org.eclipse.etrice.core.room.ActorClass;
-import org.eclipse.etrice.core.room.ActorContainerClass;
 import org.eclipse.etrice.core.room.ActorContainerRef;
 import org.eclipse.etrice.core.room.Binding;
 import org.eclipse.etrice.core.room.InterfaceItem;
@@ -182,15 +181,15 @@
 
 	@Override
 	protected IReason updateNeeded(EObject bo, IUpdateContext context) {
-		ActorContainerClass acc = (ActorContainerClass) bo;
+		StructureClass sc = (StructureClass) bo;
 		ContainerShape containerShape = (ContainerShape)context.getPictogramElement();
 		String reason = "";
 		
 		// TODO: refactor to single method for updateNeeded/update
-		Set<InterfaceItem> expectedItems = Sets.newHashSet(SupportUtil.getInstance().getRoomHelpers().getInterfaceItems(acc, true));
+		Set<InterfaceItem> expectedItems = Sets.newHashSet(SupportUtil.getInstance().getRoomHelpers().getInterfaceItems(sc, true));
 		Set<InterfaceItem> presentItems = Sets.newHashSet(SupportUtil.getInstance().getInterfaceItems(containerShape, getFeatureProvider()));
-		if(acc instanceof ActorClass){
-			ActorClass base = (ActorClass)acc;
+		if(sc instanceof ActorClass){
+			ActorClass base = (ActorClass)sc;
 			while(base != null){
 				expectedItems.addAll(base.getInternalPorts());
 				base = base.getActorBase();
@@ -200,7 +199,7 @@
 			reason += "interface item(s) missing or outdated\n";
 		
 		
-		Set<ActorContainerRef> expectedRefs = Sets.newHashSet(SupportUtil.getInstance().getRoomHelpers().getAllActorContainerRefs(acc));
+		Set<ActorContainerRef> expectedRefs = Sets.newHashSet(SupportUtil.getInstance().getRoomHelpers().getAllActorContainerRefs(sc));
 		Set<ActorContainerRef> presentRefs = Sets.newHashSet(SupportUtil.getInstance().getRefs(containerShape, getFeatureProvider()));
 		if(!expectedRefs.equals(presentRefs))
 			reason += "actor ref(s) missing or outdated\n";