Index: src/UIElements/Menu/MenuDescription.cpp
===================================================================
--- src/UIElements/Menu/MenuDescription.cpp	(revision e262c76e616587e3eb48650a71afa8c79d2eeb09)
+++ src/UIElements/Menu/MenuDescription.cpp	(revision ffb9ad3ad26c892a8aa0013c675637237728b887)
@@ -13,4 +13,5 @@
  */
 
+#include <iostream>
 #include <map>
 #include <string>
@@ -24,14 +25,16 @@
 MenuDescription::MenuDescription()
 {
-  // put each menu into set
-  MenuSet.insert("analysis");
-  MenuSet.insert("atom");
-  MenuSet.insert("command");
-  MenuSet.insert("fragmentation");
-  MenuSet.insert("molecule");
-  MenuSet.insert("parser");
-  MenuSet.insert("selection");
-  MenuSet.insert("tesselation");
-  MenuSet.insert("world");
+  // put each menu into its place, "" means top level
+  MenuPositionMap["analysis"] = TopPosition("tools",1);
+  MenuPositionMap["atom"] = TopPosition("edit",1);
+  MenuPositionMap["command"] = TopPosition("",3);
+  MenuPositionMap["edit"] = TopPosition("",2);
+  MenuPositionMap["fragmentation"] = TopPosition("tools",3);
+  MenuPositionMap["molecule"] = TopPosition("edit",2);
+  MenuPositionMap["parser"] = TopPosition("edit",3);
+  MenuPositionMap["selection"] = TopPosition("edit",4);
+  MenuPositionMap["tesselation"] = TopPosition("tools",2);
+  MenuPositionMap["tools"] = TopPosition("",4);
+  MenuPositionMap["world"] = TopPosition("",1);
 
   // put menu description into each menu category
@@ -39,4 +42,5 @@
   MenuDescriptionsMap["atom"] = "Edit atoms";
   MenuDescriptionsMap["command"] = "Configuration";
+  MenuDescriptionsMap["edit"] = "Edit";
   MenuDescriptionsMap["fragmentation"] = "Fragmentation";
   MenuDescriptionsMap["molecule"] = "Parse files into system";
@@ -44,4 +48,5 @@
   MenuDescriptionsMap["selection"] = "Select atoms/molecules";
   MenuDescriptionsMap["tesselation"] = "Tesselate molecules";
+  MenuDescriptionsMap["tools"] = "Various tools";
   MenuDescriptionsMap["world"] = "Edit world";
 
@@ -49,5 +54,6 @@
   MenuNameMap["analysis"] = "Analysis";
   MenuNameMap["atom"] = "Atoms";
-  MenuNameMap["command"] = "configuration options";
+  MenuNameMap["command"] = "Configuration";
+  MenuNameMap["edit"] = "Edit";
   MenuNameMap["fragmentation"] = "Fragmentation";
   MenuNameMap["molecule"] = "Molecules";
@@ -55,4 +61,5 @@
   MenuNameMap["selection"] = "Selection";
   MenuNameMap["tesselation"] = "Tesselation";
+  MenuNameMap["tools"] = "Tools";
   MenuNameMap["world"] = "Globals";
 }
@@ -97,4 +104,5 @@
   ActionRegistry &AR = ActionRegistry::getInstance();
   for (ActionRegistry::const_iterator iter = AR.getBeginIter();iter != AR.getEndIter();++iter) {
+    std::cout << "Inserting " << (iter->second)->getName() << " into menu " << (iter->second)->Traits.getMenuName() << std::endl;
     result.insert( std::pair<std::string, std::string> ((iter->second)->Traits.getMenuName(), (iter->second)->getName()));
   }
@@ -108,5 +116,5 @@
 MenuDescription::iterator MenuDescription::getBeginIter()
 {
-  return MenuSet.begin();
+  return MenuPositionMap.begin();
 }
 
@@ -116,5 +124,5 @@
 MenuDescription::iterator MenuDescription::getEndIter()
 {
-  return MenuSet.end();
+  return MenuPositionMap.end();
 }
 
@@ -124,5 +132,5 @@
 MenuDescription::const_iterator MenuDescription::getBeginIter() const
 {
-  return MenuSet.begin();
+  return MenuPositionMap.begin();
 }
 
@@ -132,5 +140,5 @@
 MenuDescription::const_iterator MenuDescription::getEndIter() const
 {
-  return MenuSet.end();
+  return MenuPositionMap.end();
 }
 
