Index: src/Actions/Action_impl_header.hpp
===================================================================
--- src/Actions/Action_impl_header.hpp	(revision 9ee38b1c3b23a38c779c8e4ad098fe0677a3a5b7)
+++ src/Actions/Action_impl_header.hpp	(revision b4fa106066497a55bc2e47cdbd46bf7f293eaf34)
@@ -23,13 +23,11 @@
 #define ACTION BOOST_PP_CAT(CATEGORY, BOOST_PP_CAT(ACTIONNAME, Action))
 #define COMMAND BOOST_PP_CAT(CATEGORY, ACTIONNAME)
-#define STATE BOOST_PP_CAT(CATEGORY, BOOST_PP_CAT(ACTIONNAME, State))
 #define PARAMS BOOST_PP_CAT(CATEGORY, BOOST_PP_CAT(ACTIONNAME, Parameters))
-#define PARAMSDOT BOOST_PP_CAT(CATEGORY, BOOST_PP_CAT(ACTIONNAME, Parameters))
 
 // check if no lists given
-#ifndef types
-#define MAXNOTOKENS 0
+#ifndef paramtypes
+#define MAXPARAMTYPES 0
 #else
-#define MAXNOTOKENS BOOST_PP_SEQ_SIZE(types)
+#define MAXPARAMTYPES BOOST_PP_SEQ_SIZE(paramtypes)
 #endif
 
@@ -44,59 +42,49 @@
 
 // calculate numbers and check whether all have same size
