Index: src/Actions/ActionRegistry.cpp
===================================================================
--- src/Actions/ActionRegistry.cpp	(revision 560cbfdc6f64a3ba2d8d199f06984d8ea1f79247)
+++ src/Actions/ActionRegistry.cpp	(revision 22b786ada90f98f487f6059fa83cd4ab52169ec7)
@@ -35,4 +35,6 @@
 #include "CodePatterns/MemDebug.hpp"
 
+#include "CodePatterns/Assert.hpp"
+
 #include "Actions/ActionRegistry.hpp"
 #include "CodePatterns/Singleton_impl.hpp"
@@ -65,4 +67,11 @@
 ActionRegistry::~ActionRegistry()
 {
+  // first clear each macro action that require presence of all primitive ones
+  MakroAction * presentAction =
+      dynamic_cast<MakroAction *>(getActionByName("subgraph-dissection"));
+  ASSERT( presentAction != NULL,
+      "ActionRegistry::fillRegistry() - makro action has not been registered.");
+  presentAction->unprepare(*this);
+
   //std::cout << "ActionRegistry::~ActionRegistry() called, instance is " << this << "." << std::endl;
   cleanup();
@@ -86,4 +95,11 @@
 #include BOOST_PP_LOCAL_ITERATE()
 #undef instance_print  
+
+  // now prepare each macro action that require presence of all primitive ones
+  MakroAction * presentAction =
+      dynamic_cast<MakroAction *>(getActionByName("subgraph-dissection"));
+  ASSERT( presentAction != NULL,
+      "ActionRegistry::fillRegistry() - makro action has not been registered.");
+  presentAction->prepare(*this);
 }
 
Index: src/Actions/GlobalListOfActions.hpp
===================================================================
--- src/Actions/GlobalListOfActions.hpp	(revision 560cbfdc6f64a3ba2d8d199f06984d8ea1f79247)
+++ src/Actions/GlobalListOfActions.hpp	(revision 22b786ada90f98f487f6059fa83cd4ab52169ec7)
@@ -19,8 +19,9 @@
 #define GLOBALLISTOFACTIONS_initial \
   (Redo) \
-  (GraphSubgraphDissection) \
+  (GraphUpdateMolecules) \
   (GraphCreateAdjacency) \
   (GraphDepthFirstSearch) \
   (GraphDestroyAdjacency) \
+  (GraphSubgraphDissection) \
   (MoleculeSaveTemperature) \
   (MoleculeCopy) \
Index: src/Actions/GraphAction/SubgraphDissectionAction.cpp
===================================================================
--- src/Actions/GraphAction/SubgraphDissectionAction.cpp	(revision 560cbfdc6f64a3ba2d8d199f06984d8ea1f79247)
+++ src/Actions/GraphAction/SubgraphDissectionAction.cpp	(revision 22b786ada90f98f487f6059fa83cd4ab52169ec7)
@@ -2,5 +2,5 @@
  * Project: MoleCuilder
  * Description: creates and alters molecular systems
- * Copyright (C)  2010-2012 University of Bonn. All rights reserved.
+ * Copyright (C)  2013 University of Bonn. All rights reserved.
  * 
  *
@@ -24,5 +24,5 @@
  * SubgraphDissectionAction.cpp
  *
- *  Created on: May 9, 2010
+ *  Created on: Mar 1, 2013
  *      Author: heber
  */
@@ -35,117 +35,145 @@
 #include "CodePatterns/MemDebug.hpp"
 
-#include "Descriptors/AtomIdDescriptor.hpp"
-#include "Descriptors/MoleculeDescriptor.hpp"
+#include "CodePatterns/Chronos.hpp"
 
-#include "Atom/atom.hpp"
-#include "Bond/bond.hpp"
-#include "CodePatterns/Log.hpp"
-#include "CodePatterns/Verbose.hpp"
-#include "Graph/BondGraph.hpp"
-#include "Graph/DepthFirstSearchAnalysis.hpp"
-#include "molecule.hpp"
-#include "MoleculeListClass.hpp"
-#include "World.hpp"
+#include "Actions/GraphAction/CreateAdjacencyAction.hpp"
+#include "Actions/GraphAction/DestroyAdjacencyAction.hpp"
+#include "Actions/GraphAction/UpdateMoleculesAction.hpp"
+#include "Actions/GraphAction/SubgraphDissectionAction.hpp"
+#include "Actions/ActionRegistry.hpp"
 
-#include <iostream>
-#include <string>
+#include "Descriptors/AtomDescriptor.hpp"
 