Index: src/UIElements/Menu/MenuDescription.hpp
===================================================================
--- src/UIElements/Menu/MenuDescription.hpp	(revision e262c76e616587e3eb48650a71afa8c79d2eeb09)
+++ src/UIElements/Menu/MenuDescription.hpp	(revision ffb9ad3ad26c892a8aa0013c675637237728b887)
@@ -25,6 +25,9 @@
   ~MenuDescription();
 
-  typedef std::set<std::string>::iterator iterator;
-  typedef std::set<std::string>::const_iterator const_iterator ;
+  typedef std::pair<std::string, int> TopPosition;
+  typedef std::map<std::string, TopPosition> IterableMap;
+  typedef IterableMap::iterator iterator;
+  typedef IterableMap::const_iterator const_iterator ;
+  typedef std::map<std::string, std::string> TextMap;
 
   // getter for description
@@ -41,7 +44,7 @@
 
 private:
-  std::set<std::string> MenuSet;
-  std::map<std::string, std::string> MenuDescriptionsMap;
-  std::map<std::string, std::string> MenuNameMap;
+  TextMap MenuDescriptionsMap;
+  IterableMap MenuPositionMap;
+  TextMap MenuNameMap;
   std::multimap <std::string, std::string> MenuItemMap;
 };
Index: src/UIElements/Qt4/QtMainWindow.cpp
===================================================================
--- src/UIElements/Qt4/QtMainWindow.cpp	(revision e262c76e616587e3eb48650a71afa8c79d2eeb09)
+++ src/UIElements/Qt4/QtMainWindow.cpp	(revision ffb9ad3ad26c892a8aa0013c675637237728b887)
@@ -43,4 +43,5 @@
 #include "Menu/Qt4/QtMenu.hpp"
 #include "Menu/ActionMenuItem.hpp"
+#include "Menu/SubMenuItem.hpp"
 #include "Views/Qt4/QtWorldView.hpp"
 #include "Views/Qt4/GLMoleculeView.hpp"
@@ -48,6 +49,4 @@
 #include "Views/Qt4/QtStatusBar.hpp"
 
-using namespace std;
-
 QtMainWindow::QtMainWindow(QApplication *_theApp) :
     theApp(_theApp)
@@ -63,20 +62,10 @@
   MenuBar = menuBar();
 
-  std::map <std::string, QtMenu *> NametoTextMenuMap;
-  // go through all menus and create them
-  QtMenu *Menu = NULL;
-  MenuDescription menudescriptions;
-  for(MenuDescription::const_iterator iter = menudescriptions.getBeginIter(); iter != menudescriptions.getEndIter(); ++iter) {
-    cout << "Creating menu " << *iter << endl;
-    Menu = new QtMenu(menudescriptions.getName(*iter).c_str());
-    MenuBar->addMenu(Menu);
-    NametoTextMenuMap.insert( pair <std::string, QtMenu *> (menudescriptions.getName(*iter), Menu) );
-    //new SubMenuItem(getSuitableShortForm(menudescriptions.getName(iter->first.c_str())),menudescriptions.getName(iter->first.c_str()),main_menu,Menu);
-  }
-
-  // go through all actions and add them to its menu
-  for (std::map <std::string, QtMenu *>::iterator MenuRunner = NametoTextMenuMap.begin(); MenuRunner != NametoTextMenuMap.end(); ++MenuRunner) {
-    cout << "Creating Action " << MenuRunner->first << " in menu " << MenuRunner->second << endl;
-    populateMenu(MenuRunner->second, MenuRunner->first);
+  // populate menus and add actions
+  {
+    QtMenuReferenceMap NametoTextMenuMap; // contains token to menu reference map
+    MenuShortcutMap ShortcutMap;
+    populateMenu(NametoTextMenuMap, ShortcutMap);
+    populateMenuWithActions(NametoTextMenuMap, ShortcutMap);
   }
 
@@ -97,5 +86,4 @@
 {
   menuBar()->clear();
-  delete editMoleculesMenu;
 }
 
@@ -105,30 +93,114 @@
 }
 