-#ifdef tokens
-BOOST_PP_ASSERT_MSG(BOOST_PP_EQUAL(MAXNOTOKENS, BOOST_PP_SEQ_SIZE(tokens)),\
-  ERROR: There are not the same number of "tokens" and "types" in: __FILE__ \
+#ifdef paramtokens
+BOOST_PP_ASSERT_MSG(BOOST_PP_EQUAL(MAXPARAMTYPES, BOOST_PP_SEQ_SIZE(paramtokens)),\
+  ERROR: There are not the same number of "paramtokens" and "paramtypes" in: __FILE__ \
 )
 #endif
-#ifdef references
-BOOST_PP_ASSERT_MSG(BOOST_PP_EQUAL(MAXNOTOKENS, BOOST_PP_SEQ_SIZE(references)),\
-  ERROR: There are not the same number of "tokens" and "references" in: __FILE__ \
+#ifdef paramreferences
+BOOST_PP_ASSERT_MSG(BOOST_PP_EQUAL(MAXPARAMTYPES, BOOST_PP_SEQ_SIZE(paramreferences)),\
+  ERROR: There are not the same number of "paramtokens" and "paramreferences" in: __FILE__ \
 )
 #endif
 
 // print a list of type ref followed by a separator, i.e. "int i;"
-#define type_print(z,n,separator) \
-  BOOST_PP_SEQ_ELEM(n, types) \
-  BOOST_PP_SEQ_ELEM(n, references)\
+#define type_print(z,n,TYPELIST, VARLIST, separator) \
+  BOOST_PP_SEQ_ELEM(n, TYPELIST) \
+  BOOST_PP_SEQ_ELEM(n, VARLIST)\
   separator
 
 // print a list of type ref followed, i.e. "int i, double position"
-#define type_list(z,n,unused) \
+#define type_list(z,n,TYPELIST, VARLIST) \
   BOOST_PP_COMMA_IF(n)\
-  BOOST_PP_SEQ_ELEM(n, types) \
-  BOOST_PP_SEQ_ELEM(n, references)
+  BOOST_PP_SEQ_ELEM(n, TYPELIST) \
+  BOOST_PP_SEQ_ELEM(n, VARLIST)
 
-// prints dialog->query calls for types with tokens
-#define dialog_print(z,n,unused) \
-  dialog->query<\
-  BOOST_PP_SEQ_ELEM(n, types)\
-  >(\
-  BOOST_PP_SEQ_ELEM(n, tokens)\
-  , ValueStorage::getInstance().getDescription(\
-  BOOST_PP_SEQ_ELEM(n, tokens)\
-  ));
-
-// prints set/queryCurrentValue (command) for references and tokens
-#define value_print(z,n,command) \
-  ValueStorage::getInstance(). command (\
-  BOOST_PP_SEQ_ELEM(n, tokens)\
-  , \
-  params.\
-  BOOST_PP_SEQ_ELEM(n, references)\
-  );
-
-#if BOOST_PP_NOT_EQUAL(MAXNOTOKENS,0)
-#define COMMANDFULL \
-void COMMAND( \
-BOOST_PP_REPEAT(MAXNOTOKENS, type_list, ~) \
-)
+#if defined paramtypes && defined paramreferences
+void COMMAND(
+#define BOOST_PP_LOCAL_MACRO(n) type_list(~, n, paramtypes, paramreferences)
+#define BOOST_PP_LOCAL_LIMITS  (0, MAXPARAMTYPES-1)
+#include BOOST_PP_LOCAL_ITERATE()
+    );
 # else
-#define COMMANDFULL void COMMAND()
+void COMMAND();
 #endif
 
-COMMANDFULL;
+class ACTION : public Action {
+  friend
+  #if defined paramtypes && defined paramreferences
+  void COMMAND(
+  #define BOOST_PP_LOCAL_MACRO(n) type_list(~, n, paramtypes, paramreferences)
+  #define BOOST_PP_LOCAL_LIMITS  (0, MAXPARAMTYPES-1)
+  #include BOOST_PP_LOCAL_ITERATE()
+      );
+  # else
+  void COMMAND();
+  #endif
 
-class ACTION : public Action {
-  friend COMMANDFULL;
 public:
   ACTION();
@@ -109,10 +97,8 @@
 
   struct PARAMS : ActionParameters {
-  #if BOOST_PP_NOT_EQUAL(MAXNOTOKENS,0)
-  #define BOOST_PP_LOCAL_MACRO(n) type_print(~, n, ;)
-  #define BOOST_PP_LOCAL_LIMITS  (0, MAXNOTOKENS-1)
+  #if defined paramtypes && defined paramreferences
+  #define BOOST_PP_LOCAL_MACRO(n) type_print(~, n, paramtypes, paramreferences, ;)
+  #define BOOST_PP_LOCAL_LIMITS  (0, MAXPARAMTYPES-1)
   #include BOOST_PP_LOCAL_ITERATE()
-  #undef BOOST_PP_LOCAL_MACRO
-  #undef BOOST_PP_LOCAL_LIMITS
   #endif
   } params;
@@ -129,15 +115,18 @@
 };
 
-#undef types
-#undef tokens
-#undef references
-#undef MAXNOTOKENS
+#undef paramtypes
+#undef paramtokens
+#undef paramreferences
+#undef MAXPARAMTYPES
+#undef statetypes
+#undef statereferences
+#undef MAXSTATETYPES
 
 #undef ACTION
-#undef ACTIONNAME
-#undef CATEGORY
 #undef COMMAND
 #undef COMMANDFULL
 #undef PARAMS
-#undef STATE
+
+#undef ACTIONNAME
+#undef CATEGORY
 #undef TOKEN
Index: src/Actions/Action_impl_pre.hpp
===================================================================
--- src/Actions/Action_impl_pre.hpp	(revision 9ee38b1c3b23a38c779c8e4ad098fe0677a3a5b7)
+++ src/Actions/Action_impl_pre.hpp	(revision b4fa106066497a55bc2e47cdbd46bf7f293eaf34)
@@ -14,9 +14,12 @@
  *
  *  For this, the user has the define the following values, each with
- *  parenthesis:
- *  -# types, e.g. (int)(double)
- *  -# tokens, e.g. ("Z")("length")
- *  -# references, e.g. (Z)(length)
- *  and
+ *  parenthesis, for the values/parameters the action needs
+ *  -# paramtypes, e.g. (int)(double)
+ *  -# paramtokens, e.g. ("Z")("length")
+ *  -# paramreferences, e.g. (Z)(length)
+ *  and for additional values/parameters to save in the state
+ *  -# statetypes, e.g. (int)(double)
+ *  -# statereferences, e.g. (Z)(length)
+ *  and the name and category of the action
  *  -# CATEGORY, e.g. Analysis
  *  -# ACTIONNAME, e.g. MolecularVolume
@@ -25,4 +28,5 @@
 
 #include <boost/preprocessor/cat.hpp>
+#include <boost/preprocessor/expand.hpp>
 #include <boost/preprocessor/comparison/equal.hpp>
 #include <boost/preprocessor/comparison/not_equal.hpp>
@@ -43,11 +47,15 @@
 #define STATE BOOST_PP_CAT(CATEGORY, BOOST_PP_CAT(ACTIONNAME, State))
 #define PARAMS BOOST_PP_CAT(CATEGORY, BOOST_PP_CAT(ACTIONNAME, Parameters))
-#define PARAMSDOT BOOST_PP_CAT(CATEGORY, BOOST_PP_CAT(ACTIONNAME, Parameters))
 
 // check if no lists given
-#ifndef types
-#define MAXNOTOKENS 0
-#else
-#define MAXNOTOKENS BOOST_PP_SEQ_SIZE(types)
+#ifndef paramtypes
+#define MAXPARAMTYPES 0
+#else
+#define MAXPARAMTYPES BOOST_PP_SEQ_SIZE(paramtypes)
+#endif
+#ifndef statetypes
+#define MAXSTATETYPES 0
+#else
+#define MAXSTATETYPES BOOST_PP_SEQ_SIZE(statetypes)
 #endif
 
@@ -62,35 +70,46 @@
 
 // calculate numbers and check whether all have same size
-#ifdef tokens
-BOOST_PP_ASSERT_MSG(BOOST_PP_EQUAL(MAXNOTOKENS, BOOST_PP_SEQ_SIZE(tokens)),\
-  ERROR: There are not the same number of "tokens" and "types" in: __FILE__ \
-)
-#endif
-#ifdef references
-BOOST_PP_ASSERT_MSG(BOOST_PP_EQUAL(MAXNOTOKENS, BOOST_PP_SEQ_SIZE(references)),\
-  ERROR: There are not the same number of "tokens" and "references" in: __FILE__ \
+#ifdef paramtokens
+BOOST_PP_ASSERT_MSG(BOOST_PP_EQUAL(MAXPARAMTYPES, BOOST_PP_SEQ_SIZE(paramtokens)),\
+  ERROR: There are not the same number of "paramtokens" and "paramtypes" in: __FILE__ \
+)
+#endif
+#ifdef paramreferences
+BOOST_PP_ASSERT_MSG(BOOST_PP_EQUAL(MAXPARAMTYPES, BOOST_PP_SEQ_SIZE(paramreferences)),\
+  ERROR: There are not the same number of "paramtokens" and "paramreferences" in: __FILE__ \
+)
+#endif
+
+#ifdef statetypes
+BOOST_PP_ASSERT_MSG(BOOST_PP_EQUAL(MAXSTATETYPES, BOOST_PP_SEQ_SIZE(statereferences)),\
+  ERROR: There are not the same number of "statetypes" and "statereferences" in: __FILE__ \
 )
 #endif
 
 // print a list of type ref followed by a separator, i.e. "int i;"
-#define type_print(z,n,separator) \
-  BOOST_PP_SEQ_ELEM(n, types) \
-  BOOST_PP_SEQ_ELEM(n, references)\
+#define initialiser_print(z,n,initialiserlist) \
+  BOOST_PP_SEQ_ELEM(n, initialiserlist) \
+  (BOOST_PP_CAT(_, BOOST_PP_SEQ_ELEM(n, initialiserlist))),
+
+// print a list of ref(_ref) followed by a separator, i.e. "id(_id),"
+#define type_print(z,n,TYPELIST, VARLIST, separator) \
+  BOOST_PP_SEQ_ELEM(n, TYPELIST) \
+  BOOST_PP_SEQ_ELEM(n, VARLIST)\
   separator
 
 // print a list of type ref followed, i.e. "int i, double position"
-#define type_list(z,n,unused) \
+#define type_list(z,n,TYPELIST,VARLIST) \
   BOOST_PP_COMMA_IF(n)\
-  BOOST_PP_SEQ_ELEM(n, types) \
-  BOOST_PP_SEQ_ELEM(n, references)
-
-// prints dialog->query calls for types with tokens
+  BOOST_PP_SEQ_ELEM(n, TYPELIST) \
+  BOOST_PP_SEQ_ELEM(n, VARLIST)
+
+// prints dialog->query calls for paramtypes with tokens
 #define dialog_print(z,n,unused) \
   dialog->query<\
-  BOOST_PP_SEQ_ELEM(n, types)\
+  BOOST_PP_SEQ_ELEM(n, paramtypes)\
   >(\
-  BOOST_PP_SEQ_ELEM(n, tokens)\
+  BOOST_PP_SEQ_ELEM(n, paramtokens)\
   , ValueStorage::getInstance().getDescription(\
-  BOOST_PP_SEQ_ELEM(n, tokens)\
+  BOOST_PP_SEQ_ELEM(n, paramtokens)\
   ));
 
@@ -98,18 +117,9 @@
 #define value_print(z,n,command, prefix) \
   ValueStorage::getInstance(). command (\
-  BOOST_PP_SEQ_ELEM(n, tokens)\
+  BOOST_PP_SEQ_ELEM(n, paramtokens)\
   , \
   prefix\
-  BOOST_PP_SEQ_ELEM(n, references)\
+  BOOST_PP_SEQ_ELEM(n, paramreferences)\
   );
-
-#if BOOST_PP_NOT_EQUAL(MAXNOTOKENS,0)
-#define COMMANDFULL \
-void COMMAND( \
-BOOST_PP_REPEAT(MAXNOTOKENS, type_list, ~) \
-)
-# else
-#define COMMANDFULL void COMMAND()
-#endif
 
 #include "Actions/ActionRegistry.hpp"
@@ -118,64 +128,101 @@
 
 
+// =========== memento to remember the state when undoing ===========
+class STATE : public ActionState {
+public:
+  STATE(
+#if defined statetypes && defined statereferences // if we have parameters, we have to add "_" before each reference and add the params as the last one
+#define OP(s,data,elem) BOOST_PP_CAT(data, elem)  // OP to add "_"
+#define BOOST_PP_LOCAL_MACRO(n) type_list(~, n, BOOST_PP_SEQ_PUSH_BACK(statetypes, const ACTION::PARAMS &), BOOST_PP_SEQ_TRANSFORM(OP, _, BOOST_PP_SEQ_PUSH_BACK(statereferences, params)))
+#else /// if not, params is only list
+#define BOOST_PP_LOCAL_MACRO(n) type_list(~, n, (const ACTION::PARAMS &), (_params))
+#endif
+#define BOOST_PP_LOCAL_LIMITS  (0, MAXSTATETYPES)
+#include BOOST_PP_LOCAL_ITERATE()
+) :
+#if defined statetypes && defined statereferences // do we have parameters at all?
+BOOST_PP_REPEAT(MAXSTATETYPES, initialiser_print, statereferences)
+#endif
+params(_params)
+  {}
+
+#if defined statetypes && defined statereferences // do we have parameters at all?
+#define BOOST_PP_LOCAL_MACRO(n) type_print(~, n, statetypes, statereferences, ;)
+#define BOOST_PP_LOCAL_LIMITS  (0, MAXSTATETYPES-1)
+#include BOOST_PP_LOCAL_ITERATE()
+#endif
+  ACTION::PARAMS params;
+};
+
+// =========== name of action ===========
 const char ACTION::NAME[] = TOKEN;
 
-// the actual functions constructed
-
+// =========== constructor ===========
 ACTION::ACTION () :
   Action(NAME)
 {}
 
+// =========== destructor ===========
 ACTION::~ACTION ()
 {}
 
+// =========== fill a dialog ===========
 Dialog* ACTION::fillDialog(Dialog *dialog) {
         ASSERT(dialog,"No Dialog given when filling actionname's dialog");
-#if BOOST_PP_EQUAL(MAXNOTOKENS,0)
+#if BOOST_PP_EQUAL(MAXPARAMTYPES,0)
         dialog->queryEmpty(NAME, ValueStorage::getInstance().getDescription(NAME));
 #else
 #define BOOST_PP_LOCAL_MACRO(n) dialog_print(~, n, ~)
-#define BOOST_PP_LOCAL_LIMITS  (0, MAXNOTOKENS-1)
-#include BOOST_PP_LOCAL_ITERATE()
-#undef BOOST_PP_LOCAL_MACRO
-#undef BOOST_PP_LOCAL_LIMITS
+#define BOOST_PP_LOCAL_LIMITS  (0, MAXPARAMTYPES-1)
+#include BOOST_PP_LOCAL_ITERATE()
 #endif
         return dialog;
 };
 
-COMMANDFULL
+// =========== command for calling action directly ===========
+#if defined paramtypes && defined paramreferences
+void COMMAND(
+#define BOOST_PP_LOCAL_MACRO(n) type_list(~, n, paramtypes, paramreferences)
+#define BOOST_PP_LOCAL_LIMITS  (0, MAXPARAMTYPES-1)
+#include BOOST_PP_LOCAL_ITERATE()
+)
+#else
+void COMMAND()
+#endif
 {
   ACTION::PARAMS params;
   Action *ToCall = ActionRegistry::getInstance().getActionByName( ACTION::NAME ); //->clone(params);
-#if BOOST_PP_NOT_EQUAL(MAXNOTOKENS,0)
+#if BOOST_PP_NOT_EQUAL(MAXPARAMTYPES,0)
 #define BOOST_PP_LOCAL_MACRO(n) value_print(~, n, setCurrentValue, )
-#define BOOST_PP_LOCAL_LIMITS  (0, MAXNOTOKENS-1)
-#include BOOST_PP_LOCAL_ITERATE()
-#undef BOOST_PP_LOCAL_MACRO
-#undef BOOST_PP_LOCAL_LIMITS
+#define BOOST_PP_LOCAL_LIMITS  (0, MAXPARAMTYPES-1)
+#include BOOST_PP_LOCAL_ITERATE()
 #endif
   ToCall->call(Action::NonInteractive);
 };
 
+// =========== obtain parameters from Storage, used by performCall() ===========
 void ACTION::getParametersfromValueStorage() {
-#if BOOST_PP_NOT_EQUAL(MAXNOTOKENS,0)
+#if BOOST_PP_NOT_EQUAL(MAXPARAMTYPES,0)
 #define BOOST_PP_LOCAL_MACRO(n) value_print(~, n, queryCurrentValue, params.)
-#define BOOST_PP_LOCAL_LIMITS  (0, MAXNOTOKENS-1)
-#include BOOST_PP_LOCAL_ITERATE()
-#undef BOOST_PP_LOCAL_MACRO
-#undef BOOST_PP_LOCAL_LIMITS
-#endif
-};
-
-#undef types
-#undef tokens
-#undef references
-#undef MAXNOTOKENS
+#define BOOST_PP_LOCAL_LIMITS  (0, MAXPARAMTYPES-1)
+#include BOOST_PP_LOCAL_ITERATE()
+#endif
+};
+
+// free up defines
+#undef paramtypes
+#undef paramtokens
+#undef paramreferences
+#undef MAXPARAMTYPES
+#undef statetypes
+#undef statereferences
+#undef MAXSTATETYPES
 
 #undef ACTION
+#undef COMMAND
+#undef PARAMS
+#undef STATE
+
 #undef ACTIONNAME
 #undef CATEGORY
-#undef COMMAND
-#undef COMMANDFULL
-#undef PARAMS
-#undef STATE
 #undef TOKEN
Index: src/Actions/AnalysisAction/MolecularVolumeAction.def
===================================================================
--- src/Actions/AnalysisAction/MolecularVolumeAction.def	(revision 9ee38b1c3b23a38c779c8e4ad098fe0677a3a5b7)
+++ src/Actions/AnalysisAction/MolecularVolumeAction.def	(revision b4fa106066497a55bc2e47cdbd46bf7f293eaf34)
@@ -11,7 +11,7 @@
 // ValueStorage by the token "Z" -> first column: int, Z, "Z"
 // "undefine" if no parameters are required
-//#define types (int)
-//#define references (molID)
-//#define tokens (NAME)
+//#define paramtypes (int)
+//#define paramreferences (molID)
+//#define paramtokens (NAME)
 
 // some defines for all the names, you may use ACTION, STATE and PARAMS
Index: src/Actions/AnalysisAction/PairCorrelationAction.def
===================================================================
--- src/Actions/AnalysisAction/PairCorrelationAction.def	(revision 9ee38b1c3b23a38c779c8e4ad098fe0677a3a5b7)
+++ src/Actions/AnalysisAction/PairCorrelationAction.def	(revision b4fa106066497a55bc2e47cdbd46bf7f293eaf34)
@@ -14,7 +14,7 @@
 // ValueStorage by the token "Z" -> first column: int, Z, "Z"
 // "undefine" if no parameters are required
-#define types (std::vector<const element *>)(double)(double)(double)(std::string)(std::string)(bool)
-#define references (elements)(BinStart)(BinWidth)(BinEnd)(outputname)(binoutputname)(periodic)
-#define tokens ("elements")("bin-start")("bin-width")("bin-end")("output-file")("bin-output-file")("periodic")
+#define paramtypes (std::vector<const element *>)(double)(double)(double)(std::string)(std::string)(bool)
+#define paramreferences (elements)(BinStart)(BinWidth)(BinEnd)(outputname)(binoutputname)(periodic)
+#define paramtokens ("elements")("bin-start")("bin-width")("bin-end")("output-file")("bin-output-file")("periodic")
 
 // some defines for all the names, you may use ACTION, STATE and PARAMS
Index: src/Actions/AnalysisAction/PointCorrelationAction.def
===================================================================
--- src/Actions/AnalysisAction/PointCorrelationAction.def	(revision 9ee38b1c3b23a38c779c8e4ad098fe0677a3a5b7)
+++ src/Actions/AnalysisAction/PointCorrelationAction.def	(revision b4fa106066497a55bc2e47cdbd46bf7f293eaf34)
@@ -16,7 +16,7 @@
 // ValueStorage by the token "Z" -> first column: int, Z, "Z"
 // "undefine" if no parameters are required
-#define types (std::vector<const element *>)(Vector)(double)(double)(double)(std::string)(std::string)(bool)
-#define references (elements)(Point)(BinStart)(BinWidth)(BinEnd)(outputname)(binoutputname)(periodic)
-#define tokens ("elements")("position")("bin-start")("bin-width")("bin-end")("output-file")("bin-output-file")("periodic")
+#define paramtypes (std::vector<const element *>)(Vector)(double)(double)(double)(std::string)(std::string)(bool)
+#define paramreferences (elements)(Point)(BinStart)(BinWidth)(BinEnd)(outputname)(binoutputname)(periodic)
+#define paramtokens ("elements")("position")("bin-start")("bin-width")("bin-end")("output-file")("bin-output-file")("periodic")
 
 // some defines for all the names, you may use ACTION, STATE and PARAMS
Index: src/Actions/AnalysisAction/SurfaceCorrelationAction.def
===================================================================
--- src/Actions/AnalysisAction/SurfaceCorrelationAction.def	(revision 9ee38b1c3b23a38c779c8e4ad098fe0677a3a5b7)
+++ src/Actions/AnalysisAction/SurfaceCorrelationAction.def	(revision b4fa106066497a55bc2e47cdbd46bf7f293eaf34)
@@ -15,7 +15,7 @@
 // ValueStorage by the token "Z" -> first column: int, Z, "Z"
 // "undefine" if no parameters are required
-#define types (std::vector<const element *>)(molecule *)(double)(double)(double)(std::string)(std::string)(bool)
-#define references (elements)(Boundary)(BinStart)(BinWidth)(BinEnd)(outputname)(binoutputname)(periodic)
-#define tokens ("elements")("molecule-by-id")("bin-start")("bin-width")("bin-end")("output-file")("bin-output-file")("periodic")
+#define paramtypes (std::vector<const element *>)(molecule *)(double)(double)(double)(std::string)(std::string)(bool)
+#define paramreferences (elements)(Boundary)(BinStart)(BinWidth)(BinEnd)(outputname)(binoutputname)(periodic)
+#define paramtokens ("elements")("molecule-by-id")("bin-start")("bin-width")("bin-end")("output-file")("bin-output-file")("periodic")
 
 // some defines for all the names, you may use ACTION, STATE and PARAMS