-typedef std::map< moleculeId_t, std::vector<atomId_t> > MolAtomList;
-typedef std::map< atomId_t, atomId_t > AtomAtomList;
+#include "SubgraphDissectionAction.def"
 
-#include "Actions/GraphAction/SubgraphDissectionAction.hpp"
+// some derived names: if CATEGORY is not given, we don't prefix with it
+#ifdef CATEGORY
+#define ACTION BOOST_PP_CAT(CATEGORY, BOOST_PP_CAT(ACTIONNAME, Action))
+#define COMMAND BOOST_PP_CAT(CATEGORY, ACTIONNAME)
+#define PARAMS BOOST_PP_CAT(CATEGORY, BOOST_PP_CAT(ACTIONNAME, Parameters))
+#else
+#define ACTION BOOST_PP_CAT(ACTIONNAME, Action)
+#define COMMAND ACTIONNAME
+#define PARAMS BOOST_PP_CAT(ACTIONNAME, Parameters)
+#endif
+// check if no lists given
+#ifndef paramtypes
+#define MAXPARAMTYPES 0
+#else
+#define MAXPARAMTYPES BOOST_PP_SEQ_SIZE(paramtypes)
+#endif
+#ifndef paramdefaults
+#define MAXPARAMDEFAULTS 0
+#else
+#define MAXPARAMDEFAULTS BOOST_PP_SEQ_SIZE(paramdefaults)
+#endif
 