-char QtMainWindow::getSuitableShortForm(set <char> &ShortcutList, const std::string name) const
-{
-  for (std::string::const_iterator CharRunner = name.begin(); CharRunner != name.end(); ++CharRunner) {
-    if (ShortcutList.find(*CharRunner) == ShortcutList.end())
-      return *CharRunner;
-  }
-  DoeLog(1) && (eLog() << Verbose(1) << "Could not find a suitable shortform for TextWindow::getSuitableShortForm()." << endl);
-  return ((char)(ShortcutList.size() % 10) + '0');
-}
-
-void QtMainWindow::populateMenu(QtMenu* Menu, const  std::string &MenuName)
-{
+/** Puts Qt's token, the ampersand, in front of the accelerator char in the menu name.
+ * \param ShortcutMap map to all already present accelerator keys
+ * \param MenuName Action of menu
+ * \param ActionName Action of menu
+ * \return name with ampersand added at the right place
+ */
+std::string QtMainWindow::getNameWithAccelerator(MenuShortcutMap &ShortcutMap, const std::string &MenuName, const std::string &ActionName) const
+{
+  std::string newname;
+  bool Inserted = false;
+  std::pair < MenuShortcutMap::iterator, bool > Inserter;
+  for (std::string::const_iterator CharRunner = ActionName.begin(); CharRunner != ActionName.end(); ++CharRunner) {
+    if (!Inserted) {
+      Inserter = ShortcutMap.insert( std::pair<std::string, char> (MenuName, *CharRunner) );
+      if (Inserter.second) {
+        newname += '&';
+        Inserted = true;
+      }
+    }
+    newname += *CharRunner;
+  }
+  return newname;
+}
+
+/** Instantiate all menus.
+ * \param NametoTextMenuMap lookup for token to menu reference
+ */
+void QtMainWindow::populateMenu(QtMenuReferenceMap &NametoTextMenuMap, MenuShortcutMap &ShortcutMap)
+{
+  // go through all menus and create them
+  std::map <std::string, int> TopPositions;
+  TopPositions.insert( std::pair<std::string, int> ("", 0) ); // contains which position was added last
+  QtMenu *Menu = NULL;
+  MenuDescription menudescriptions;
+  std::set <char> ShortcutList;
+  bool CompleteFlag = false;
+  while (!CompleteFlag) {
+    CompleteFlag = true;
+    for(MenuDescription::const_iterator iter = menudescriptions.getBeginIter(); iter != menudescriptions.getEndIter(); ++iter) {
+      // skip when already present
+      if (NametoTextMenuMap.find(iter->first) == NametoTextMenuMap.end()) {
+        // have some short refs to infos
+        const std::string &MenuName = iter->first;
+        const std::string &TopName = iter->second.first;
+        const int &MenuPosition = iter->second.second;
+        std::cout << "MenuName is " << MenuName << ", TopName is " << TopName << " and Position is " << MenuPosition << std::endl;
+
+        // is it top level?
+        if (TopName == "") {
+          ASSERT(TopPositions.find(TopName) != TopPositions.end(),
+              "QtMainWindow::QtMainWindow() - "+TopName+" not present in TopPositions.");
+          if (MenuPosition-1 == TopPositions[TopName]) {
+            std::cout << "Creating top-level menu " << MenuName << " at position " << MenuPosition << std::endl;
+            Menu = new QtMenu(getNameWithAccelerator(ShortcutMap, TopName, MenuName).c_str());
+            MenuBar->addMenu(Menu);
+            NametoTextMenuMap.insert( pair <std::string, QtMenu *> (MenuName, Menu) );
+            CompleteFlag = false;
+            TopPositions[TopName] = MenuPosition;
+            TopPositions[MenuName] = 0;
+          }
+        }
+        // is it a submenu and the top-level menu is present?
+        else if (NametoTextMenuMap.find(TopName) != NametoTextMenuMap.end()) {
+          ASSERT(TopPositions.find(TopName) != TopPositions.end(),
+              "QtMainWindow::QtMainWindow() - "+TopName+" not present in TopPositions.");
+          if (MenuPosition-1 == TopPositions[TopName]) {
+            QtMenu *& TopMenu = NametoTextMenuMap[TopName];
+            std::cout << "Creating submenu " << MenuName << " to menu " << TopName << " at position " << MenuPosition << std::endl;
+            Menu = new QtMenu(getNameWithAccelerator(ShortcutMap, TopName, MenuName).c_str());
+            TopMenu->addMenu(Menu);
+            NametoTextMenuMap.insert( pair <std::string, QtMenu *> (MenuName, Menu) );
+            CompleteFlag = false;
+            TopPositions[TopName] = MenuPosition;
+          }
+        }
+      }
+    }
+  }
+}
+
+/** Instantiate all actions within the menus.
+ * \param NametoTextMenuMap lookup for token to menu reference
+ * \param ShortcutMap map for all shortcuts within one menu
+ */
+void QtMainWindow::populateMenuWithActions(QtMenuReferenceMap &NametoTextMenuMap, MenuShortcutMap &ShortcutMap)
+{
+  typedef std::multimap <std::string, std::string> MenuMap;
+
+  // go through all menus
+  MenuDescription md;
+  MenuMap MenuItems = md.getMenuItemsMap();
+  QtMenu *Menu = NULL;
   Action *ActionItem = NULL;
-  set <char> ShortcutList;
-  // through all actions for this menu
-  MenuDescription md;
-  std::multimap <std::string, std::string> MenuItems = md.getMenuItemsMap();
-  std::pair < std::multimap <std::string, std::string>::iterator, std::multimap <std::string, std::string>::iterator > MenuActions = MenuItems.equal_range(MenuName);
-  for (std::multimap <std::string, std::string>::const_iterator MenuRunner = MenuActions.first; MenuRunner != MenuActions.second; ++MenuRunner) {
-    cout << " Adding " << MenuRunner->second << " to submenu " << MenuName << endl;
-    ActionItem = ActionRegistry::getInstance().getActionByName(MenuRunner->second);
-    new ActionMenuItem(getSuitableShortForm(ShortcutList, MenuRunner->second),ActionItem->Traits.getDescription().c_str(),Menu,ActionItem);
-  }
-  // finally add default quit item
-  //Action *returnFromAction = new TextMenu::LeaveAction(Menu);
-  //MenuItem *returnFromItem = new ActionMenuItem('q',"return to Main menu",Menu,returnFromAction);
-  //Menu->addDefault(returnFromItem);
-}
+  std::string OldMenuName;
+  for (MenuMap::const_iterator MenuRunner = MenuItems.begin(); MenuRunner != MenuItems.end(); ++MenuRunner) {
+    const std::string &ActionName = MenuRunner->second;
+    const std::string &MenuName = MenuRunner->first;
+    // add the actions to this menu
+    std::cout << " Adding " << ActionName << " to submenu " << MenuName << std::endl;
+    ActionItem = ActionRegistry::getInstance().getActionByName(ActionName);
+    ASSERT(NametoTextMenuMap.find(MenuName) != NametoTextMenuMap.end(),
+        "QtMainWindow::populateMenu() - cannot find reference for menu "+MenuName+" in NametoTextMenuMap.");
+    Menu = NametoTextMenuMap[MenuName];
+    //ASSERT(ShortcutMap.find(MenuName) != ShortcutMap.end(),
+      //  "QtMainWindow::populateMenuWithActions() - missing "+MenuName+" in ShortcutMap.");
+    new ActionMenuItem(
+        'a',
+        ActionItem->Traits.getDescription().c_str(),
+        Menu,
+        ActionItem);
+  }
+}
Index: src/UIElements/Qt4/QtMainWindow.hpp
===================================================================
--- src/UIElements/Qt4/QtMainWindow.hpp	(revision e262c76e616587e3eb48650a71afa8c79d2eeb09)
+++ src/UIElements/Qt4/QtMainWindow.hpp	(revision ffb9ad3ad26c892a8aa0013c675637237728b887)
@@ -12,4 +12,5 @@
 #include <QtGui/QMainWindow>
 
+#include <map>
 #include <set>
 
@@ -31,12 +32,16 @@
   virtual void display();
 
-  char getSuitableShortForm(std::set <char> &ShortcutList, const std::string name) const;
-  void populateMenu(QtMenu* Menu, const  std::string &MenuName);
 
 private:
+  typedef std::map <std::string, QtMenu *> QtMenuReferenceMap;
+  typedef std::map <std::string, char> MenuShortcutMap;
+
+  void populateMenu(QtMenuReferenceMap &NametoTextMenuMap, MenuShortcutMap &ShortcutMap);
+  void populateMenuWithActions(QtMenuReferenceMap &NametoTextMenuMap, MenuShortcutMap &ShortcutMap);
+  std::string getNameWithAccelerator(MenuShortcutMap &ShortcutMap, const std::string &MenuName, const std::string &ActionName) const;
+
   // All kinds of QTStuff used in this window
   QApplication *theApp;
   QtWorldView *worldDisplay;
-  QtMenu *editMoleculesMenu;
   GLMoleculeView *molecule3dDisplay;
   QtMoleculeView *moleculeDisplay;
Index: src/UIElements/TextUI/TextWindow.cpp
===================================================================
--- src/UIElements/TextUI/TextWindow.cpp	(revision e262c76e616587e3eb48650a71afa8c79d2eeb09)
+++ src/UIElements/TextUI/TextWindow.cpp	(revision ffb9ad3ad26c892a8aa0013c675637237728b887)
@@ -81,7 +81,8 @@
   MenuDescription menudescriptions;
   for(MenuDescription::const_iterator iter = menudescriptions.getBeginIter(); iter != menudescriptions.getEndIter(); ++iter) {
-    TextMenu *Menu = new TextMenu((ostream &)std::cout, menudescriptions.getDescription(*iter));
-    NametoTextMenuMap.insert( pair <std::string, TextMenu *> (*iter, Menu) );
-    new SubMenuItem(getSuitableShortForm(ShortcutList,*iter),menudescriptions.getDescription(*iter).c_str(),main_menu,Menu);
+    const std::string &MenuName = iter->first;
+    TextMenu *Menu = new TextMenu((ostream &)std::cout, menudescriptions.getDescription(MenuName));
+    NametoTextMenuMap.insert( pair <std::string, TextMenu *> (MenuName, Menu) );
+    new SubMenuItem(getSuitableShortForm(ShortcutList,MenuName),menudescriptions.getDescription(MenuName).c_str(),main_menu,Menu);
   }
 