-using namespace MoleCuilder;
+namespace MoleCuilder {
 
-// and construct the stuff
-#include "SubgraphDissectionAction.def"
-#include "Action_impl_pre.hpp"
-/** =========== define the function ====================== */
-Action::state_ptr GraphSubgraphDissectionAction::performCall() {
-  // first create stuff for undo state
-  LOG(0, "STATUS: Creating undo state.");
-  MolAtomList moleculelist;
-  vector<molecule *> allmolecules = World::getInstance().getAllMolecules();
-  for (vector<molecule *>::const_iterator moliter = allmolecules.begin(); moliter != allmolecules.end(); ++moliter) {
-    std::vector<atomId_t> atomlist;
-    atomlist.resize((*moliter)->size());
-    for (molecule::const_iterator atomiter = (*moliter)->begin(); atomiter != (*moliter)->end(); ++atomiter) {
-      atomlist.push_back((*atomiter)->getId());
-    }
-    moleculelist.insert( std::pair< moleculeId_t, std::vector<atomId_t> > ((*moliter)->getId(), atomlist));
-  }
-  GraphSubgraphDissectionState *UndoState = new GraphSubgraphDissectionState(moleculelist, params);
+// static instances
+ActionSequence GraphSubgraphDissectionAction::actions;
+bool GraphSubgraphDissectionAction::isPrepared = false;
 
-  // 0a. remove all present molecules
-  LOG(0, "STATUS: Removing all present molecules.");
-  MoleculeListClass *molecules = World::getInstance().getMolecules();
-  for (vector<molecule *>::iterator MolRunner = allmolecules.begin(); MolRunner != allmolecules.end(); ++MolRunner) {
-    molecules->erase(*MolRunner);
-    World::getInstance().destroyMolecule(*MolRunner);
-  }
+GraphSubgraphDissectionAction::GraphSubgraphDissectionAction() :
+  MakroAction(ActionTraits< GraphSubgraphDissectionAction >(), actions, false)
+{}
 
-  // 1. create the bond structure of the single molecule
-  LOG(0, "STATUS: (Re-)constructing adjacency.");
-  BondGraph *BG = World::getInstance().getBondGraph();
-  World::AtomComposite Set = World::getInstance().getAllAtoms();
-  BG->CreateAdjacency(Set);
+GraphSubgraphDissectionAction::~GraphSubgraphDissectionAction()
+{}
 
-  // 2. scan for connected subgraphs
-  DepthFirstSearchAnalysis DFS;
-  DFS();
-  DFS.UpdateMoleculeStructure();
-  if (World::getInstance().numMolecules() == 0) {
-    //World::getInstance().destroyMolecule(mol);
-    ELOG(1, "There are no molecules.");
-    return Action::failure;
-  }
+void GraphSubgraphDissectionAction::prepare(ActionRegistry &AR)
+{
+  actions.addAction(AR.getActionByName(std::string("destroy-adjacency")));
+  actions.addAction(AR.getActionByName(std::string("create-adjacency")));
+  actions.addAction(AR.getActionByName(std::string("update-molecules")));
+  isPrepared = true;
+}
 
-  LOG(1, "I scanned " << World::getInstance().numMolecules() << " molecules.");
+void GraphSubgraphDissectionAction::unprepare(ActionRegistry &AR)
+{
+  // empty sequence
+  while (actions.removeLastAction() != NULL);
+  isPrepared = false;
+}
 
-  return Action::state_ptr(UndoState);
+void reselectAtoms(const std::vector<atom *> &selected_atoms)
+{
+  World::getInstance().clearAtomSelection();
+  for (std::vector<atom *>::const_iterator iter = selected_atoms.begin();
+      iter != selected_atoms.end();
+      ++iter)
+    World::getInstance().selectAtom(*iter);
+}
+
+Action::state_ptr GraphSubgraphDissectionAction::performCall(){
+  // we need to "emulate" that all atoms have been selected without destroying
+  // current selection
+  Chronos::getInstance().startTiming(TOKEN);
+  const std::vector<atom *> selected_atoms = World::getInstance().getSelectedAtoms();
+  World::getInstance().selectAllAtoms(AllAtoms());
+  Action::state_ptr state(MakroAction::performCall());
+  reselectAtoms(selected_atoms);
+  Chronos::getInstance().endTiming(TOKEN);
+
+  return state;
 }
 
 Action::state_ptr GraphSubgraphDissectionAction::performUndo(Action::state_ptr _state) {
-  GraphSubgraphDissectionState *state = assert_cast<GraphSubgraphDissectionState*>(_state.get());
+  // we need to "emulate" that all atoms have been selected without destroying
+  // current selection
+  const std::vector<atom *> selected_atoms = World::getInstance().getSelectedAtoms();
+  World::getInstance().selectAllAtoms(AllAtoms());
+  Action::state_ptr state(MakroAction::performUndo(_state));
+  reselectAtoms(selected_atoms);
 
-  {
-    // remove all present molecules
-    MoleculeListClass *molecules = World::getInstance().getMolecules();
-    vector<molecule *> allmolecules = World::getInstance().getAllMolecules();
-    for (vector<molecule *>::iterator MolRunner = allmolecules.begin(); MolRunner != allmolecules.end(); ++MolRunner) {
-      molecules->erase(*MolRunner);
-      World::getInstance().destroyMolecule(*MolRunner);
-    }
-  }
-
-  {
-    // construct the old state
-    MoleculeListClass *molecules = World::getInstance().getMolecules();
-    molecule *mol = NULL;
-    for (MolAtomList::const_iterator iter = state->moleculelist.begin(); iter != state->moleculelist.end(); ++iter) {
-      mol = World::getInstance().createMolecule();
-      if (mol->getId() != (*iter).first)
-        World::getInstance().changeMoleculeId(mol->getId(), (*iter).first);
-      for (std::vector<atomId_t>::const_iterator atomiter = (*iter).second.begin(); atomiter != (*iter).second.end(); ++atomiter) {
-        atom *Walker = World::getInstance().getAtom(AtomById(*atomiter));
-        mol->AddAtom(Walker);
-      }
-      molecules->insert(mol);
-    }
-  }
-
-  return Action::state_ptr(_state);
+  return state;
 }
 
 Action::state_ptr GraphSubgraphDissectionAction::performRedo(Action::state_ptr _state){
-  return performCall();
+  // we need to "emulate" that all atoms have been selected without destroying
+  // current selection
+  const std::vector<atom *> selected_atoms = World::getInstance().getSelectedAtoms();
+  World::getInstance().selectAllAtoms(AllAtoms());
+  Action::state_ptr state(MakroAction::performRedo(_state));
+  reselectAtoms(selected_atoms);
+
+  return state;
 }
 
-bool GraphSubgraphDissectionAction::canUndo() {
-  return true;
+// =========== command for calling action directly ===========
+void COMMAND(
+#if defined paramtypes && defined paramreferences && BOOST_PP_NOT_EQUAL(MAXPARAMTYPES,0)
+#define BOOST_PP_LOCAL_MACRO(n) type_list(~, n, paramtypes, paramreferences)
+#define BOOST_PP_LOCAL_LIMITS  (0, MAXPARAMTYPES-1)
+#include BOOST_PP_LOCAL_ITERATE()
+#endif
+)
+{
+  ACTION *ToCall = dynamic_cast<ACTION*>(ActionRegistry::getInstance().getActionByName( TOKEN )); //->clone(params);
+  //ACTION::PARAMS params;
+#if defined paramreferences && BOOST_PP_NOT_EQUAL(MAXPARAMTYPES,0)
+#define BOOST_PP_LOCAL_MACRO(n) value_print(~, n, paramreferences, ToCall->params.)
+#define BOOST_PP_LOCAL_LIMITS  (0, MAXPARAMTYPES-1)
+#include BOOST_PP_LOCAL_ITERATE()
+#endif
+  ToCall->call(Action::NonInteractive);
+};
+
+void BOOST_PP_CAT( COMMAND, _stringargs)(
+#if defined paramtypes && defined paramreferences && BOOST_PP_NOT_EQUAL(MAXPARAMTYPES,0)
+#define BOOST_PP_LOCAL_MACRO(n) type_list(~, n, BOOST_PP_SEQ_TRANSFORM( type2string, , paramtypes), paramreferences)
+#define BOOST_PP_LOCAL_LIMITS  (0, MAXPARAMTYPES-1)
+#include BOOST_PP_LOCAL_ITERATE()
+#endif
+  ) {
+  ACTION *ToCall = dynamic_cast<ACTION*>(ActionRegistry::getInstance().getActionByName( TOKEN )); //->clone(params);
+  //ACTION::PARAMS params;
+#if defined paramtypes && defined paramtypes && BOOST_PP_NOT_EQUAL(MAXPARAMTYPES,0)
+#define BOOST_PP_LOCAL_MACRO(n) valuetype_print(~, n, paramreferences, paramtypes, ToCall->params. )
+#define BOOST_PP_LOCAL_LIMITS  (0, MAXPARAMTYPES-1)
+#include BOOST_PP_LOCAL_ITERATE()
+#endif
+  ToCall->call(MoleCuilder::Action::NonInteractive);
+};
+
 }
-
-bool GraphSubgraphDissectionAction::shouldUndo() {
-  return true;
-}
-/** =========== end of function ====================== */
Index: src/Actions/GraphAction/SubgraphDissectionAction.def
===================================================================
--- src/Actions/GraphAction/SubgraphDissectionAction.def	(revision 560cbfdc6f64a3ba2d8d199f06984d8ea1f79247)
+++ src/Actions/GraphAction/SubgraphDissectionAction.def	(revision 22b786ada90f98f487f6059fa83cd4ab52169ec7)
@@ -2,5 +2,5 @@
  * SubgraphDissectionAction.def
  *
- *  Created on: Aug 26, 2010
+ *  Created on: Mar 1, 2013
  *      Author: heber
  */
Index: src/Actions/GraphAction/SubgraphDissectionAction.hpp
===================================================================
--- src/Actions/GraphAction/SubgraphDissectionAction.hpp	(revision 560cbfdc6f64a3ba2d8d199f06984d8ea1f79247)
+++ src/Actions/GraphAction/SubgraphDissectionAction.hpp	(revision 22b786ada90f98f487f6059fa83cd4ab52169ec7)
@@ -2,5 +2,5 @@
  * SubgraphDissectionAction.hpp
  *
- *  Created on: May 9, 2010
+ *  Created on: Mar 1, 2013
  *      Author: heber
  */
@@ -14,9 +14,113 @@
 #endif
 
-
-#include "Actions/Action.hpp"
+#include "Actions/ActionSequence.hpp"
+#include "Actions/ActionTraits.hpp"
+#include "Actions/MakroAction.hpp"
 
 #include "SubgraphDissectionAction.def"
-#include "Action_impl_header.hpp"
+
+// some derived names: if CATEGORY is not given, we don't prefix with it
+#ifdef CATEGORY
+#define ACTION BOOST_PP_CAT(CATEGORY, BOOST_PP_CAT(ACTIONNAME, Action))
+#define COMMAND BOOST_PP_CAT(CATEGORY, ACTIONNAME)
+#define PARAMS BOOST_PP_CAT(CATEGORY, BOOST_PP_CAT(ACTIONNAME, Parameters))
+#else
+#define ACTION BOOST_PP_CAT(ACTIONNAME, Action)
+#define COMMAND ACTIONNAME
+#define PARAMS BOOST_PP_CAT(ACTIONNAME, Parameters)
+#endif
+// check if no lists given
+#ifndef paramtypes
+#define MAXPARAMTYPES 0
+#else
+#define MAXPARAMTYPES BOOST_PP_SEQ_SIZE(paramtypes)
+#endif
+#ifndef paramdefaults
+#define MAXPARAMDEFAULTS 0
+#else
+#define MAXPARAMDEFAULTS BOOST_PP_SEQ_SIZE(paramdefaults)
+#endif
+
+namespace MoleCuilder {
+
+// print a list of type ref followed, i.e. "int i, double position"
+#define type_list(z,n,TYPELIST, VARLIST) \
+  BOOST_PP_COMMA_IF(n)\
+  BOOST_PP_SEQ_ELEM(n, TYPELIST) \
+  BOOST_PP_SEQ_ELEM(n, VARLIST)
+
+void COMMAND(
+#if defined paramtypes && defined paramreferences
+#define BOOST_PP_LOCAL_MACRO(n) type_list(~, n, paramtypes, paramreferences)
+#define BOOST_PP_LOCAL_LIMITS  (0, MAXPARAMTYPES-1)
+#include BOOST_PP_LOCAL_ITERATE()
+#endif
+    );
+
+class GraphSubgraphDissectionAction;
+
+template <>
+class ActionTraits<ACTION> : public ActionTrait {
+public:
+  ActionTraits() :
+#ifndef SHORTFORM
+    ActionTrait(OptionTrait(TOKEN, &typeid(void), DESCRIPTION, std::string()))
+#else
+    ActionTrait(OptionTrait(TOKEN, &typeid(void), DESCRIPTION, std::string(), SHORTFORM))
+#endif /* SHORTFORM */
+  {
+  // initialize remainder of action info
+#ifdef MENUNAME
+    MenuTitle = MENUNAME;
+#endif
+#ifdef MENUPOSITION
+    MenuPosition = MENUPOSITION;
+#endif
+
+    // we got no options to initialize
+  }
+
+  virtual ~ActionTraits() {
+    //std::cout << "ActionTraits<" << BOOST_PP_STRINGIZE(ACTION) << ">::~ActionTraits() on instance " << this << " with name " << getName() << " called." << std::endl;
+  }
+};
+
+class GraphSubgraphDissectionAction : public MakroAction
+{
+public:
+  GraphSubgraphDissectionAction();
+  virtual ~GraphSubgraphDissectionAction();
+
+  // must be called after all primitive actions are present
+  void prepare(ActionRegistry &AR);
+  // must be called before alle primitive actions are removed
+  void unprepare(ActionRegistry &AR);
+
+  virtual Action::state_ptr performCall();
+  virtual Action::state_ptr performUndo(Action::state_ptr);
+  virtual Action::state_ptr performRedo(Action::state_ptr);
+
+private:
+  //!> flag to check whether actions have been prepared
+  static bool isPrepared;
+  //!> sequence of actions for this macro action
+  static ActionSequence actions;
+};
+
+}
+
+#undef ACTION
+#undef COMMAND
+#undef COMMANDFULL
+#undef PARAMS
+
+#undef ACTIONNAME
+#undef CATEGORY
+#undef MENUNAME
+#undef MENUPOSITION
+#undef TOKEN
+
+#undef DESCRIPTION
+#undef SHORTFORM
 
 #endif /* SUBGRAPHDISSECTIONACTION_HPP_ */
Index: src/Actions/GraphAction/UpdateMoleculesAction.cpp
===================================================================
--- src/Actions/GraphAction/UpdateMoleculesAction.cpp	(revision 22b786ada90f98f487f6059fa83cd4ab52169ec7)
+++ src/Actions/GraphAction/UpdateMoleculesAction.cpp	(revision 22b786ada90f98f487f6059fa83cd4ab52169ec7)
@@ -0,0 +1,145 @@
+/*
+ * Project: MoleCuilder
+ * Description: creates and alters molecular systems
+ * Copyright (C)  2010-2012 University of Bonn. All rights reserved.
+ * 
+ *
+ *   This file is part of MoleCuilder.
+ *
+ *    MoleCuilder is free software: you can redistribute it and/or modify
+ *    it under the terms of the GNU General Public License as published by
+ *    the Free Software Foundation, either version 2 of the License, or
+ *    (at your option) any later version.
+ *
+ *    MoleCuilder is distributed in the hope that it will be useful,
+ *    but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *    GNU General Public License for more details.
+ *
+ *    You should have received a copy of the GNU General Public License
+ *    along with MoleCuilder.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+/*
+ * UpdateMoleculesAction.cpp
+ *
+ *  Created on: May 9, 2010
+ *      Author: heber
+ */
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "CodePatterns/MemDebug.hpp"
+
+#include "Descriptors/AtomIdDescriptor.hpp"
+#include "Descriptors/MoleculeDescriptor.hpp"
+
+#include "Atom/atom.hpp"
+#include "Bond/bond.hpp"
+#include "CodePatterns/Log.hpp"
+#include "CodePatterns/Verbose.hpp"
+#include "Graph/BondGraph.hpp"
+#include "Graph/DepthFirstSearchAnalysis.hpp"
+#include "molecule.hpp"
+#include "MoleculeListClass.hpp"
+#include "World.hpp"
+
+#include <iostream>
+#include <string>
+
+typedef std::map< moleculeId_t, std::vector<atomId_t> > MolAtomList;
+typedef std::map< atomId_t, atomId_t > AtomAtomList;
+
+#include "Actions/GraphAction/UpdateMoleculesAction.hpp"
+
+using namespace MoleCuilder;
+
+// and construct the stuff
+#include "UpdateMoleculesAction.def"
+#include "Action_impl_pre.hpp"
+/** =========== define the function ====================== */
+Action::state_ptr GraphUpdateMoleculesAction::performCall() {
+  // first create stuff for undo state
+  LOG(0, "STATUS: Creating undo state.");
+  MolAtomList moleculelist;
+  vector<molecule *> allmolecules = World::getInstance().getAllMolecules();
+  for (vector<molecule *>::const_iterator moliter = allmolecules.begin(); moliter != allmolecules.end(); ++moliter) {
+    std::vector<atomId_t> atomlist;
+    atomlist.resize((*moliter)->size());
+    for (molecule::const_iterator atomiter = (*moliter)->begin(); atomiter != (*moliter)->end(); ++atomiter) {
+      atomlist.push_back((*atomiter)->getId());
+    }
+    moleculelist.insert( std::pair< moleculeId_t, std::vector<atomId_t> > ((*moliter)->getId(), atomlist));
+  }
+  GraphUpdateMoleculesState *UndoState = new GraphUpdateMoleculesState(moleculelist, params);
+
+  // 0a. remove all present molecules
+  LOG(0, "STATUS: Removing all present molecules.");
+  MoleculeListClass *molecules = World::getInstance().getMolecules();
+  for (vector<molecule *>::iterator MolRunner = allmolecules.begin(); MolRunner != allmolecules.end(); ++MolRunner) {
+    molecules->erase(*MolRunner);
+    World::getInstance().destroyMolecule(*MolRunner);
+  }
+
+  // 2. scan for connected subgraphs
+  DepthFirstSearchAnalysis DFS;
+  DFS();
+  DFS.UpdateMoleculeStructure();
+  if (World::getInstance().numMolecules() == 0) {
+    //World::getInstance().destroyMolecule(mol);
+    ELOG(1, "There are no molecules.");
+    return Action::failure;
+  }
+
+  LOG(1, "I scanned " << World::getInstance().numMolecules() << " molecules.");
+
+  return Action::state_ptr(UndoState);
+}
+
+Action::state_ptr GraphUpdateMoleculesAction::performUndo(Action::state_ptr _state) {
+  GraphUpdateMoleculesState *state = assert_cast<GraphUpdateMoleculesState*>(_state.get());
+
+  {
+    // remove all present molecules
+    MoleculeListClass *molecules = World::getInstance().getMolecules();
+    vector<molecule *> allmolecules = World::getInstance().getAllMolecules();
+    for (vector<molecule *>::iterator MolRunner = allmolecules.begin(); MolRunner != allmolecules.end(); ++MolRunner) {
+      molecules->erase(*MolRunner);
+      World::getInstance().destroyMolecule(*MolRunner);
+    }
+  }
+
+  {
+    // construct the old state
+    MoleculeListClass *molecules = World::getInstance().getMolecules();
+    molecule *mol = NULL;
+    for (MolAtomList::const_iterator iter = state->moleculelist.begin(); iter != state->moleculelist.end(); ++iter) {
+      mol = World::getInstance().createMolecule();
+      if (mol->getId() != (*iter).first)
+        World::getInstance().changeMoleculeId(mol->getId(), (*iter).first);
+      for (std::vector<atomId_t>::const_iterator atomiter = (*iter).second.begin(); atomiter != (*iter).second.end(); ++atomiter) {
+        atom *Walker = World::getInstance().getAtom(AtomById(*atomiter));
+        mol->AddAtom(Walker);
+      }
+      molecules->insert(mol);
+    }
+  }
+
+  return Action::state_ptr(_state);
+}
+
+Action::state_ptr GraphUpdateMoleculesAction::performRedo(Action::state_ptr _state){
+  return performCall();
+}
+
+bool GraphUpdateMoleculesAction::canUndo() {
+  return true;
+}
+
+bool GraphUpdateMoleculesAction::shouldUndo() {
+  return true;
+}
+/** =========== end of function ====================== */
Index: src/Actions/GraphAction/UpdateMoleculesAction.def
===================================================================
--- src/Actions/GraphAction/UpdateMoleculesAction.def	(revision 22b786ada90f98f487f6059fa83cd4ab52169ec7)
+++ src/Actions/GraphAction/UpdateMoleculesAction.def	(revision 22b786ada90f98f487f6059fa83cd4ab52169ec7)
@@ -0,0 +1,36 @@
+/*
+ * UpdateMoleculesAction.def
+ *
+ *  Created on: Aug 26, 2010
+ *      Author: heber
+ */
+
+// all includes and forward declarations necessary for non-integral types below
+
+
+#include "Parameters/Validators/DummyValidator.hpp"
+
+// i.e. there is an integer with variable name Z that can be found in
+// ValueStorage by the token "Z" -> first column: int, Z, "Z"
+// "undefine" if no parameters are required, use (NOPARAM_DEFAULT) for each (undefined) default value
+#undef paramtypes
+#undef paramtokens
+#undef paramdescriptions
+#undef paramdefaults
+#undef paramreferences
+#undef paramvalids
+
+#define statetypes (MolAtomList)
+#define statereferences (moleculelist)
+
+// some defines for all the names, you may use ACTION, STATE and PARAMS
+#define CATEGORY Graph
+#define MENUNAME "graph"
+#define MENUPOSITION 4
+#define ACTIONNAME UpdateMolecules
+#define TOKEN "update-molecules"
+
+
+// finally the information stored in the ActionTrait specialization
+#define DESCRIPTION "make sure that all present molecules represent disconnected subgraphs"
+#undef SHORTFORM
Index: src/Actions/GraphAction/UpdateMoleculesAction.hpp
===================================================================
--- src/Actions/GraphAction/UpdateMoleculesAction.hpp	(revision 22b786ada90f98f487f6059fa83cd4ab52169ec7)
+++ src/Actions/GraphAction/UpdateMoleculesAction.hpp	(revision 22b786ada90f98f487f6059fa83cd4ab52169ec7)
@@ -0,0 +1,22 @@
+/*
+ * UpdateMoleculesAction.hpp
+ *
+ *  Created on: May 9, 2010
+ *      Author: heber
+ */
+
+#ifndef UPDATEMOLECULESACTION_HPP_
+#define UPDATEMOLECULESACTION_HPP_
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+
+#include "Actions/Action.hpp"
+
+#include "UpdateMoleculesAction.def"
+#include "Action_impl_header.hpp"
+
+#endif /* UPDATEMOLECULESACTION_HPP_ */
Index: src/Actions/Makefile.am
===================================================================
--- src/Actions/Makefile.am	(revision 560cbfdc6f64a3ba2d8d199f06984d8ea1f79247)
+++ src/Actions/Makefile.am	(revision 22b786ada90f98f487f6059fa83cd4ab52169ec7)
@@ -233,15 +233,18 @@
   Actions/GraphAction/DepthFirstSearchAction.cpp \
   Actions/GraphAction/DestroyAdjacencyAction.cpp \
-  Actions/GraphAction/SubgraphDissectionAction.cpp
+  Actions/GraphAction/SubgraphDissectionAction.cpp \
+  Actions/GraphAction/UpdateMoleculesAction.cpp
 GRAPHACTIONHEADER = \
   Actions/GraphAction/CreateAdjacencyAction.hpp \
   Actions/GraphAction/DepthFirstSearchAction.hpp \
   Actions/GraphAction/DestroyAdjacencyAction.hpp \
-  Actions/GraphAction/SubgraphDissectionAction.hpp
+  Actions/GraphAction/SubgraphDissectionAction.hpp \
+  Actions/GraphAction/UpdateMoleculesAction.hpp
 GRAPHACTIONDEFS = \
   Actions/GraphAction/CreateAdjacencyAction.def \
   Actions/GraphAction/DepthFirstSearchAction.def \
   Actions/GraphAction/DestroyAdjacencyAction.def \
-  Actions/GraphAction/SubgraphDissectionAction.def
+  Actions/GraphAction/SubgraphDissectionAction.def \
+  Actions/GraphAction/UpdateMoleculesAction.def
 
 MOLECULEACTIONSOURCE = \
Index: src/Actions/MakroAction.cpp
===================================================================
--- src/Actions/MakroAction.cpp	(revision 560cbfdc6f64a3ba2d8d199f06984d8ea1f79247)
+++ src/Actions/MakroAction.cpp	(revision 22b786ada90f98f487f6059fa83cd4ab52169ec7)
@@ -56,5 +56,5 @@
 };
 
-MakroAction::MakroAction(const ActionTrait &_trait,ActionSequence* _actions,bool _doRegister) :
+MakroAction::MakroAction(const ActionTrait &_trait,ActionSequence& _actions,bool _doRegister) :
 Action(_trait,_doRegister),
 actions(_actions)
@@ -64,17 +64,23 @@
 MakroAction::~MakroAction()
 {
-  Action* action;
-  while((action=actions->removeLastAction())){
-    delete action;
-  }
-  delete actions;
+  // emptying the sequence is someone else responsibility
+//  Action* action;
+//  while((action=actions.removeLastAction())){
+//    delete action;
+//  }
 }
 
+void MakroAction::prepare(ActionRegistry &AR)
+{}
+
+void MakroAction::unprepare(ActionRegistry &AR)
+{}
+
 Dialog* MakroAction::fillDialog(Dialog *dialog) {
-  return actions->fillAllDialogs(dialog);
+  return actions.fillAllDialogs(dialog);
 }
 
 Action::state_ptr MakroAction::performCall(){
-  ActionSequence::stateSet states = actions->callAll(true);
+  ActionSequence::stateSet states = actions.callAll(true);
   return Action::state_ptr(new MakroActionState(states));
 }
@@ -83,5 +89,5 @@
   MakroActionState *state = dynamic_cast<MakroActionState*>(_state.get());
   ASSERT(state,"Type mismatch for the state of the MakroAction");
-  ActionSequence::stateSet states = actions->undoAll(state->states);
+  ActionSequence::stateSet states = actions.undoAll(state->states);
   return Action::state_ptr(new MakroActionState(states));
 }