Index: src/unittests/MenuDescriptionUnitTest.cpp
===================================================================
--- src/unittests/MenuDescriptionUnitTest.cpp	(revision e262c76e616587e3eb48650a71afa8c79d2eeb09)
+++ src/unittests/MenuDescriptionUnitTest.cpp	(revision ffb9ad3ad26c892a8aa0013c675637237728b887)
@@ -51,12 +51,13 @@
 {
   // from MenuSet
-  for(MenuDescription::const_iterator iter = md.MenuSet.begin(); iter != md.MenuSet.end(); ++iter) {
-    CPPUNIT_ASSERT_MESSAGE( "menu token not contained in MenuDescription::MenuDewscriptionsMap", md.MenuDescriptionsMap.find(*iter) != md.MenuDescriptionsMap.end());
-    CPPUNIT_ASSERT_MESSAGE( "menu token not contained in MenuDescription::MenuNameMap", md.MenuNameMap.find(*iter) != md.MenuNameMap.end());
+  for(MenuDescription::const_iterator iter = md.MenuPositionMap.begin(); iter != md.MenuPositionMap.end(); ++iter) {
+    const std::string &MenuName = iter->first;
+    CPPUNIT_ASSERT_MESSAGE( "menu token not contained in MenuDescription::MenuDewscriptionsMap", md.MenuDescriptionsMap.find(MenuName) != md.MenuDescriptionsMap.end());
+    CPPUNIT_ASSERT_MESSAGE( "menu token not contained in MenuDescription::MenuNameMap", md.MenuNameMap.find(MenuName) != md.MenuNameMap.end());
   }
 
   // from MenuDescriptionsMap
   for(std::map<std::string, std::string>::const_iterator iter = md.MenuDescriptionsMap.begin(); iter != md.MenuDescriptionsMap.end(); ++iter) {
-    CPPUNIT_ASSERT_MESSAGE( "menu token not contained in MenuDescription::MenuSet", md.MenuSet.find(iter->first) != md.MenuSet.end());
+    CPPUNIT_ASSERT_MESSAGE( "menu token not contained in MenuDescription::MenuSet", md.MenuPositionMap.find(iter->first) != md.MenuPositionMap.end());
     CPPUNIT_ASSERT_MESSAGE( "menu token not contained in MenuDescription::MenuNameMap", md.MenuNameMap.find(iter->first) != md.MenuNameMap.end());
   }
@@ -65,5 +66,5 @@
   for(std::map<std::string, std::string>::const_iterator iter = md.MenuNameMap.begin(); iter != md.MenuNameMap.end(); ++iter) {
     CPPUNIT_ASSERT_MESSAGE( "menu token not contained in MenuDescription::MenuDescriptionsMap", md.MenuDescriptionsMap.find(iter->first) != md.MenuDescriptionsMap.end());
-    CPPUNIT_ASSERT_MESSAGE( "menu token not contained in MenuDescription::MenuSet", md.MenuSet.find(iter->first) != md.MenuSet.end());
+    CPPUNIT_ASSERT_MESSAGE( "menu token not contained in MenuDescription::MenuSet", md.MenuPositionMap.find(iter->first) != md.MenuPositionMap.end());
   }
 