@@ -90,13 +96,13 @@
   MakroActionState *state = dynamic_cast<MakroActionState*>(_state.get());
   ASSERT(state,"Type mismatch for the state of the MakroAction");
-  ActionSequence::stateSet states = actions->redoAll(state->states);
+  ActionSequence::stateSet states = actions.redoAll(state->states);
   return Action::state_ptr(new MakroActionState(states));
 }
 
 bool MakroAction::canUndo() {
-  return actions->canUndo();
+  return actions.canUndo();
 }
 
 bool MakroAction::shouldUndo() {
-  return actions->shouldUndo();
+  return actions.shouldUndo();
 }
Index: src/Actions/MakroAction.hpp
===================================================================
--- src/Actions/MakroAction.hpp	(revision 560cbfdc6f64a3ba2d8d199f06984d8ea1f79247)
+++ src/Actions/MakroAction.hpp	(revision 22b786ada90f98f487f6059fa83cd4ab52169ec7)
@@ -20,4 +20,5 @@
 
 namespace MoleCuilder {
+  class ActionRegistry;
   class ActionSequence;
 
@@ -30,5 +31,5 @@
 {
 public:
-  MakroAction(const ActionTrait &_trait,ActionSequence* _actions,bool _doRegister=true);
+  MakroAction(const ActionTrait &_trait,ActionSequence& _actions,bool _doRegister=true);
   virtual ~MakroAction();
 
@@ -36,12 +37,18 @@
   bool shouldUndo();
 
+  // must be called after all primitive actions are present
+  virtual void prepare(ActionRegistry &AR);
+  // must be called before alle primitive actions are removed
+  virtual void unprepare(ActionRegistry &AR);
+
 protected:
   virtual Dialog *fillDialog(Dialog *dialog);
-private:
+
   virtual Action::state_ptr performCall();
   virtual Action::state_ptr performUndo(Action::state_ptr);
   virtual Action::state_ptr performRedo(Action::state_ptr);
 
-  ActionSequence *actions;
+private:
+  ActionSequence &actions;
 };
 
Index: src/Actions/unittests/ActionSequenceUnitTest.cpp
===================================================================
--- src/Actions/unittests/ActionSequenceUnitTest.cpp	(revision 560cbfdc6f64a3ba2d8d199f06984d8ea1f79247)
+++ src/Actions/unittests/ActionSequenceUnitTest.cpp	(revision 22b786ada90f98f487f6059fa83cd4ab52169ec7)
@@ -277,5 +277,5 @@
 
   ActionTrait MakroTrait("Test MakroAction");
-  MakroAction act(MakroTrait,sequence,false);
+  MakroAction act(MakroTrait,*sequence,false);
 
   act.call();
@@ -289,5 +289,6 @@
   CPPUNIT_ASSERT_EQUAL(false,wasCalled2->wasCalled());
 
-}
-
-
+  delete sequence;
+}
+
+
