Index: .gitignore
===================================================================
--- .gitignore	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
+++ .gitignore	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -0,0 +1,24 @@
+# specific source code stuff
+version.c
+.git-version
+
+# eclipse file
+.project
+.cproject
+.settings
+
+# automake stuff
+configure
+config.h*
+*.in
+build*
+aclocal.m4
+autom4te.cache
+
+# testsuite stuff
+testsuite
+*.m4
+
+# miscellaneous stuff
+*.log
+
Index: Makefile.am
===================================================================
--- Makefile.am	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ Makefile.am	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -1,4 +1,6 @@
 ACLOCAL_AMFLAGS = -I m4
 SUBDIRS = src src/unittests doc tests 
+
+AUTOMAKE_OPTIONS = subdir-objects
 
 EXTRA_DIST = autogen.sh
@@ -7,2 +9,5 @@
 doc:
 	cd doc && make doxygen-docs
+	
+unity:
+	cd src && make unity
Index: TestRunnerClient.cpp
===================================================================
--- TestRunnerClient.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
+++ TestRunnerClient.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -0,0 +1,542 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Gerhard Leonhartsberger.
+ * 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
+ *******************************************************************************/
+
+#include "TestRunnerClient.h"
+
+#ifdef CPPUNIT_MAIN
+
+#include "cppunit/TestResultCollector.h"
+#include "cppunit/XmlOutputter.h"
+#include "cppunit/TestSuite.h"
+#include "cppunit/TestResult.h"
+#include "cppunit/TestFailure.h"
+#include "cppunit/SourceLine.h"
+#include "cppunit/Exception.h"
+#include "cppunit/extensions/TestFactoryRegistry.h"
+#include "cppunit/extensions/TestDecorator.h"
+#include "cppunit/ui/text/TestRunner.h"
+
+#include <iostream>
+#include <sstream>
+#include <typeinfo>
+#include <vector>
+#include <cstring>
+
+#include <errno.h>
+#include <unistd.h>
+#include <sys/time.h>
+#include <stdlib.h>
+
+
+#ifdef _WIN32 // Bugzilla 40710
+#include <windows.h>
+#include <winbase.h>
+#include <winsock.h>
+#else
+#include <netinet/in.h>
+#include <sys/socket.h>
+#include <arpa/inet.h>
+#include <netdb.h>
+#endif
+
+enum { MAX_HOSTNAME_SIZE=255 };
+
+/*
+ * CppUnitServer protocol constants
+ */
+static const std::string TRACE_START = "%TRACES ";
+static const std::string TRACE_END = "%TRACEE ";
+static const std::string TEST_RUN_START = "%TESTC  ";
+static const std::string TEST_START = "%TESTS  ";
+static const std::string TEST_END = "%TESTE  ";
+static const std::string TEST_ERROR = "%ERROR  ";
+static const std::string TEST_FAILED = "%FAILED ";
+static const std::string TEST_RUN_END = "%RUNTIME";
+static const std::string TEST_STOPPED = "%TSTSTP ";
+static const std::string TEST_TREE = "%TSTTREE";
+
+TestRunnerClient::TestRunnerClient()
+{
+	fTestResult = 0;
+	fClientSocket = -1;
+	fPort = 0;
+	fKeepAlive = 0;
+	fDebugMode = 0;
+
+	fHost = (char *) malloc(MAX_HOSTNAME_SIZE);
+	strcpy(fHost, "");
+}
+
+TestRunnerClient::~TestRunnerClient() {
+
+	if (fHost != NULL) {
+		free(fHost);
+	}
+}
+
+int TestRunnerClient::Run()
+{
+	if (fDebugMode)
+	{
+		std::cerr << "TestRunnerClient: Starting client." << std::endl;
+	}
+
+	if (Connect() == -1) {
+		return -1;
+	}
+
+	InstallListeners();
+
+	RunTests();
+
+	UninstallListeners();
+
+	if(fTestResult != NULL)
+	{
+		fTestResult->stop();
+		fTestResult= NULL;
+	}
+
+	ShutDown();
+
+	return 0;
+}
+
+void TestRunnerClient::Init(int n, char *args[])
+{
+	ParseCommandLine(n, args);
+	DefineHostName();
+}
+
+void TestRunnerClient::ParseCommandLine(int n, char *args[])
+{
+	// parse all arguments passed by args
+	for(int i = 0; i < n; i++)
+	{
+		std::string arg(args[i]);
+
+		// port option
+		std::string portOption("-port=");
+		int pos = arg.find(portOption);
+		if(pos> -1)
+		{
+			std::string v = arg.substr(pos + portOption.length(), arg.length());
+			fPort = atoi(v.c_str());
+		}
+
+		// debug option
+		std::string debugOption("-debug");
+		pos = arg.find(debugOption);
+		if(pos> - 1)
+		{
+			fDebugMode = 1;
+		}
+	}
+}
+
+void TestRunnerClient::DefineHostName()
+{
+	// set fHost to hostname or localhost
+	int ret = gethostname(fHost, MAX_HOSTNAME_SIZE);
+	if (ret == -1)
+	{
+		strcpy(fHost, "localhost");
+	}
+}
+
+int TestRunnerClient::Connect()
+{
+
+#ifdef _WIN32 // Bugzilla 40710
+	if (fDebugMode)
+	{
+		std::cerr << "TestRunnerClient: Starting Windows Sockets WSAStartup()." << std:endl;
+	}
+
+	// start up Windows Sockets
+	WSADATA WSAData;
+	int result = WSAStartup (MAKEWORD(1, 1), &WSAData);
+	if (result != NO_ERROR)
+	{
+		std::cerr << "TestRunnerClient: WSAStartup() failed! Error code: " << result << std::endl;
+		return -1;
+	}
+#endif
+
+	if (fDebugMode)
+	{
+		std::cerr << "TestRunnerClient: Trying to connect to " << fHost << ":" << fPort << std::endl;
+	}
+
+	fClientSocket = socket(AF_INET, SOCK_STREAM, 0);
+	if (fClientSocket == -1)
+	{
+		std::cerr << "TestRunnerClient: Socket creation failed! error code: " << fClientSocket << std::endl;
+		return -1;
+	}
+
+	struct hostent *host = gethostbyname(fHost);
+	if (host == NULL)
+	{
+		std::cerr << "TestRunnerClient: Cannot find host address for " << fHost << "." << std::endl;
+		fClientSocket = -1;
+		return -1;
+	}
+
+	struct sockaddr_in name;
+	memset((void *)&name, 0, sizeof(struct sockaddr_in));
+	name.sin_family = AF_INET;
+	name.sin_port = htons(fPort);
+
+	memcpy(&name.sin_addr, host->h_addr, host->h_length);
+
+	if (fDebugMode) {
+		std::cerr << "TestRunnerClient: Waiting for the JVM to listen ... (trying 3 times)" << std::endl;
+	}
+
+	int ret = -1;
+	int j = 0;
+	while ((j < 3) && (ret == -1))
+	{
+		ret = ::connect(fClientSocket, (struct sockaddr *) &name, sizeof(struct sockaddr_in));
+		if (ret == -1)
+		{
+			if (fDebugMode) {
+				std::cerr << "TestRunnerClient: Connection request, waiting 1 second. "
+				<< ((j-3)*-1) << " times left." << std::endl;
+			}
+			PrivateSleep(1000);
+			j++;
+		}
+	}
+	if (ret == -1)
+	{
+		std::cerr << "TestRunnerClient: No connection established. Error code: " << errno << std::endl;
+		fClientSocket = -1;
+		return -1;
+	}
+
+	if (fDebugMode) {
+		std::cerr << "TestRunnerClient: Connection established." << std::endl;
+	}
+	return 0;
+}
+
+void TestRunnerClient::InstallListeners()
+{
+	fTestResult = new CppUnit::TestResult();
+	fTestResult->addListener(this);
+}
+
+void TestRunnerClient::UninstallListeners()
+{
+	fTestResult->removeListener(this);
+}
+
+void TestRunnerClient::RunTests()
+{
+
+	CppUnit::TestFactoryRegistry &registry = CppUnit::TestFactoryRegistry::getRegistry();
+	CppUnit::Test *suite = registry.makeTest();
+	int count = suite->countTestCases();
+	NotifyTestRunStarted(count);
+
+	if (count == 0)
+	{
+		NotifyTestRunEnded(0);
+	}
+
+	long startTime = CurrentTimeMillis();
+	if (fDebugMode)
+	{
+		std::cerr <<"TestRunnerClient: Start sending test case tree ..." << std::endl;
+	}
+
+	SendTestTree(suite);
+
+	int elapsedTime = CurrentTimeMillis() - startTime;
+	if (fDebugMode) {
+		std::cerr << "TestRunnerClient: Done sending test case tree. Elapsed time is "
+		<< elapsedTime << "ms." << std::endl;
+	}
+
+	long testStartTime = CurrentTimeMillis();
+	if (fDebugMode) {
+		std::cerr << "TestRunnerClient: Test start time is " << testStartTime
+		<< "ms." << std::endl;
+	}
+
+	suite->run(fTestResult);
+
+	if (fTestResult == NULL || fTestResult->shouldStop())
+	{
+		NotifyTestRunStopped(CurrentTimeMillis() - testStartTime);
+	}
+	else
+	{
+		NotifyTestRunEnded(CurrentTimeMillis() - testStartTime);
+	}
+}
+
+void TestRunnerClient::ShutDown()
+{
+	if (fClientSocket != -1)
+	{
+		if (fDebugMode) {
+			std::cerr << "TestRunnerClient: Closing connection to CppUnit sever at "
+			<< fHost << ":" << fPort << std::endl;
+		}
+
+#ifdef _WIN32 // Bugzilla 40710
+		// TODO: std:err output for error return codes
+		closesocket(fClientSocket);
+		WSACleanup();
+#else
+		int result = close(fClientSocket);
+		if (result != 0)
+		{
+			std::cerr << "TestRunnerClient: Close connection error: " << errno << std::endl;
+		}
+#endif
+
+		fClientSocket = -1;
+	}
+}
+
+void TestRunnerClient::Stop()
+{
+	if (fTestResult != NULL)
+	{
+		fTestResult->stop();
+	}
+}
+
+void TestRunnerClient::SendTestTree(CppUnit::Test *test)
+{
+	if (typeid(*test) == typeid(CppUnit::TestDecorator))
+	{
+		class TmpClass : public CppUnit::TestDecorator {
+
+		public:
+			TmpClass(Test *t):CppUnit::TestDecorator(t)
+			{
+				// nothing to do
+			}
+
+			~TmpClass() // Bugzilla 39894
+			{
+				// nothing to do
+			}
+
+			CppUnit::Test *getTest()
+			{
+				return m_test;
+			}
+		};
+
+		TmpClass *t = (TmpClass *)test;
+		SendTestTree(t->getTest());
+	}
+	else if (typeid(*test) == typeid(CppUnit::TestSuite))
+	{
+		CppUnit::TestSuite *suite = (CppUnit::TestSuite *)test;
+		const std::vector<CppUnit::Test *> &x = suite->getTests();
+
+		std::ostringstream os;
+		os << suite->getName() << ",true," << x.size();
+		NotifyTestTreeEntry(os.str());
+
+		for(unsigned int i=0; i < x.size(); i++)
+		{
+			SendTestTree(x[i]);
+		}
+	}
+	else
+	{
+		std::ostringstream os;
+		os << test->getName() << ",false," << test->countTestCases();
+		NotifyTestTreeEntry(os.str());
+	}
+}
+
+void TestRunnerClient::SendMessage(std::string msg)
+{
+	if (fClientSocket == -1)
+	{
+		return;
+	}
+
+#ifdef _WIN32 // Bugzilla 40710
+	send (fClientSocket, msg.c_str(), msg.length(), 0);
+	send (fClientSocket, "\n", 1, 0);
+#else
+	write(fClientSocket, msg.c_str(), msg.length());
+	write(fClientSocket, "\n", 1);
+#endif
+
+	if (fDebugMode)
+	{
+		std::cerr << "TestRunnerClient: Sent message \"" << msg << "\""
+		<< std::endl;
+	}
+}
+
+void TestRunnerClient::NotifyTestRunStarted(int testCount)
+{
+	std::ostringstream os;
+	os << TEST_RUN_START << testCount;
+	SendMessage(os.str());
+}
+
+void TestRunnerClient::NotifyTestRunEnded(long elapsedTime)
+{
+	std::ostringstream os;
+	os << TEST_RUN_END << elapsedTime;
+	SendMessage(os.str());
+}
+
+void TestRunnerClient::NotifyTestRunStopped(long elapsedTime)
+{
+	std::ostringstream os;
+	os << TEST_STOPPED << elapsedTime;
+	SendMessage(os.str());
+}
+
+void TestRunnerClient::NotifyTestTreeEntry(std::string treeEntry)
+{
+	SendMessage(TEST_TREE + treeEntry);
+}
+
+void TestRunnerClient::NotifyTestStarted(std::string testName)
+{
+	SendMessage(TEST_START + testName);
+}
+
+void TestRunnerClient::NotifyTestEnded(std::string testName)
+{
+	SendMessage(TEST_END + testName);
+}
+
+void TestRunnerClient::NotifyTestFailed(std::string status, std::string testName, std::string trace)
+{
+	SendMessage(status + testName);
+	SendMessage(TRACE_START);
+	SendMessage(trace);
+	SendMessage(TRACE_END);
+}
+
+// From TestListener
+void TestRunnerClient::startTest(CppUnit::Test *test)
+{
+	NotifyTestStarted(test->getName());
+}
+
+// From TestListener
+void TestRunnerClient::addFailure(const CppUnit::TestFailure &failure)
+{
+	if(failure.isError())
+	{
+		NotifyTestFailed(TEST_ERROR,failure.failedTestName(),GetTrace(failure));
+	}
+	else
+	{
+		NotifyTestFailed(TEST_FAILED,failure.failedTestName(),GetTrace(failure));
+	}
+}
+
+// From TestListener
+void TestRunnerClient::endTest(CppUnit::Test *test)
+{
+	NotifyTestEnded(test->getName());
+}
+
+std::string TestRunnerClient::GetTrace(const CppUnit::TestFailure &failure)
+{
+	std::ostringstream os;
+
+	CppUnit::Exception *e=failure.thrownException();
+	if(e->sourceLine().lineNumber()!=-1)
+	{
+		os << "File " << e->sourceLine().fileName() << ":" << e->sourceLine().lineNumber() << "\n";
+	}
+	else
+	{
+		os << "File Unknown:1\n";
+	}
+	/* TODO: expected, actual value implementation
+	 if(typeid(*e)==typeid(CppUnit::NotEqualException))
+	 {
+	 CppUnit::NotEqualException *ne=(CppUnit::NotEqualException *)e;
+
+	 os << "Expected Value: " << ne->expectedValue() << "\n";
+	 os << "Actual Value: " << ne->expectedValue() << "\n";
+	 os << "Additional Message: " << ne->additionalMessage() << "\n";
+	 }
+	 else
+	 {
+	 End		*/
+	os << "Message: " << std::string(e->what()) << "\n";
+	/*		} */
+
+	return(os.str());
+}
+
+long TestRunnerClient::CurrentTimeMillis()
+{
+#ifdef _WIN32 // Bugzilla 40710
+	unsigned long long p;
+	__asm__ __volatile__ ("rdtsc" : "=A" (p));
+	return (unsigned long)p;
+#else
+	struct timeval tv;
+	gettimeofday(&tv, NULL);
+
+	return((long)(tv.tv_sec*1000) + (tv.tv_usec/1000));
+#endif
+}
+
+void TestRunnerClient::PrivateSleep(int millisecs)
+{
+	struct timeval delta;
+	delta.tv_sec = (millisecs * 1000L) / 1000000L;
+	delta.tv_usec = (millisecs * 1000L) % 1000000L;
+	select (0, NULL, NULL, NULL, &delta);
+}
+
+/*!
+ * This is the main routine. The TestRunnerClient is initialized and run. The
+ * CppUnit tests are created, executed, and sent to the CppUnitServer.
+ * If no connection to the CppUnitServer was established the CppUnit tests are
+ * displayed on the console.
+ *
+ * @return <code>0</code> if the results of the CppUnit tests were sent to the
+ *         CppUnitServer successfully.
+ *         <code>-1</code> if a connection could not be established to the
+ *         CppUnitServer.
+ */
+int CPPUNIT_MAIN(int n, char *arg[])
+{
+	TestRunnerClient client;
+
+	client.Init(n, arg);
+	int ret = client.Run();
+	if (ret == -1)
+	{
+		CppUnit::TestFactoryRegistry &registry = CppUnit::TestFactoryRegistry::getRegistry();
+		CppUnit::Test *suite = registry.makeTest();
+
+		CppUnit::TextUi::TestRunner *runner = NULL;
+		runner = new CppUnit::TextUi::TestRunner();
+		runner->addTest(suite);
+		runner->run();
+	}
+
+	exit(ret);
+}
+
+#endif /*CPPUNIT_MAIN*/
Index: TestRunnerClient.h
===================================================================
--- TestRunnerClient.h	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
+++ TestRunnerClient.h	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -0,0 +1,140 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Gerhard Leonhartsberger.
+ * 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
+ *******************************************************************************/
+
+#ifndef TESTRUNNERSERVER_H_
+#define TESTRUNNERSERVER_H_
+
+#ifdef CPPUNIT_MAIN
+
+#include "cppunit/TestListener.h"
+
+#include <vector>
+#include <string>
+
+/*!
+ * Class <code>TestRunnerClient</code> handles the network connection to the
+ * <code>CppUnitServer</code> and executes all registered CppUnit tests.
+ * <p>
+ * The meta data of the CppUnit tests and the test results are sent to the
+ * <code>CppUnitServer</code> for displaying.
+ * </p>
+ * <p>
+ * For debugging purposes class <code>TestRunnerClient</code> displays debug
+ * messages on <code>std.cerr</code>. The debug modus is activated by specifying
+ * <code>debug</code> command line option. The command line is parsed by method
+ * <code>Init()</code>.
+ * </p>
+ * <p>
+ * Note: This class is not intended to be subclassed by clients. This class is
+ * based on the original <code>RemoteTestRunner</code> class provided by
+ * <code>org.eclipse.cdt.cppunit</code>.
+ * </p>
+ *
+ * @author Gerhard Leonhartsberger
+ */
+class TestRunnerClient: public CppUnit::TestListener
+{
+private:
+	CppUnit::TestResult *fTestResult;
+	int fClientSocket;
+	char *fHost;
+	int fPort;
+	int fDebugMode;
+	int fKeepAlive;
+
+public:
+	TestRunnerClient();
+	virtual ~TestRunnerClient();
+
+	/*!
+	 * Initializes the <code>TestRunnerClient</code>.
+	 * <p>
+	 * The given <code>args</code> are parsed. The syntax for the arguments is
+	 * defined in EBNF as follows: <code>{-option=value}</code>
+	 * </p>
+	 *
+	 * @param n The number of arguments.
+	 * @param args The argument values. Valid options are:
+	 * 			   <li><code>-debug</code> When present the TestRunnerClient
+	 * 				is run in debug modus and displays debug messages.</li>
+	 * 			   <li><code>-port=number</code> Defines the port where
+	 * 			   CppUnitServer is listening for client connections.</li>
+	 */
+	void Init(int n,char *args[]);
+
+	/*!
+	 * Runs the TestRunnerClient. A trial to connect to the CppUnitServer is done.
+	 * The test results are sent to the CppUnitServer.
+	 *
+	 * @return The return value is <code>0</code> when the CppUnitServer was connected successfully
+	 * otherwise the return value is <code>-1</code>.
+	 */
+	int Run();
+
+	/*!
+	 * Stops processing <code>CppUnit</code> from executing tests.
+	 */
+	void Stop();
+
+	/*!
+	 * Method defined in <code>CppUnit::TestListener</code>.
+	 */
+	void startTest(CppUnit::Test *test);
+
+	/*!
+	 * Method defined in <code>CppUnit::TestListener</code>.
+	 */
+	void addFailure(const CppUnit::TestFailure &failure);
+
+	/*!
+	 * Method defined in <code>CppUnit::TestListener</code>.
+	 */
+	void endTest(CppUnit::Test *test);
+
+private:
+	int Connect();
+	void RunTests();
+	void ShutDown();
+
+	// utility methods
+	void ParseCommandLine(int n, char *args[]);
+	void DefineHostName();
+	void InstallListeners();
+	void UninstallListeners();
+
+	/*!
+	 * Sends the given test to the CppUnitView.
+	 * <p>
+	 * In case of test is of type CppUnit::Test the following protocol is sent:
+	 * <code>TSTTREE name, false, testCaseCount</code>
+	 * </p>
+	 * <p>
+	 * In case of test is of type CppUnit::TestSuite the following protocol is sent:
+	 * TSTTREE name, true, testCount
+	 * </p>
+	 * @param test the CppUnit test
+	 */
+	void SendTestTree(CppUnit::Test *test);
+	void SendMessage(std::string msg);
+
+	// Notification methods
+	void NotifyTestRunStarted(int testCount);
+	void NotifyTestRunEnded(long elapsedTime);
+	void NotifyTestRunStopped(long elapsedTime);
+	void NotifyTestTreeEntry(std::string treeEntry);
+	void NotifyTestStarted(std::string testName);
+	void NotifyTestEnded(std::string testName);
+	void NotifyTestFailed(std::string status, std::string testName, std::string trace);
+
+	std::string GetTrace(const CppUnit::TestFailure &failure);
+	long CurrentTimeMillis();
+	void PrivateSleep(int millisecs);
+};
+
+#endif /*CPPUNIT_MAIN*/
+#endif /*TESTRUNNERSERVER_H_*/
Index: config/ltmain.sh
===================================================================
--- config/ltmain.sh	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
+++ config/ltmain.sh	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -0,0 +1,8413 @@
+# Generated from ltmain.m4sh.
+
+# ltmain.sh (GNU libtool) 2.2.6b
+# Written by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996
+
+# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, 2006, 2007 2008 Free Software Foundation, Inc.
+# This is free software; see the source for copying conditions.  There is NO
+# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+# GNU Libtool 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.
+#
+# As a special exception to the GNU General Public License,
+# if you distribute this file as part of a program or library that
+# is built using GNU Libtool, you may include this file under the
+# same distribution terms that you use for the rest of that program.
+#
+# GNU Libtool 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 GNU Libtool; see the file COPYING.  If not, a copy
+# can be downloaded from http://www.gnu.org/licenses/gpl.html,
+# or obtained by writing to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+# Usage: $progname [OPTION]... [MODE-ARG]...
+#
+# Provide generalized library-building support services.
+#
+#     --config             show all configuration variables
+#     --debug              enable verbose shell tracing
+# -n, --dry-run            display commands without modifying any files
+#     --features           display basic configuration information and exit
+#     --mode=MODE          use operation mode MODE
+#     --preserve-dup-deps  don't remove duplicate dependency libraries
+#     --quiet, --silent    don't print informational messages
+#     --tag=TAG            use configuration variables from tag TAG
+# -v, --verbose            print informational messages (default)
+#     --version            print version information
+# -h, --help               print short or long help message
+#
+# MODE must be one of the following:
+#
+#       clean              remove files from the build directory
+#       compile            compile a source file into a libtool object
+#       execute            automatically set library path, then run a program
+#       finish             complete the installation of libtool libraries
+#       install            install libraries or executables
+#       link               create a library or an executable
+#       uninstall          remove libraries from an installed directory
+#
+# MODE-ARGS vary depending on the MODE.
+# Try `$progname --help --mode=MODE' for a more detailed description of MODE.
+#
+# When reporting a bug, please describe a test case to reproduce it and
+# include the following information:
+#
+#       host-triplet:	$host
+#       shell:		$SHELL
+#       compiler:		$LTCC
+#       compiler flags:		$LTCFLAGS
+#       linker:		$LD (gnu? $with_gnu_ld)
+#       $progname:		(GNU libtool) 2.2.6b Debian-2.2.6b-2ubuntu1
+#       automake:		$automake_version
+#       autoconf:		$autoconf_version
+#
+# Report bugs to <bug-libtool@gnu.org>.
+
+PROGRAM=ltmain.sh
+PACKAGE=libtool
+VERSION="2.2.6b Debian-2.2.6b-2ubuntu1"
+TIMESTAMP=""
+package_revision=1.3017
+
+# Be Bourne compatible
+if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
+  emulate sh
+  NULLCMD=:
+  # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which
+  # is contrary to our usage.  Disable this feature.
+  alias -g '${1+"$@"}'='"$@"'
+  setopt NO_GLOB_SUBST
+else
+  case `(set -o) 2>/dev/null` in *posix*) set -o posix;; esac
+fi
+BIN_SH=xpg4; export BIN_SH # for Tru64
+DUALCASE=1; export DUALCASE # for MKS sh
+
+# NLS nuisances: We save the old values to restore during execute mode.
+# Only set LANG and LC_ALL to C if already set.
+# These must not be set unconditionally because not all systems understand
+# e.g. LANG=C (notably SCO).
+lt_user_locale=
+lt_safe_locale=
+for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES
+do
+  eval "if test \"\${$lt_var+set}\" = set; then
+          save_$lt_var=\$$lt_var
+          $lt_var=C
+	  export $lt_var
+	  lt_user_locale=\"$lt_var=\\\$save_\$lt_var; \$lt_user_locale\"
+	  lt_safe_locale=\"$lt_var=C; \$lt_safe_locale\"
+	fi"
+done
+
+$lt_unset CDPATH
+
+
+
+
+
+: ${CP="cp -f"}
+: ${ECHO="echo"}
+: ${EGREP="/bin/grep -E"}
+: ${FGREP="/bin/grep -F"}
+: ${GREP="/bin/grep"}
+: ${LN_S="ln -s"}
+: ${MAKE="make"}
+: ${MKDIR="mkdir"}
+: ${MV="mv -f"}
+: ${RM="rm -f"}
+: ${SED="/bin/sed"}
+: ${SHELL="${CONFIG_SHELL-/bin/sh}"}
+: ${Xsed="$SED -e 1s/^X//"}
+
+# Global variables:
+EXIT_SUCCESS=0
+EXIT_FAILURE=1
+EXIT_MISMATCH=63  # $? = 63 is used to indicate version mismatch to missing.
+EXIT_SKIP=77	  # $? = 77 is used to indicate a skipped test to automake.
+
+exit_status=$EXIT_SUCCESS
+
+# Make sure IFS has a sensible default
+lt_nl='
+'
+IFS=" 	$lt_nl"
+
+dirname="s,/[^/]*$,,"
+basename="s,^.*/,,"
+
+# func_dirname_and_basename file append nondir_replacement
+# perform func_basename and func_dirname in a single function
+# call:
+#   dirname:  Compute the dirname of FILE.  If nonempty,
+#             add APPEND to the result, otherwise set result
+#             to NONDIR_REPLACEMENT.
+#             value returned in "$func_dirname_result"
+#   basename: Compute filename of FILE.
+#             value retuned in "$func_basename_result"
+# Implementation must be kept synchronized with func_dirname
+# and func_basename. For efficiency, we do not delegate to
+# those functions but instead duplicate the functionality here.
+func_dirname_and_basename ()
+{
+  # Extract subdirectory from the argument.
+  func_dirname_result=`$ECHO "X${1}" | $Xsed -e "$dirname"`
+  if test "X$func_dirname_result" = "X${1}"; then
+    func_dirname_result="${3}"
+  else
+    func_dirname_result="$func_dirname_result${2}"
+  fi
+  func_basename_result=`$ECHO "X${1}" | $Xsed -e "$basename"`
+}
+
+# Generated shell functions inserted here.
+
+# Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh
+# is ksh but when the shell is invoked as "sh" and the current value of
+# the _XPG environment variable is not equal to 1 (one), the special
+# positional parameter $0, within a function call, is the name of the
+# function.
+progpath="$0"
+
+# The name of this program:
+# In the unlikely event $progname began with a '-', it would play havoc with
+# func_echo (imagine progname=-n), so we prepend ./ in that case:
+func_dirname_and_basename "$progpath"
+progname=$func_basename_result
+case $progname in
+  -*) progname=./$progname ;;
+esac
+
+# Make sure we have an absolute path for reexecution:
+case $progpath in
+  [\\/]*|[A-Za-z]:\\*) ;;
+  *[\\/]*)
+     progdir=$func_dirname_result
+     progdir=`cd "$progdir" && pwd`
+     progpath="$progdir/$progname"
+     ;;
+  *)
+     save_IFS="$IFS"
+     IFS=:
+     for progdir in $PATH; do
+       IFS="$save_IFS"
+       test -x "$progdir/$progname" && break
+     done
+     IFS="$save_IFS"
+     test -n "$progdir" || progdir=`pwd`
+     progpath="$progdir/$progname"
+     ;;
+esac
+
+# Sed substitution that helps us do robust quoting.  It backslashifies
+# metacharacters that are still active within double-quoted strings.
+Xsed="${SED}"' -e 1s/^X//'
+sed_quote_subst='s/\([`"$\\]\)/\\\1/g'
+
+# Same as above, but do not quote variable references.
+double_quote_subst='s/\(["`\\]\)/\\\1/g'
+
+# Re-`\' parameter expansions in output of double_quote_subst that were
+# `\'-ed in input to the same.  If an odd number of `\' preceded a '$'
+# in input to double_quote_subst, that '$' was protected from expansion.
+# Since each input `\' is now two `\'s, look for any number of runs of
+# four `\'s followed by two `\'s and then a '$'.  `\' that '$'.
+bs='\\'
+bs2='\\\\'
+bs4='\\\\\\\\'
+dollar='\$'
+sed_double_backslash="\
+  s/$bs4/&\\
+/g
+  s/^$bs2$dollar/$bs&/
+  s/\\([^$bs]\\)$bs2$dollar/\\1$bs2$bs$dollar/g
+  s/\n//g"
+
+# Standard options:
+opt_dry_run=false
+opt_help=false
+opt_quiet=false
+opt_verbose=false
+opt_warning=:
+
+# func_echo arg...
+# Echo program name prefixed message, along with the current mode
+# name if it has been set yet.
+func_echo ()
+{
+    $ECHO "$progname${mode+: }$mode: $*"
+}
+
+# func_verbose arg...
+# Echo program name prefixed message in verbose mode only.
+func_verbose ()
+{
+    $opt_verbose && func_echo ${1+"$@"}
+
+    # A bug in bash halts the script if the last line of a function
+    # fails when set -e is in force, so we need another command to
+    # work around that:
+    :
+}
+
+# func_error arg...
+# Echo program name prefixed message to standard error.
+func_error ()
+{
+    $ECHO "$progname${mode+: }$mode: "${1+"$@"} 1>&2
+}
+
+# func_warning arg...
+# Echo program name prefixed warning message to standard error.
+func_warning ()
+{
+    $opt_warning && $ECHO "$progname${mode+: }$mode: warning: "${1+"$@"} 1>&2
+
+    # bash bug again:
+    :
+}
+
+# func_fatal_error arg...
+# Echo program name prefixed message to standard error, and exit.
+func_fatal_error ()
+{
+    func_error ${1+"$@"}
+    exit $EXIT_FAILURE
+}
+
+# func_fatal_help arg...
+# Echo program name prefixed message to standard error, followed by
+# a help hint, and exit.
+func_fatal_help ()
+{
+    func_error ${1+"$@"}
+    func_fatal_error "$help"
+}
+help="Try \`$progname --help' for more information."  ## default
+
+
+# func_grep expression filename
+# Check whether EXPRESSION matches any line of FILENAME, without output.
+func_grep ()
+{
+    $GREP "$1" "$2" >/dev/null 2>&1
+}
+
+
+# func_mkdir_p directory-path
+# Make sure the entire path to DIRECTORY-PATH is available.
+func_mkdir_p ()
+{
+    my_directory_path="$1"
+    my_dir_list=
+
+    if test -n "$my_directory_path" && test "$opt_dry_run" != ":"; then
+
+      # Protect directory names starting with `-'
+      case $my_directory_path in
+        -*) my_directory_path="./$my_directory_path" ;;
+      esac
+
+      # While some portion of DIR does not yet exist...
+      while test ! -d "$my_directory_path"; do
+        # ...make a list in topmost first order.  Use a colon delimited
+	# list incase some portion of path contains whitespace.
+        my_dir_list="$my_directory_path:$my_dir_list"
+
+        # If the last portion added has no slash in it, the list is done
+        case $my_directory_path in */*) ;; *) break ;; esac
+
+        # ...otherwise throw away the child directory and loop
+        my_directory_path=`$ECHO "X$my_directory_path" | $Xsed -e "$dirname"`
+      done
+      my_dir_list=`$ECHO "X$my_dir_list" | $Xsed -e 's,:*$,,'`
+
+      save_mkdir_p_IFS="$IFS"; IFS=':'
+      for my_dir in $my_dir_list; do
+	IFS="$save_mkdir_p_IFS"
+        # mkdir can fail with a `File exist' error if two processes
+        # try to create one of the directories concurrently.  Don't
+        # stop in that case!
+        $MKDIR "$my_dir" 2>/dev/null || :
+      done
+      IFS="$save_mkdir_p_IFS"
+
+      # Bail out if we (or some other process) failed to create a directory.
+      test -d "$my_directory_path" || \
+        func_fatal_error "Failed to create \`$1'"
+    fi
+}
+
+
+# func_mktempdir [string]
+# Make a temporary directory that won't clash with other running
+# libtool processes, and avoids race conditions if possible.  If
+# given, STRING is the basename for that directory.
+func_mktempdir ()
+{
+    my_template="${TMPDIR-/tmp}/${1-$progname}"
+
+    if test "$opt_dry_run" = ":"; then
+      # Return a directory name, but don't create it in dry-run mode
+      my_tmpdir="${my_template}-$$"
+    else
+
+      # If mktemp works, use that first and foremost
+      my_tmpdir=`mktemp -d "${my_template}-XXXXXXXX" 2>/dev/null`
+
+      if test ! -d "$my_tmpdir"; then
+        # Failing that, at least try and use $RANDOM to avoid a race
+        my_tmpdir="${my_template}-${RANDOM-0}$$"
+
+        save_mktempdir_umask=`umask`
+        umask 0077
+        $MKDIR "$my_tmpdir"
+        umask $save_mktempdir_umask
+      fi
+
+      # If we're not in dry-run mode, bomb out on failure
+      test -d "$my_tmpdir" || \
+        func_fatal_error "cannot create temporary directory \`$my_tmpdir'"
+    fi
+
+    $ECHO "X$my_tmpdir" | $Xsed
+}
+
+
+# func_quote_for_eval arg
+# Aesthetically quote ARG to be evaled later.
+# This function returns two values: FUNC_QUOTE_FOR_EVAL_RESULT
+# is double-quoted, suitable for a subsequent eval, whereas
+# FUNC_QUOTE_FOR_EVAL_UNQUOTED_RESULT has merely all characters
+# which are still active within double quotes backslashified.
+func_quote_for_eval ()
+{
+    case $1 in
+      *[\\\`\"\$]*)
+	func_quote_for_eval_unquoted_result=`$ECHO "X$1" | $Xsed -e "$sed_quote_subst"` ;;
+      *)
+        func_quote_for_eval_unquoted_result="$1" ;;
+    esac
+
+    case $func_quote_for_eval_unquoted_result in
+      # Double-quote args containing shell metacharacters to delay
+      # word splitting, command substitution and and variable
+      # expansion for a subsequent eval.
+      # Many Bourne shells cannot handle close brackets correctly
+      # in scan sets, so we specify it separately.
+      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
+        func_quote_for_eval_result="\"$func_quote_for_eval_unquoted_result\""
+        ;;
+      *)
+        func_quote_for_eval_result="$func_quote_for_eval_unquoted_result"
+    esac
+}
+
+
+# func_quote_for_expand arg
+# Aesthetically quote ARG to be evaled later; same as above,
+# but do not quote variable references.
+func_quote_for_expand ()
+{
+    case $1 in
+      *[\\\`\"]*)
+	my_arg=`$ECHO "X$1" | $Xsed \
+	    -e "$double_quote_subst" -e "$sed_double_backslash"` ;;
+      *)
+        my_arg="$1" ;;
+    esac
+
+    case $my_arg in
+      # Double-quote args containing shell metacharacters to delay
+      # word splitting and command substitution for a subsequent eval.
+      # Many Bourne shells cannot handle close brackets correctly
+      # in scan sets, so we specify it separately.
+      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
+        my_arg="\"$my_arg\""
+        ;;
+    esac
+
+    func_quote_for_expand_result="$my_arg"
+}
+
+
+# func_show_eval cmd [fail_exp]
+# Unless opt_silent is true, then output CMD.  Then, if opt_dryrun is
+# not true, evaluate CMD.  If the evaluation of CMD fails, and FAIL_EXP
+# is given, then evaluate it.
+func_show_eval ()
+{
+    my_cmd="$1"
+    my_fail_exp="${2-:}"
+
+    ${opt_silent-false} || {
+      func_quote_for_expand "$my_cmd"
+      eval "func_echo $func_quote_for_expand_result"
+    }
+
+    if ${opt_dry_run-false}; then :; else
+      eval "$my_cmd"
+      my_status=$?
+      if test "$my_status" -eq 0; then :; else
+	eval "(exit $my_status); $my_fail_exp"
+      fi
+    fi
+}
+
+
+# func_show_eval_locale cmd [fail_exp]
+# Unless opt_silent is true, then output CMD.  Then, if opt_dryrun is
+# not true, evaluate CMD.  If the evaluation of CMD fails, and FAIL_EXP
+# is given, then evaluate it.  Use the saved locale for evaluation.
+func_show_eval_locale ()
+{
+    my_cmd="$1"
+    my_fail_exp="${2-:}"
+
+    ${opt_silent-false} || {
+      func_quote_for_expand "$my_cmd"
+      eval "func_echo $func_quote_for_expand_result"
+    }
+
+    if ${opt_dry_run-false}; then :; else
+      eval "$lt_user_locale
+	    $my_cmd"
+      my_status=$?
+      eval "$lt_safe_locale"
+      if test "$my_status" -eq 0; then :; else
+	eval "(exit $my_status); $my_fail_exp"
+      fi
+    fi
+}
+
+
+
+
+
+# func_version
+# Echo version message to standard output and exit.
+func_version ()
+{
+    $SED -n '/^# '$PROGRAM' (GNU /,/# warranty; / {
+        s/^# //
+	s/^# *$//
+        s/\((C)\)[ 0-9,-]*\( [1-9][0-9]*\)/\1\2/
+        p
+     }' < "$progpath"
+     exit $?
+}
+
+# func_usage
+# Echo short help message to standard output and exit.
+func_usage ()
+{
+    $SED -n '/^# Usage:/,/# -h/ {
+        s/^# //
+	s/^# *$//
+	s/\$progname/'$progname'/
+	p
+    }' < "$progpath"
+    $ECHO
+    $ECHO "run \`$progname --help | more' for full usage"
+    exit $?
+}
+
+# func_help
+# Echo long help message to standard output and exit.
+func_help ()
+{
+    $SED -n '/^# Usage:/,/# Report bugs to/ {
+        s/^# //
+	s/^# *$//
+	s*\$progname*'$progname'*
+	s*\$host*'"$host"'*
+	s*\$SHELL*'"$SHELL"'*
+	s*\$LTCC*'"$LTCC"'*
+	s*\$LTCFLAGS*'"$LTCFLAGS"'*
+	s*\$LD*'"$LD"'*
+	s/\$with_gnu_ld/'"$with_gnu_ld"'/
+	s/\$automake_version/'"`(automake --version) 2>/dev/null |$SED 1q`"'/
+	s/\$autoconf_version/'"`(autoconf --version) 2>/dev/null |$SED 1q`"'/
+	p
+     }' < "$progpath"
+    exit $?
+}
+
+# func_missing_arg argname
+# Echo program name prefixed message to standard error and set global
+# exit_cmd.
+func_missing_arg ()
+{
+    func_error "missing argument for $1"
+    exit_cmd=exit
+}
+
+exit_cmd=:
+
+
+
+
+
+# Check that we have a working $ECHO.
+if test "X$1" = X--no-reexec; then
+  # Discard the --no-reexec flag, and continue.
+  shift
+elif test "X$1" = X--fallback-echo; then
+  # Avoid inline document here, it may be left over
+  :
+elif test "X`{ $ECHO '\t'; } 2>/dev/null`" = 'X\t'; then
+  # Yippee, $ECHO works!
+  :
+else
+  # Restart under the correct shell, and then maybe $ECHO will work.
+  exec $SHELL "$progpath" --no-reexec ${1+"$@"}
+fi
+
+if test "X$1" = X--fallback-echo; then
+  # used as fallback echo
+  shift
+  cat <<EOF
+$*
+EOF
+  exit $EXIT_SUCCESS
+fi
+
+magic="%%%MAGIC variable%%%"
+magic_exe="%%%MAGIC EXE variable%%%"
+
+# Global variables.
+# $mode is unset
+nonopt=
+execute_dlfiles=
+preserve_args=
+lo2o="s/\\.lo\$/.${objext}/"
+o2lo="s/\\.${objext}\$/.lo/"
+extracted_archives=
+extracted_serial=0
+
+opt_dry_run=false
+opt_duplicate_deps=false
+opt_silent=false
+opt_debug=:
+
+# If this variable is set in any of the actions, the command in it
+# will be execed at the end.  This prevents here-documents from being
+# left over by shells.
+exec_cmd=
+
+# func_fatal_configuration arg...
+# Echo program name prefixed message to standard error, followed by
+# a configuration failure hint, and exit.
+func_fatal_configuration ()
+{
+    func_error ${1+"$@"}
+    func_error "See the $PACKAGE documentation for more information."
+    func_fatal_error "Fatal configuration error."
+}
+
+
+# func_config
+# Display the configuration for all the tags in this script.
+func_config ()
+{
+    re_begincf='^# ### BEGIN LIBTOOL'
+    re_endcf='^# ### END LIBTOOL'
+
+    # Default configuration.
+    $SED "1,/$re_begincf CONFIG/d;/$re_endcf CONFIG/,\$d" < "$progpath"
+
+    # Now print the configurations for the tags.
+    for tagname in $taglist; do
+      $SED -n "/$re_begincf TAG CONFIG: $tagname\$/,/$re_endcf TAG CONFIG: $tagname\$/p" < "$progpath"
+    done
+
+    exit $?
+}
+
+# func_features
+# Display the features supported by this script.
+func_features ()
+{
+    $ECHO "host: $host"
+    if test "$build_libtool_libs" = yes; then
+      $ECHO "enable shared libraries"
+    else
+      $ECHO "disable shared libraries"
+    fi
+    if test "$build_old_libs" = yes; then
+      $ECHO "enable static libraries"
+    else
+      $ECHO "disable static libraries"
+    fi
+
+    exit $?
+}
+
+# func_enable_tag tagname
+# Verify that TAGNAME is valid, and either flag an error and exit, or
+# enable the TAGNAME tag.  We also add TAGNAME to the global $taglist
+# variable here.
+func_enable_tag ()
+{
+  # Global variable:
+  tagname="$1"
+
+  re_begincf="^# ### BEGIN LIBTOOL TAG CONFIG: $tagname\$"
+  re_endcf="^# ### END LIBTOOL TAG CONFIG: $tagname\$"
+  sed_extractcf="/$re_begincf/,/$re_endcf/p"
+
+  # Validate tagname.
+  case $tagname in
+    *[!-_A-Za-z0-9,/]*)
+      func_fatal_error "invalid tag name: $tagname"
+      ;;
+  esac
+
+  # Don't test for the "default" C tag, as we know it's
+  # there but not specially marked.
+  case $tagname in
+    CC) ;;
+    *)
+      if $GREP "$re_begincf" "$progpath" >/dev/null 2>&1; then
+	taglist="$taglist $tagname"
+
+	# Evaluate the configuration.  Be careful to quote the path
+	# and the sed script, to avoid splitting on whitespace, but
+	# also don't use non-portable quotes within backquotes within
+	# quotes we have to do it in 2 steps:
+	extractedcf=`$SED -n -e "$sed_extractcf" < "$progpath"`
+	eval "$extractedcf"
+      else
+	func_error "ignoring unknown tag $tagname"
+      fi
+      ;;
+  esac
+}
+
+# Parse options once, thoroughly.  This comes as soon as possible in
+# the script to make things like `libtool --version' happen quickly.
+{
+
+  # Shorthand for --mode=foo, only valid as the first argument
+  case $1 in
+  clean|clea|cle|cl)
+    shift; set dummy --mode clean ${1+"$@"}; shift
+    ;;
+  compile|compil|compi|comp|com|co|c)
+    shift; set dummy --mode compile ${1+"$@"}; shift
+    ;;
+  execute|execut|execu|exec|exe|ex|e)
+    shift; set dummy --mode execute ${1+"$@"}; shift
+    ;;
+  finish|finis|fini|fin|fi|f)
+    shift; set dummy --mode finish ${1+"$@"}; shift
+    ;;
+  install|instal|insta|inst|ins|in|i)
+    shift; set dummy --mode install ${1+"$@"}; shift
+    ;;
+  link|lin|li|l)
+    shift; set dummy --mode link ${1+"$@"}; shift
+    ;;
+  uninstall|uninstal|uninsta|uninst|unins|unin|uni|un|u)
+    shift; set dummy --mode uninstall ${1+"$@"}; shift
+    ;;
+  esac
+
+  # Parse non-mode specific arguments:
+  while test "$#" -gt 0; do
+    opt="$1"
+    shift
+
+    case $opt in
+      --config)		func_config					;;
+
+      --debug)		preserve_args="$preserve_args $opt"
+			func_echo "enabling shell trace mode"
+			opt_debug='set -x'
+			$opt_debug
+			;;
+
+      -dlopen)		test "$#" -eq 0 && func_missing_arg "$opt" && break
+			execute_dlfiles="$execute_dlfiles $1"
+			shift
+			;;
+
+      --dry-run | -n)	opt_dry_run=:					;;
+      --features)       func_features					;;
+      --finish)		mode="finish"					;;
+
+      --mode)		test "$#" -eq 0 && func_missing_arg "$opt" && break
+			case $1 in
+			  # Valid mode arguments:
+			  clean)	;;
+			  compile)	;;
+			  execute)	;;
+			  finish)	;;
+			  install)	;;
+			  link)		;;
+			  relink)	;;
+			  uninstall)	;;
+
+			  # Catch anything else as an error
+			  *) func_error "invalid argument for $opt"
+			     exit_cmd=exit
+			     break
+			     ;;
+		        esac
+
+			mode="$1"
+			shift
+			;;
+
+      --preserve-dup-deps)
+			opt_duplicate_deps=:				;;
+
+      --quiet|--silent)	preserve_args="$preserve_args $opt"
+			opt_silent=:
+			;;
+
+      --verbose| -v)	preserve_args="$preserve_args $opt"
+			opt_silent=false
+			;;
+
+      --tag)		test "$#" -eq 0 && func_missing_arg "$opt" && break
+			preserve_args="$preserve_args $opt $1"
+			func_enable_tag "$1"	# tagname is set here
+			shift
+			;;
+
+      # Separate optargs to long options:
+      -dlopen=*|--mode=*|--tag=*)
+			func_opt_split "$opt"
+			set dummy "$func_opt_split_opt" "$func_opt_split_arg" ${1+"$@"}
+			shift
+			;;
+
+      -\?|-h)		func_usage					;;
+      --help)		opt_help=:					;;
+      --version)	func_version					;;
+
+      -*)		func_fatal_help "unrecognized option \`$opt'"	;;
+
+      *)		nonopt="$opt"
+			break
+			;;
+    esac
+  done
+
+
+  case $host in
+    *cygwin* | *mingw* | *pw32* | *cegcc*)
+      # don't eliminate duplications in $postdeps and $predeps
+      opt_duplicate_compiler_generated_deps=:
+      ;;
+    *)
+      opt_duplicate_compiler_generated_deps=$opt_duplicate_deps
+      ;;
+  esac
+
+  # Having warned about all mis-specified options, bail out if
+  # anything was wrong.
+  $exit_cmd $EXIT_FAILURE
+}
+
+# func_check_version_match
+# Ensure that we are using m4 macros, and libtool script from the same
+# release of libtool.
+func_check_version_match ()
+{
+  if test "$package_revision" != "$macro_revision"; then
+    if test "$VERSION" != "$macro_version"; then
+      if test -z "$macro_version"; then
+        cat >&2 <<_LT_EOF
+$progname: Version mismatch error.  This is $PACKAGE $VERSION, but the
+$progname: definition of this LT_INIT comes from an older release.
+$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION
+$progname: and run autoconf again.
+_LT_EOF
+      else
+        cat >&2 <<_LT_EOF
+$progname: Version mismatch error.  This is $PACKAGE $VERSION, but the
+$progname: definition of this LT_INIT comes from $PACKAGE $macro_version.
+$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION
+$progname: and run autoconf again.
+_LT_EOF
+      fi
+    else
+      cat >&2 <<_LT_EOF
+$progname: Version mismatch error.  This is $PACKAGE $VERSION, revision $package_revision,
+$progname: but the definition of this LT_INIT comes from revision $macro_revision.
+$progname: You should recreate aclocal.m4 with macros from revision $package_revision
+$progname: of $PACKAGE $VERSION and run autoconf again.
+_LT_EOF
+    fi
+
+    exit $EXIT_MISMATCH
+  fi
+}
+
+
+## ----------- ##
+##    Main.    ##
+## ----------- ##
+
+$opt_help || {
+  # Sanity checks first:
+  func_check_version_match
+
+  if test "$build_libtool_libs" != yes && test "$build_old_libs" != yes; then
+    func_fatal_configuration "not configured to build any kind of library"
+  fi
+
+  test -z "$mode" && func_fatal_error "error: you must specify a MODE."
+
+
+  # Darwin sucks
+  eval std_shrext=\"$shrext_cmds\"
+
+
+  # Only execute mode is allowed to have -dlopen flags.
+  if test -n "$execute_dlfiles" && test "$mode" != execute; then
+    func_error "unrecognized option \`-dlopen'"
+    $ECHO "$help" 1>&2
+    exit $EXIT_FAILURE
+  fi
+
+  # Change the help message to a mode-specific one.
+  generic_help="$help"
+  help="Try \`$progname --help --mode=$mode' for more information."
+}
+
+
+# func_lalib_p file
+# True iff FILE is a libtool `.la' library or `.lo' object file.
+# This function is only a basic sanity check; it will hardly flush out
+# determined imposters.
+func_lalib_p ()
+{
+    test -f "$1" &&
+      $SED -e 4q "$1" 2>/dev/null \
+        | $GREP "^# Generated by .*$PACKAGE" > /dev/null 2>&1
+}
+
+# func_lalib_unsafe_p file
+# True iff FILE is a libtool `.la' library or `.lo' object file.
+# This function implements the same check as func_lalib_p without
+# resorting to external programs.  To this end, it redirects stdin and
+# closes it afterwards, without saving the original file descriptor.
+# As a safety measure, use it only where a negative result would be
+# fatal anyway.  Works if `file' does not exist.
+func_lalib_unsafe_p ()
+{
+    lalib_p=no
+    if test -f "$1" && test -r "$1" && exec 5<&0 <"$1"; then
+	for lalib_p_l in 1 2 3 4
+	do
+	    read lalib_p_line
+	    case "$lalib_p_line" in
+		\#\ Generated\ by\ *$PACKAGE* ) lalib_p=yes; break;;
+	    esac
+	done
+	exec 0<&5 5<&-
+    fi
+    test "$lalib_p" = yes
+}
+
+# func_ltwrapper_script_p file
+# True iff FILE is a libtool wrapper script
+# This function is only a basic sanity check; it will hardly flush out
+# determined imposters.
+func_ltwrapper_script_p ()
+{
+    func_lalib_p "$1"
+}
+
+# func_ltwrapper_executable_p file
+# True iff FILE is a libtool wrapper executable
+# This function is only a basic sanity check; it will hardly flush out
+# determined imposters.
+func_ltwrapper_executable_p ()
+{
+    func_ltwrapper_exec_suffix=
+    case $1 in
+    *.exe) ;;
+    *) func_ltwrapper_exec_suffix=.exe ;;
+    esac
+    $GREP "$magic_exe" "$1$func_ltwrapper_exec_suffix" >/dev/null 2>&1
+}
+
+# func_ltwrapper_scriptname file
+# Assumes file is an ltwrapper_executable
+# uses $file to determine the appropriate filename for a
+# temporary ltwrapper_script.
+func_ltwrapper_scriptname ()
+{
+    func_ltwrapper_scriptname_result=""
+    if func_ltwrapper_executable_p "$1"; then
+	func_dirname_and_basename "$1" "" "."
+	func_stripname '' '.exe' "$func_basename_result"
+	func_ltwrapper_scriptname_result="$func_dirname_result/$objdir/${func_stripname_result}_ltshwrapper"
+    fi
+}
+
+# func_ltwrapper_p file
+# True iff FILE is a libtool wrapper script or wrapper executable
+# This function is only a basic sanity check; it will hardly flush out
+# determined imposters.
+func_ltwrapper_p ()
+{
+    func_ltwrapper_script_p "$1" || func_ltwrapper_executable_p "$1"
+}
+
+
+# func_execute_cmds commands fail_cmd
+# Execute tilde-delimited COMMANDS.
+# If FAIL_CMD is given, eval that upon failure.
+# FAIL_CMD may read-access the current command in variable CMD!
+func_execute_cmds ()
+{
+    $opt_debug
+    save_ifs=$IFS; IFS='~'
+    for cmd in $1; do
+      IFS=$save_ifs
+      eval cmd=\"$cmd\"
+      func_show_eval "$cmd" "${2-:}"
+    done
+    IFS=$save_ifs
+}
+
+
+# func_source file
+# Source FILE, adding directory component if necessary.
+# Note that it is not necessary on cygwin/mingw to append a dot to
+# FILE even if both FILE and FILE.exe exist: automatic-append-.exe
+# behavior happens only for exec(3), not for open(2)!  Also, sourcing
+# `FILE.' does not work on cygwin managed mounts.
+func_source ()
+{
+    $opt_debug
+    case $1 in
+    */* | *\\*)	. "$1" ;;
+    *)		. "./$1" ;;
+    esac
+}
+
+
+# func_infer_tag arg
+# Infer tagged configuration to use if any are available and
+# if one wasn't chosen via the "--tag" command line option.
+# Only attempt this if the compiler in the base compile
+# command doesn't match the default compiler.
+# arg is usually of the form 'gcc ...'
+func_infer_tag ()
+{
+    $opt_debug
+    if test -n "$available_tags" && test -z "$tagname"; then
+      CC_quoted=
+      for arg in $CC; do
+        func_quote_for_eval "$arg"
+	CC_quoted="$CC_quoted $func_quote_for_eval_result"
+      done
+      case $@ in
+      # Blanks in the command may have been stripped by the calling shell,
+      # but not from the CC environment variable when configure was run.
+      " $CC "* | "$CC "* | " `$ECHO $CC` "* | "`$ECHO $CC` "* | " $CC_quoted"* | "$CC_quoted "* | " `$ECHO $CC_quoted` "* | "`$ECHO $CC_quoted` "*) ;;
+      # Blanks at the start of $base_compile will cause this to fail
+      # if we don't check for them as well.
+      *)
+	for z in $available_tags; do
+	  if $GREP "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then
+	    # Evaluate the configuration.
+	    eval "`${SED} -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`"
+	    CC_quoted=
+	    for arg in $CC; do
+	      # Double-quote args containing other shell metacharacters.
+	      func_quote_for_eval "$arg"
+	      CC_quoted="$CC_quoted $func_quote_for_eval_result"
+	    done
+	    case "$@ " in
+	      " $CC "* | "$CC "* | " `$ECHO $CC` "* | "`$ECHO $CC` "* | " $CC_quoted"* | "$CC_quoted "* | " `$ECHO $CC_quoted` "* | "`$ECHO $CC_quoted` "*)
+	      # The compiler in the base compile command matches
+	      # the one in the tagged configuration.
+	      # Assume this is the tagged configuration we want.
+	      tagname=$z
+	      break
+	      ;;
+	    esac
+	  fi
+	done
+	# If $tagname still isn't set, then no tagged configuration
+	# was found and let the user know that the "--tag" command
+	# line option must be used.
+	if test -z "$tagname"; then
+	  func_echo "unable to infer tagged configuration"
+	  func_fatal_error "specify a tag with \`--tag'"
+#	else
+#	  func_verbose "using $tagname tagged configuration"
+	fi
+	;;
+      esac
+    fi
+}
+
+
+
+# func_write_libtool_object output_name pic_name nonpic_name
+# Create a libtool object file (analogous to a ".la" file),
+# but don't create it if we're doing a dry run.
+func_write_libtool_object ()
+{
+    write_libobj=${1}
+    if test "$build_libtool_libs" = yes; then
+      write_lobj=\'${2}\'
+    else
+      write_lobj=none
+    fi
+
+    if test "$build_old_libs" = yes; then
+      write_oldobj=\'${3}\'
+    else
+      write_oldobj=none
+    fi
+
+    $opt_dry_run || {
+      cat >${write_libobj}T <<EOF
+# $write_libobj - a libtool object file
+# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
+#
+# Please DO NOT delete this file!
+# It is necessary for linking the library.
+
+# Name of the PIC object.
+pic_object=$write_lobj
+
+# Name of the non-PIC object
+non_pic_object=$write_oldobj
+
+EOF
+      $MV "${write_libobj}T" "${write_libobj}"
+    }
+}
+
+# func_mode_compile arg...
+func_mode_compile ()
+{
+    $opt_debug
+    # Get the compilation command and the source file.
+    base_compile=
+    srcfile="$nonopt"  #  always keep a non-empty value in "srcfile"
+    suppress_opt=yes
+    suppress_output=
+    arg_mode=normal
+    libobj=
+    later=
+    pie_flag=
+
+    for arg
+    do
+      case $arg_mode in
+      arg  )
+	# do not "continue".  Instead, add this to base_compile
+	lastarg="$arg"
+	arg_mode=normal
+	;;
+
+      target )
+	libobj="$arg"
+	arg_mode=normal
+	continue
+	;;
+
+      normal )
+	# Accept any command-line options.
+	case $arg in
+	-o)
+	  test -n "$libobj" && \
+	    func_fatal_error "you cannot specify \`-o' more than once"
+	  arg_mode=target
+	  continue
+	  ;;
+
+	-pie | -fpie | -fPIE)
+          pie_flag="$pie_flag $arg"
+	  continue
+	  ;;
+
+	-shared | -static | -prefer-pic | -prefer-non-pic)
+	  later="$later $arg"
+	  continue
+	  ;;
+
+	-no-suppress)
+	  suppress_opt=no
+	  continue
+	  ;;
+
+	-Xcompiler)
+	  arg_mode=arg  #  the next one goes into the "base_compile" arg list
+	  continue      #  The current "srcfile" will either be retained or
+	  ;;            #  replaced later.  I would guess that would be a bug.
+
+	-Wc,*)
+	  func_stripname '-Wc,' '' "$arg"
+	  args=$func_stripname_result
+	  lastarg=
+	  save_ifs="$IFS"; IFS=','
+	  for arg in $args; do
+	    IFS="$save_ifs"
+	    func_quote_for_eval "$arg"
+	    lastarg="$lastarg $func_quote_for_eval_result"
+	  done
+	  IFS="$save_ifs"
+	  func_stripname ' ' '' "$lastarg"
+	  lastarg=$func_stripname_result
+
+	  # Add the arguments to base_compile.
+	  base_compile="$base_compile $lastarg"
+	  continue
+	  ;;
+
+	*)
+	  # Accept the current argument as the source file.
+	  # The previous "srcfile" becomes the current argument.
+	  #
+	  lastarg="$srcfile"
+	  srcfile="$arg"
+	  ;;
+	esac  #  case $arg
+	;;
+      esac    #  case $arg_mode
+
+      # Aesthetically quote the previous argument.
+      func_quote_for_eval "$lastarg"
+      base_compile="$base_compile $func_quote_for_eval_result"
+    done # for arg
+
+    case $arg_mode in
+    arg)
+      func_fatal_error "you must specify an argument for -Xcompile"
+      ;;
+    target)
+      func_fatal_error "you must specify a target with \`-o'"
+      ;;
+    *)
+      # Get the name of the library object.
+      test -z "$libobj" && {
+	func_basename "$srcfile"
+	libobj="$func_basename_result"
+      }
+      ;;
+    esac
+
+    # Recognize several different file suffixes.
+    # If the user specifies -o file.o, it is replaced with file.lo
+    case $libobj in
+    *.[cCFSifmso] | \
+    *.ada | *.adb | *.ads | *.asm | \
+    *.c++ | *.cc | *.ii | *.class | *.cpp | *.cxx | \
+    *.[fF][09]? | *.for | *.java | *.obj | *.sx)
+      func_xform "$libobj"
+      libobj=$func_xform_result
+      ;;
+    esac
+
+    case $libobj in
+    *.lo) func_lo2o "$libobj"; obj=$func_lo2o_result ;;
+    *)
+      func_fatal_error "cannot determine name of library object from \`$libobj'"
+      ;;
+    esac
+
+    func_infer_tag $base_compile
+
+    for arg in $later; do
+      case $arg in
+      -shared)
+	test "$build_libtool_libs" != yes && \
+	  func_fatal_configuration "can not build a shared library"
+	build_old_libs=no
+	continue
+	;;
+
+      -static)
+	build_libtool_libs=no
+	build_old_libs=yes
+	continue
+	;;
+
+      -prefer-pic)
+	pic_mode=yes
+	continue
+	;;
+
+      -prefer-non-pic)
+	pic_mode=no
+	continue
+	;;
+      esac
+    done
+
+    func_quote_for_eval "$libobj"
+    test "X$libobj" != "X$func_quote_for_eval_result" \
+      && $ECHO "X$libobj" | $GREP '[]~#^*{};<>?"'"'"'	 &()|`$[]' \
+      && func_warning "libobj name \`$libobj' may not contain shell special characters."
+    func_dirname_and_basename "$obj" "/" ""
+    objname="$func_basename_result"
+    xdir="$func_dirname_result"
+    lobj=${xdir}$objdir/$objname
+
+    test -z "$base_compile" && \
+      func_fatal_help "you must specify a compilation command"
+
+    # Delete any leftover library objects.
+    if test "$build_old_libs" = yes; then
+      removelist="$obj $lobj $libobj ${libobj}T"
+    else
+      removelist="$lobj $libobj ${libobj}T"
+    fi
+
+    # On Cygwin there's no "real" PIC flag so we must build both object types
+    case $host_os in
+    cygwin* | mingw* | pw32* | os2* | cegcc*)
+      pic_mode=default
+      ;;
+    esac
+    if test "$pic_mode" = no && test "$deplibs_check_method" != pass_all; then
+      # non-PIC code in shared libraries is not supported
+      pic_mode=default
+    fi
+
+    # Calculate the filename of the output object if compiler does
+    # not support -o with -c
+    if test "$compiler_c_o" = no; then
+      output_obj=`$ECHO "X$srcfile" | $Xsed -e 's%^.*/%%' -e 's%\.[^.]*$%%'`.${objext}
+      lockfile="$output_obj.lock"
+    else
+      output_obj=
+      need_locks=no
+      lockfile=
+    fi
+
+    # Lock this critical section if it is needed
+    # We use this script file to make the link, it avoids creating a new file
+    if test "$need_locks" = yes; then
+      until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do
+	func_echo "Waiting for $lockfile to be removed"
+	sleep 2
+      done
+    elif test "$need_locks" = warn; then
+      if test -f "$lockfile"; then
+	$ECHO "\
+*** ERROR, $lockfile exists and contains:
+`cat $lockfile 2>/dev/null`
+
+This indicates that another process is trying to use the same
+temporary object file, and libtool could not work around it because
+your compiler does not support \`-c' and \`-o' together.  If you
+repeat this compilation, it may succeed, by chance, but you had better
+avoid parallel builds (make -j) in this platform, or get a better
+compiler."
+
+	$opt_dry_run || $RM $removelist
+	exit $EXIT_FAILURE
+      fi
+      removelist="$removelist $output_obj"
+      $ECHO "$srcfile" > "$lockfile"
+    fi
+
+    $opt_dry_run || $RM $removelist
+    removelist="$removelist $lockfile"
+    trap '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 1 2 15
+
+    if test -n "$fix_srcfile_path"; then
+      eval srcfile=\"$fix_srcfile_path\"
+    fi
+    func_quote_for_eval "$srcfile"
+    qsrcfile=$func_quote_for_eval_result
+
+    # Only build a PIC object if we are building libtool libraries.
+    if test "$build_libtool_libs" = yes; then
+      # Without this assignment, base_compile gets emptied.
+      fbsd_hideous_sh_bug=$base_compile
+
+      if test "$pic_mode" != no; then
+	command="$base_compile $qsrcfile $pic_flag"
+      else
+	# Don't build PIC code
+	command="$base_compile $qsrcfile"
+      fi
+
+      func_mkdir_p "$xdir$objdir"
+
+      if test -z "$output_obj"; then
+	# Place PIC objects in $objdir
+	command="$command -o $lobj"
+      fi
+
+      func_show_eval_locale "$command"	\
+          'test -n "$output_obj" && $RM $removelist; exit $EXIT_FAILURE'
+
+      if test "$need_locks" = warn &&
+	 test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
+	$ECHO "\
+*** ERROR, $lockfile contains:
+`cat $lockfile 2>/dev/null`
+
+but it should contain:
+$srcfile
+
+This indicates that another process is trying to use the same
+temporary object file, and libtool could not work around it because
+your compiler does not support \`-c' and \`-o' together.  If you
+repeat this compilation, it may succeed, by chance, but you had better
+avoid parallel builds (make -j) in this platform, or get a better
+compiler."
+
+	$opt_dry_run || $RM $removelist
+	exit $EXIT_FAILURE
+      fi
+
+      # Just move the object if needed, then go on to compile the next one
+      if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then
+	func_show_eval '$MV "$output_obj" "$lobj"' \
+	  'error=$?; $opt_dry_run || $RM $removelist; exit $error'
+      fi
+
+      # Allow error messages only from the first compilation.
+      if test "$suppress_opt" = yes; then
+	suppress_output=' >/dev/null 2>&1'
+      fi
+    fi
+
+    # Only build a position-dependent object if we build old libraries.
+    if test "$build_old_libs" = yes; then
+      if test "$pic_mode" != yes; then
+	# Don't build PIC code
+	command="$base_compile $qsrcfile$pie_flag"
+      else
+	command="$base_compile $qsrcfile $pic_flag"
+      fi
+      if test "$compiler_c_o" = yes; then
+	command="$command -o $obj"
+      fi
+
+      # Suppress compiler output if we already did a PIC compilation.
+      command="$command$suppress_output"
+      func_show_eval_locale "$command" \
+        '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE'
+
+      if test "$need_locks" = warn &&
+	 test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
+	$ECHO "\
+*** ERROR, $lockfile contains:
+`cat $lockfile 2>/dev/null`
+
+but it should contain:
+$srcfile
+
+This indicates that another process is trying to use the same
+temporary object file, and libtool could not work around it because
+your compiler does not support \`-c' and \`-o' together.  If you
+repeat this compilation, it may succeed, by chance, but you had better
+avoid parallel builds (make -j) in this platform, or get a better
+compiler."
+
+	$opt_dry_run || $RM $removelist
+	exit $EXIT_FAILURE
+      fi
+
+      # Just move the object if needed
+      if test -n "$output_obj" && test "X$output_obj" != "X$obj"; then
+	func_show_eval '$MV "$output_obj" "$obj"' \
+	  'error=$?; $opt_dry_run || $RM $removelist; exit $error'
+      fi
+    fi
+
+    $opt_dry_run || {
+      func_write_libtool_object "$libobj" "$objdir/$objname" "$objname"
+
+      # Unlock the critical section if it was locked
+      if test "$need_locks" != no; then
+	removelist=$lockfile
+        $RM "$lockfile"
+      fi
+    }
+
+    exit $EXIT_SUCCESS
+}
+
+$opt_help || {
+test "$mode" = compile && func_mode_compile ${1+"$@"}
+}
+
+func_mode_help ()
+{
+    # We need to display help for each of the modes.
+    case $mode in
+      "")
+        # Generic help is extracted from the usage comments
+        # at the start of this file.
+        func_help
+        ;;
+
+      clean)
+        $ECHO \
+"Usage: $progname [OPTION]... --mode=clean RM [RM-OPTION]... FILE...
+
+Remove files from the build directory.
+
+RM is the name of the program to use to delete files associated with each FILE
+(typically \`/bin/rm').  RM-OPTIONS are options (such as \`-f') to be passed
+to RM.
+
+If FILE is a libtool library, object or program, all the files associated
+with it are deleted. Otherwise, only FILE itself is deleted using RM."
+        ;;
+
+      compile)
+      $ECHO \
+"Usage: $progname [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE
+
+Compile a source file into a libtool library object.
+
+This mode accepts the following additional options:
+
+  -o OUTPUT-FILE    set the output file name to OUTPUT-FILE
+  -no-suppress      do not suppress compiler output for multiple passes
+  -prefer-pic       try to building PIC objects only
+  -prefer-non-pic   try to building non-PIC objects only
+  -shared           do not build a \`.o' file suitable for static linking
+  -static           only build a \`.o' file suitable for static linking
+
+COMPILE-COMMAND is a command to be used in creating a \`standard' object file
+from the given SOURCEFILE.
+
+The output file name is determined by removing the directory component from
+SOURCEFILE, then substituting the C source code suffix \`.c' with the
+library object suffix, \`.lo'."
+        ;;
+
+      execute)
+        $ECHO \
+"Usage: $progname [OPTION]... --mode=execute COMMAND [ARGS]...
+
+Automatically set library path, then run a program.
+
+This mode accepts the following additional options:
+
+  -dlopen FILE      add the directory containing FILE to the library path
+
+This mode sets the library path environment variable according to \`-dlopen'
+flags.
+
+If any of the ARGS are libtool executable wrappers, then they are translated
+into their corresponding uninstalled binary, and any of their required library
+directories are added to the library path.
+
+Then, COMMAND is executed, with ARGS as arguments."
+        ;;
+
+      finish)
+        $ECHO \
+"Usage: $progname [OPTION]... --mode=finish [LIBDIR]...
+
+Complete the installation of libtool libraries.
+
+Each LIBDIR is a directory that contains libtool libraries.
+
+The commands that this mode executes may require superuser privileges.  Use
+the \`--dry-run' option if you just want to see what would be executed."
+        ;;
+
+      install)
+        $ECHO \
+"Usage: $progname [OPTION]... --mode=install INSTALL-COMMAND...
+
+Install executables or libraries.
+
+INSTALL-COMMAND is the installation command.  The first component should be
+either the \`install' or \`cp' program.
+
+The following components of INSTALL-COMMAND are treated specially:
+
+  -inst-prefix PREFIX-DIR  Use PREFIX-DIR as a staging area for installation
+
+The rest of the components are interpreted as arguments to that command (only
+BSD-compatible install options are recognized)."
+        ;;
+
+      link)
+        $ECHO \
+"Usage: $progname [OPTION]... --mode=link LINK-COMMAND...
+
+Link object files or libraries together to form another library, or to
+create an executable program.
+
+LINK-COMMAND is a command using the C compiler that you would use to create
+a program from several object files.
+
+The following components of LINK-COMMAND are treated specially:
+
+  -all-static       do not do any dynamic linking at all
+  -avoid-version    do not add a version suffix if possible
+  -dlopen FILE      \`-dlpreopen' FILE if it cannot be dlopened at runtime
+  -dlpreopen FILE   link in FILE and add its symbols to lt_preloaded_symbols
+  -export-dynamic   allow symbols from OUTPUT-FILE to be resolved with dlsym(3)
+  -export-symbols SYMFILE
+                    try to export only the symbols listed in SYMFILE
+  -export-symbols-regex REGEX
+                    try to export only the symbols matching REGEX
+  -LLIBDIR          search LIBDIR for required installed libraries
+  -lNAME            OUTPUT-FILE requires the installed library libNAME
+  -module           build a library that can dlopened
+  -no-fast-install  disable the fast-install mode
+  -no-install       link a not-installable executable
+  -no-undefined     declare that a library does not refer to external symbols
+  -o OUTPUT-FILE    create OUTPUT-FILE from the specified objects
+  -objectlist FILE  Use a list of object files found in FILE to specify objects
+  -precious-files-regex REGEX
+                    don't remove output files matching REGEX
+  -release RELEASE  specify package release information
+  -rpath LIBDIR     the created library will eventually be installed in LIBDIR
+  -R[ ]LIBDIR       add LIBDIR to the runtime path of programs and libraries
+  -shared           only do dynamic linking of libtool libraries
+  -shrext SUFFIX    override the standard shared library file extension
+  -static           do not do any dynamic linking of uninstalled libtool libraries
+  -static-libtool-libs
+                    do not do any dynamic linking of libtool libraries
+  -version-info CURRENT[:REVISION[:AGE]]
+                    specify library version info [each variable defaults to 0]
+  -weak LIBNAME     declare that the target provides the LIBNAME interface
+
+All other options (arguments beginning with \`-') are ignored.
+
+Every other argument is treated as a filename.  Files ending in \`.la' are
+treated as uninstalled libtool libraries, other files are standard or library
+object files.
+
+If the OUTPUT-FILE ends in \`.la', then a libtool library is created,
+only library objects (\`.lo' files) may be specified, and \`-rpath' is
+required, except when creating a convenience library.
+
+If OUTPUT-FILE ends in \`.a' or \`.lib', then a standard library is created
+using \`ar' and \`ranlib', or on Windows using \`lib'.
+
+If OUTPUT-FILE ends in \`.lo' or \`.${objext}', then a reloadable object file
+is created, otherwise an executable program is created."
+        ;;
+
+      uninstall)
+        $ECHO \
+"Usage: $progname [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE...
+
+Remove libraries from an installation directory.
+
+RM is the name of the program to use to delete files associated with each FILE
+(typically \`/bin/rm').  RM-OPTIONS are options (such as \`-f') to be passed
+to RM.
+
+If FILE is a libtool library, all the files associated with it are deleted.
+Otherwise, only FILE itself is deleted using RM."
+        ;;
+
+      *)
+        func_fatal_help "invalid operation mode \`$mode'"
+        ;;
+    esac
+
+    $ECHO
+    $ECHO "Try \`$progname --help' for more information about other modes."
+
+    exit $?
+}
+
+  # Now that we've collected a possible --mode arg, show help if necessary
+  $opt_help && func_mode_help
+
+
+# func_mode_execute arg...
+func_mode_execute ()
+{
+    $opt_debug
+    # The first argument is the command name.
+    cmd="$nonopt"
+    test -z "$cmd" && \
+      func_fatal_help "you must specify a COMMAND"
+
+    # Handle -dlopen flags immediately.
+    for file in $execute_dlfiles; do
+      test -f "$file" \
+	|| func_fatal_help "\`$file' is not a file"
+
+      dir=
+      case $file in
+      *.la)
+	# Check to see that this really is a libtool archive.
+	func_lalib_unsafe_p "$file" \
+	  || func_fatal_help "\`$lib' is not a valid libtool archive"
+
+	# Read the libtool library.
+	dlname=
+	library_names=
+	func_source "$file"
+
+	# Skip this library if it cannot be dlopened.
+	if test -z "$dlname"; then
+	  # Warn if it was a shared library.
+	  test -n "$library_names" && \
+	    func_warning "\`$file' was not linked with \`-export-dynamic'"
+	  continue
+	fi
+
+	func_dirname "$file" "" "."
+	dir="$func_dirname_result"
+
+	if test -f "$dir/$objdir/$dlname"; then
+	  dir="$dir/$objdir"
+	else
+	  if test ! -f "$dir/$dlname"; then
+	    func_fatal_error "cannot find \`$dlname' in \`$dir' or \`$dir/$objdir'"
+	  fi
+	fi
+	;;
+
+      *.lo)
+	# Just add the directory containing the .lo file.
+	func_dirname "$file" "" "."
+	dir="$func_dirname_result"
+	;;
+
+      *)
+	func_warning "\`-dlopen' is ignored for non-libtool libraries and objects"
+	continue
+	;;
+      esac
+
+      # Get the absolute pathname.
+      absdir=`cd "$dir" && pwd`
+      test -n "$absdir" && dir="$absdir"
+
+      # Now add the directory to shlibpath_var.
+      if eval "test -z \"\$$shlibpath_var\""; then
+	eval "$shlibpath_var=\"\$dir\""
+      else
+	eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\""
+      fi
+    done
+
+    # This variable tells wrapper scripts just to set shlibpath_var
+    # rather than running their programs.
+    libtool_execute_magic="$magic"
+
+    # Check if any of the arguments is a wrapper script.
+    args=
+    for file
+    do
+      case $file in
+      -*) ;;
+      *)
+	# Do a test to see if this is really a libtool program.
+	if func_ltwrapper_script_p "$file"; then
+	  func_source "$file"
+	  # Transform arg to wrapped name.
+	  file="$progdir/$program"
+	elif func_ltwrapper_executable_p "$file"; then
+	  func_ltwrapper_scriptname "$file"
+	  func_source "$func_ltwrapper_scriptname_result"
+	  # Transform arg to wrapped name.
+	  file="$progdir/$program"
+	fi
+	;;
+      esac
+      # Quote arguments (to preserve shell metacharacters).
+      func_quote_for_eval "$file"
+      args="$args $func_quote_for_eval_result"
+    done
+
+    if test "X$opt_dry_run" = Xfalse; then
+      if test -n "$shlibpath_var"; then
+	# Export the shlibpath_var.
+	eval "export $shlibpath_var"
+      fi
+
+      # Restore saved environment variables
+      for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES
+      do
+	eval "if test \"\${save_$lt_var+set}\" = set; then
+                $lt_var=\$save_$lt_var; export $lt_var
+	      else
+		$lt_unset $lt_var
+	      fi"
+      done
+
+      # Now prepare to actually exec the command.
+      exec_cmd="\$cmd$args"
+    else
+      # Display what would be done.
+      if test -n "$shlibpath_var"; then
+	eval "\$ECHO \"\$shlibpath_var=\$$shlibpath_var\""
+	$ECHO "export $shlibpath_var"
+      fi
+      $ECHO "$cmd$args"
+      exit $EXIT_SUCCESS
+    fi
+}
+
+test "$mode" = execute && func_mode_execute ${1+"$@"}
+
+
+# func_mode_finish arg...
+func_mode_finish ()
+{
+    $opt_debug
+    libdirs="$nonopt"
+    admincmds=
+
+    if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then
+      for dir
+      do
+	libdirs="$libdirs $dir"
+      done
+
+      for libdir in $libdirs; do
+	if test -n "$finish_cmds"; then
+	  # Do each command in the finish commands.
+	  func_execute_cmds "$finish_cmds" 'admincmds="$admincmds
+'"$cmd"'"'
+	fi
+	if test -n "$finish_eval"; then
+	  # Do the single finish_eval.
+	  eval cmds=\"$finish_eval\"
+	  $opt_dry_run || eval "$cmds" || admincmds="$admincmds
+       $cmds"
+	fi
+      done
+    fi
+
+    # Exit here if they wanted silent mode.
+    $opt_silent && exit $EXIT_SUCCESS
+
+    $ECHO "X----------------------------------------------------------------------" | $Xsed
+    $ECHO "Libraries have been installed in:"
+    for libdir in $libdirs; do
+      $ECHO "   $libdir"
+    done
+    $ECHO
+    $ECHO "If you ever happen to want to link against installed libraries"
+    $ECHO "in a given directory, LIBDIR, you must either use libtool, and"
+    $ECHO "specify the full pathname of the library, or use the \`-LLIBDIR'"
+    $ECHO "flag during linking and do at least one of the following:"
+    if test -n "$shlibpath_var"; then
+      $ECHO "   - add LIBDIR to the \`$shlibpath_var' environment variable"
+      $ECHO "     during execution"
+    fi
+    if test -n "$runpath_var"; then
+      $ECHO "   - add LIBDIR to the \`$runpath_var' environment variable"
+      $ECHO "     during linking"
+    fi
+    if test -n "$hardcode_libdir_flag_spec"; then
+      libdir=LIBDIR
+      eval flag=\"$hardcode_libdir_flag_spec\"
+
+      $ECHO "   - use the \`$flag' linker flag"
+    fi
+    if test -n "$admincmds"; then
+      $ECHO "   - have your system administrator run these commands:$admincmds"
+    fi
+    if test -f /etc/ld.so.conf; then
+      $ECHO "   - have your system administrator add LIBDIR to \`/etc/ld.so.conf'"
+    fi
+    $ECHO
+
+    $ECHO "See any operating system documentation about shared libraries for"
+    case $host in
+      solaris2.[6789]|solaris2.1[0-9])
+        $ECHO "more information, such as the ld(1), crle(1) and ld.so(8) manual"
+	$ECHO "pages."
+	;;
+      *)
+        $ECHO "more information, such as the ld(1) and ld.so(8) manual pages."
+        ;;
+    esac
+    $ECHO "X----------------------------------------------------------------------" | $Xsed
+    exit $EXIT_SUCCESS
+}
+
+test "$mode" = finish && func_mode_finish ${1+"$@"}
+
+
+# func_mode_install arg...
+func_mode_install ()
+{
+    $opt_debug
+    # There may be an optional sh(1) argument at the beginning of
+    # install_prog (especially on Windows NT).
+    if test "$nonopt" = "$SHELL" || test "$nonopt" = /bin/sh ||
+       # Allow the use of GNU shtool's install command.
+       $ECHO "X$nonopt" | $GREP shtool >/dev/null; then
+      # Aesthetically quote it.
+      func_quote_for_eval "$nonopt"
+      install_prog="$func_quote_for_eval_result "
+      arg=$1
+      shift
+    else
+      install_prog=
+      arg=$nonopt
+    fi
+
+    # The real first argument should be the name of the installation program.
+    # Aesthetically quote it.
+    func_quote_for_eval "$arg"
+    install_prog="$install_prog$func_quote_for_eval_result"
+
+    # We need to accept at least all the BSD install flags.
+    dest=
+    files=
+    opts=
+    prev=
+    install_type=
+    isdir=no
+    stripme=
+    for arg
+    do
+      if test -n "$dest"; then
+	files="$files $dest"
+	dest=$arg
+	continue
+      fi
+
+      case $arg in
+      -d) isdir=yes ;;
+      -f)
+	case " $install_prog " in
+	*[\\\ /]cp\ *) ;;
+	*) prev=$arg ;;
+	esac
+	;;
+      -g | -m | -o)
+	prev=$arg
+	;;
+      -s)
+	stripme=" -s"
+	continue
+	;;
+      -*)
+	;;
+      *)
+	# If the previous option needed an argument, then skip it.
+	if test -n "$prev"; then
+	  prev=
+	else
+	  dest=$arg
+	  continue
+	fi
+	;;
+      esac
+
+      # Aesthetically quote the argument.
+      func_quote_for_eval "$arg"
+      install_prog="$install_prog $func_quote_for_eval_result"
+    done
+
+    test -z "$install_prog" && \
+      func_fatal_help "you must specify an install program"
+
+    test -n "$prev" && \
+      func_fatal_help "the \`$prev' option requires an argument"
+
+    if test -z "$files"; then
+      if test -z "$dest"; then
+	func_fatal_help "no file or destination specified"
+      else
+	func_fatal_help "you must specify a destination"
+      fi
+    fi
+
+    # Strip any trailing slash from the destination.
+    func_stripname '' '/' "$dest"
+    dest=$func_stripname_result
+
+    # Check to see that the destination is a directory.
+    test -d "$dest" && isdir=yes
+    if test "$isdir" = yes; then
+      destdir="$dest"
+      destname=
+    else
+      func_dirname_and_basename "$dest" "" "."
+      destdir="$func_dirname_result"
+      destname="$func_basename_result"
+
+      # Not a directory, so check to see that there is only one file specified.
+      set dummy $files; shift
+      test "$#" -gt 1 && \
+	func_fatal_help "\`$dest' is not a directory"
+    fi
+    case $destdir in
+    [\\/]* | [A-Za-z]:[\\/]*) ;;
+    *)
+      for file in $files; do
+	case $file in
+	*.lo) ;;
+	*)
+	  func_fatal_help "\`$destdir' must be an absolute directory name"
+	  ;;
+	esac
+      done
+      ;;
+    esac
+
+    # This variable tells wrapper scripts just to set variables rather
+    # than running their programs.
+    libtool_install_magic="$magic"
+
+    staticlibs=
+    future_libdirs=
+    current_libdirs=
+    for file in $files; do
+
+      # Do each installation.
+      case $file in
+      *.$libext)
+	# Do the static libraries later.
+	staticlibs="$staticlibs $file"
+	;;
+
+      *.la)
+	# Check to see that this really is a libtool archive.
+	func_lalib_unsafe_p "$file" \
+	  || func_fatal_help "\`$file' is not a valid libtool archive"
+
+	library_names=
+	old_library=
+	relink_command=
+	func_source "$file"
+
+	# Add the libdir to current_libdirs if it is the destination.
+	if test "X$destdir" = "X$libdir"; then
+	  case "$current_libdirs " in
+	  *" $libdir "*) ;;
+	  *) current_libdirs="$current_libdirs $libdir" ;;
+	  esac
+	else
+	  # Note the libdir as a future libdir.
+	  case "$future_libdirs " in
+	  *" $libdir "*) ;;
+	  *) future_libdirs="$future_libdirs $libdir" ;;
+	  esac
+	fi
+
+	func_dirname "$file" "/" ""
+	dir="$func_dirname_result"
+	dir="$dir$objdir"
+
+	if test -n "$relink_command"; then
+	  # Determine the prefix the user has applied to our future dir.
+	  inst_prefix_dir=`$ECHO "X$destdir" | $Xsed -e "s%$libdir\$%%"`
+
+	  # Don't allow the user to place us outside of our expected
+	  # location b/c this prevents finding dependent libraries that
+	  # are installed to the same prefix.
+	  # At present, this check doesn't affect windows .dll's that
+	  # are installed into $libdir/../bin (currently, that works fine)
+	  # but it's something to keep an eye on.
+	  test "$inst_prefix_dir" = "$destdir" && \
+	    func_fatal_error "error: cannot install \`$file' to a directory not ending in $libdir"
+
+	  if test -n "$inst_prefix_dir"; then
+	    # Stick the inst_prefix_dir data into the link command.
+	    relink_command=`$ECHO "X$relink_command" | $Xsed -e "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%"`
+	  else
+	    relink_command=`$ECHO "X$relink_command" | $Xsed -e "s%@inst_prefix_dir@%%"`
+	  fi
+
+	  func_warning "relinking \`$file'"
+	  func_show_eval "$relink_command" \
+	    'func_fatal_error "error: relink \`$file'\'' with the above command before installing it"'
+	fi
+
+	# See the names of the shared library.
+	set dummy $library_names; shift
+	if test -n "$1"; then
+	  realname="$1"
+	  shift
+
+	  srcname="$realname"
+	  test -n "$relink_command" && srcname="$realname"T
+
+	  # Install the shared library and build the symlinks.
+	  func_show_eval "$install_prog $dir/$srcname $destdir/$realname" \
+	      'exit $?'
+	  tstripme="$stripme"
+	  case $host_os in
+	  cygwin* | mingw* | pw32* | cegcc*)
+	    case $realname in
+	    *.dll.a)
+	      tstripme=""
+	      ;;
+	    esac
+	    ;;
+	  esac
+	  if test -n "$tstripme" && test -n "$striplib"; then
+	    func_show_eval "$striplib $destdir/$realname" 'exit $?'
+	  fi
+
+	  if test "$#" -gt 0; then
+	    # Delete the old symlinks, and create new ones.
+	    # Try `ln -sf' first, because the `ln' binary might depend on
+	    # the symlink we replace!  Solaris /bin/ln does not understand -f,
+	    # so we also need to try rm && ln -s.
+	    for linkname
+	    do
+	      test "$linkname" != "$realname" \
+		&& func_show_eval "(cd $destdir && { $LN_S -f $realname $linkname || { $RM $linkname && $LN_S $realname $linkname; }; })"
+	    done
+	  fi
+
+	  # Do each command in the postinstall commands.
+	  lib="$destdir/$realname"
+	  func_execute_cmds "$postinstall_cmds" 'exit $?'
+	fi
+
+	# Install the pseudo-library for information purposes.
+	func_basename "$file"
+	name="$func_basename_result"
+	instname="$dir/$name"i
+	func_show_eval "$install_prog $instname $destdir/$name" 'exit $?'
+
+	# Maybe install the static library, too.
+	test -n "$old_library" && staticlibs="$staticlibs $dir/$old_library"
+	;;
+
+      *.lo)
+	# Install (i.e. copy) a libtool object.
+
+	# Figure out destination file name, if it wasn't already specified.
+	if test -n "$destname"; then
+	  destfile="$destdir/$destname"
+	else
+	  func_basename "$file"
+	  destfile="$func_basename_result"
+	  destfile="$destdir/$destfile"
+	fi
+
+	# Deduce the name of the destination old-style object file.
+	case $destfile in
+	*.lo)
+	  func_lo2o "$destfile"
+	  staticdest=$func_lo2o_result
+	  ;;
+	*.$objext)
+	  staticdest="$destfile"
+	  destfile=
+	  ;;
+	*)
+	  func_fatal_help "cannot copy a libtool object to \`$destfile'"
+	  ;;
+	esac
+
+	# Install the libtool object if requested.
+	test -n "$destfile" && \
+	  func_show_eval "$install_prog $file $destfile" 'exit $?'
+
+	# Install the old object if enabled.
+	if test "$build_old_libs" = yes; then
+	  # Deduce the name of the old-style object file.
+	  func_lo2o "$file"
+	  staticobj=$func_lo2o_result
+	  func_show_eval "$install_prog \$staticobj \$staticdest" 'exit $?'
+	fi
+	exit $EXIT_SUCCESS
+	;;
+
+      *)
+	# Figure out destination file name, if it wasn't already specified.
+	if test -n "$destname"; then
+	  destfile="$destdir/$destname"
+	else
+	  func_basename "$file"
+	  destfile="$func_basename_result"
+	  destfile="$destdir/$destfile"
+	fi
+
+	# If the file is missing, and there is a .exe on the end, strip it
+	# because it is most likely a libtool script we actually want to
+	# install
+	stripped_ext=""
+	case $file in
+	  *.exe)
+	    if test ! -f "$file"; then
+	      func_stripname '' '.exe' "$file"
+	      file=$func_stripname_result
+	      stripped_ext=".exe"
+	    fi
+	    ;;
+	esac
+
+	# Do a test to see if this is really a libtool program.
+	case $host in
+	*cygwin* | *mingw*)
+	    if func_ltwrapper_executable_p "$file"; then
+	      func_ltwrapper_scriptname "$file"
+	      wrapper=$func_ltwrapper_scriptname_result
+	    else
+	      func_stripname '' '.exe' "$file"
+	      wrapper=$func_stripname_result
+	    fi
+	    ;;
+	*)
+	    wrapper=$file
+	    ;;
+	esac
+	if func_ltwrapper_script_p "$wrapper"; then
+	  notinst_deplibs=
+	  relink_command=
+
+	  func_source "$wrapper"
+
+	  # Check the variables that should have been set.
+	  test -z "$generated_by_libtool_version" && \
+	    func_fatal_error "invalid libtool wrapper script \`$wrapper'"
+
+	  finalize=yes
+	  for lib in $notinst_deplibs; do
+	    # Check to see that each library is installed.
+	    libdir=
+	    if test -f "$lib"; then
+	      func_source "$lib"
+	    fi
+	    libfile="$libdir/"`$ECHO "X$lib" | $Xsed -e 's%^.*/%%g'` ### testsuite: skip nested quoting test
+	    if test -n "$libdir" && test ! -f "$libfile"; then
+	      func_warning "\`$lib' has not been installed in \`$libdir'"
+	      finalize=no
+	    fi
+	  done
+
+	  relink_command=
+	  func_source "$wrapper"
+
+	  outputname=
+	  if test "$fast_install" = no && test -n "$relink_command"; then
+	    $opt_dry_run || {
+	      if test "$finalize" = yes; then
+	        tmpdir=`func_mktempdir`
+		func_basename "$file$stripped_ext"
+		file="$func_basename_result"
+	        outputname="$tmpdir/$file"
+	        # Replace the output file specification.
+	        relink_command=`$ECHO "X$relink_command" | $Xsed -e 's%@OUTPUT@%'"$outputname"'%g'`
+
+	        $opt_silent || {
+	          func_quote_for_expand "$relink_command"
+		  eval "func_echo $func_quote_for_expand_result"
+	        }
+	        if eval "$relink_command"; then :
+	          else
+		  func_error "error: relink \`$file' with the above command before installing it"
+		  $opt_dry_run || ${RM}r "$tmpdir"
+		  continue
+	        fi
+	        file="$outputname"
+	      else
+	        func_warning "cannot relink \`$file'"
+	      fi
+	    }
+	  else
+	    # Install the binary that we compiled earlier.
+	    file=`$ECHO "X$file$stripped_ext" | $Xsed -e "s%\([^/]*\)$%$objdir/\1%"`
+	  fi
+	fi
+
+	# remove .exe since cygwin /usr/bin/install will append another
+	# one anyway
+	case $install_prog,$host in
+	*/usr/bin/install*,*cygwin*)
+	  case $file:$destfile in
+	  *.exe:*.exe)
+	    # this is ok
+	    ;;
+	  *.exe:*)
+	    destfile=$destfile.exe
+	    ;;
+	  *:*.exe)
+	    func_stripname '' '.exe' "$destfile"
+	    destfile=$func_stripname_result
+	    ;;
+	  esac
+	  ;;
+	esac
+	func_show_eval "$install_prog\$stripme \$file \$destfile" 'exit $?'
+	$opt_dry_run || if test -n "$outputname"; then
+	  ${RM}r "$tmpdir"
+	fi
+	;;
+      esac
+    done
+
+    for file in $staticlibs; do
+      func_basename "$file"
+      name="$func_basename_result"
+
+      # Set up the ranlib parameters.
+      oldlib="$destdir/$name"
+
+      func_show_eval "$install_prog \$file \$oldlib" 'exit $?'
+
+      if test -n "$stripme" && test -n "$old_striplib"; then
+	func_show_eval "$old_striplib $oldlib" 'exit $?'
+      fi
+
+      # Do each command in the postinstall commands.
+      func_execute_cmds "$old_postinstall_cmds" 'exit $?'
+    done
+
+    test -n "$future_libdirs" && \
+      func_warning "remember to run \`$progname --finish$future_libdirs'"
+
+    if test -n "$current_libdirs"; then
+      # Maybe just do a dry run.
+      $opt_dry_run && current_libdirs=" -n$current_libdirs"
+      exec_cmd='$SHELL $progpath $preserve_args --finish$current_libdirs'
+    else
+      exit $EXIT_SUCCESS
+    fi
+}
+
+test "$mode" = install && func_mode_install ${1+"$@"}
+
+
+# func_generate_dlsyms outputname originator pic_p
+# Extract symbols from dlprefiles and create ${outputname}S.o with
+# a dlpreopen symbol table.
+func_generate_dlsyms ()
+{
+    $opt_debug
+    my_outputname="$1"
+    my_originator="$2"
+    my_pic_p="${3-no}"
+    my_prefix=`$ECHO "$my_originator" | sed 's%[^a-zA-Z0-9]%_%g'`
+    my_dlsyms=
+
+    if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
+      if test -n "$NM" && test -n "$global_symbol_pipe"; then
+	my_dlsyms="${my_outputname}S.c"
+      else
+	func_error "not configured to extract global symbols from dlpreopened files"
+      fi
+    fi
+
+    if test -n "$my_dlsyms"; then
+      case $my_dlsyms in
+      "") ;;
+      *.c)
+	# Discover the nlist of each of the dlfiles.
+	nlist="$output_objdir/${my_outputname}.nm"
+
+	func_show_eval "$RM $nlist ${nlist}S ${nlist}T"
+
+	# Parse the name list into a source file.
+	func_verbose "creating $output_objdir/$my_dlsyms"
+
+	$opt_dry_run || $ECHO > "$output_objdir/$my_dlsyms" "\
+/* $my_dlsyms - symbol resolution table for \`$my_outputname' dlsym emulation. */
+/* Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION */
+
+#ifdef __cplusplus
+extern \"C\" {
+#endif
+
+/* External symbol declarations for the compiler. */\
+"
+
+	if test "$dlself" = yes; then
+	  func_verbose "generating symbol list for \`$output'"
+
+	  $opt_dry_run || echo ': @PROGRAM@ ' > "$nlist"
+
+	  # Add our own program objects to the symbol list.
+	  progfiles=`$ECHO "X$objs$old_deplibs" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP`
+	  for progfile in $progfiles; do
+	    func_verbose "extracting global C symbols from \`$progfile'"
+	    $opt_dry_run || eval "$NM $progfile | $global_symbol_pipe >> '$nlist'"
+	  done
+
+	  if test -n "$exclude_expsyms"; then
+	    $opt_dry_run || {
+	      eval '$EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T'
+	      eval '$MV "$nlist"T "$nlist"'
+	    }
+	  fi
+
+	  if test -n "$export_symbols_regex"; then
+	    $opt_dry_run || {
+	      eval '$EGREP -e "$export_symbols_regex" "$nlist" > "$nlist"T'
+	      eval '$MV "$nlist"T "$nlist"'
+	    }
+	  fi
+
+	  # Prepare the list of exported symbols
+	  if test -z "$export_symbols"; then
+	    export_symbols="$output_objdir/$outputname.exp"
+	    $opt_dry_run || {
+	      $RM $export_symbols
+	      eval "${SED} -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"'
+	      case $host in
+	      *cygwin* | *mingw* | *cegcc* )
+                eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'
+                eval 'cat "$export_symbols" >> "$output_objdir/$outputname.def"'
+	        ;;
+	      esac
+	    }
+	  else
+	    $opt_dry_run || {
+	      eval "${SED} -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"'
+	      eval '$GREP -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T'
+	      eval '$MV "$nlist"T "$nlist"'
+	      case $host in
+	        *cygwin | *mingw* | *cegcc* )
+	          eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'
+	          eval 'cat "$nlist" >> "$output_objdir/$outputname.def"'
+	          ;;
+	      esac
+	    }
+	  fi
+	fi
+
+	for dlprefile in $dlprefiles; do
+	  func_verbose "extracting global C symbols from \`$dlprefile'"
+	  func_basename "$dlprefile"
+	  name="$func_basename_result"
+	  $opt_dry_run || {
+	    eval '$ECHO ": $name " >> "$nlist"'
+	    eval "$NM $dlprefile 2>/dev/null | $global_symbol_pipe >> '$nlist'"
+	  }
+	done
+
+	$opt_dry_run || {
+	  # Make sure we have at least an empty file.
+	  test -f "$nlist" || : > "$nlist"
+
+	  if test -n "$exclude_expsyms"; then
+	    $EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T
+	    $MV "$nlist"T "$nlist"
+	  fi
+
+	  # Try sorting and uniquifying the output.
+	  if $GREP -v "^: " < "$nlist" |
+	      if sort -k 3 </dev/null >/dev/null 2>&1; then
+		sort -k 3
+	      else
+		sort +2
+	      fi |
+	      uniq > "$nlist"S; then
+	    :
+	  else
+	    $GREP -v "^: " < "$nlist" > "$nlist"S
+	  fi
+
+	  if test -f "$nlist"S; then
+	    eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$my_dlsyms"'
+	  else
+	    $ECHO '/* NONE */' >> "$output_objdir/$my_dlsyms"
+	  fi
+
+	  $ECHO >> "$output_objdir/$my_dlsyms" "\
+
+/* The mapping between symbol names and symbols.  */
+typedef struct {
+  const char *name;
+  void *address;
+} lt_dlsymlist;
+"
+	  case $host in
+	  *cygwin* | *mingw* | *cegcc* )
+	    $ECHO >> "$output_objdir/$my_dlsyms" "\
+/* DATA imports from DLLs on WIN32 con't be const, because
+   runtime relocations are performed -- see ld's documentation
+   on pseudo-relocs.  */"
+	    lt_dlsym_const= ;;
+	  *osf5*)
+	    echo >> "$output_objdir/$my_dlsyms" "\
+/* This system does not cope well with relocations in const data */"
+	    lt_dlsym_const= ;;
+	  *)
+	    lt_dlsym_const=const ;;
+	  esac
+
+	  $ECHO >> "$output_objdir/$my_dlsyms" "\
+extern $lt_dlsym_const lt_dlsymlist
+lt_${my_prefix}_LTX_preloaded_symbols[];
+$lt_dlsym_const lt_dlsymlist
+lt_${my_prefix}_LTX_preloaded_symbols[] =
+{\
+  { \"$my_originator\", (void *) 0 },"
+
+	  case $need_lib_prefix in
+	  no)
+	    eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$my_dlsyms"
+	    ;;
+	  *)
+	    eval "$global_symbol_to_c_name_address_lib_prefix" < "$nlist" >> "$output_objdir/$my_dlsyms"
+	    ;;
+	  esac
+	  $ECHO >> "$output_objdir/$my_dlsyms" "\
+  {0, (void *) 0}
+};
+
+/* This works around a problem in FreeBSD linker */
+#ifdef FREEBSD_WORKAROUND
+static const void *lt_preloaded_setup() {
+  return lt_${my_prefix}_LTX_preloaded_symbols;
+}
+#endif
+
+#ifdef __cplusplus
+}
+#endif\
+"
+	} # !$opt_dry_run
+
+	pic_flag_for_symtable=
+	case "$compile_command " in
+	*" -static "*) ;;
+	*)
+	  case $host in
+	  # compiling the symbol table file with pic_flag works around
+	  # a FreeBSD bug that causes programs to crash when -lm is
+	  # linked before any other PIC object.  But we must not use
+	  # pic_flag when linking with -static.  The problem exists in
+	  # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1.
+	  *-*-freebsd2*|*-*-freebsd3.0*|*-*-freebsdelf3.0*)
+	    pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND" ;;
+	  *-*-hpux*)
+	    pic_flag_for_symtable=" $pic_flag"  ;;
+	  *)
+	    if test "X$my_pic_p" != Xno; then
+	      pic_flag_for_symtable=" $pic_flag"
+	    fi
+	    ;;
+	  esac
+	  ;;
+	esac
+	symtab_cflags=
+	for arg in $LTCFLAGS; do
+	  case $arg in
+	  -pie | -fpie | -fPIE) ;;
+	  *) symtab_cflags="$symtab_cflags $arg" ;;
+	  esac
+	done
+
+	# Now compile the dynamic symbol file.
+	func_show_eval '(cd $output_objdir && $LTCC$symtab_cflags -c$no_builtin_flag$pic_flag_for_symtable "$my_dlsyms")' 'exit $?'
+
+	# Clean up the generated files.
+	func_show_eval '$RM "$output_objdir/$my_dlsyms" "$nlist" "${nlist}S" "${nlist}T"'
+
+	# Transform the symbol file into the correct name.
+	symfileobj="$output_objdir/${my_outputname}S.$objext"
+	case $host in
+	*cygwin* | *mingw* | *cegcc* )
+	  if test -f "$output_objdir/$my_outputname.def"; then
+	    compile_command=`$ECHO "X$compile_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"`
+	    finalize_command=`$ECHO "X$finalize_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"`
+	  else
+	    compile_command=`$ECHO "X$compile_command" | $Xsed -e "s%@SYMFILE@%$symfileobj%"`
+	    finalize_command=`$ECHO "X$finalize_command" | $Xsed -e "s%@SYMFILE@%$symfileobj%"`
+	  fi
+	  ;;
+	*)
+	  compile_command=`$ECHO "X$compile_command" | $Xsed -e "s%@SYMFILE@%$symfileobj%"`
+	  finalize_command=`$ECHO "X$finalize_command" | $Xsed -e "s%@SYMFILE@%$symfileobj%"`
+	  ;;
+	esac
+	;;
+      *)
+	func_fatal_error "unknown suffix for \`$my_dlsyms'"
+	;;
+      esac
+    else
+      # We keep going just in case the user didn't refer to
+      # lt_preloaded_symbols.  The linker will fail if global_symbol_pipe
+      # really was required.
+
+      # Nullify the symbol file.
+      compile_command=`$ECHO "X$compile_command" | $Xsed -e "s% @SYMFILE@%%"`
+      finalize_command=`$ECHO "X$finalize_command" | $Xsed -e "s% @SYMFILE@%%"`
+    fi
+}
+
+# func_win32_libid arg
+# return the library type of file 'arg'
+#
+# Need a lot of goo to handle *both* DLLs and import libs
+# Has to be a shell function in order to 'eat' the argument
+# that is supplied when $file_magic_command is called.
+func_win32_libid ()
+{
+  $opt_debug
+  win32_libid_type="unknown"
+  win32_fileres=`file -L $1 2>/dev/null`
+  case $win32_fileres in
+  *ar\ archive\ import\ library*) # definitely import
+    win32_libid_type="x86 archive import"
+    ;;
+  *ar\ archive*) # could be an import, or static
+    if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null |
+       $EGREP 'file format pe-i386(.*architecture: i386)?' >/dev/null ; then
+      win32_nmres=`eval $NM -f posix -A $1 |
+	$SED -n -e '
+	    1,100{
+		/ I /{
+		    s,.*,import,
+		    p
+		    q
+		}
+	    }'`
+      case $win32_nmres in
+      import*)  win32_libid_type="x86 archive import";;
+      *)        win32_libid_type="x86 archive static";;
+      esac
+    fi
+    ;;
+  *DLL*)
+    win32_libid_type="x86 DLL"
+    ;;
+  *executable*) # but shell scripts are "executable" too...
+    case $win32_fileres in
+    *MS\ Windows\ PE\ Intel*)
+      win32_libid_type="x86 DLL"
+      ;;
+    esac
+    ;;
+  esac
+  $ECHO "$win32_libid_type"
+}
+
+
+
+# func_extract_an_archive dir oldlib
+func_extract_an_archive ()
+{
+    $opt_debug
+    f_ex_an_ar_dir="$1"; shift
+    f_ex_an_ar_oldlib="$1"
+    func_show_eval "(cd \$f_ex_an_ar_dir && $AR x \"\$f_ex_an_ar_oldlib\")" 'exit $?'
+    if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then
+     :
+    else
+      func_fatal_error "object name conflicts in archive: $f_ex_an_ar_dir/$f_ex_an_ar_oldlib"
+    fi
+}
+
+
+# func_extract_archives gentop oldlib ...
+func_extract_archives ()
+{
+    $opt_debug
+    my_gentop="$1"; shift
+    my_oldlibs=${1+"$@"}
+    my_oldobjs=""
+    my_xlib=""
+    my_xabs=""
+    my_xdir=""
+
+    for my_xlib in $my_oldlibs; do
+      # Extract the objects.
+      case $my_xlib in
+	[\\/]* | [A-Za-z]:[\\/]*) my_xabs="$my_xlib" ;;
+	*) my_xabs=`pwd`"/$my_xlib" ;;
+      esac
+      func_basename "$my_xlib"
+      my_xlib="$func_basename_result"
+      my_xlib_u=$my_xlib
+      while :; do
+        case " $extracted_archives " in
+	*" $my_xlib_u "*)
+	  func_arith $extracted_serial + 1
+	  extracted_serial=$func_arith_result
+	  my_xlib_u=lt$extracted_serial-$my_xlib ;;
+	*) break ;;
+	esac
+      done
+      extracted_archives="$extracted_archives $my_xlib_u"
+      my_xdir="$my_gentop/$my_xlib_u"
+
+      func_mkdir_p "$my_xdir"
+
+      case $host in
+      *-darwin*)
+	func_verbose "Extracting $my_xabs"
+	# Do not bother doing anything if just a dry run
+	$opt_dry_run || {
+	  darwin_orig_dir=`pwd`
+	  cd $my_xdir || exit $?
+	  darwin_archive=$my_xabs
+	  darwin_curdir=`pwd`
+	  darwin_base_archive=`basename "$darwin_archive"`
+	  darwin_arches=`$LIPO -info "$darwin_archive" 2>/dev/null | $GREP Architectures 2>/dev/null || true`
+	  if test -n "$darwin_arches"; then
+	    darwin_arches=`$ECHO "$darwin_arches" | $SED -e 's/.*are://'`
+	    darwin_arch=
+	    func_verbose "$darwin_base_archive has multiple architectures $darwin_arches"
+	    for darwin_arch in  $darwin_arches ; do
+	      func_mkdir_p "unfat-$$/${darwin_base_archive}-${darwin_arch}"
+	      $LIPO -thin $darwin_arch -output "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}" "${darwin_archive}"
+	      cd "unfat-$$/${darwin_base_archive}-${darwin_arch}"
+	      func_extract_an_archive "`pwd`" "${darwin_base_archive}"
+	      cd "$darwin_curdir"
+	      $RM "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}"
+	    done # $darwin_arches
+            ## Okay now we've a bunch of thin objects, gotta fatten them up :)
+	    darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print | $SED -e "$basename" | sort -u`
+	    darwin_file=
+	    darwin_files=
+	    for darwin_file in $darwin_filelist; do
+	      darwin_files=`find unfat-$$ -name $darwin_file -print | $NL2SP`
+	      $LIPO -create -output "$darwin_file" $darwin_files
+	    done # $darwin_filelist
+	    $RM -rf unfat-$$
+	    cd "$darwin_orig_dir"
+	  else
+	    cd $darwin_orig_dir
+	    func_extract_an_archive "$my_xdir" "$my_xabs"
+	  fi # $darwin_arches
+	} # !$opt_dry_run
+	;;
+      *)
+        func_extract_an_archive "$my_xdir" "$my_xabs"
+	;;
+      esac
+      my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | $NL2SP`
+    done
+
+    func_extract_archives_result="$my_oldobjs"
+}
+
+
+
+# func_emit_wrapper_part1 [arg=no]
+#
+# Emit the first part of a libtool wrapper script on stdout.
+# For more information, see the description associated with
+# func_emit_wrapper(), below.
+func_emit_wrapper_part1 ()
+{
+	func_emit_wrapper_part1_arg1=no
+	if test -n "$1" ; then
+	  func_emit_wrapper_part1_arg1=$1
+	fi
+
+	$ECHO "\
+#! $SHELL
+
+# $output - temporary wrapper script for $objdir/$outputname
+# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
+#
+# The $output program cannot be directly executed until all the libtool
+# libraries that it depends on are installed.
+#
+# This wrapper script should never be moved out of the build directory.
+# If it is, it will not operate correctly.
+
+# Sed substitution that helps us do robust quoting.  It backslashifies
+# metacharacters that are still active within double-quoted strings.
+Xsed='${SED} -e 1s/^X//'
+sed_quote_subst='$sed_quote_subst'
+
+# Be Bourne compatible
+if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then
+  emulate sh
+  NULLCMD=:
+  # Zsh 3.x and 4.x performs word splitting on \${1+\"\$@\"}, which
+  # is contrary to our usage.  Disable this feature.
+  alias -g '\${1+\"\$@\"}'='\"\$@\"'
+  setopt NO_GLOB_SUBST
+else
+  case \`(set -o) 2>/dev/null\` in *posix*) set -o posix;; esac
+fi
+BIN_SH=xpg4; export BIN_SH # for Tru64
+DUALCASE=1; export DUALCASE # for MKS sh
+
+# The HP-UX ksh and POSIX shell print the target directory to stdout
+# if CDPATH is set.
+(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
+
+relink_command=\"$relink_command\"
+
+# This environment variable determines our operation mode.
+if test \"\$libtool_install_magic\" = \"$magic\"; then
+  # install mode needs the following variables:
+  generated_by_libtool_version='$macro_version'
+  notinst_deplibs='$notinst_deplibs'
+else
+  # When we are sourced in execute mode, \$file and \$ECHO are already set.
+  if test \"\$libtool_execute_magic\" != \"$magic\"; then
+    ECHO=\"$qecho\"
+    file=\"\$0\"
+    # Make sure echo works.
+    if test \"X\$1\" = X--no-reexec; then
+      # Discard the --no-reexec flag, and continue.
+      shift
+    elif test \"X\`{ \$ECHO '\t'; } 2>/dev/null\`\" = 'X\t'; then
+      # Yippee, \$ECHO works!
+      :
+    else
+      # Restart under the correct shell, and then maybe \$ECHO will work.
+      exec $SHELL \"\$0\" --no-reexec \${1+\"\$@\"}
+    fi
+  fi\
+"
+	$ECHO "\
+
+  # Find the directory that this script lives in.
+  thisdir=\`\$ECHO \"X\$file\" | \$Xsed -e 's%/[^/]*$%%'\`
+  test \"x\$thisdir\" = \"x\$file\" && thisdir=.
+
+  # Follow symbolic links until we get to the real thisdir.
+  file=\`ls -ld \"\$file\" | ${SED} -n 's/.*-> //p'\`
+  while test -n \"\$file\"; do
+    destdir=\`\$ECHO \"X\$file\" | \$Xsed -e 's%/[^/]*\$%%'\`
+
+    # If there was a directory component, then change thisdir.
+    if test \"x\$destdir\" != \"x\$file\"; then
+      case \"\$destdir\" in
+      [\\\\/]* | [A-Za-z]:[\\\\/]*) thisdir=\"\$destdir\" ;;
+      *) thisdir=\"\$thisdir/\$destdir\" ;;
+      esac
+    fi
+
+    file=\`\$ECHO \"X\$file\" | \$Xsed -e 's%^.*/%%'\`
+    file=\`ls -ld \"\$thisdir/\$file\" | ${SED} -n 's/.*-> //p'\`
+  done
+"
+}
+# end: func_emit_wrapper_part1
+
+# func_emit_wrapper_part2 [arg=no]
+#
+# Emit the second part of a libtool wrapper script on stdout.
+# For more information, see the description associated with
+# func_emit_wrapper(), below.
+func_emit_wrapper_part2 ()
+{
+	func_emit_wrapper_part2_arg1=no
+	if test -n "$1" ; then
+	  func_emit_wrapper_part2_arg1=$1
+	fi
+
+	$ECHO "\
+
+  # Usually 'no', except on cygwin/mingw when embedded into
+  # the cwrapper.
+  WRAPPER_SCRIPT_BELONGS_IN_OBJDIR=$func_emit_wrapper_part2_arg1
+  if test \"\$WRAPPER_SCRIPT_BELONGS_IN_OBJDIR\" = \"yes\"; then
+    # special case for '.'
+    if test \"\$thisdir\" = \".\"; then
+      thisdir=\`pwd\`
+    fi
+    # remove .libs from thisdir
+    case \"\$thisdir\" in
+    *[\\\\/]$objdir ) thisdir=\`\$ECHO \"X\$thisdir\" | \$Xsed -e 's%[\\\\/][^\\\\/]*$%%'\` ;;
+    $objdir )   thisdir=. ;;
+    esac
+  fi
+
+  # Try to get the absolute directory name.
+  absdir=\`cd \"\$thisdir\" && pwd\`
+  test -n \"\$absdir\" && thisdir=\"\$absdir\"
+"
+
+	if test "$fast_install" = yes; then
+	  $ECHO "\
+  program=lt-'$outputname'$exeext
+  progdir=\"\$thisdir/$objdir\"
+
+  if test ! -f \"\$progdir/\$program\" ||
+     { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | ${SED} 1q\`; \\
+       test \"X\$file\" != \"X\$progdir/\$program\"; }; then
+
+    file=\"\$\$-\$program\"
+
+    if test ! -d \"\$progdir\"; then
+      $MKDIR \"\$progdir\"
+    else
+      $RM \"\$progdir/\$file\"
+    fi"
+
+	  $ECHO "\
+
+    # relink executable if necessary
+    if test -n \"\$relink_command\"; then
+      if relink_command_output=\`eval \$relink_command 2>&1\`; then :
+      else
+	$ECHO \"\$relink_command_output\" >&2
+	$RM \"\$progdir/\$file\"
+	exit 1
+      fi
+    fi
+
+    $MV \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null ||
+    { $RM \"\$progdir/\$program\";
+      $MV \"\$progdir/\$file\" \"\$progdir/\$program\"; }
+    $RM \"\$progdir/\$file\"
+  fi"
+	else
+	  $ECHO "\
+  program='$outputname'
+  progdir=\"\$thisdir/$objdir\"
+"
+	fi
+
+	$ECHO "\
+
+  if test -f \"\$progdir/\$program\"; then"
+
+	# Export our shlibpath_var if we have one.
+	if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then
+	  $ECHO "\
+    # Add our own library path to $shlibpath_var
+    $shlibpath_var=\"$temp_rpath\$$shlibpath_var\"
+
+    # Some systems cannot cope with colon-terminated $shlibpath_var
+    # The second colon is a workaround for a bug in BeOS R4 sed
+    $shlibpath_var=\`\$ECHO \"X\$$shlibpath_var\" | \$Xsed -e 's/::*\$//'\`
+
+    export $shlibpath_var
+"
+	fi
+
+	# fixup the dll searchpath if we need to.
+	if test -n "$dllsearchpath"; then
+	  $ECHO "\
+    # Add the dll search path components to the executable PATH
+    PATH=$dllsearchpath:\$PATH
+"
+	fi
+
+	$ECHO "\
+    if test \"\$libtool_execute_magic\" != \"$magic\"; then
+      # Run the actual program with our arguments.
+"
+	case $host in
+	# Backslashes separate directories on plain windows
+	*-*-mingw | *-*-os2* | *-cegcc*)
+	  $ECHO "\
+      exec \"\$progdir\\\\\$program\" \${1+\"\$@\"}
+"
+	  ;;
+
+	*)
+	  $ECHO "\
+      exec \"\$progdir/\$program\" \${1+\"\$@\"}
+"
+	  ;;
+	esac
+	$ECHO "\
+      \$ECHO \"\$0: cannot exec \$program \$*\" 1>&2
+      exit 1
+    fi
+  else
+    # The program doesn't exist.
+    \$ECHO \"\$0: error: \\\`\$progdir/\$program' does not exist\" 1>&2
+    \$ECHO \"This script is just a wrapper for \$program.\" 1>&2
+    $ECHO \"See the $PACKAGE documentation for more information.\" 1>&2
+    exit 1
+  fi
+fi\
+"
+}
+# end: func_emit_wrapper_part2
+
+
+# func_emit_wrapper [arg=no]
+#
+# Emit a libtool wrapper script on stdout.
+# Don't directly open a file because we may want to
+# incorporate the script contents within a cygwin/mingw
+# wrapper executable.  Must ONLY be called from within
+# func_mode_link because it depends on a number of variables
+# set therein.
+#
+# ARG is the value that the WRAPPER_SCRIPT_BELONGS_IN_OBJDIR
+# variable will take.  If 'yes', then the emitted script
+# will assume that the directory in which it is stored is
+# the $objdir directory.  This is a cygwin/mingw-specific
+# behavior.
+func_emit_wrapper ()
+{
+	func_emit_wrapper_arg1=no
+	if test -n "$1" ; then
+	  func_emit_wrapper_arg1=$1
+	fi
+
+	# split this up so that func_emit_cwrapperexe_src
+	# can call each part independently.
+	func_emit_wrapper_part1 "${func_emit_wrapper_arg1}"
+	func_emit_wrapper_part2 "${func_emit_wrapper_arg1}"
+}
+
+
+# func_to_host_path arg
+#
+# Convert paths to host format when used with build tools.
+# Intended for use with "native" mingw (where libtool itself
+# is running under the msys shell), or in the following cross-
+# build environments:
+#    $build          $host
+#    mingw (msys)    mingw  [e.g. native]
+#    cygwin          mingw
+#    *nix + wine     mingw
+# where wine is equipped with the `winepath' executable.
+# In the native mingw case, the (msys) shell automatically
+# converts paths for any non-msys applications it launches,
+# but that facility isn't available from inside the cwrapper.
+# Similar accommodations are necessary for $host mingw and
+# $build cygwin.  Calling this function does no harm for other
+# $host/$build combinations not listed above.
+#
+# ARG is the path (on $build) that should be converted to
+# the proper representation for $host. The result is stored
+# in $func_to_host_path_result.
+func_to_host_path ()
+{
+  func_to_host_path_result="$1"
+  if test -n "$1" ; then
+    case $host in
+      *mingw* )
+        lt_sed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g'
+        case $build in
+          *mingw* ) # actually, msys
+            # awkward: cmd appends spaces to result
+            lt_sed_strip_trailing_spaces="s/[ ]*\$//"
+            func_to_host_path_tmp1=`( cmd //c echo "$1" |\
+              $SED -e "$lt_sed_strip_trailing_spaces" ) 2>/dev/null || echo ""`
+            func_to_host_path_result=`echo "$func_to_host_path_tmp1" |\
+              $SED -e "$lt_sed_naive_backslashify"`
+            ;;
+          *cygwin* )
+            func_to_host_path_tmp1=`cygpath -w "$1"`
+            func_to_host_path_result=`echo "$func_to_host_path_tmp1" |\
+              $SED -e "$lt_sed_naive_backslashify"`
+            ;;
+          * )
+            # Unfortunately, winepath does not exit with a non-zero
+            # error code, so we are forced to check the contents of
+            # stdout. On the other hand, if the command is not
+            # found, the shell will set an exit code of 127 and print
+            # *an error message* to stdout. So we must check for both
+            # error code of zero AND non-empty stdout, which explains
+            # the odd construction:
+            func_to_host_path_tmp1=`winepath -w "$1" 2>/dev/null`
+            if test "$?" -eq 0 && test -n "${func_to_host_path_tmp1}"; then
+              func_to_host_path_result=`echo "$func_to_host_path_tmp1" |\
+                $SED -e "$lt_sed_naive_backslashify"`
+            else
+              # Allow warning below.
+              func_to_host_path_result=""
+            fi
+            ;;
+        esac
+        if test -z "$func_to_host_path_result" ; then
+          func_error "Could not determine host path corresponding to"
+          func_error "  '$1'"
+          func_error "Continuing, but uninstalled executables may not work."
+          # Fallback:
+          func_to_host_path_result="$1"
+        fi
+        ;;
+    esac
+  fi
+}
+# end: func_to_host_path
+
+# func_to_host_pathlist arg
+#
+# Convert pathlists to host format when used with build tools.
+# See func_to_host_path(), above. This function supports the
+# following $build/$host combinations (but does no harm for
+# combinations not listed here):
+#    $build          $host
+#    mingw (msys)    mingw  [e.g. native]
+#    cygwin          mingw
+#    *nix + wine     mingw
+#
+# Path separators are also converted from $build format to
+# $host format. If ARG begins or ends with a path separator
+# character, it is preserved (but converted to $host format)
+# on output.
+#
+# ARG is a pathlist (on $build) that should be converted to
+# the proper representation on $host. The result is stored
+# in $func_to_host_pathlist_result.
+func_to_host_pathlist ()
+{
+  func_to_host_pathlist_result="$1"
+  if test -n "$1" ; then
+    case $host in
+      *mingw* )
+        lt_sed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g'
+        # Remove leading and trailing path separator characters from
+        # ARG. msys behavior is inconsistent here, cygpath turns them
+        # into '.;' and ';.', and winepath ignores them completely.
+        func_to_host_pathlist_tmp2="$1"
+        # Once set for this call, this variable should not be
+        # reassigned. It is used in tha fallback case.
+        func_to_host_pathlist_tmp1=`echo "$func_to_host_pathlist_tmp2" |\
+          $SED -e 's|^:*||' -e 's|:*$||'`
+        case $build in
+          *mingw* ) # Actually, msys.
+            # Awkward: cmd appends spaces to result.
+            lt_sed_strip_trailing_spaces="s/[ ]*\$//"
+            func_to_host_pathlist_tmp2=`( cmd //c echo "$func_to_host_pathlist_tmp1" |\
+              $SED -e "$lt_sed_strip_trailing_spaces" ) 2>/dev/null || echo ""`
+            func_to_host_pathlist_result=`echo "$func_to_host_pathlist_tmp2" |\
+              $SED -e "$lt_sed_naive_backslashify"`
+            ;;
+          *cygwin* )
+            func_to_host_pathlist_tmp2=`cygpath -w -p "$func_to_host_pathlist_tmp1"`
+            func_to_host_pathlist_result=`echo "$func_to_host_pathlist_tmp2" |\
+              $SED -e "$lt_sed_naive_backslashify"`
+            ;;
+          * )
+            # unfortunately, winepath doesn't convert pathlists
+            func_to_host_pathlist_result=""
+            func_to_host_pathlist_oldIFS=$IFS
+            IFS=:
+            for func_to_host_pathlist_f in $func_to_host_pathlist_tmp1 ; do
+              IFS=$func_to_host_pathlist_oldIFS
+              if test -n "$func_to_host_pathlist_f" ; then
+                func_to_host_path "$func_to_host_pathlist_f"
+                if test -n "$func_to_host_path_result" ; then
+                  if test -z "$func_to_host_pathlist_result" ; then
+                    func_to_host_pathlist_result="$func_to_host_path_result"
+                  else
+                    func_to_host_pathlist_result="$func_to_host_pathlist_result;$func_to_host_path_result"
+                  fi
+                fi
+              fi
+              IFS=:
+            done
+            IFS=$func_to_host_pathlist_oldIFS
+            ;;
+        esac
+        if test -z "$func_to_host_pathlist_result" ; then
+          func_error "Could not determine the host path(s) corresponding to"
+          func_error "  '$1'"
+          func_error "Continuing, but uninstalled executables may not work."
+          # Fallback. This may break if $1 contains DOS-style drive
+          # specifications. The fix is not to complicate the expression
+          # below, but for the user to provide a working wine installation
+          # with winepath so that path translation in the cross-to-mingw
+          # case works properly.
+          lt_replace_pathsep_nix_to_dos="s|:|;|g"
+          func_to_host_pathlist_result=`echo "$func_to_host_pathlist_tmp1" |\
+            $SED -e "$lt_replace_pathsep_nix_to_dos"`
+        fi
+        # Now, add the leading and trailing path separators back
+        case "$1" in
+          :* ) func_to_host_pathlist_result=";$func_to_host_pathlist_result"
+            ;;
+        esac
+        case "$1" in
+          *: ) func_to_host_pathlist_result="$func_to_host_pathlist_result;"
+            ;;
+        esac
+        ;;
+    esac
+  fi
+}
+# end: func_to_host_pathlist
+
+# func_emit_cwrapperexe_src
+# emit the source code for a wrapper executable on stdout
+# Must ONLY be called from within func_mode_link because
+# it depends on a number of variable set therein.
+func_emit_cwrapperexe_src ()
+{
+	cat <<EOF
+
+/* $cwrappersource - temporary wrapper executable for $objdir/$outputname
+   Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
+
+   The $output program cannot be directly executed until all the libtool
+   libraries that it depends on are installed.
+
+   This wrapper executable should never be moved out of the build directory.
+   If it is, it will not operate correctly.
+
+   Currently, it simply execs the wrapper *script* "$SHELL $output",
+   but could eventually absorb all of the scripts functionality and
+   exec $objdir/$outputname directly.
+*/
+EOF
+	    cat <<"EOF"
+#include <stdio.h>
+#include <stdlib.h>
+#ifdef _MSC_VER
+# include <direct.h>
+# include <process.h>
+# include <io.h>
+# define setmode _setmode
+#else
+# include <unistd.h>
+# include <stdint.h>
+# ifdef __CYGWIN__
+#  include <io.h>
+#  define HAVE_SETENV
+#  ifdef __STRICT_ANSI__
+char *realpath (const char *, char *);
+int putenv (char *);
+int setenv (const char *, const char *, int);
+#  endif
+# endif
+#endif
+#include <malloc.h>
+#include <stdarg.h>
+#include <assert.h>
+#include <string.h>
+#include <ctype.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <sys/stat.h>
+
+#if defined(PATH_MAX)
+# define LT_PATHMAX PATH_MAX
+#elif defined(MAXPATHLEN)
+# define LT_PATHMAX MAXPATHLEN
+#else
+# define LT_PATHMAX 1024
+#endif
+
+#ifndef S_IXOTH
+# define S_IXOTH 0
+#endif
+#ifndef S_IXGRP
+# define S_IXGRP 0
+#endif
+
+#ifdef _MSC_VER
+# define S_IXUSR _S_IEXEC
+# define stat _stat
+# ifndef _INTPTR_T_DEFINED
+#  define intptr_t int
+# endif
+#endif
+
+#ifndef DIR_SEPARATOR
+# define DIR_SEPARATOR '/'
+# define PATH_SEPARATOR ':'
+#endif
+
+#if defined (_WIN32) || defined (__MSDOS__) || defined (__DJGPP__) || \
+  defined (__OS2__)
+# define HAVE_DOS_BASED_FILE_SYSTEM
+# define FOPEN_WB "wb"
+# ifndef DIR_SEPARATOR_2
+#  define DIR_SEPARATOR_2 '\\'
+# endif
+# ifndef PATH_SEPARATOR_2
+#  define PATH_SEPARATOR_2 ';'
+# endif
+#endif
+
+#ifndef DIR_SEPARATOR_2
+# define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR)
+#else /* DIR_SEPARATOR_2 */
+# define IS_DIR_SEPARATOR(ch) \
+	(((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2))
+#endif /* DIR_SEPARATOR_2 */
+
+#ifndef PATH_SEPARATOR_2
+# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR)
+#else /* PATH_SEPARATOR_2 */
+# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR_2)
+#endif /* PATH_SEPARATOR_2 */
+
+#ifdef __CYGWIN__
+# define FOPEN_WB "wb"
+#endif
+
+#ifndef FOPEN_WB
+# define FOPEN_WB "w"
+#endif
+#ifndef _O_BINARY
+# define _O_BINARY 0
+#endif
+
+#define XMALLOC(type, num)      ((type *) xmalloc ((num) * sizeof(type)))
+#define XFREE(stale) do { \
+  if (stale) { free ((void *) stale); stale = 0; } \
+} while (0)
+
+#undef LTWRAPPER_DEBUGPRINTF
+#if defined DEBUGWRAPPER
+# define LTWRAPPER_DEBUGPRINTF(args) ltwrapper_debugprintf args
+static void
+ltwrapper_debugprintf (const char *fmt, ...)
+{
+    va_list args;
+    va_start (args, fmt);
+    (void) vfprintf (stderr, fmt, args);
+    va_end (args);
+}
+#else
+# define LTWRAPPER_DEBUGPRINTF(args)
+#endif
+
+const char *program_name = NULL;
+
+void *xmalloc (size_t num);
+char *xstrdup (const char *string);
+const char *base_name (const char *name);
+char *find_executable (const char *wrapper);
+char *chase_symlinks (const char *pathspec);
+int make_executable (const char *path);
+int check_executable (const char *path);
+char *strendzap (char *str, const char *pat);
+void lt_fatal (const char *message, ...);
+void lt_setenv (const char *name, const char *value);
+char *lt_extend_str (const char *orig_value, const char *add, int to_end);
+void lt_opt_process_env_set (const char *arg);
+void lt_opt_process_env_prepend (const char *arg);
+void lt_opt_process_env_append (const char *arg);
+int lt_split_name_value (const char *arg, char** name, char** value);
+void lt_update_exe_path (const char *name, const char *value);
+void lt_update_lib_path (const char *name, const char *value);
+
+static const char *script_text_part1 =
+EOF
+
+	    func_emit_wrapper_part1 yes |
+	        $SED -e 's/\([\\"]\)/\\\1/g' \
+	             -e 's/^/  "/' -e 's/$/\\n"/'
+	    echo ";"
+	    cat <<EOF
+
+static const char *script_text_part2 =
+EOF
+	    func_emit_wrapper_part2 yes |
+	        $SED -e 's/\([\\"]\)/\\\1/g' \
+	             -e 's/^/  "/' -e 's/$/\\n"/'
+	    echo ";"
+
+	    cat <<EOF
+const char * MAGIC_EXE = "$magic_exe";
+const char * LIB_PATH_VARNAME = "$shlibpath_var";
+EOF
+
+	    if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then
+              func_to_host_pathlist "$temp_rpath"
+	      cat <<EOF
+const char * LIB_PATH_VALUE   = "$func_to_host_pathlist_result";
+EOF
+	    else
+	      cat <<"EOF"
+const char * LIB_PATH_VALUE   = "";
+EOF
+	    fi
+
+	    if test -n "$dllsearchpath"; then
+              func_to_host_pathlist "$dllsearchpath:"
+	      cat <<EOF
+const char * EXE_PATH_VARNAME = "PATH";
+const char * EXE_PATH_VALUE   = "$func_to_host_pathlist_result";
+EOF
+	    else
+	      cat <<"EOF"
+const char * EXE_PATH_VARNAME = "";
+const char * EXE_PATH_VALUE   = "";
+EOF
+	    fi
+
+	    if test "$fast_install" = yes; then
+	      cat <<EOF
+const char * TARGET_PROGRAM_NAME = "lt-$outputname"; /* hopefully, no .exe */
+EOF
+	    else
+	      cat <<EOF
+const char * TARGET_PROGRAM_NAME = "$outputname"; /* hopefully, no .exe */
+EOF
+	    fi
+
+
+	    cat <<"EOF"
+
+#define LTWRAPPER_OPTION_PREFIX         "--lt-"
+#define LTWRAPPER_OPTION_PREFIX_LENGTH  5
+
+static const size_t opt_prefix_len         = LTWRAPPER_OPTION_PREFIX_LENGTH;
+static const char *ltwrapper_option_prefix = LTWRAPPER_OPTION_PREFIX;
+
+static const char *dumpscript_opt       = LTWRAPPER_OPTION_PREFIX "dump-script";
+
+static const size_t env_set_opt_len     = LTWRAPPER_OPTION_PREFIX_LENGTH + 7;
+static const char *env_set_opt          = LTWRAPPER_OPTION_PREFIX "env-set";
+  /* argument is putenv-style "foo=bar", value of foo is set to bar */
+
+static const size_t env_prepend_opt_len = LTWRAPPER_OPTION_PREFIX_LENGTH + 11;
+static const char *env_prepend_opt      = LTWRAPPER_OPTION_PREFIX "env-prepend";
+  /* argument is putenv-style "foo=bar", new value of foo is bar${foo} */
+
+static const size_t env_append_opt_len  = LTWRAPPER_OPTION_PREFIX_LENGTH + 10;
+static const char *env_append_opt       = LTWRAPPER_OPTION_PREFIX "env-append";
+  /* argument is putenv-style "foo=bar", new value of foo is ${foo}bar */
+
+int
+main (int argc, char *argv[])
+{
+  char **newargz;
+  int  newargc;
+  char *tmp_pathspec;
+  char *actual_cwrapper_path;
+  char *actual_cwrapper_name;
+  char *target_name;
+  char *lt_argv_zero;
+  intptr_t rval = 127;
+
+  int i;
+
+  program_name = (char *) xstrdup (base_name (argv[0]));
+  LTWRAPPER_DEBUGPRINTF (("(main) argv[0]      : %s\n", argv[0]));
+  LTWRAPPER_DEBUGPRINTF (("(main) program_name : %s\n", program_name));
+
+  /* very simple arg parsing; don't want to rely on getopt */
+  for (i = 1; i < argc; i++)
+    {
+      if (strcmp (argv[i], dumpscript_opt) == 0)
+	{
+EOF
+	    case "$host" in
+	      *mingw* | *cygwin* )
+		# make stdout use "unix" line endings
+		echo "          setmode(1,_O_BINARY);"
+		;;
+	      esac
+
+	    cat <<"EOF"
+	  printf ("%s", script_text_part1);
+	  printf ("%s", script_text_part2);
+	  return 0;
+	}
+    }
+
+  newargz = XMALLOC (char *, argc + 1);
+  tmp_pathspec = find_executable (argv[0]);
+  if (tmp_pathspec == NULL)
+    lt_fatal ("Couldn't find %s", argv[0]);
+  LTWRAPPER_DEBUGPRINTF (("(main) found exe (before symlink chase) at : %s\n",
+			  tmp_pathspec));
+
+  actual_cwrapper_path = chase_symlinks (tmp_pathspec);
+  LTWRAPPER_DEBUGPRINTF (("(main) found exe (after symlink chase) at : %s\n",
+			  actual_cwrapper_path));
+  XFREE (tmp_pathspec);
+
+  actual_cwrapper_name = xstrdup( base_name (actual_cwrapper_path));
+  strendzap (actual_cwrapper_path, actual_cwrapper_name);
+
+  /* wrapper name transforms */
+  strendzap (actual_cwrapper_name, ".exe");
+  tmp_pathspec = lt_extend_str (actual_cwrapper_name, ".exe", 1);
+  XFREE (actual_cwrapper_name);
+  actual_cwrapper_name = tmp_pathspec;
+  tmp_pathspec = 0;
+
+  /* target_name transforms -- use actual target program name; might have lt- prefix */
+  target_name = xstrdup (base_name (TARGET_PROGRAM_NAME));
+  strendzap (target_name, ".exe");
+  tmp_pathspec = lt_extend_str (target_name, ".exe", 1);
+  XFREE (target_name);
+  target_name = tmp_pathspec;
+  tmp_pathspec = 0;
+
+  LTWRAPPER_DEBUGPRINTF (("(main) libtool target name: %s\n",
+			  target_name));
+EOF
+
+	    cat <<EOF
+  newargz[0] =
+    XMALLOC (char, (strlen (actual_cwrapper_path) +
+		    strlen ("$objdir") + 1 + strlen (actual_cwrapper_name) + 1));
+  strcpy (newargz[0], actual_cwrapper_path);
+  strcat (newargz[0], "$objdir");
+  strcat (newargz[0], "/");
+EOF
+
+	    cat <<"EOF"
+  /* stop here, and copy so we don't have to do this twice */
+  tmp_pathspec = xstrdup (newargz[0]);
+
+  /* do NOT want the lt- prefix here, so use actual_cwrapper_name */
+  strcat (newargz[0], actual_cwrapper_name);
+
+  /* DO want the lt- prefix here if it exists, so use target_name */
+  lt_argv_zero = lt_extend_str (tmp_pathspec, target_name, 1);
+  XFREE (tmp_pathspec);
+  tmp_pathspec = NULL;
+EOF
+
+	    case $host_os in
+	      mingw*)
+	    cat <<"EOF"
+  {
+    char* p;
+    while ((p = strchr (newargz[0], '\\')) != NULL)
+      {
+	*p = '/';
+      }
+    while ((p = strchr (lt_argv_zero, '\\')) != NULL)
+      {
+	*p = '/';
+      }
+  }
+EOF
+	    ;;
+	    esac
+
+	    cat <<"EOF"
+  XFREE (target_name);
+  XFREE (actual_cwrapper_path);
+  XFREE (actual_cwrapper_name);
+
+  lt_setenv ("BIN_SH", "xpg4"); /* for Tru64 */
+  lt_setenv ("DUALCASE", "1");  /* for MSK sh */
+  lt_update_lib_path (LIB_PATH_VARNAME, LIB_PATH_VALUE);
+  lt_update_exe_path (EXE_PATH_VARNAME, EXE_PATH_VALUE);
+
+  newargc=0;
+  for (i = 1; i < argc; i++)
+    {
+      if (strncmp (argv[i], env_set_opt, env_set_opt_len) == 0)
+        {
+          if (argv[i][env_set_opt_len] == '=')
+            {
+              const char *p = argv[i] + env_set_opt_len + 1;
+              lt_opt_process_env_set (p);
+            }
+          else if (argv[i][env_set_opt_len] == '\0' && i + 1 < argc)
+            {
+              lt_opt_process_env_set (argv[++i]); /* don't copy */
+            }
+          else
+            lt_fatal ("%s missing required argument", env_set_opt);
+          continue;
+        }
+      if (strncmp (argv[i], env_prepend_opt, env_prepend_opt_len) == 0)
+        {
+          if (argv[i][env_prepend_opt_len] == '=')
+            {
+              const char *p = argv[i] + env_prepend_opt_len + 1;
+              lt_opt_process_env_prepend (p);
+            }
+          else if (argv[i][env_prepend_opt_len] == '\0' && i + 1 < argc)
+            {
+              lt_opt_process_env_prepend (argv[++i]); /* don't copy */
+            }
+          else
+            lt_fatal ("%s missing required argument", env_prepend_opt);
+          continue;
+        }
+      if (strncmp (argv[i], env_append_opt, env_append_opt_len) == 0)
+        {
+          if (argv[i][env_append_opt_len] == '=')
+            {
+              const char *p = argv[i] + env_append_opt_len + 1;
+              lt_opt_process_env_append (p);
+            }
+          else if (argv[i][env_append_opt_len] == '\0' && i + 1 < argc)
+            {
+              lt_opt_process_env_append (argv[++i]); /* don't copy */
+            }
+          else
+            lt_fatal ("%s missing required argument", env_append_opt);
+          continue;
+        }
+      if (strncmp (argv[i], ltwrapper_option_prefix, opt_prefix_len) == 0)
+        {
+          /* however, if there is an option in the LTWRAPPER_OPTION_PREFIX
+             namespace, but it is not one of the ones we know about and
+             have already dealt with, above (inluding dump-script), then
+             report an error. Otherwise, targets might begin to believe
+             they are allowed to use options in the LTWRAPPER_OPTION_PREFIX
+             namespace. The first time any user complains about this, we'll
+             need to make LTWRAPPER_OPTION_PREFIX a configure-time option
+             or a configure.ac-settable value.
+           */
+          lt_fatal ("Unrecognized option in %s namespace: '%s'",
+                    ltwrapper_option_prefix, argv[i]);
+        }
+      /* otherwise ... */
+      newargz[++newargc] = xstrdup (argv[i]);
+    }
+  newargz[++newargc] = NULL;
+
+  LTWRAPPER_DEBUGPRINTF     (("(main) lt_argv_zero : %s\n", (lt_argv_zero ? lt_argv_zero : "<NULL>")));
+  for (i = 0; i < newargc; i++)
+    {
+      LTWRAPPER_DEBUGPRINTF (("(main) newargz[%d]   : %s\n", i, (newargz[i] ? newargz[i] : "<NULL>")));
+    }
+
+EOF
+
+	    case $host_os in
+	      mingw*)
+		cat <<"EOF"
+  /* execv doesn't actually work on mingw as expected on unix */
+  rval = _spawnv (_P_WAIT, lt_argv_zero, (const char * const *) newargz);
+  if (rval == -1)
+    {
+      /* failed to start process */
+      LTWRAPPER_DEBUGPRINTF (("(main) failed to launch target \"%s\": errno = %d\n", lt_argv_zero, errno));
+      return 127;
+    }
+  return rval;
+EOF
+		;;
+	      *)
+		cat <<"EOF"
+  execv (lt_argv_zero, newargz);
+  return rval; /* =127, but avoids unused variable warning */
+EOF
+		;;
+	    esac
+
+	    cat <<"EOF"
+}
+
+void *
+xmalloc (size_t num)
+{
+  void *p = (void *) malloc (num);
+  if (!p)
+    lt_fatal ("Memory exhausted");
+
+  return p;
+}
+
+char *
+xstrdup (const char *string)
+{
+  return string ? strcpy ((char *) xmalloc (strlen (string) + 1),
+			  string) : NULL;
+}
+
+const char *
+base_name (const char *name)
+{
+  const char *base;
+
+#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
+  /* Skip over the disk name in MSDOS pathnames. */
+  if (isalpha ((unsigned char) name[0]) && name[1] == ':')
+    name += 2;
+#endif
+
+  for (base = name; *name; name++)
+    if (IS_DIR_SEPARATOR (*name))
+      base = name + 1;
+  return base;
+}
+
+int
+check_executable (const char *path)
+{
+  struct stat st;
+
+  LTWRAPPER_DEBUGPRINTF (("(check_executable)  : %s\n",
+			  path ? (*path ? path : "EMPTY!") : "NULL!"));
+  if ((!path) || (!*path))
+    return 0;
+
+  if ((stat (path, &st) >= 0)
+      && (st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH)))
+    return 1;
+  else
+    return 0;
+}
+
+int
+make_executable (const char *path)
+{
+  int rval = 0;
+  struct stat st;
+
+  LTWRAPPER_DEBUGPRINTF (("(make_executable)   : %s\n",
+			  path ? (*path ? path : "EMPTY!") : "NULL!"));
+  if ((!path) || (!*path))
+    return 0;
+
+  if (stat (path, &st) >= 0)
+    {
+      rval = chmod (path, st.st_mode | S_IXOTH | S_IXGRP | S_IXUSR);
+    }
+  return rval;
+}
+
+/* Searches for the full path of the wrapper.  Returns
+   newly allocated full path name if found, NULL otherwise
+   Does not chase symlinks, even on platforms that support them.
+*/
+char *
+find_executable (const char *wrapper)
+{
+  int has_slash = 0;
+  const char *p;
+  const char *p_next;
+  /* static buffer for getcwd */
+  char tmp[LT_PATHMAX + 1];
+  int tmp_len;
+  char *concat_name;
+
+  LTWRAPPER_DEBUGPRINTF (("(find_executable)   : %s\n",
+			  wrapper ? (*wrapper ? wrapper : "EMPTY!") : "NULL!"));
+
+  if ((wrapper == NULL) || (*wrapper == '\0'))
+    return NULL;
+
+  /* Absolute path? */
+#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
+  if (isalpha ((unsigned char) wrapper[0]) && wrapper[1] == ':')
+    {
+      concat_name = xstrdup (wrapper);
+      if (check_executable (concat_name))
+	return concat_name;
+      XFREE (concat_name);
+    }
+  else
+    {
+#endif
+      if (IS_DIR_SEPARATOR (wrapper[0]))
+	{
+	  concat_name = xstrdup (wrapper);
+	  if (check_executable (concat_name))
+	    return concat_name;
+	  XFREE (concat_name);
+	}
+#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
+    }
+#endif
+
+  for (p = wrapper; *p; p++)
+    if (*p == '/')
+      {
+	has_slash = 1;
+	break;
+      }
+  if (!has_slash)
+    {
+      /* no slashes; search PATH */
+      const char *path = getenv ("PATH");
+      if (path != NULL)
+	{
+	  for (p = path; *p; p = p_next)
+	    {
+	      const char *q;
+	      size_t p_len;
+	      for (q = p; *q; q++)
+		if (IS_PATH_SEPARATOR (*q))
+		  break;
+	      p_len = q - p;
+	      p_next = (*q == '\0' ? q : q + 1);
+	      if (p_len == 0)
+		{
+		  /* empty path: current directory */
+		  if (getcwd (tmp, LT_PATHMAX) == NULL)
+		    lt_fatal ("getcwd failed");
+		  tmp_len = strlen (tmp);
+		  concat_name =
+		    XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1);
+		  memcpy (concat_name, tmp, tmp_len);
+		  concat_name[tmp_len] = '/';
+		  strcpy (concat_name + tmp_len + 1, wrapper);
+		}
+	      else
+		{
+		  concat_name =
+		    XMALLOC (char, p_len + 1 + strlen (wrapper) + 1);
+		  memcpy (concat_name, p, p_len);
+		  concat_name[p_len] = '/';
+		  strcpy (concat_name + p_len + 1, wrapper);
+		}
+	      if (check_executable (concat_name))
+		return concat_name;
+	      XFREE (concat_name);
+	    }
+	}
+      /* not found in PATH; assume curdir */
+    }
+  /* Relative path | not found in path: prepend cwd */
+  if (getcwd (tmp, LT_PATHMAX) == NULL)
+    lt_fatal ("getcwd failed");
+  tmp_len = strlen (tmp);
+  concat_name = XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1);
+  memcpy (concat_name, tmp, tmp_len);
+  concat_name[tmp_len] = '/';
+  strcpy (concat_name + tmp_len + 1, wrapper);
+
+  if (check_executable (concat_name))
+    return concat_name;
+  XFREE (concat_name);
+  return NULL;
+}
+
+char *
+chase_symlinks (const char *pathspec)
+{
+#ifndef S_ISLNK
+  return xstrdup (pathspec);
+#else
+  char buf[LT_PATHMAX];
+  struct stat s;
+  char *tmp_pathspec = xstrdup (pathspec);
+  char *p;
+  int has_symlinks = 0;
+  while (strlen (tmp_pathspec) && !has_symlinks)
+    {
+      LTWRAPPER_DEBUGPRINTF (("checking path component for symlinks: %s\n",
+			      tmp_pathspec));
+      if (lstat (tmp_pathspec, &s) == 0)
+	{
+	  if (S_ISLNK (s.st_mode) != 0)
+	    {
+	      has_symlinks = 1;
+	      break;
+	    }
+
+	  /* search backwards for last DIR_SEPARATOR */
+	  p = tmp_pathspec + strlen (tmp_pathspec) - 1;
+	  while ((p > tmp_pathspec) && (!IS_DIR_SEPARATOR (*p)))
+	    p--;
+	  if ((p == tmp_pathspec) && (!IS_DIR_SEPARATOR (*p)))
+	    {
+	      /* no more DIR_SEPARATORS left */
+	      break;
+	    }
+	  *p = '\0';
+	}
+      else
+	{
+	  char *errstr = strerror (errno);
+	  lt_fatal ("Error accessing file %s (%s)", tmp_pathspec, errstr);
+	}
+    }
+  XFREE (tmp_pathspec);
+
+  if (!has_symlinks)
+    {
+      return xstrdup (pathspec);
+    }
+
+  tmp_pathspec = realpath (pathspec, buf);
+  if (tmp_pathspec == 0)
+    {
+      lt_fatal ("Could not follow symlinks for %s", pathspec);
+    }
+  return xstrdup (tmp_pathspec);
+#endif
+}
+
+char *
+strendzap (char *str, const char *pat)
+{
+  size_t len, patlen;
+
+  assert (str != NULL);
+  assert (pat != NULL);
+
+  len = strlen (str);
+  patlen = strlen (pat);
+
+  if (patlen <= len)
+    {
+      str += len - patlen;
+      if (strcmp (str, pat) == 0)
+	*str = '\0';
+    }
+  return str;
+}
+
+static void
+lt_error_core (int exit_status, const char *mode,
+	       const char *message, va_list ap)
+{
+  fprintf (stderr, "%s: %s: ", program_name, mode);
+  vfprintf (stderr, message, ap);
+  fprintf (stderr, ".\n");
+
+  if (exit_status >= 0)
+    exit (exit_status);
+}
+
+void
+lt_fatal (const char *message, ...)
+{
+  va_list ap;
+  va_start (ap, message);
+  lt_error_core (EXIT_FAILURE, "FATAL", message, ap);
+  va_end (ap);
+}
+
+void
+lt_setenv (const char *name, const char *value)
+{
+  LTWRAPPER_DEBUGPRINTF (("(lt_setenv) setting '%s' to '%s'\n",
+                          (name ? name : "<NULL>"),
+                          (value ? value : "<NULL>")));
+  {
+#ifdef HAVE_SETENV
+    /* always make a copy, for consistency with !HAVE_SETENV */
+    char *str = xstrdup (value);
+    setenv (name, str, 1);
+#else
+    int len = strlen (name) + 1 + strlen (value) + 1;
+    char *str = XMALLOC (char, len);
+    sprintf (str, "%s=%s", name, value);
+    if (putenv (str) != EXIT_SUCCESS)
+      {
+        XFREE (str);
+      }
+#endif
+  }
+}
+
+char *
+lt_extend_str (const char *orig_value, const char *add, int to_end)
+{
+  char *new_value;
+  if (orig_value && *orig_value)
+    {
+      int orig_value_len = strlen (orig_value);
+      int add_len = strlen (add);
+      new_value = XMALLOC (char, add_len + orig_value_len + 1);
+      if (to_end)
+        {
+          strcpy (new_value, orig_value);
+          strcpy (new_value + orig_value_len, add);
+        }
+      else
+        {
+          strcpy (new_value, add);
+          strcpy (new_value + add_len, orig_value);
+        }
+    }
+  else
+    {
+      new_value = xstrdup (add);
+    }
+  return new_value;
+}
+
+int
+lt_split_name_value (const char *arg, char** name, char** value)
+{
+  const char *p;
+  int len;
+  if (!arg || !*arg)
+    return 1;
+
+  p = strchr (arg, (int)'=');
+
+  if (!p)
+    return 1;
+
+  *value = xstrdup (++p);
+
+  len = strlen (arg) - strlen (*value);
+  *name = XMALLOC (char, len);
+  strncpy (*name, arg, len-1);
+  (*name)[len - 1] = '\0';
+
+  return 0;
+}
+
+void
+lt_opt_process_env_set (const char *arg)
+{
+  char *name = NULL;
+  char *value = NULL;
+
+  if (lt_split_name_value (arg, &name, &value) != 0)
+    {
+      XFREE (name);
+      XFREE (value);
+      lt_fatal ("bad argument for %s: '%s'", env_set_opt, arg);
+    }
+
+  lt_setenv (name, value);
+  XFREE (name);
+  XFREE (value);
+}
+
+void
+lt_opt_process_env_prepend (const char *arg)
+{
+  char *name = NULL;
+  char *value = NULL;
+  char *new_value = NULL;
+
+  if (lt_split_name_value (arg, &name, &value) != 0)
+    {
+      XFREE (name);
+      XFREE (value);
+      lt_fatal ("bad argument for %s: '%s'", env_prepend_opt, arg);
+    }
+
+  new_value = lt_extend_str (getenv (name), value, 0);
+  lt_setenv (name, new_value);
+  XFREE (new_value);
+  XFREE (name);
+  XFREE (value);
+}
+
+void
+lt_opt_process_env_append (const char *arg)
+{
+  char *name = NULL;
+  char *value = NULL;
+  char *new_value = NULL;
+
+  if (lt_split_name_value (arg, &name, &value) != 0)
+    {
+      XFREE (name);
+      XFREE (value);
+      lt_fatal ("bad argument for %s: '%s'", env_append_opt, arg);
+    }
+
+  new_value = lt_extend_str (getenv (name), value, 1);
+  lt_setenv (name, new_value);
+  XFREE (new_value);
+  XFREE (name);
+  XFREE (value);
+}
+
+void
+lt_update_exe_path (const char *name, const char *value)
+{
+  LTWRAPPER_DEBUGPRINTF (("(lt_update_exe_path) modifying '%s' by prepending '%s'\n",
+                          (name ? name : "<NULL>"),
+                          (value ? value : "<NULL>")));
+
+  if (name && *name && value && *value)
+    {
+      char *new_value = lt_extend_str (getenv (name), value, 0);
+      /* some systems can't cope with a ':'-terminated path #' */
+      int len = strlen (new_value);
+      while (((len = strlen (new_value)) > 0) && IS_PATH_SEPARATOR (new_value[len-1]))
+        {
+          new_value[len-1] = '\0';
+        }
+      lt_setenv (name, new_value);
+      XFREE (new_value);
+    }
+}
+
+void
+lt_update_lib_path (const char *name, const char *value)
+{
+  LTWRAPPER_DEBUGPRINTF (("(lt_update_lib_path) modifying '%s' by prepending '%s'\n",
+                          (name ? name : "<NULL>"),
+                          (value ? value : "<NULL>")));
+
+  if (name && *name && value && *value)
+    {
+      char *new_value = lt_extend_str (getenv (name), value, 0);
+      lt_setenv (name, new_value);
+      XFREE (new_value);
+    }
+}
+
+
+EOF
+}
+# end: func_emit_cwrapperexe_src
+
+# func_mode_link arg...
+func_mode_link ()
+{
+    $opt_debug
+    case $host in
+    *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
+      # It is impossible to link a dll without this setting, and
+      # we shouldn't force the makefile maintainer to figure out
+      # which system we are compiling for in order to pass an extra
+      # flag for every libtool invocation.
+      # allow_undefined=no
+
+      # FIXME: Unfortunately, there are problems with the above when trying
+      # to make a dll which has undefined symbols, in which case not
+      # even a static library is built.  For now, we need to specify
+      # -no-undefined on the libtool link line when we can be certain
+      # that all symbols are satisfied, otherwise we get a static library.
+      allow_undefined=yes
+      ;;
+    *)
+      allow_undefined=yes
+      ;;
+    esac
+    libtool_args=$nonopt
+    base_compile="$nonopt $@"
+    compile_command=$nonopt
+    finalize_command=$nonopt
+
+    compile_rpath=
+    finalize_rpath=
+    compile_shlibpath=
+    finalize_shlibpath=
+    convenience=
+    old_convenience=
+    deplibs=
+    old_deplibs=
+    compiler_flags=
+    linker_flags=
+    dllsearchpath=
+    lib_search_path=`pwd`
+    inst_prefix_dir=
+    new_inherited_linker_flags=
+
+    avoid_version=no
+    dlfiles=
+    dlprefiles=
+    dlself=no
+    export_dynamic=no
+    export_symbols=
+    export_symbols_regex=
+    generated=
+    libobjs=
+    ltlibs=
+    module=no
+    no_install=no
+    objs=
+    non_pic_objects=
+    precious_files_regex=
+    prefer_static_libs=no
+    preload=no
+    prev=
+    prevarg=
+    release=
+    rpath=
+    xrpath=
+    perm_rpath=
+    temp_rpath=
+    thread_safe=no
+    vinfo=
+    vinfo_number=no
+    weak_libs=
+    single_module="${wl}-single_module"
+    func_infer_tag $base_compile
+
+    # We need to know -static, to get the right output filenames.
+    for arg
+    do
+      case $arg in
+      -shared)
+	test "$build_libtool_libs" != yes && \
+	  func_fatal_configuration "can not build a shared library"
+	build_old_libs=no
+	break
+	;;
+      -all-static | -static | -static-libtool-libs)
+	case $arg in
+	-all-static)
+	  if test "$build_libtool_libs" = yes && test -z "$link_static_flag"; then
+	    func_warning "complete static linking is impossible in this configuration"
+	  fi
+	  if test -n "$link_static_flag"; then
+	    dlopen_self=$dlopen_self_static
+	  fi
+	  prefer_static_libs=yes
+	  ;;
+	-static)
+	  if test -z "$pic_flag" && test -n "$link_static_flag"; then
+	    dlopen_self=$dlopen_self_static
+	  fi
+	  prefer_static_libs=built
+	  ;;
+	-static-libtool-libs)
+	  if test -z "$pic_flag" && test -n "$link_static_flag"; then
+	    dlopen_self=$dlopen_self_static
+	  fi
+	  prefer_static_libs=yes
+	  ;;
+	esac
+	build_libtool_libs=no
+	build_old_libs=yes
+	break
+	;;
+      esac
+    done
+
+    # See if our shared archives depend on static archives.
+    test -n "$old_archive_from_new_cmds" && build_old_libs=yes
+
+    # Go through the arguments, transforming them on the way.
+    while test "$#" -gt 0; do
+      arg="$1"
+      shift
+      func_quote_for_eval "$arg"
+      qarg=$func_quote_for_eval_unquoted_result
+      func_append libtool_args " $func_quote_for_eval_result"
+
+      # If the previous option needs an argument, assign it.
+      if test -n "$prev"; then
+	case $prev in
+	output)
+	  func_append compile_command " @OUTPUT@"
+	  func_append finalize_command " @OUTPUT@"
+	  ;;
+	esac
+
+	case $prev in
+	dlfiles|dlprefiles)
+	  if test "$preload" = no; then
+	    # Add the symbol object into the linking commands.
+	    func_append compile_command " @SYMFILE@"
+	    func_append finalize_command " @SYMFILE@"
+	    preload=yes
+	  fi
+	  case $arg in
+	  *.la | *.lo) ;;  # We handle these cases below.
+	  force)
+	    if test "$dlself" = no; then
+	      dlself=needless
+	      export_dynamic=yes
+	    fi
+	    prev=
+	    continue
+	    ;;
+	  self)
+	    if test "$prev" = dlprefiles; then
+	      dlself=yes
+	    elif test "$prev" = dlfiles && test "$dlopen_self" != yes; then
+	      dlself=yes
+	    else
+	      dlself=needless
+	      export_dynamic=yes
+	    fi
+	    prev=
+	    continue
+	    ;;
+	  *)
+	    if test "$prev" = dlfiles; then
+	      dlfiles="$dlfiles $arg"
+	    else
+	      dlprefiles="$dlprefiles $arg"
+	    fi
+	    prev=
+	    continue
+	    ;;
+	  esac
+	  ;;
+	expsyms)
+	  export_symbols="$arg"
+	  test -f "$arg" \
+	    || func_fatal_error "symbol file \`$arg' does not exist"
+	  prev=
+	  continue
+	  ;;
+	expsyms_regex)
+	  export_symbols_regex="$arg"
+	  prev=
+	  continue
+	  ;;
+	framework)
+	  case $host in
+	    *-*-darwin*)
+	      case "$deplibs " in
+		*" $qarg.ltframework "*) ;;
+		*) deplibs="$deplibs $qarg.ltframework" # this is fixed later
+		   ;;
+	      esac
+	      ;;
+	  esac
+	  prev=
+	  continue
+	  ;;
+	inst_prefix)
+	  inst_prefix_dir="$arg"
+	  prev=
+	  continue
+	  ;;
+	objectlist)
+	  if test -f "$arg"; then
+	    save_arg=$arg
+	    moreargs=
+	    for fil in `cat "$save_arg"`
+	    do
+#	      moreargs="$moreargs $fil"
+	      arg=$fil
+	      # A libtool-controlled object.
+
+	      # Check to see that this really is a libtool object.
+	      if func_lalib_unsafe_p "$arg"; then
+		pic_object=
+		non_pic_object=
+
+		# Read the .lo file
+		func_source "$arg"
+
+		if test -z "$pic_object" ||
+		   test -z "$non_pic_object" ||
+		   test "$pic_object" = none &&
+		   test "$non_pic_object" = none; then
+		  func_fatal_error "cannot find name of object for \`$arg'"
+		fi
+
+		# Extract subdirectory from the argument.
+		func_dirname "$arg" "/" ""
+		xdir="$func_dirname_result"
+
+		if test "$pic_object" != none; then
+		  # Prepend the subdirectory the object is found in.
+		  pic_object="$xdir$pic_object"
+
+		  if test "$prev" = dlfiles; then
+		    if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then
+		      dlfiles="$dlfiles $pic_object"
+		      prev=
+		      continue
+		    else
+		      # If libtool objects are unsupported, then we need to preload.
+		      prev=dlprefiles
+		    fi
+		  fi
+
+		  # CHECK ME:  I think I busted this.  -Ossama
+		  if test "$prev" = dlprefiles; then
+		    # Preload the old-style object.
+		    dlprefiles="$dlprefiles $pic_object"
+		    prev=
+		  fi
+
+		  # A PIC object.
+		  func_append libobjs " $pic_object"
+		  arg="$pic_object"
+		fi
+
+		# Non-PIC object.
+		if test "$non_pic_object" != none; then
+		  # Prepend the subdirectory the object is found in.
+		  non_pic_object="$xdir$non_pic_object"
+
+		  # A standard non-PIC object
+		  func_append non_pic_objects " $non_pic_object"
+		  if test -z "$pic_object" || test "$pic_object" = none ; then
+		    arg="$non_pic_object"
+		  fi
+		else
+		  # If the PIC object exists, use it instead.
+		  # $xdir was prepended to $pic_object above.
+		  non_pic_object="$pic_object"
+		  func_append non_pic_objects " $non_pic_object"
+		fi
+	      else
+		# Only an error if not doing a dry-run.
+		if $opt_dry_run; then
+		  # Extract subdirectory from the argument.
+		  func_dirname "$arg" "/" ""
+		  xdir="$func_dirname_result"
+
+		  func_lo2o "$arg"
+		  pic_object=$xdir$objdir/$func_lo2o_result
+		  non_pic_object=$xdir$func_lo2o_result
+		  func_append libobjs " $pic_object"
+		  func_append non_pic_objects " $non_pic_object"
+	        else
+		  func_fatal_error "\`$arg' is not a valid libtool object"
+		fi
+	      fi
+	    done
+	  else
+	    func_fatal_error "link input file \`$arg' does not exist"
+	  fi
+	  arg=$save_arg
+	  prev=
+	  continue
+	  ;;
+	precious_regex)
+	  precious_files_regex="$arg"
+	  prev=
+	  continue
+	  ;;
+	release)
+	  release="-$arg"
+	  prev=
+	  continue
+	  ;;
+	rpath | xrpath)
+	  # We need an absolute path.
+	  case $arg in
+	  [\\/]* | [A-Za-z]:[\\/]*) ;;
+	  *)
+	    func_fatal_error "only absolute run-paths are allowed"
+	    ;;
+	  esac
+	  if test "$prev" = rpath; then
+	    case "$rpath " in
+	    *" $arg "*) ;;
+	    *) rpath="$rpath $arg" ;;
+	    esac
+	  else
+	    case "$xrpath " in
+	    *" $arg "*) ;;
+	    *) xrpath="$xrpath $arg" ;;
+	    esac
+	  fi
+	  prev=
+	  continue
+	  ;;
+	shrext)
+	  shrext_cmds="$arg"
+	  prev=
+	  continue
+	  ;;
+	weak)
+	  weak_libs="$weak_libs $arg"
+	  prev=
+	  continue
+	  ;;
+	xcclinker)
+	  linker_flags="$linker_flags $qarg"
+	  compiler_flags="$compiler_flags $qarg"
+	  prev=
+	  func_append compile_command " $qarg"
+	  func_append finalize_command " $qarg"
+	  continue
+	  ;;
+	xcompiler)
+	  compiler_flags="$compiler_flags $qarg"
+	  prev=
+	  func_append compile_command " $qarg"
+	  func_append finalize_command " $qarg"
+	  continue
+	  ;;
+	xlinker)
+	  linker_flags="$linker_flags $qarg"
+	  compiler_flags="$compiler_flags $wl$qarg"
+	  prev=
+	  func_append compile_command " $wl$qarg"
+	  func_append finalize_command " $wl$qarg"
+	  continue
+	  ;;
+	*)
+	  eval "$prev=\"\$arg\""
+	  prev=
+	  continue
+	  ;;
+	esac
+      fi # test -n "$prev"
+
+      prevarg="$arg"
+
+      case $arg in
+      -all-static)
+	if test -n "$link_static_flag"; then
+	  # See comment for -static flag below, for more details.
+	  func_append compile_command " $link_static_flag"
+	  func_append finalize_command " $link_static_flag"
+	fi
+	continue
+	;;
+
+      -allow-undefined)
+	# FIXME: remove this flag sometime in the future.
+	func_fatal_error "\`-allow-undefined' must not be used because it is the default"
+	;;
+
+      -avoid-version)
+	avoid_version=yes
+	continue
+	;;
+
+      -dlopen)
+	prev=dlfiles
+	continue
+	;;
+
+      -dlpreopen)
+	prev=dlprefiles
+	continue
+	;;
+
+      -export-dynamic)
+	export_dynamic=yes
+	continue
+	;;
+
+      -export-symbols | -export-symbols-regex)
+	if test -n "$export_symbols" || test -n "$export_symbols_regex"; then
+	  func_fatal_error "more than one -exported-symbols argument is not allowed"
+	fi
+	if test "X$arg" = "X-export-symbols"; then
+	  prev=expsyms
+	else
+	  prev=expsyms_regex
+	fi
+	continue
+	;;
+
+      -framework)
+	prev=framework
+	continue
+	;;
+
+      -inst-prefix-dir)
+	prev=inst_prefix
+	continue
+	;;
+
+      # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:*
+      # so, if we see these flags be careful not to treat them like -L
+      -L[A-Z][A-Z]*:*)
+	case $with_gcc/$host in
+	no/*-*-irix* | /*-*-irix*)
+	  func_append compile_command " $arg"
+	  func_append finalize_command " $arg"
+	  ;;
+	esac
+	continue
+	;;
+
+      -L*)
+	func_stripname '-L' '' "$arg"
+	dir=$func_stripname_result
+	if test -z "$dir"; then
+	  if test "$#" -gt 0; then
+	    func_fatal_error "require no space between \`-L' and \`$1'"
+	  else
+	    func_fatal_error "need path for \`-L' option"
+	  fi
+	fi
+	# We need an absolute path.
+	case $dir in
+	[\\/]* | [A-Za-z]:[\\/]*) ;;
+	*)
+	  absdir=`cd "$dir" && pwd`
+	  test -z "$absdir" && \
+	    func_fatal_error "cannot determine absolute directory name of \`$dir'"
+	  dir="$absdir"
+	  ;;
+	esac
+	case "$deplibs " in
+	*" -L$dir "*) ;;
+	*)
+	  deplibs="$deplibs -L$dir"
+	  lib_search_path="$lib_search_path $dir"
+	  ;;
+	esac
+	case $host in
+	*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
+	  testbindir=`$ECHO "X$dir" | $Xsed -e 's*/lib$*/bin*'`
+	  case :$dllsearchpath: in
+	  *":$dir:"*) ;;
+	  ::) dllsearchpath=$dir;;
+	  *) dllsearchpath="$dllsearchpath:$dir";;
+	  esac
+	  case :$dllsearchpath: in
+	  *":$testbindir:"*) ;;
+	  ::) dllsearchpath=$testbindir;;
+	  *) dllsearchpath="$dllsearchpath:$testbindir";;
+	  esac
+	  ;;
+	esac
+	continue
+	;;
+
+      -l*)
+	if test "X$arg" = "X-lc" || test "X$arg" = "X-lm"; then
+	  case $host in
+	  *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos* | *-cegcc*)
+	    # These systems don't actually have a C or math library (as such)
+	    continue
+	    ;;
+	  *-*-os2*)
+	    # These systems don't actually have a C library (as such)
+	    test "X$arg" = "X-lc" && continue
+	    ;;
+	  *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
+	    # Do not include libc due to us having libc/libc_r.
+	    test "X$arg" = "X-lc" && continue
+	    ;;
+	  *-*-rhapsody* | *-*-darwin1.[012])
+	    # Rhapsody C and math libraries are in the System framework
+	    deplibs="$deplibs System.ltframework"
+	    continue
+	    ;;
+	  *-*-sco3.2v5* | *-*-sco5v6*)
+	    # Causes problems with __ctype
+	    test "X$arg" = "X-lc" && continue
+	    ;;
+	  *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*)
+	    # Compiler inserts libc in the correct place for threads to work
+	    test "X$arg" = "X-lc" && continue
+	    ;;
+	  esac
+	elif test "X$arg" = "X-lc_r"; then
+	 case $host in
+	 *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
+	   # Do not include libc_r directly, use -pthread flag.
+	   continue
+	   ;;
+	 esac
+	fi
+	deplibs="$deplibs $arg"
+	continue
+	;;
+
+      -module)
+	module=yes
+	continue
+	;;
+
+      # Tru64 UNIX uses -model [arg] to determine the layout of C++
+      # classes, name mangling, and exception handling.
+      # Darwin uses the -arch flag to determine output architecture.
+      -model|-arch|-isysroot)
+	compiler_flags="$compiler_flags $arg"
+	func_append compile_command " $arg"
+	func_append finalize_command " $arg"
+	prev=xcompiler
+	continue
+	;;
+
+      -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe|-threads)
+	compiler_flags="$compiler_flags $arg"
+	func_append compile_command " $arg"
+	func_append finalize_command " $arg"
+	case "$new_inherited_linker_flags " in
+	    *" $arg "*) ;;
+	    * ) new_inherited_linker_flags="$new_inherited_linker_flags $arg" ;;
+	esac
+	continue
+	;;
+
+      -multi_module)
+	single_module="${wl}-multi_module"
+	continue
+	;;
+
+      -no-fast-install)
+	fast_install=no
+	continue
+	;;
+
+      -no-install)
+	case $host in
+	*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-darwin* | *-cegcc*)
+	  # The PATH hackery in wrapper scripts is required on Windows
+	  # and Darwin in order for the loader to find any dlls it needs.
+	  func_warning "\`-no-install' is ignored for $host"
+	  func_warning "assuming \`-no-fast-install' instead"
+	  fast_install=no
+	  ;;
+	*) no_install=yes ;;
+	esac
+	continue
+	;;
+
+      -no-undefined)
+	allow_undefined=no
+	continue
+	;;
+
+      -objectlist)
+	prev=objectlist
+	continue
+	;;
+
+      -o) prev=output ;;
+
+      -precious-files-regex)
+	prev=precious_regex
+	continue
+	;;
+
+      -release)
+	prev=release
+	continue
+	;;
+
+      -rpath)
+	prev=rpath
+	continue
+	;;
+
+      -R)
+	prev=xrpath
+	continue
+	;;
+
+      -R*)
+	func_stripname '-R' '' "$arg"
+	dir=$func_stripname_result
+	# We need an absolute path.
+	case $dir in
+	[\\/]* | [A-Za-z]:[\\/]*) ;;
+	*)
+	  func_fatal_error "only absolute run-paths are allowed"
+	  ;;
+	esac
+	case "$xrpath " in
+	*" $dir "*) ;;
+	*) xrpath="$xrpath $dir" ;;
+	esac
+	continue
+	;;
+
+      -shared)
+	# The effects of -shared are defined in a previous loop.
+	continue
+	;;
+
+      -shrext)
+	prev=shrext
+	continue
+	;;
+
+      -static | -static-libtool-libs)
+	# The effects of -static are defined in a previous loop.
+	# We used to do the same as -all-static on platforms that
+	# didn't have a PIC flag, but the assumption that the effects
+	# would be equivalent was wrong.  It would break on at least
+	# Digital Unix and AIX.
+	continue
+	;;
+
+      -thread-safe)
+	thread_safe=yes
+	continue
+	;;
+
+      -version-info)
+	prev=vinfo
+	continue
+	;;
+
+      -version-number)
+	prev=vinfo
+	vinfo_number=yes
+	continue
+	;;
+
+      -weak)
+        prev=weak
+	continue
+	;;
+
+      -Wc,*)
+	func_stripname '-Wc,' '' "$arg"
+	args=$func_stripname_result
+	arg=
+	save_ifs="$IFS"; IFS=','
+	for flag in $args; do
+	  IFS="$save_ifs"
+          func_quote_for_eval "$flag"
+	  arg="$arg $wl$func_quote_for_eval_result"
+	  compiler_flags="$compiler_flags $func_quote_for_eval_result"
+	done
+	IFS="$save_ifs"
+	func_stripname ' ' '' "$arg"
+	arg=$func_stripname_result
+	;;
+
+      -Wl,*)
+	func_stripname '-Wl,' '' "$arg"
+	args=$func_stripname_result
+	arg=
+	save_ifs="$IFS"; IFS=','
+	for flag in $args; do
+	  IFS="$save_ifs"
+          func_quote_for_eval "$flag"
+	  arg="$arg $wl$func_quote_for_eval_result"
+	  compiler_flags="$compiler_flags $wl$func_quote_for_eval_result"
+	  linker_flags="$linker_flags $func_quote_for_eval_result"
+	done
+	IFS="$save_ifs"
+	func_stripname ' ' '' "$arg"
+	arg=$func_stripname_result
+	;;
+
+      -Xcompiler)
+	prev=xcompiler
+	continue
+	;;
+
+      -Xlinker)
+	prev=xlinker
+	continue
+	;;
+
+      -XCClinker)
+	prev=xcclinker
+	continue
+	;;
+
+      # -msg_* for osf cc
+      -msg_*)
+	func_quote_for_eval "$arg"
+	arg="$func_quote_for_eval_result"
+	;;
+
+      # -64, -mips[0-9] enable 64-bit mode on the SGI compiler
+      # -r[0-9][0-9]* specifies the processor on the SGI compiler
+      # -xarch=*, -xtarget=* enable 64-bit mode on the Sun compiler
+      # +DA*, +DD* enable 64-bit mode on the HP compiler
+      # -q* pass through compiler args for the IBM compiler
+      # -m*, -t[45]*, -txscale* pass through architecture-specific
+      # compiler args for GCC
+      # -F/path gives path to uninstalled frameworks, gcc on darwin
+      # -p, -pg, --coverage, -fprofile-* pass through profiling flag for GCC
+      # @file GCC response files
+      -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \
+      -t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*)
+        func_quote_for_eval "$arg"
+	arg="$func_quote_for_eval_result"
+        func_append compile_command " $arg"
+        func_append finalize_command " $arg"
+        compiler_flags="$compiler_flags $arg"
+        continue
+        ;;
+
+      # Some other compiler flag.
+      -* | +*)
+        func_quote_for_eval "$arg"
+	arg="$func_quote_for_eval_result"
+	;;
+
+      *.$objext)
+	# A standard object.
+	objs="$objs $arg"
+	;;
+
+      *.lo)
+	# A libtool-controlled object.
+
+	# Check to see that this really is a libtool object.
+	if func_lalib_unsafe_p "$arg"; then
+	  pic_object=
+	  non_pic_object=
+
+	  # Read the .lo file
+	  func_source "$arg"
+
+	  if test -z "$pic_object" ||
+	     test -z "$non_pic_object" ||
+	     test "$pic_object" = none &&
+	     test "$non_pic_object" = none; then
+	    func_fatal_error "cannot find name of object for \`$arg'"
+	  fi
+
+	  # Extract subdirectory from the argument.
+	  func_dirname "$arg" "/" ""
+	  xdir="$func_dirname_result"
+
+	  if test "$pic_object" != none; then
+	    # Prepend the subdirectory the object is found in.
+	    pic_object="$xdir$pic_object"
+
+	    if test "$prev" = dlfiles; then
+	      if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then
+		dlfiles="$dlfiles $pic_object"
+		prev=
+		continue
+	      else
+		# If libtool objects are unsupported, then we need to preload.
+		prev=dlprefiles
+	      fi
+	    fi
+
+	    # CHECK ME:  I think I busted this.  -Ossama
+	    if test "$prev" = dlprefiles; then
+	      # Preload the old-style object.
+	      dlprefiles="$dlprefiles $pic_object"
+	      prev=
+	    fi
+
+	    # A PIC object.
+	    func_append libobjs " $pic_object"
+	    arg="$pic_object"
+	  fi
+
+	  # Non-PIC object.
+	  if test "$non_pic_object" != none; then
+	    # Prepend the subdirectory the object is found in.
+	    non_pic_object="$xdir$non_pic_object"
+
+	    # A standard non-PIC object
+	    func_append non_pic_objects " $non_pic_object"
+	    if test -z "$pic_object" || test "$pic_object" = none ; then
+	      arg="$non_pic_object"
+	    fi
+	  else
+	    # If the PIC object exists, use it instead.
+	    # $xdir was prepended to $pic_object above.
+	    non_pic_object="$pic_object"
+	    func_append non_pic_objects " $non_pic_object"
+	  fi
+	else
+	  # Only an error if not doing a dry-run.
+	  if $opt_dry_run; then
+	    # Extract subdirectory from the argument.
+	    func_dirname "$arg" "/" ""
+	    xdir="$func_dirname_result"
+
+	    func_lo2o "$arg"
+	    pic_object=$xdir$objdir/$func_lo2o_result
+	    non_pic_object=$xdir$func_lo2o_result
+	    func_append libobjs " $pic_object"
+	    func_append non_pic_objects " $non_pic_object"
+	  else
+	    func_fatal_error "\`$arg' is not a valid libtool object"
+	  fi
+	fi
+	;;
+
+      *.$libext)
+	# An archive.
+	deplibs="$deplibs $arg"
+	old_deplibs="$old_deplibs $arg"
+	continue
+	;;
+
+      *.la)
+	# A libtool-controlled library.
+
+	if test "$prev" = dlfiles; then
+	  # This library was specified with -dlopen.
+	  dlfiles="$dlfiles $arg"
+	  prev=
+	elif test "$prev" = dlprefiles; then
+	  # The library was specified with -dlpreopen.
+	  dlprefiles="$dlprefiles $arg"
+	  prev=
+	else
+	  deplibs="$deplibs $arg"
+	fi
+	continue
+	;;
+
+      # Some other compiler argument.
+      *)
+	# Unknown arguments in both finalize_command and compile_command need
+	# to be aesthetically quoted because they are evaled later.
+	func_quote_for_eval "$arg"
+	arg="$func_quote_for_eval_result"
+	;;
+      esac # arg
+
+      # Now actually substitute the argument into the commands.
+      if test -n "$arg"; then
+	func_append compile_command " $arg"
+	func_append finalize_command " $arg"
+      fi
+    done # argument parsing loop
+
+    test -n "$prev" && \
+      func_fatal_help "the \`$prevarg' option requires an argument"
+
+    if test "$export_dynamic" = yes && test -n "$export_dynamic_flag_spec"; then
+      eval arg=\"$export_dynamic_flag_spec\"
+      func_append compile_command " $arg"
+      func_append finalize_command " $arg"
+    fi
+
+    oldlibs=
+    # calculate the name of the file, without its directory
+    func_basename "$output"
+    outputname="$func_basename_result"
+    libobjs_save="$libobjs"
+
+    if test -n "$shlibpath_var"; then
+      # get the directories listed in $shlibpath_var
+      eval shlib_search_path=\`\$ECHO \"X\${$shlibpath_var}\" \| \$Xsed -e \'s/:/ /g\'\`
+    else
+      shlib_search_path=
+    fi
+    eval sys_lib_search_path=\"$sys_lib_search_path_spec\"
+    eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\"
+
+    func_dirname "$output" "/" ""
+    output_objdir="$func_dirname_result$objdir"
+    # Create the object directory.
+    func_mkdir_p "$output_objdir"
+
+    # Determine the type of output
+    case $output in
+    "")
+      func_fatal_help "you must specify an output file"
+      ;;
+    *.$libext) linkmode=oldlib ;;
+    *.lo | *.$objext) linkmode=obj ;;
+    *.la) linkmode=lib ;;
+    *) linkmode=prog ;; # Anything else should be a program.
+    esac
+
+    specialdeplibs=
+
+    libs=
+    # Find all interdependent deplibs by searching for libraries
+    # that are linked more than once (e.g. -la -lb -la)
+    for deplib in $deplibs; do
+      if $opt_duplicate_deps ; then
+	case "$libs " in
+	*" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
+	esac
+      fi
+      libs="$libs $deplib"
+    done
+
+    if test "$linkmode" = lib; then
+      libs="$predeps $libs $compiler_lib_search_path $postdeps"
+
+      # Compute libraries that are listed more than once in $predeps
+      # $postdeps and mark them as special (i.e., whose duplicates are
+      # not to be eliminated).
+      pre_post_deps=
+      if $opt_duplicate_compiler_generated_deps; then
+	for pre_post_dep in $predeps $postdeps; do
+	  case "$pre_post_deps " in
+	  *" $pre_post_dep "*) specialdeplibs="$specialdeplibs $pre_post_deps" ;;
+	  esac
+	  pre_post_deps="$pre_post_deps $pre_post_dep"
+	done
+      fi
+      pre_post_deps=
+    fi
+
+    deplibs=
+    newdependency_libs=
+    newlib_search_path=
+    need_relink=no # whether we're linking any uninstalled libtool libraries
+    notinst_deplibs= # not-installed libtool libraries
+    notinst_path= # paths that contain not-installed libtool libraries
+
+    case $linkmode in
+    lib)
+	passes="conv dlpreopen link"
+	for file in $dlfiles $dlprefiles; do
+	  case $file in
+	  *.la) ;;
+	  *)
+	    func_fatal_help "libraries can \`-dlopen' only libtool libraries: $file"
+	    ;;
+	  esac
+	done
+	;;
+    prog)
+	compile_deplibs=
+	finalize_deplibs=
+	alldeplibs=no
+	newdlfiles=
+	newdlprefiles=
+	passes="conv scan dlopen dlpreopen link"
+	;;
+    *)  passes="conv"
+	;;
+    esac
+
+    for pass in $passes; do
+      # The preopen pass in lib mode reverses $deplibs; put it back here
+      # so that -L comes before libs that need it for instance...
+      if test "$linkmode,$pass" = "lib,link"; then
+	## FIXME: Find the place where the list is rebuilt in the wrong
+	##        order, and fix it there properly
+        tmp_deplibs=
+	for deplib in $deplibs; do
+	  tmp_deplibs="$deplib $tmp_deplibs"
+	done
+	deplibs="$tmp_deplibs"
+      fi
+
+      if test "$linkmode,$pass" = "lib,link" ||
+	 test "$linkmode,$pass" = "prog,scan"; then
+	libs="$deplibs"
+	deplibs=
+      fi
+      if test "$linkmode" = prog; then
+	case $pass in
+	dlopen) libs="$dlfiles" ;;
+	dlpreopen) libs="$dlprefiles" ;;
+	link)
+	  libs="$deplibs %DEPLIBS%"
+	  test "X$link_all_deplibs" != Xno && libs="$libs $dependency_libs"
+	  ;;
+	esac
+      fi
+      if test "$linkmode,$pass" = "lib,dlpreopen"; then
+	# Collect and forward deplibs of preopened libtool libs
+	for lib in $dlprefiles; do
+	  # Ignore non-libtool-libs
+	  dependency_libs=
+	  case $lib in
+	  *.la)	func_source "$lib" ;;
+	  esac
+
+	  # Collect preopened libtool deplibs, except any this library
+	  # has declared as weak libs
+	  for deplib in $dependency_libs; do
+            deplib_base=`$ECHO "X$deplib" | $Xsed -e "$basename"`
+	    case " $weak_libs " in
+	    *" $deplib_base "*) ;;
+	    *) deplibs="$deplibs $deplib" ;;
+	    esac
+	  done
+	done
+	libs="$dlprefiles"
+      fi
+      if test "$pass" = dlopen; then
+	# Collect dlpreopened libraries
+	save_deplibs="$deplibs"
+	deplibs=
+      fi
+
+      for deplib in $libs; do
+	lib=
+	found=no
+	case $deplib in
+	-mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe|-threads)
+	  if test "$linkmode,$pass" = "prog,link"; then
+	    compile_deplibs="$deplib $compile_deplibs"
+	    finalize_deplibs="$deplib $finalize_deplibs"
+	  else
+	    compiler_flags="$compiler_flags $deplib"
+	    if test "$linkmode" = lib ; then
+		case "$new_inherited_linker_flags " in
+		    *" $deplib "*) ;;
+		    * ) new_inherited_linker_flags="$new_inherited_linker_flags $deplib" ;;
+		esac
+	    fi
+	  fi
+	  continue
+	  ;;
+	-l*)
+	  if test "$linkmode" != lib && test "$linkmode" != prog; then
+	    func_warning "\`-l' is ignored for archives/objects"
+	    continue
+	  fi
+	  func_stripname '-l' '' "$deplib"
+	  name=$func_stripname_result
+	  if test "$linkmode" = lib; then
+	    searchdirs="$newlib_search_path $lib_search_path $compiler_lib_search_dirs $sys_lib_search_path $shlib_search_path"
+	  else
+	    searchdirs="$newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path"
+	  fi
+	  for searchdir in $searchdirs; do
+	    for search_ext in .la $std_shrext .so .a; do
+	      # Search the libtool library
+	      lib="$searchdir/lib${name}${search_ext}"
+	      if test -f "$lib"; then
+		if test "$search_ext" = ".la"; then
+		  found=yes
+		else
+		  found=no
+		fi
+		break 2
+	      fi
+	    done
+	  done
+	  if test "$found" != yes; then
+	    # deplib doesn't seem to be a libtool library
+	    if test "$linkmode,$pass" = "prog,link"; then
+	      compile_deplibs="$deplib $compile_deplibs"
+	      finalize_deplibs="$deplib $finalize_deplibs"
+	    else
+	      deplibs="$deplib $deplibs"
+	      test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs"
+	    fi
+	    continue
+	  else # deplib is a libtool library
+	    # If $allow_libtool_libs_with_static_runtimes && $deplib is a stdlib,
+	    # We need to do some special things here, and not later.
+	    if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
+	      case " $predeps $postdeps " in
+	      *" $deplib "*)
+		if func_lalib_p "$lib"; then
+		  library_names=
+		  old_library=
+		  func_source "$lib"
+		  for l in $old_library $library_names; do
+		    ll="$l"
+		  done
+		  if test "X$ll" = "X$old_library" ; then # only static version available
+		    found=no
+		    func_dirname "$lib" "" "."
+		    ladir="$func_dirname_result"
+		    lib=$ladir/$old_library
+		    if test "$linkmode,$pass" = "prog,link"; then
+		      compile_deplibs="$deplib $compile_deplibs"
+		      finalize_deplibs="$deplib $finalize_deplibs"
+		    else
+		      deplibs="$deplib $deplibs"
+		      test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs"
+		    fi
+		    continue
+		  fi
+		fi
+		;;
+	      *) ;;
+	      esac
+	    fi
+	  fi
+	  ;; # -l
+	*.ltframework)
+	  if test "$linkmode,$pass" = "prog,link"; then
+	    compile_deplibs="$deplib $compile_deplibs"
+	    finalize_deplibs="$deplib $finalize_deplibs"
+	  else
+	    deplibs="$deplib $deplibs"
+	    if test "$linkmode" = lib ; then
+		case "$new_inherited_linker_flags " in
+		    *" $deplib "*) ;;
+		    * ) new_inherited_linker_flags="$new_inherited_linker_flags $deplib" ;;
+		esac
+	    fi
+	  fi
+	  continue
+	  ;;
+	-L*)
+	  case $linkmode in
+	  lib)
+	    deplibs="$deplib $deplibs"
+	    test "$pass" = conv && continue
+	    newdependency_libs="$deplib $newdependency_libs"
+	    func_stripname '-L' '' "$deplib"
+	    newlib_search_path="$newlib_search_path $func_stripname_result"
+	    ;;
+	  prog)
+	    if test "$pass" = conv; then
+	      deplibs="$deplib $deplibs"
+	      continue
+	    fi
+	    if test "$pass" = scan; then
+	      deplibs="$deplib $deplibs"
+	    else
+	      compile_deplibs="$deplib $compile_deplibs"
+	      finalize_deplibs="$deplib $finalize_deplibs"
+	    fi
+	    func_stripname '-L' '' "$deplib"
+	    newlib_search_path="$newlib_search_path $func_stripname_result"
+	    ;;
+	  *)
+	    func_warning "\`-L' is ignored for archives/objects"
+	    ;;
+	  esac # linkmode
+	  continue
+	  ;; # -L
+	-R*)
+	  if test "$pass" = link; then
+	    func_stripname '-R' '' "$deplib"
+	    dir=$func_stripname_result
+	    # Make sure the xrpath contains only unique directories.
+	    case "$xrpath " in
+	    *" $dir "*) ;;
+	    *) xrpath="$xrpath $dir" ;;
+	    esac
+	  fi
+	  deplibs="$deplib $deplibs"
+	  continue
+	  ;;
+	*.la) lib="$deplib" ;;
+	*.$libext)
+	  if test "$pass" = conv; then
+	    deplibs="$deplib $deplibs"
+	    continue
+	  fi
+	  case $linkmode in
+	  lib)
+	    # Linking convenience modules into shared libraries is allowed,
+	    # but linking other static libraries is non-portable.
+	    case " $dlpreconveniencelibs " in
+	    *" $deplib "*) ;;
+	    *)
+	      valid_a_lib=no
+	      case $deplibs_check_method in
+		match_pattern*)
+		  set dummy $deplibs_check_method; shift
+		  match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
+		  if eval "\$ECHO \"X$deplib\"" 2>/dev/null | $Xsed -e 10q \
+		    | $EGREP "$match_pattern_regex" > /dev/null; then
+		    valid_a_lib=yes
+		  fi
+		;;
+		pass_all)
+		  valid_a_lib=yes
+		;;
+	      esac
+	      if test "$valid_a_lib" != yes; then
+		$ECHO
+		$ECHO "*** Warning: Trying to link with static lib archive $deplib."
+		$ECHO "*** I have the capability to make that library automatically link in when"
+		$ECHO "*** you link to this library.  But I can only do this if you have a"
+		$ECHO "*** shared version of the library, which you do not appear to have"
+		$ECHO "*** because the file extensions .$libext of this argument makes me believe"
+		$ECHO "*** that it is just a static archive that I should not use here."
+	      else
+		$ECHO
+		$ECHO "*** Warning: Linking the shared library $output against the"
+		$ECHO "*** static library $deplib is not portable!"
+		deplibs="$deplib $deplibs"
+	      fi
+	      ;;
+	    esac
+	    continue
+	    ;;
+	  prog)
+	    if test "$pass" != link; then
+	      deplibs="$deplib $deplibs"
+	    else
+	      compile_deplibs="$deplib $compile_deplibs"
+	      finalize_deplibs="$deplib $finalize_deplibs"
+	    fi
+	    continue
+	    ;;
+	  esac # linkmode
+	  ;; # *.$libext
+	*.lo | *.$objext)
+	  if test "$pass" = conv; then
+	    deplibs="$deplib $deplibs"
+	  elif test "$linkmode" = prog; then
+	    if test "$pass" = dlpreopen || test "$dlopen_support" != yes || test "$build_libtool_libs" = no; then
+	      # If there is no dlopen support or we're linking statically,
+	      # we need to preload.
+	      newdlprefiles="$newdlprefiles $deplib"
+	      compile_deplibs="$deplib $compile_deplibs"
+	      finalize_deplibs="$deplib $finalize_deplibs"
+	    else
+	      newdlfiles="$newdlfiles $deplib"
+	    fi
+	  fi
+	  continue
+	  ;;
+	%DEPLIBS%)
+	  alldeplibs=yes
+	  continue
+	  ;;
+	esac # case $deplib
+
+	if test "$found" = yes || test -f "$lib"; then :
+	else
+	  func_fatal_error "cannot find the library \`$lib' or unhandled argument \`$deplib'"
+	fi
+
+	# Check to see that this really is a libtool archive.
+	func_lalib_unsafe_p "$lib" \
+	  || func_fatal_error "\`$lib' is not a valid libtool archive"
+
+	func_dirname "$lib" "" "."
+	ladir="$func_dirname_result"
+
+	dlname=
+	dlopen=
+	dlpreopen=
+	libdir=
+	library_names=
+	old_library=
+	inherited_linker_flags=
+	# If the library was installed with an old release of libtool,
+	# it will not redefine variables installed, or shouldnotlink
+	installed=yes
+	shouldnotlink=no
+	avoidtemprpath=
+
+
+	# Read the .la file
+	func_source "$lib"
+
+	# Convert "-framework foo" to "foo.ltframework"
+	if test -n "$inherited_linker_flags"; then
+	  tmp_inherited_linker_flags=`$ECHO "X$inherited_linker_flags" | $Xsed -e 's/-framework \([^ $]*\)/\1.ltframework/g'`
+	  for tmp_inherited_linker_flag in $tmp_inherited_linker_flags; do
+	    case " $new_inherited_linker_flags " in
+	      *" $tmp_inherited_linker_flag "*) ;;
+	      *) new_inherited_linker_flags="$new_inherited_linker_flags $tmp_inherited_linker_flag";;
+	    esac
+	  done
+	fi
+	dependency_libs=`$ECHO "X $dependency_libs" | $Xsed -e 's% \([^ $]*\).ltframework% -framework \1%g'`
+	if test "$linkmode,$pass" = "lib,link" ||
+	   test "$linkmode,$pass" = "prog,scan" ||
+	   { test "$linkmode" != prog && test "$linkmode" != lib; }; then
+	  test -n "$dlopen" && dlfiles="$dlfiles $dlopen"
+	  test -n "$dlpreopen" && dlprefiles="$dlprefiles $dlpreopen"
+	fi
+
+	if test "$pass" = conv; then
+	  # Only check for convenience libraries
+	  deplibs="$lib $deplibs"
+	  if test -z "$libdir"; then
+	    if test -z "$old_library"; then
+	      func_fatal_error "cannot find name of link library for \`$lib'"
+	    fi
+	    # It is a libtool convenience library, so add in its objects.
+	    convenience="$convenience $ladir/$objdir/$old_library"
+	    old_convenience="$old_convenience $ladir/$objdir/$old_library"
+	    tmp_libs=
+	    for deplib in $dependency_libs; do
+	      deplibs="$deplib $deplibs"
+	      if $opt_duplicate_deps ; then
+		case "$tmp_libs " in
+		*" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
+		esac
+	      fi
+	      tmp_libs="$tmp_libs $deplib"
+	    done
+	  elif test "$linkmode" != prog && test "$linkmode" != lib; then
+	    func_fatal_error "\`$lib' is not a convenience library"
+	  fi
+	  continue
+	fi # $pass = conv
+
+
+	# Get the name of the library we link against.
+	linklib=
+	for l in $old_library $library_names; do
+	  linklib="$l"
+	done
+	if test -z "$linklib"; then
+	  func_fatal_error "cannot find name of link library for \`$lib'"
+	fi
+
+	# This library was specified with -dlopen.
+	if test "$pass" = dlopen; then
+	  if test -z "$libdir"; then
+	    func_fatal_error "cannot -dlopen a convenience library: \`$lib'"
+	  fi
+	  if test -z "$dlname" ||
+	     test "$dlopen_support" != yes ||
+	     test "$build_libtool_libs" = no; then
+	    # If there is no dlname, no dlopen support or we're linking
+	    # statically, we need to preload.  We also need to preload any
+	    # dependent libraries so libltdl's deplib preloader doesn't
+	    # bomb out in the load deplibs phase.
+	    dlprefiles="$dlprefiles $lib $dependency_libs"
+	  else
+	    newdlfiles="$newdlfiles $lib"
+	  fi
+	  continue
+	fi # $pass = dlopen
+
+	# We need an absolute path.
+	case $ladir in
+	[\\/]* | [A-Za-z]:[\\/]*) abs_ladir="$ladir" ;;
+	*)
+	  abs_ladir=`cd "$ladir" && pwd`
+	  if test -z "$abs_ladir"; then
+	    func_warning "cannot determine absolute directory name of \`$ladir'"
+	    func_warning "passing it literally to the linker, although it might fail"
+	    abs_ladir="$ladir"
+	  fi
+	  ;;
+	esac
+	func_basename "$lib"
+	laname="$func_basename_result"
+
+	# Find the relevant object directory and library name.
+	if test "X$installed" = Xyes; then
+	  if test ! -f "$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then
+	    func_warning "library \`$lib' was moved."
+	    dir="$ladir"
+	    absdir="$abs_ladir"
+	    libdir="$abs_ladir"
+	  else
+	    dir="$libdir"
+	    absdir="$libdir"
+	  fi
+	  test "X$hardcode_automatic" = Xyes && avoidtemprpath=yes
+	else
+	  if test ! -f "$ladir/$objdir/$linklib" && test -f "$abs_ladir/$linklib"; then
+	    dir="$ladir"
+	    absdir="$abs_ladir"
+	    # Remove this search path later
+	    notinst_path="$notinst_path $abs_ladir"
+	  else
+	    dir="$ladir/$objdir"
+	    absdir="$abs_ladir/$objdir"
+	    # Remove this search path later
+	    notinst_path="$notinst_path $abs_ladir"
+	  fi
+	fi # $installed = yes
+	func_stripname 'lib' '.la' "$laname"
+	name=$func_stripname_result
+
+	# This library was specified with -dlpreopen.
+	if test "$pass" = dlpreopen; then
+	  if test -z "$libdir" && test "$linkmode" = prog; then
+	    func_fatal_error "only libraries may -dlpreopen a convenience library: \`$lib'"
+	  fi
+	  # Prefer using a static library (so that no silly _DYNAMIC symbols
+	  # are required to link).
+	  if test -n "$old_library"; then
+	    newdlprefiles="$newdlprefiles $dir/$old_library"
+	    # Keep a list of preopened convenience libraries to check
+	    # that they are being used correctly in the link pass.
+	    test -z "$libdir" && \
+		dlpreconveniencelibs="$dlpreconveniencelibs $dir/$old_library"
+	  # Otherwise, use the dlname, so that lt_dlopen finds it.
+	  elif test -n "$dlname"; then
+	    newdlprefiles="$newdlprefiles $dir/$dlname"
+	  else
+	    newdlprefiles="$newdlprefiles $dir/$linklib"
+	  fi
+	fi # $pass = dlpreopen
+
+	if test -z "$libdir"; then
+	  # Link the convenience library
+	  if test "$linkmode" = lib; then
+	    deplibs="$dir/$old_library $deplibs"
+	  elif test "$linkmode,$pass" = "prog,link"; then
+	    compile_deplibs="$dir/$old_library $compile_deplibs"
+	    finalize_deplibs="$dir/$old_library $finalize_deplibs"
+	  else
+	    deplibs="$lib $deplibs" # used for prog,scan pass
+	  fi
+	  continue
+	fi
+
+
+	if test "$linkmode" = prog && test "$pass" != link; then
+	  newlib_search_path="$newlib_search_path $ladir"
+	  deplibs="$lib $deplibs"
+
+	  linkalldeplibs=no
+	  if test "$link_all_deplibs" != no || test -z "$library_names" ||
+	     test "$build_libtool_libs" = no; then
+	    linkalldeplibs=yes
+	  fi
+
+	  tmp_libs=
+	  for deplib in $dependency_libs; do
+	    case $deplib in
+	    -L*) func_stripname '-L' '' "$deplib"
+	         newlib_search_path="$newlib_search_path $func_stripname_result"
+		 ;;
+	    esac
+	    # Need to link against all dependency_libs?
+	    if test "$linkalldeplibs" = yes; then
+	      deplibs="$deplib $deplibs"
+	    else
+	      # Need to hardcode shared library paths
+	      # or/and link against static libraries
+	      newdependency_libs="$deplib $newdependency_libs"
+	    fi
+	    if $opt_duplicate_deps ; then
+	      case "$tmp_libs " in
+	      *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
+	      esac
+	    fi
+	    tmp_libs="$tmp_libs $deplib"
+	  done # for deplib
+	  continue
+	fi # $linkmode = prog...
+
+	if test "$linkmode,$pass" = "prog,link"; then
+	  if test -n "$library_names" &&
+	     { { test "$prefer_static_libs" = no ||
+	         test "$prefer_static_libs,$installed" = "built,yes"; } ||
+	       test -z "$old_library"; }; then
+	    # We need to hardcode the library path
+	    if test -n "$shlibpath_var" && test -z "$avoidtemprpath" ; then
+	      # Make sure the rpath contains only unique directories.
+	      case "$temp_rpath:" in
+	      *"$absdir:"*) ;;
+	      *) temp_rpath="$temp_rpath$absdir:" ;;
+	      esac
+	    fi
+
+	    # Hardcode the library path.
+	    # Skip directories that are in the system default run-time
+	    # search path.
+	    case " $sys_lib_dlsearch_path " in
+	    *" $absdir "*) ;;
+	    *)
+	      case "$compile_rpath " in
+	      *" $absdir "*) ;;
+	      *) compile_rpath="$compile_rpath $absdir"
+	      esac
+	      ;;
+	    esac
+	    case " $sys_lib_dlsearch_path " in
+	    *" $libdir "*) ;;
+	    *)
+	      case "$finalize_rpath " in
+	      *" $libdir "*) ;;
+	      *) finalize_rpath="$finalize_rpath $libdir"
+	      esac
+	      ;;
+	    esac
+	  fi # $linkmode,$pass = prog,link...
+
+	  if test "$alldeplibs" = yes &&
+	     { test "$deplibs_check_method" = pass_all ||
+	       { test "$build_libtool_libs" = yes &&
+		 test -n "$library_names"; }; }; then
+	    # We only need to search for static libraries
+	    continue
+	  fi
+	fi
+
+	link_static=no # Whether the deplib will be linked statically
+	use_static_libs=$prefer_static_libs
+	if test "$use_static_libs" = built && test "$installed" = yes; then
+	  use_static_libs=no
+	fi
+	if test -n "$library_names" &&
+	   { test "$use_static_libs" = no || test -z "$old_library"; }; then
+	  case $host in
+	  *cygwin* | *mingw* | *cegcc*)
+	      # No point in relinking DLLs because paths are not encoded
+	      notinst_deplibs="$notinst_deplibs $lib"
+	      need_relink=no
+	    ;;
+	  *)
+	    if test "$installed" = no; then
+	      notinst_deplibs="$notinst_deplibs $lib"
+	      need_relink=yes
+	    fi
+	    ;;
+	  esac
+	  # This is a shared library
+
+	  # Warn about portability, can't link against -module's on some
+	  # systems (darwin).  Don't bleat about dlopened modules though!
+	  dlopenmodule=""
+	  for dlpremoduletest in $dlprefiles; do
+	    if test "X$dlpremoduletest" = "X$lib"; then
+	      dlopenmodule="$dlpremoduletest"
+	      break
+	    fi
+	  done
+	  if test -z "$dlopenmodule" && test "$shouldnotlink" = yes && test "$pass" = link; then
+	    $ECHO
+	    if test "$linkmode" = prog; then
+	      $ECHO "*** Warning: Linking the executable $output against the loadable module"
+	    else
+	      $ECHO "*** Warning: Linking the shared library $output against the loadable module"
+	    fi
+	    $ECHO "*** $linklib is not portable!"
+	  fi
+	  if test "$linkmode" = lib &&
+	     test "$hardcode_into_libs" = yes; then
+	    # Hardcode the library path.
+	    # Skip directories that are in the system default run-time
+	    # search path.
+	    case " $sys_lib_dlsearch_path " in
+	    *" $absdir "*) ;;
+	    *)
+	      case "$compile_rpath " in
+	      *" $absdir "*) ;;
+	      *) compile_rpath="$compile_rpath $absdir"
+	      esac
+	      ;;
+	    esac
+	    case " $sys_lib_dlsearch_path " in
+	    *" $libdir "*) ;;
+	    *)
+	      case "$finalize_rpath " in
+	      *" $libdir "*) ;;
+	      *) finalize_rpath="$finalize_rpath $libdir"
+	      esac
+	      ;;
+	    esac
+	  fi
+
+	  if test -n "$old_archive_from_expsyms_cmds"; then
+	    # figure out the soname
+	    set dummy $library_names
+	    shift
+	    realname="$1"
+	    shift
+	    libname=`eval "\\$ECHO \"$libname_spec\""`
+	    # use dlname if we got it. it's perfectly good, no?
+	    if test -n "$dlname"; then
+	      soname="$dlname"
+	    elif test -n "$soname_spec"; then
+	      # bleh windows
+	      case $host in
+	      *cygwin* | mingw* | *cegcc*)
+	        func_arith $current - $age
+		major=$func_arith_result
+		versuffix="-$major"
+		;;
+	      esac
+	      eval soname=\"$soname_spec\"
+	    else
+	      soname="$realname"
+	    fi
+
+	    # Make a new name for the extract_expsyms_cmds to use
+	    soroot="$soname"
+	    func_basename "$soroot"
+	    soname="$func_basename_result"
+	    func_stripname 'lib' '.dll' "$soname"
+	    newlib=libimp-$func_stripname_result.a
+
+	    # If the library has no export list, then create one now
+	    if test -f "$output_objdir/$soname-def"; then :
+	    else
+	      func_verbose "extracting exported symbol list from \`$soname'"
+	      func_execute_cmds "$extract_expsyms_cmds" 'exit $?'
+	    fi
+
+	    # Create $newlib
+	    if test -f "$output_objdir/$newlib"; then :; else
+	      func_verbose "generating import library for \`$soname'"
+	      func_execute_cmds "$old_archive_from_expsyms_cmds" 'exit $?'
+	    fi
+	    # make sure the library variables are pointing to the new library
+	    dir=$output_objdir
+	    linklib=$newlib
+	  fi # test -n "$old_archive_from_expsyms_cmds"
+
+	  if test "$linkmode" = prog || test "$mode" != relink; then
+	    add_shlibpath=
+	    add_dir=
+	    add=
+	    lib_linked=yes
+	    case $hardcode_action in
+	    immediate | unsupported)
+	      if test "$hardcode_direct" = no; then
+		add="$dir/$linklib"
+		case $host in
+		  *-*-sco3.2v5.0.[024]*) add_dir="-L$dir" ;;
+		  *-*-sysv4*uw2*) add_dir="-L$dir" ;;
+		  *-*-sysv5OpenUNIX* | *-*-sysv5UnixWare7.[01].[10]* | \
+		    *-*-unixware7*) add_dir="-L$dir" ;;
+		  *-*-darwin* )
+		    # if the lib is a (non-dlopened) module then we can not
+		    # link against it, someone is ignoring the earlier warnings
+		    if /usr/bin/file -L $add 2> /dev/null |
+			 $GREP ": [^:]* bundle" >/dev/null ; then
+		      if test "X$dlopenmodule" != "X$lib"; then
+			$ECHO "*** Warning: lib $linklib is a module, not a shared library"
+			if test -z "$old_library" ; then
+			  $ECHO
+			  $ECHO "*** And there doesn't seem to be a static archive available"
+			  $ECHO "*** The link will probably fail, sorry"
+			else
+			  add="$dir/$old_library"
+			fi
+		      elif test -n "$old_library"; then
+			add="$dir/$old_library"
+		      fi
+		    fi
+		esac
+	      elif test "$hardcode_minus_L" = no; then
+		case $host in
+		*-*-sunos*) add_shlibpath="$dir" ;;
+		esac
+		add_dir="-L$dir"
+		add="-l$name"
+	      elif test "$hardcode_shlibpath_var" = no; then
+		add_shlibpath="$dir"
+		add="-l$name"
+	      else
+		lib_linked=no
+	      fi
+	      ;;
+	    relink)
+	      if test "$hardcode_direct" = yes &&
+	         test "$hardcode_direct_absolute" = no; then
+		add="$dir/$linklib"
+	      elif test "$hardcode_minus_L" = yes; then
+		add_dir="-L$dir"
+		# Try looking first in the location we're being installed to.
+		if test -n "$inst_prefix_dir"; then
+		  case $libdir in
+		    [\\/]*)
+		      add_dir="$add_dir -L$inst_prefix_dir$libdir"
+		      ;;
+		  esac
+		fi
+		add="-l$name"
+	      elif test "$hardcode_shlibpath_var" = yes; then
+		add_shlibpath="$dir"
+		add="-l$name"
+	      else
+		lib_linked=no
+	      fi
+	      ;;
+	    *) lib_linked=no ;;
+	    esac
+
+	    if test "$lib_linked" != yes; then
+	      func_fatal_configuration "unsupported hardcode properties"
+	    fi
+
+	    if test -n "$add_shlibpath"; then
+	      case :$compile_shlibpath: in
+	      *":$add_shlibpath:"*) ;;
+	      *) compile_shlibpath="$compile_shlibpath$add_shlibpath:" ;;
+	      esac
+	    fi
+	    if test "$linkmode" = prog; then
+	      test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs"
+	      test -n "$add" && compile_deplibs="$add $compile_deplibs"
+	    else
+	      test -n "$add_dir" && deplibs="$add_dir $deplibs"
+	      test -n "$add" && deplibs="$add $deplibs"
+	      if test "$hardcode_direct" != yes &&
+		 test "$hardcode_minus_L" != yes &&
+		 test "$hardcode_shlibpath_var" = yes; then
+		case :$finalize_shlibpath: in
+		*":$libdir:"*) ;;
+		*) finalize_shlibpath="$finalize_shlibpath$libdir:" ;;
+		esac
+	      fi
+	    fi
+	  fi
+
+	  if test "$linkmode" = prog || test "$mode" = relink; then
+	    add_shlibpath=
+	    add_dir=
+	    add=
+	    # Finalize command for both is simple: just hardcode it.
+	    if test "$hardcode_direct" = yes &&
+	       test "$hardcode_direct_absolute" = no; then
+	      add="$libdir/$linklib"
+	    elif test "$hardcode_minus_L" = yes; then
+	      add_dir="-L$libdir"
+	      add="-l$name"
+	    elif test "$hardcode_shlibpath_var" = yes; then
+	      case :$finalize_shlibpath: in
+	      *":$libdir:"*) ;;
+	      *) finalize_shlibpath="$finalize_shlibpath$libdir:" ;;
+	      esac
+	      add="-l$name"
+	    elif test "$hardcode_automatic" = yes; then
+	      if test -n "$inst_prefix_dir" &&
+		 test -f "$inst_prefix_dir$libdir/$linklib" ; then
+		add="$inst_prefix_dir$libdir/$linklib"
+	      else
+		add="$libdir/$linklib"
+	      fi
+	    else
+	      # We cannot seem to hardcode it, guess we'll fake it.
+	      add_dir="-L$libdir"
+	      # Try looking first in the location we're being installed to.
+	      if test -n "$inst_prefix_dir"; then
+		case $libdir in
+		  [\\/]*)
+		    add_dir="$add_dir -L$inst_prefix_dir$libdir"
+		    ;;
+		esac
+	      fi
+	      add="-l$name"
+	    fi
+
+	    if test "$linkmode" = prog; then
+	      test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs"
+	      test -n "$add" && finalize_deplibs="$add $finalize_deplibs"
+	    else
+	      test -n "$add_dir" && deplibs="$add_dir $deplibs"
+	      test -n "$add" && deplibs="$add $deplibs"
+	    fi
+	  fi
+	elif test "$linkmode" = prog; then
+	  # Here we assume that one of hardcode_direct or hardcode_minus_L
+	  # is not unsupported.  This is valid on all known static and
+	  # shared platforms.
+	  if test "$hardcode_direct" != unsupported; then
+	    test -n "$old_library" && linklib="$old_library"
+	    compile_deplibs="$dir/$linklib $compile_deplibs"
+	    finalize_deplibs="$dir/$linklib $finalize_deplibs"
+	  else
+	    compile_deplibs="-l$name -L$dir $compile_deplibs"
+	    finalize_deplibs="-l$name -L$dir $finalize_deplibs"
+	  fi
+	elif test "$build_libtool_libs" = yes; then
+	  # Not a shared library
+	  if test "$deplibs_check_method" != pass_all; then
+	    # We're trying link a shared library against a static one
+	    # but the system doesn't support it.
+
+	    # Just print a warning and add the library to dependency_libs so
+	    # that the program can be linked against the static library.
+	    $ECHO
+	    $ECHO "*** Warning: This system can not link to static lib archive $lib."
+	    $ECHO "*** I have the capability to make that library automatically link in when"
+	    $ECHO "*** you link to this library.  But I can only do this if you have a"
+	    $ECHO "*** shared version of the library, which you do not appear to have."
+	    if test "$module" = yes; then
+	      $ECHO "*** But as you try to build a module library, libtool will still create "
+	      $ECHO "*** a static module, that should work as long as the dlopening application"
+	      $ECHO "*** is linked with the -dlopen flag to resolve symbols at runtime."
+	      if test -z "$global_symbol_pipe"; then
+		$ECHO
+		$ECHO "*** However, this would only work if libtool was able to extract symbol"
+		$ECHO "*** lists from a program, using \`nm' or equivalent, but libtool could"
+		$ECHO "*** not find such a program.  So, this module is probably useless."
+		$ECHO "*** \`nm' from GNU binutils and a full rebuild may help."
+	      fi
+	      if test "$build_old_libs" = no; then
+		build_libtool_libs=module
+		build_old_libs=yes
+	      else
+		build_libtool_libs=no
+	      fi
+	    fi
+	  else
+	    deplibs="$dir/$old_library $deplibs"
+	    link_static=yes
+	  fi
+	fi # link shared/static library?
+
+	if test "$linkmode" = lib; then
+	  if test -n "$dependency_libs" &&
+	     { test "$hardcode_into_libs" != yes ||
+	       test "$build_old_libs" = yes ||
+	       test "$link_static" = yes; }; then
+	    # Extract -R from dependency_libs
+	    temp_deplibs=
+	    for libdir in $dependency_libs; do
+	      case $libdir in
+	      -R*) func_stripname '-R' '' "$libdir"
+	           temp_xrpath=$func_stripname_result
+		   case " $xrpath " in
+		   *" $temp_xrpath "*) ;;
+		   *) xrpath="$xrpath $temp_xrpath";;
+		   esac;;
+	      *) temp_deplibs="$temp_deplibs $libdir";;
+	      esac
+	    done
+	    dependency_libs="$temp_deplibs"
+	  fi
+
+	  newlib_search_path="$newlib_search_path $absdir"
+	  # Link against this library
+	  test "$link_static" = no && newdependency_libs="$abs_ladir/$laname $newdependency_libs"
+	  # ... and its dependency_libs
+	  tmp_libs=
+	  for deplib in $dependency_libs; do
+	    newdependency_libs="$deplib $newdependency_libs"
+	    if $opt_duplicate_deps ; then
+	      case "$tmp_libs " in
+	      *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
+	      esac
+	    fi
+	    tmp_libs="$tmp_libs $deplib"
+	  done
+
+	  if test "$link_all_deplibs" != no; then
+	    # Add the search paths of all dependency libraries
+	    for deplib in $dependency_libs; do
+	      path=
+	      case $deplib in
+	      -L*) path="$deplib" ;;
+	      *.la)
+	        func_dirname "$deplib" "" "."
+		dir="$func_dirname_result"
+		# We need an absolute path.
+		case $dir in
+		[\\/]* | [A-Za-z]:[\\/]*) absdir="$dir" ;;
+		*)
+		  absdir=`cd "$dir" && pwd`
+		  if test -z "$absdir"; then
+		    func_warning "cannot determine absolute directory name of \`$dir'"
+		    absdir="$dir"
+		  fi
+		  ;;
+		esac
+		if $GREP "^installed=no" $deplib > /dev/null; then
+		case $host in
+		*-*-darwin*)
+		  depdepl=
+		  eval deplibrary_names=`${SED} -n -e 's/^library_names=\(.*\)$/\1/p' $deplib`
+		  if test -n "$deplibrary_names" ; then
+		    for tmp in $deplibrary_names ; do
+		      depdepl=$tmp
+		    done
+		    if test -f "$absdir/$objdir/$depdepl" ; then
+		      depdepl="$absdir/$objdir/$depdepl"
+		      darwin_install_name=`${OTOOL} -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'`
+                      if test -z "$darwin_install_name"; then
+                          darwin_install_name=`${OTOOL64} -L $depdepl  | awk '{if (NR == 2) {print $1;exit}}'`
+                      fi
+		      compiler_flags="$compiler_flags ${wl}-dylib_file ${wl}${darwin_install_name}:${depdepl}"
+		      linker_flags="$linker_flags -dylib_file ${darwin_install_name}:${depdepl}"
+		      path=
+		    fi
+		  fi
+		  ;;
+		*)
+		  path="-L$absdir/$objdir"
+		  ;;
+		esac
+		else
+		  eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib`
+		  test -z "$libdir" && \
+		    func_fatal_error "\`$deplib' is not a valid libtool archive"
+		  test "$absdir" != "$libdir" && \
+		    func_warning "\`$deplib' seems to be moved"
+
+		  path="-L$absdir"
+		fi
+		;;
+	      esac
+	      case " $deplibs " in
+	      *" $path "*) ;;
+	      *) deplibs="$path $deplibs" ;;
+	      esac
+	    done
+	  fi # link_all_deplibs != no
+	fi # linkmode = lib
+      done # for deplib in $libs
+      if test "$pass" = link; then
+	if test "$linkmode" = "prog"; then
+	  compile_deplibs="$new_inherited_linker_flags $compile_deplibs"
+	  finalize_deplibs="$new_inherited_linker_flags $finalize_deplibs"
+	else
+	  compiler_flags="$compiler_flags "`$ECHO "X $new_inherited_linker_flags" | $Xsed -e 's% \([^ $]*\).ltframework% -framework \1%g'`
+	fi
+      fi
+      dependency_libs="$newdependency_libs"
+      if test "$pass" = dlpreopen; then
+	# Link the dlpreopened libraries before other libraries
+	for deplib in $save_deplibs; do
+	  deplibs="$deplib $deplibs"
+	done
+      fi
+      if test "$pass" != dlopen; then
+	if test "$pass" != conv; then
+	  # Make sure lib_search_path contains only unique directories.
+	  lib_search_path=
+	  for dir in $newlib_search_path; do
+	    case "$lib_search_path " in
+	    *" $dir "*) ;;
+	    *) lib_search_path="$lib_search_path $dir" ;;
+	    esac
+	  done
+	  newlib_search_path=
+	fi
+
+	if test "$linkmode,$pass" != "prog,link"; then
+	  vars="deplibs"
+	else
+	  vars="compile_deplibs finalize_deplibs"
+	fi
+	for var in $vars dependency_libs; do
+	  # Add libraries to $var in reverse order
+	  eval tmp_libs=\"\$$var\"
+	  new_libs=
+	  for deplib in $tmp_libs; do
+	    # FIXME: Pedantically, this is the right thing to do, so
+	    #        that some nasty dependency loop isn't accidentally
+	    #        broken:
+	    #new_libs="$deplib $new_libs"
+	    # Pragmatically, this seems to cause very few problems in
+	    # practice:
+	    case $deplib in
+	    -L*) new_libs="$deplib $new_libs" ;;
+	    -R*) ;;
+	    *)
+	      # And here is the reason: when a library appears more
+	      # than once as an explicit dependence of a library, or
+	      # is implicitly linked in more than once by the
+	      # compiler, it is considered special, and multiple
+	      # occurrences thereof are not removed.  Compare this
+	      # with having the same library being listed as a
+	      # dependency of multiple other libraries: in this case,
+	      # we know (pedantically, we assume) the library does not
+	      # need to be listed more than once, so we keep only the
+	      # last copy.  This is not always right, but it is rare
+	      # enough that we require users that really mean to play
+	      # such unportable linking tricks to link the library
+	      # using -Wl,-lname, so that libtool does not consider it
+	      # for duplicate removal.
+	      case " $specialdeplibs " in
+	      *" $deplib "*) new_libs="$deplib $new_libs" ;;
+	      *)
+		case " $new_libs " in
+		*" $deplib "*) ;;
+		*) new_libs="$deplib $new_libs" ;;
+		esac
+		;;
+	      esac
+	      ;;
+	    esac
+	  done
+	  tmp_libs=
+	  for deplib in $new_libs; do
+	    case $deplib in
+	    -L*)
+	      case " $tmp_libs " in
+	      *" $deplib "*) ;;
+	      *) tmp_libs="$tmp_libs $deplib" ;;
+	      esac
+	      ;;
+	    *) tmp_libs="$tmp_libs $deplib" ;;
+	    esac
+	  done
+	  eval $var=\"$tmp_libs\"
+	done # for var
+      fi
+      # Last step: remove runtime libs from dependency_libs
+      # (they stay in deplibs)
+      tmp_libs=
+      for i in $dependency_libs ; do
+	case " $predeps $postdeps $compiler_lib_search_path " in
+	*" $i "*)
+	  i=""
+	  ;;
+	esac
+	if test -n "$i" ; then
+	  tmp_libs="$tmp_libs $i"
+	fi
+      done
+      dependency_libs=$tmp_libs
+    done # for pass
+    if test "$linkmode" = prog; then
+      dlfiles="$newdlfiles"
+    fi
+    if test "$linkmode" = prog || test "$linkmode" = lib; then
+      dlprefiles="$newdlprefiles"
+    fi
+
+    case $linkmode in
+    oldlib)
+      if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
+	func_warning "\`-dlopen' is ignored for archives"
+      fi
+
+      case " $deplibs" in
+      *\ -l* | *\ -L*)
+	func_warning "\`-l' and \`-L' are ignored for archives" ;;
+      esac
+
+      test -n "$rpath" && \
+	func_warning "\`-rpath' is ignored for archives"
+
+      test -n "$xrpath" && \
+	func_warning "\`-R' is ignored for archives"
+
+      test -n "$vinfo" && \
+	func_warning "\`-version-info/-version-number' is ignored for archives"
+
+      test -n "$release" && \
+	func_warning "\`-release' is ignored for archives"
+
+      test -n "$export_symbols$export_symbols_regex" && \
+	func_warning "\`-export-symbols' is ignored for archives"
+
+      # Now set the variables for building old libraries.
+      build_libtool_libs=no
+      oldlibs="$output"
+      objs="$objs$old_deplibs"
+      ;;
+
+    lib)
+      # Make sure we only generate libraries of the form `libNAME.la'.
+      case $outputname in
+      lib*)
+	func_stripname 'lib' '.la' "$outputname"
+	name=$func_stripname_result
+	eval shared_ext=\"$shrext_cmds\"
+	eval libname=\"$libname_spec\"
+	;;
+      *)
+	test "$module" = no && \
+	  func_fatal_help "libtool library \`$output' must begin with \`lib'"
+
+	if test "$need_lib_prefix" != no; then
+	  # Add the "lib" prefix for modules if required
+	  func_stripname '' '.la' "$outputname"
+	  name=$func_stripname_result
+	  eval shared_ext=\"$shrext_cmds\"
+	  eval libname=\"$libname_spec\"
+	else
+	  func_stripname '' '.la' "$outputname"
+	  libname=$func_stripname_result
+	fi
+	;;
+      esac
+
+      if test -n "$objs"; then
+	if test "$deplibs_check_method" != pass_all; then
+	  func_fatal_error "cannot build libtool library \`$output' from non-libtool objects on this host:$objs"
+	else
+	  $ECHO
+	  $ECHO "*** Warning: Linking the shared library $output against the non-libtool"
+	  $ECHO "*** objects $objs is not portable!"
+	  libobjs="$libobjs $objs"
+	fi
+      fi
+
+      test "$dlself" != no && \
+	func_warning "\`-dlopen self' is ignored for libtool libraries"
+
+      set dummy $rpath
+      shift
+      test "$#" -gt 1 && \
+	func_warning "ignoring multiple \`-rpath's for a libtool library"
+
+      install_libdir="$1"
+
+      oldlibs=
+      if test -z "$rpath"; then
+	if test "$build_libtool_libs" = yes; then
+	  # Building a libtool convenience library.
+	  # Some compilers have problems with a `.al' extension so
+	  # convenience libraries should have the same extension an
+	  # archive normally would.
+	  oldlibs="$output_objdir/$libname.$libext $oldlibs"
+	  build_libtool_libs=convenience
+	  build_old_libs=yes
+	fi
+
+	test -n "$vinfo" && \
+	  func_warning "\`-version-info/-version-number' is ignored for convenience libraries"
+
+	test -n "$release" && \
+	  func_warning "\`-release' is ignored for convenience libraries"
+      else
+
+	# Parse the version information argument.
+	save_ifs="$IFS"; IFS=':'
+	set dummy $vinfo 0 0 0
+	shift
+	IFS="$save_ifs"
+
+	test -n "$7" && \
+	  func_fatal_help "too many parameters to \`-version-info'"
+
+	# convert absolute version numbers to libtool ages
+	# this retains compatibility with .la files and attempts
+	# to make the code below a bit more comprehensible
+
+	case $vinfo_number in
+	yes)
+	  number_major="$1"
+	  number_minor="$2"
+	  number_revision="$3"
+	  #
+	  # There are really only two kinds -- those that
+	  # use the current revision as the major version
+	  # and those that subtract age and use age as
+	  # a minor version.  But, then there is irix
+	  # which has an extra 1 added just for fun
+	  #
+	  case $version_type in
+	  darwin|linux|osf|windows|none)
+	    func_arith $number_major + $number_minor
+	    current=$func_arith_result
+	    age="$number_minor"
+	    revision="$number_revision"
+	    ;;
+	  freebsd-aout|freebsd-elf|sunos)
+	    current="$number_major"
+	    revision="$number_minor"
+	    age="0"
+	    ;;
+	  irix|nonstopux)
+	    func_arith $number_major + $number_minor
+	    current=$func_arith_result
+	    age="$number_minor"
+	    revision="$number_minor"
+	    lt_irix_increment=no
+	    ;;
+	  *)
+	    func_fatal_configuration "$modename: unknown library version type \`$version_type'"
+	    ;;
+	  esac
+	  ;;
+	no)
+	  current="$1"
+	  revision="$2"
+	  age="$3"
+	  ;;
+	esac
+
+	# Check that each of the things are valid numbers.
+	case $current in
+	0|[1-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9]) ;;
+	*)
+	  func_error "CURRENT \`$current' must be a nonnegative integer"
+	  func_fatal_error "\`$vinfo' is not valid version information"
+	  ;;
+	esac
+
+	case $revision in
+	0|[1-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9]) ;;
+	*)
+	  func_error "REVISION \`$revision' must be a nonnegative integer"
+	  func_fatal_error "\`$vinfo' is not valid version information"
+	  ;;
+	esac
+
+	case $age in
+	0|[1-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9]) ;;
+	*)
+	  func_error "AGE \`$age' must be a nonnegative integer"
+	  func_fatal_error "\`$vinfo' is not valid version information"
+	  ;;
+	esac
+
+	if test "$age" -gt "$current"; then
+	  func_error "AGE \`$age' is greater than the current interface number \`$current'"
+	  func_fatal_error "\`$vinfo' is not valid version information"
+	fi
+
+	# Calculate the version variables.
+	major=
+	versuffix=
+	verstring=
+	case $version_type in
+	none) ;;
+
+	darwin)
+	  # Like Linux, but with the current version available in
+	  # verstring for coding it into the library header
+	  func_arith $current - $age
+	  major=.$func_arith_result
+	  versuffix="$major.$age.$revision"
+	  # Darwin ld doesn't like 0 for these options...
+	  func_arith $current + 1
+	  minor_current=$func_arith_result
+	  xlcverstring="${wl}-compatibility_version ${wl}$minor_current ${wl}-current_version ${wl}$minor_current.$revision"
+	  verstring="-compatibility_version $minor_current -current_version $minor_current.$revision"
+	  ;;
+
+	freebsd-aout)
+	  major=".$current"
+	  versuffix=".$current.$revision";
+	  ;;
+
+	freebsd-elf)
+	  major=".$current"
+	  versuffix=".$current"
+	  ;;
+
+	irix | nonstopux)
+	  if test "X$lt_irix_increment" = "Xno"; then
+	    func_arith $current - $age
+	  else
+	    func_arith $current - $age + 1
+	  fi
+	  major=$func_arith_result
+
+	  case $version_type in
+	    nonstopux) verstring_prefix=nonstopux ;;
+	    *)         verstring_prefix=sgi ;;
+	  esac
+	  verstring="$verstring_prefix$major.$revision"
+
+	  # Add in all the interfaces that we are compatible with.
+	  loop=$revision
+	  while test "$loop" -ne 0; do
+	    func_arith $revision - $loop
+	    iface=$func_arith_result
+	    func_arith $loop - 1
+	    loop=$func_arith_result
+	    verstring="$verstring_prefix$major.$iface:$verstring"
+	  done
+
+	  # Before this point, $major must not contain `.'.
+	  major=.$major
+	  versuffix="$major.$revision"
+	  ;;
+
+	linux)
+	  func_arith $current - $age
+	  major=.$func_arith_result
+	  versuffix="$major.$age.$revision"
+	  ;;
+
+	osf)
+	  func_arith $current - $age
+	  major=.$func_arith_result
+	  versuffix=".$current.$age.$revision"
+	  verstring="$current.$age.$revision"
+
+	  # Add in all the interfaces that we are compatible with.
+	  loop=$age
+	  while test "$loop" -ne 0; do
+	    func_arith $current - $loop
+	    iface=$func_arith_result
+	    func_arith $loop - 1
+	    loop=$func_arith_result
+	    verstring="$verstring:${iface}.0"
+	  done
+
+	  # Make executables depend on our current version.
+	  verstring="$verstring:${current}.0"
+	  ;;
+
+	qnx)
+	  major=".$current"
+	  versuffix=".$current"
+	  ;;
+
+	sunos)
+	  major=".$current"
+	  versuffix=".$current.$revision"
+	  ;;
+
+	windows)
+	  # Use '-' rather than '.', since we only want one
+	  # extension on DOS 8.3 filesystems.
+	  func_arith $current - $age
+	  major=$func_arith_result
+	  versuffix="-$major"
+	  ;;
+
+	*)
+	  func_fatal_configuration "unknown library version type \`$version_type'"
+	  ;;
+	esac
+
+	# Clear the version info if we defaulted, and they specified a release.
+	if test -z "$vinfo" && test -n "$release"; then
+	  major=
+	  case $version_type in
+	  darwin)
+	    # we can't check for "0.0" in archive_cmds due to quoting
+	    # problems, so we reset it completely
+	    verstring=
+	    ;;
+	  *)
+	    verstring="0.0"
+	    ;;
+	  esac
+	  if test "$need_version" = no; then
+	    versuffix=
+	  else
+	    versuffix=".0.0"
+	  fi
+	fi
+
+	# Remove version info from name if versioning should be avoided
+	if test "$avoid_version" = yes && test "$need_version" = no; then
+	  major=
+	  versuffix=
+	  verstring=""
+	fi
+
+	# Check to see if the archive will have undefined symbols.
+	if test "$allow_undefined" = yes; then
+	  if test "$allow_undefined_flag" = unsupported; then
+	    func_warning "undefined symbols not allowed in $host shared libraries"
+	    build_libtool_libs=no
+	    build_old_libs=yes
+	  fi
+	else
+	  # Don't allow undefined symbols.
+	  allow_undefined_flag="$no_undefined_flag"
+	fi
+
+      fi
+
+      func_generate_dlsyms "$libname" "$libname" "yes"
+      libobjs="$libobjs $symfileobj"
+      test "X$libobjs" = "X " && libobjs=
+
+      if test "$mode" != relink; then
+	# Remove our outputs, but don't remove object files since they
+	# may have been created when compiling PIC objects.
+	removelist=
+	tempremovelist=`$ECHO "$output_objdir/*"`
+	for p in $tempremovelist; do
+	  case $p in
+	    *.$objext | *.gcno)
+	       ;;
+	    $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/${libname}${release}.*)
+	       if test "X$precious_files_regex" != "X"; then
+		 if $ECHO "$p" | $EGREP -e "$precious_files_regex" >/dev/null 2>&1
+		 then
+		   continue
+		 fi
+	       fi
+	       removelist="$removelist $p"
+	       ;;
+	    *) ;;
+	  esac
+	done
+	test -n "$removelist" && \
+	  func_show_eval "${RM}r \$removelist"
+      fi
+
+      # Now set the variables for building old libraries.
+      if test "$build_old_libs" = yes && test "$build_libtool_libs" != convenience ; then
+	oldlibs="$oldlibs $output_objdir/$libname.$libext"
+
+	# Transform .lo files to .o files.
+	oldobjs="$objs "`$ECHO "X$libobjs" | $SP2NL | $Xsed -e '/\.'${libext}'$/d' -e "$lo2o" | $NL2SP`
+      fi
+
+      # Eliminate all temporary directories.
+      #for path in $notinst_path; do
+      #	lib_search_path=`$ECHO "X$lib_search_path " | $Xsed -e "s% $path % %g"`
+      #	deplibs=`$ECHO "X$deplibs " | $Xsed -e "s% -L$path % %g"`
+      #	dependency_libs=`$ECHO "X$dependency_libs " | $Xsed -e "s% -L$path % %g"`
+      #done
+
+      if test -n "$xrpath"; then
+	# If the user specified any rpath flags, then add them.
+	temp_xrpath=
+	for libdir in $xrpath; do
+	  temp_xrpath="$temp_xrpath -R$libdir"
+	  case "$finalize_rpath " in
+	  *" $libdir "*) ;;
+	  *) finalize_rpath="$finalize_rpath $libdir" ;;
+	  esac
+	done
+	if test "$hardcode_into_libs" != yes || test "$build_old_libs" = yes; then
+	  dependency_libs="$temp_xrpath $dependency_libs"
+	fi
+      fi
+
+      # Make sure dlfiles contains only unique files that won't be dlpreopened
+      old_dlfiles="$dlfiles"
+      dlfiles=
+      for lib in $old_dlfiles; do
+	case " $dlprefiles $dlfiles " in
+	*" $lib "*) ;;
+	*) dlfiles="$dlfiles $lib" ;;
+	esac
+      done
+
+      # Make sure dlprefiles contains only unique files
+      old_dlprefiles="$dlprefiles"
+      dlprefiles=
+      for lib in $old_dlprefiles; do
+	case "$dlprefiles " in
+	*" $lib "*) ;;
+	*) dlprefiles="$dlprefiles $lib" ;;
+	esac
+      done
+
+      if test "$build_libtool_libs" = yes; then
+	if test -n "$rpath"; then
+	  case $host in
+	  *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos* | *-cegcc*)
+	    # these systems don't actually have a c library (as such)!
+	    ;;
+	  *-*-rhapsody* | *-*-darwin1.[012])
+	    # Rhapsody C library is in the System framework
+	    deplibs="$deplibs System.ltframework"
+	    ;;
+	  *-*-netbsd*)
+	    # Don't link with libc until the a.out ld.so is fixed.
+	    ;;
+	  *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
+	    # Do not include libc due to us having libc/libc_r.
+	    ;;
+	  *-*-sco3.2v5* | *-*-sco5v6*)
+	    # Causes problems with __ctype
+	    ;;
+	  *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*)
+	    # Compiler inserts libc in the correct place for threads to work
+	    ;;
+	  *)
+	    # Add libc to deplibs on all other systems if necessary.
+	    if test "$build_libtool_need_lc" = "yes"; then
+	      deplibs="$deplibs -lc"
+	    fi
+	    ;;
+	  esac
+	fi
+
+	# Transform deplibs into only deplibs that can be linked in shared.
+	name_save=$name
+	libname_save=$libname
+	release_save=$release
+	versuffix_save=$versuffix
+	major_save=$major
+	# I'm not sure if I'm treating the release correctly.  I think
+	# release should show up in the -l (ie -lgmp5) so we don't want to
+	# add it in twice.  Is that correct?
+	release=""
+	versuffix=""
+	major=""
+	newdeplibs=
+	droppeddeps=no
+	case $deplibs_check_method in
+	pass_all)
+	  # Don't check for shared/static.  Everything works.
+	  # This might be a little naive.  We might want to check
+	  # whether the library exists or not.  But this is on
+	  # osf3 & osf4 and I'm not really sure... Just
+	  # implementing what was already the behavior.
+	  newdeplibs=$deplibs
+	  ;;
+	test_compile)
+	  # This code stresses the "libraries are programs" paradigm to its
+	  # limits. Maybe even breaks it.  We compile a program, linking it
+	  # against the deplibs as a proxy for the library.  Then we can check
+	  # whether they linked in statically or dynamically with ldd.
+	  $opt_dry_run || $RM conftest.c
+	  cat > conftest.c <<EOF
+	  int main() { return 0; }
+EOF
+	  $opt_dry_run || $RM conftest
+	  if $LTCC $LTCFLAGS -o conftest conftest.c $deplibs; then
+	    ldd_output=`ldd conftest`
+	    for i in $deplibs; do
+	      case $i in
+	      -l*)
+		func_stripname -l '' "$i"
+		name=$func_stripname_result
+		if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
+		  case " $predeps $postdeps " in
+		  *" $i "*)
+		    newdeplibs="$newdeplibs $i"
+		    i=""
+		    ;;
+		  esac
+		fi
+		if test -n "$i" ; then
+		  libname=`eval "\\$ECHO \"$libname_spec\""`
+		  deplib_matches=`eval "\\$ECHO \"$library_names_spec\""`
+		  set dummy $deplib_matches; shift
+		  deplib_match=$1
+		  if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then
+		    newdeplibs="$newdeplibs $i"
+		  else
+		    droppeddeps=yes
+		    $ECHO
+		    $ECHO "*** Warning: dynamic linker does not accept needed library $i."
+		    $ECHO "*** I have the capability to make that library automatically link in when"
+		    $ECHO "*** you link to this library.  But I can only do this if you have a"
+		    $ECHO "*** shared version of the library, which I believe you do not have"
+		    $ECHO "*** because a test_compile did reveal that the linker did not use it for"
+		    $ECHO "*** its dynamic dependency list that programs get resolved with at runtime."
+		  fi
+		fi
+		;;
+	      *)
+		newdeplibs="$newdeplibs $i"
+		;;
+	      esac
+	    done
+	  else
+	    # Error occurred in the first compile.  Let's try to salvage
+	    # the situation: Compile a separate program for each library.
+	    for i in $deplibs; do
+	      case $i in
+	      -l*)
+		func_stripname -l '' "$i"
+		name=$func_stripname_result
+		$opt_dry_run || $RM conftest
+		if $LTCC $LTCFLAGS -o conftest conftest.c $i; then
+		  ldd_output=`ldd conftest`
+		  if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
+		    case " $predeps $postdeps " in
+		    *" $i "*)
+		      newdeplibs="$newdeplibs $i"
+		      i=""
+		      ;;
+		    esac
+		  fi
+		  if test -n "$i" ; then
+		    libname=`eval "\\$ECHO \"$libname_spec\""`
+		    deplib_matches=`eval "\\$ECHO \"$library_names_spec\""`
+		    set dummy $deplib_matches; shift
+		    deplib_match=$1
+		    if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then
+		      newdeplibs="$newdeplibs $i"
+		    else
+		      droppeddeps=yes
+		      $ECHO
+		      $ECHO "*** Warning: dynamic linker does not accept needed library $i."
+		      $ECHO "*** I have the capability to make that library automatically link in when"
+		      $ECHO "*** you link to this library.  But I can only do this if you have a"
+		      $ECHO "*** shared version of the library, which you do not appear to have"
+		      $ECHO "*** because a test_compile did reveal that the linker did not use this one"
+		      $ECHO "*** as a dynamic dependency that programs can get resolved with at runtime."
+		    fi
+		  fi
+		else
+		  droppeddeps=yes
+		  $ECHO
+		  $ECHO "*** Warning!  Library $i is needed by this library but I was not able to"
+		  $ECHO "*** make it link in!  You will probably need to install it or some"
+		  $ECHO "*** library that it depends on before this library will be fully"
+		  $ECHO "*** functional.  Installing it before continuing would be even better."
+		fi
+		;;
+	      *)
+		newdeplibs="$newdeplibs $i"
+		;;
+	      esac
+	    done
+	  fi
+	  ;;
+	file_magic*)
+	  set dummy $deplibs_check_method; shift
+	  file_magic_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
+	  for a_deplib in $deplibs; do
+	    case $a_deplib in
+	    -l*)
+	      func_stripname -l '' "$a_deplib"
+	      name=$func_stripname_result
+	      if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
+		case " $predeps $postdeps " in
+		*" $a_deplib "*)
+		  newdeplibs="$newdeplibs $a_deplib"
+		  a_deplib=""
+		  ;;
+		esac
+	      fi
+	      if test -n "$a_deplib" ; then
+		libname=`eval "\\$ECHO \"$libname_spec\""`
+		for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
+		  potential_libs=`ls $i/$libname[.-]* 2>/dev/null`
+		  for potent_lib in $potential_libs; do
+		      # Follow soft links.
+		      if ls -lLd "$potent_lib" 2>/dev/null |
+			 $GREP " -> " >/dev/null; then
+			continue
+		      fi
+		      # The statement above tries to avoid entering an
+		      # endless loop below, in case of cyclic links.
+		      # We might still enter an endless loop, since a link
+		      # loop can be closed while we follow links,
+		      # but so what?
+		      potlib="$potent_lib"
+		      while test -h "$potlib" 2>/dev/null; do
+			potliblink=`ls -ld $potlib | ${SED} 's/.* -> //'`
+			case $potliblink in
+			[\\/]* | [A-Za-z]:[\\/]*) potlib="$potliblink";;
+			*) potlib=`$ECHO "X$potlib" | $Xsed -e 's,[^/]*$,,'`"$potliblink";;
+			esac
+		      done
+		      if eval $file_magic_cmd \"\$potlib\" 2>/dev/null |
+			 $SED -e 10q |
+			 $EGREP "$file_magic_regex" > /dev/null; then
+			newdeplibs="$newdeplibs $a_deplib"
+			a_deplib=""
+			break 2
+		      fi
+		  done
+		done
+	      fi
+	      if test -n "$a_deplib" ; then
+		droppeddeps=yes
+		$ECHO
+		$ECHO "*** Warning: linker path does not have real file for library $a_deplib."
+		$ECHO "*** I have the capability to make that library automatically link in when"
+		$ECHO "*** you link to this library.  But I can only do this if you have a"
+		$ECHO "*** shared version of the library, which you do not appear to have"
+		$ECHO "*** because I did check the linker path looking for a file starting"
+		if test -z "$potlib" ; then
+		  $ECHO "*** with $libname but no candidates were found. (...for file magic test)"
+		else
+		  $ECHO "*** with $libname and none of the candidates passed a file format test"
+		  $ECHO "*** using a file magic. Last file checked: $potlib"
+		fi
+	      fi
+	      ;;
+	    *)
+	      # Add a -L argument.
+	      newdeplibs="$newdeplibs $a_deplib"
+	      ;;
+	    esac
+	  done # Gone through all deplibs.
+	  ;;
+	match_pattern*)
+	  set dummy $deplibs_check_method; shift
+	  match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
+	  for a_deplib in $deplibs; do
+	    case $a_deplib in
+	    -l*)
+	      func_stripname -l '' "$a_deplib"
+	      name=$func_stripname_result
+	      if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
+		case " $predeps $postdeps " in
+		*" $a_deplib "*)
+		  newdeplibs="$newdeplibs $a_deplib"
+		  a_deplib=""
+		  ;;
+		esac
+	      fi
+	      if test -n "$a_deplib" ; then
+		libname=`eval "\\$ECHO \"$libname_spec\""`
+		for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
+		  potential_libs=`ls $i/$libname[.-]* 2>/dev/null`
+		  for potent_lib in $potential_libs; do
+		    potlib="$potent_lib" # see symlink-check above in file_magic test
+		    if eval "\$ECHO \"X$potent_lib\"" 2>/dev/null | $Xsed -e 10q | \
+		       $EGREP "$match_pattern_regex" > /dev/null; then
+		      newdeplibs="$newdeplibs $a_deplib"
+		      a_deplib=""
+		      break 2
+		    fi
+		  done
+		done
+	      fi
+	      if test -n "$a_deplib" ; then
+		droppeddeps=yes
+		$ECHO
+		$ECHO "*** Warning: linker path does not have real file for library $a_deplib."
+		$ECHO "*** I have the capability to make that library automatically link in when"
+		$ECHO "*** you link to this library.  But I can only do this if you have a"
+		$ECHO "*** shared version of the library, which you do not appear to have"
+		$ECHO "*** because I did check the linker path looking for a file starting"
+		if test -z "$potlib" ; then
+		  $ECHO "*** with $libname but no candidates were found. (...for regex pattern test)"
+		else
+		  $ECHO "*** with $libname and none of the candidates passed a file format test"
+		  $ECHO "*** using a regex pattern. Last file checked: $potlib"
+		fi
+	      fi
+	      ;;
+	    *)
+	      # Add a -L argument.
+	      newdeplibs="$newdeplibs $a_deplib"
+	      ;;
+	    esac
+	  done # Gone through all deplibs.
+	  ;;
+	none | unknown | *)
+	  newdeplibs=""
+	  tmp_deplibs=`$ECHO "X $deplibs" | $Xsed \
+	      -e 's/ -lc$//' -e 's/ -[LR][^ ]*//g'`
+	  if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
+	    for i in $predeps $postdeps ; do
+	      # can't use Xsed below, because $i might contain '/'
+	      tmp_deplibs=`$ECHO "X $tmp_deplibs" | $Xsed -e "s,$i,,"`
+	    done
+	  fi
+	  if $ECHO "X $tmp_deplibs" | $Xsed -e 's/[	 ]//g' |
+	     $GREP . >/dev/null; then
+	    $ECHO
+	    if test "X$deplibs_check_method" = "Xnone"; then
+	      $ECHO "*** Warning: inter-library dependencies are not supported in this platform."
+	    else
+	      $ECHO "*** Warning: inter-library dependencies are not known to be supported."
+	    fi
+	    $ECHO "*** All declared inter-library dependencies are being dropped."
+	    droppeddeps=yes
+	  fi
+	  ;;
+	esac
+	versuffix=$versuffix_save
+	major=$major_save
+	release=$release_save
+	libname=$libname_save
+	name=$name_save
+
+	case $host in
+	*-*-rhapsody* | *-*-darwin1.[012])
+	  # On Rhapsody replace the C library with the System framework
+	  newdeplibs=`$ECHO "X $newdeplibs" | $Xsed -e 's/ -lc / System.ltframework /'`
+	  ;;
+	esac
+
+	if test "$droppeddeps" = yes; then
+	  if test "$module" = yes; then
+	    $ECHO
+	    $ECHO "*** Warning: libtool could not satisfy all declared inter-library"
+	    $ECHO "*** dependencies of module $libname.  Therefore, libtool will create"
+	    $ECHO "*** a static module, that should work as long as the dlopening"
+	    $ECHO "*** application is linked with the -dlopen flag."
+	    if test -z "$global_symbol_pipe"; then
+	      $ECHO
+	      $ECHO "*** However, this would only work if libtool was able to extract symbol"
+	      $ECHO "*** lists from a program, using \`nm' or equivalent, but libtool could"
+	      $ECHO "*** not find such a program.  So, this module is probably useless."
+	      $ECHO "*** \`nm' from GNU binutils and a full rebuild may help."
+	    fi
+	    if test "$build_old_libs" = no; then
+	      oldlibs="$output_objdir/$libname.$libext"
+	      build_libtool_libs=module
+	      build_old_libs=yes
+	    else
+	      build_libtool_libs=no
+	    fi
+	  else
+	    $ECHO "*** The inter-library dependencies that have been dropped here will be"
+	    $ECHO "*** automatically added whenever a program is linked with this library"
+	    $ECHO "*** or is declared to -dlopen it."
+
+	    if test "$allow_undefined" = no; then
+	      $ECHO
+	      $ECHO "*** Since this library must not contain undefined symbols,"
+	      $ECHO "*** because either the platform does not support them or"
+	      $ECHO "*** it was explicitly requested with -no-undefined,"
+	      $ECHO "*** libtool will only create a static version of it."
+	      if test "$build_old_libs" = no; then
+		oldlibs="$output_objdir/$libname.$libext"
+		build_libtool_libs=module
+		build_old_libs=yes
+	      else
+		build_libtool_libs=no
+	      fi
+	    fi
+	  fi
+	fi
+	# Done checking deplibs!
+	deplibs=$newdeplibs
+      fi
+      # Time to change all our "foo.ltframework" stuff back to "-framework foo"
+      case $host in
+	*-*-darwin*)
+	  newdeplibs=`$ECHO "X $newdeplibs" | $Xsed -e 's% \([^ $]*\).ltframework% -framework \1%g'`
+	  new_inherited_linker_flags=`$ECHO "X $new_inherited_linker_flags" | $Xsed -e 's% \([^ $]*\).ltframework% -framework \1%g'`
+	  deplibs=`$ECHO "X $deplibs" | $Xsed -e 's% \([^ $]*\).ltframework% -framework \1%g'`
+	  ;;
+      esac
+
+      # move library search paths that coincide with paths to not yet
+      # installed libraries to the beginning of the library search list
+      new_libs=
+      for path in $notinst_path; do
+	case " $new_libs " in
+	*" -L$path/$objdir "*) ;;
+	*)
+	  case " $deplibs " in
+	  *" -L$path/$objdir "*)
+	    new_libs="$new_libs -L$path/$objdir" ;;
+	  esac
+	  ;;
+	esac
+      done
+      for deplib in $deplibs; do
+	case $deplib in
+	-L*)
+	  case " $new_libs " in
+	  *" $deplib "*) ;;
+	  *) new_libs="$new_libs $deplib" ;;
+	  esac
+	  ;;
+	*) new_libs="$new_libs $deplib" ;;
+	esac
+      done
+      deplibs="$new_libs"
+
+      # All the library-specific variables (install_libdir is set above).
+      library_names=
+      old_library=
+      dlname=
+
+      # Test again, we may have decided not to build it any more
+      if test "$build_libtool_libs" = yes; then
+	if test "$hardcode_into_libs" = yes; then
+	  # Hardcode the library paths
+	  hardcode_libdirs=
+	  dep_rpath=
+	  rpath="$finalize_rpath"
+	  test "$mode" != relink && rpath="$compile_rpath$rpath"
+	  for libdir in $rpath; do
+	    if test -n "$hardcode_libdir_flag_spec"; then
+	      if test -n "$hardcode_libdir_separator"; then
+		if test -z "$hardcode_libdirs"; then
+		  hardcode_libdirs="$libdir"
+		else
+		  # Just accumulate the unique libdirs.
+		  case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
+		  *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
+		    ;;
+		  *)
+		    hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir"
+		    ;;
+		  esac
+		fi
+	      else
+		eval flag=\"$hardcode_libdir_flag_spec\"
+		dep_rpath="$dep_rpath $flag"
+	      fi
+	    elif test -n "$runpath_var"; then
+	      case "$perm_rpath " in
+	      *" $libdir "*) ;;
+	      *) perm_rpath="$perm_rpath $libdir" ;;
+	      esac
+	    fi
+	  done
+	  # Substitute the hardcoded libdirs into the rpath.
+	  if test -n "$hardcode_libdir_separator" &&
+	     test -n "$hardcode_libdirs"; then
+	    libdir="$hardcode_libdirs"
+	    if test -n "$hardcode_libdir_flag_spec_ld"; then
+	      eval dep_rpath=\"$hardcode_libdir_flag_spec_ld\"
+	    else
+	      eval dep_rpath=\"$hardcode_libdir_flag_spec\"
+	    fi
+	  fi
+	  if test -n "$runpath_var" && test -n "$perm_rpath"; then
+	    # We should set the runpath_var.
+	    rpath=
+	    for dir in $perm_rpath; do
+	      rpath="$rpath$dir:"
+	    done
+	    eval "$runpath_var='$rpath\$$runpath_var'; export $runpath_var"
+	  fi
+	  test -n "$dep_rpath" && deplibs="$dep_rpath $deplibs"
+	fi
+
+	shlibpath="$finalize_shlibpath"
+	test "$mode" != relink && shlibpath="$compile_shlibpath$shlibpath"
+	if test -n "$shlibpath"; then
+	  eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export $shlibpath_var"
+	fi
+
+	# Get the real and link names of the library.
+	eval shared_ext=\"$shrext_cmds\"
+	eval library_names=\"$library_names_spec\"
+	set dummy $library_names
+	shift
+	realname="$1"
+	shift
+
+	if test -n "$soname_spec"; then
+	  eval soname=\"$soname_spec\"
+	else
+	  soname="$realname"
+	fi
+	if test -z "$dlname"; then
+	  dlname=$soname
+	fi
+
+	lib="$output_objdir/$realname"
+	linknames=
+	for link
+	do
+	  linknames="$linknames $link"
+	done
+
+	# Use standard objects if they are pic
+	test -z "$pic_flag" && libobjs=`$ECHO "X$libobjs" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP`
+	test "X$libobjs" = "X " && libobjs=
+
+	delfiles=
+	if test -n "$export_symbols" && test -n "$include_expsyms"; then
+	  $opt_dry_run || cp "$export_symbols" "$output_objdir/$libname.uexp"
+	  export_symbols="$output_objdir/$libname.uexp"
+	  delfiles="$delfiles $export_symbols"
+	fi
+
+	orig_export_symbols=
+	case $host_os in
+	cygwin* | mingw* | cegcc*)
+	  if test -n "$export_symbols" && test -z "$export_symbols_regex"; then
+	    # exporting using user supplied symfile
+	    if test "x`$SED 1q $export_symbols`" != xEXPORTS; then
+	      # and it's NOT already a .def file. Must figure out
+	      # which of the given symbols are data symbols and tag
+	      # them as such. So, trigger use of export_symbols_cmds.
+	      # export_symbols gets reassigned inside the "prepare
+	      # the list of exported symbols" if statement, so the
+	      # include_expsyms logic still works.
+	      orig_export_symbols="$export_symbols"
+	      export_symbols=
+	      always_export_symbols=yes
+	    fi
+	  fi
+	  ;;
+	esac
+
+	# Prepare the list of exported symbols
+	if test -z "$export_symbols"; then
+	  if test "$always_export_symbols" = yes || test -n "$export_symbols_regex"; then
+	    func_verbose "generating symbol list for \`$libname.la'"
+	    export_symbols="$output_objdir/$libname.exp"
+	    $opt_dry_run || $RM $export_symbols
+	    cmds=$export_symbols_cmds
+	    save_ifs="$IFS"; IFS='~'
+	    for cmd in $cmds; do
+	      IFS="$save_ifs"
+	      eval cmd=\"$cmd\"
+	      func_len " $cmd"
+	      len=$func_len_result
+	      if test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then
+		func_show_eval "$cmd" 'exit $?'
+		skipped_export=false
+	      else
+		# The command line is too long to execute in one step.
+		func_verbose "using reloadable object file for export list..."
+		skipped_export=:
+		# Break out early, otherwise skipped_export may be
+		# set to false by a later but shorter cmd.
+		break
+	      fi
+	    done
+	    IFS="$save_ifs"
+	    if test -n "$export_symbols_regex" && test "X$skipped_export" != "X:"; then
+	      func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"'
+	      func_show_eval '$MV "${export_symbols}T" "$export_symbols"'
+	    fi
+	  fi
+	fi
+
+	if test -n "$export_symbols" && test -n "$include_expsyms"; then
+	  tmp_export_symbols="$export_symbols"
+	  test -n "$orig_export_symbols" && tmp_export_symbols="$orig_export_symbols"
+	  $opt_dry_run || eval '$ECHO "X$include_expsyms" | $Xsed | $SP2NL >> "$tmp_export_symbols"'
+	fi
+
+	if test "X$skipped_export" != "X:" && test -n "$orig_export_symbols"; then
+	  # The given exports_symbols file has to be filtered, so filter it.
+	  func_verbose "filter symbol list for \`$libname.la' to tag DATA exports"
+	  # FIXME: $output_objdir/$libname.filter potentially contains lots of
+	  # 's' commands which not all seds can handle. GNU sed should be fine
+	  # though. Also, the filter scales superlinearly with the number of
+	  # global variables. join(1) would be nice here, but unfortunately
+	  # isn't a blessed tool.
+	  $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter
+	  delfiles="$delfiles $export_symbols $output_objdir/$libname.filter"
+	  export_symbols=$output_objdir/$libname.def
+	  $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols
+	fi
+
+	tmp_deplibs=
+	for test_deplib in $deplibs; do
+	  case " $convenience " in
+	  *" $test_deplib "*) ;;
+	  *)
+	    tmp_deplibs="$tmp_deplibs $test_deplib"
+	    ;;
+	  esac
+	done
+	deplibs="$tmp_deplibs"
+
+	if test -n "$convenience"; then
+	  if test -n "$whole_archive_flag_spec" &&
+	    test "$compiler_needs_object" = yes &&
+	    test -z "$libobjs"; then
+	    # extract the archives, so we have objects to list.
+	    # TODO: could optimize this to just extract one archive.
+	    whole_archive_flag_spec=
+	  fi
+	  if test -n "$whole_archive_flag_spec"; then
+	    save_libobjs=$libobjs
+	    eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
+	    test "X$libobjs" = "X " && libobjs=
+	  else
+	    gentop="$output_objdir/${outputname}x"
+	    generated="$generated $gentop"
+
+	    func_extract_archives $gentop $convenience
+	    libobjs="$libobjs $func_extract_archives_result"
+	    test "X$libobjs" = "X " && libobjs=
+	  fi
+	fi
+
+	if test "$thread_safe" = yes && test -n "$thread_safe_flag_spec"; then
+	  eval flag=\"$thread_safe_flag_spec\"
+	  linker_flags="$linker_flags $flag"
+	fi
+
+	# Make a backup of the uninstalled library when relinking
+	if test "$mode" = relink; then
+	  $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}U && $MV $realname ${realname}U)' || exit $?
+	fi
+
+	# Do each of the archive commands.
+	if test "$module" = yes && test -n "$module_cmds" ; then
+	  if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then
+	    eval test_cmds=\"$module_expsym_cmds\"
+	    cmds=$module_expsym_cmds
+	  else
+	    eval test_cmds=\"$module_cmds\"
+	    cmds=$module_cmds
+	  fi
+	else
+	  if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
+	    eval test_cmds=\"$archive_expsym_cmds\"
+	    cmds=$archive_expsym_cmds
+	  else
+	    eval test_cmds=\"$archive_cmds\"
+	    cmds=$archive_cmds
+	  fi
+	fi
+
+	if test "X$skipped_export" != "X:" &&
+	   func_len " $test_cmds" &&
+	   len=$func_len_result &&
+	   test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then
+	  :
+	else
+	  # The command line is too long to link in one step, link piecewise
+	  # or, if using GNU ld and skipped_export is not :, use a linker
+	  # script.
+
+	  # Save the value of $output and $libobjs because we want to
+	  # use them later.  If we have whole_archive_flag_spec, we
+	  # want to use save_libobjs as it was before
+	  # whole_archive_flag_spec was expanded, because we can't
+	  # assume the linker understands whole_archive_flag_spec.
+	  # This may have to be revisited, in case too many
+	  # convenience libraries get linked in and end up exceeding
+	  # the spec.
+	  if test -z "$convenience" || test -z "$whole_archive_flag_spec"; then
+	    save_libobjs=$libobjs
+	  fi
+	  save_output=$output
+	  output_la=`$ECHO "X$output" | $Xsed -e "$basename"`
+
+	  # Clear the reloadable object creation command queue and
+	  # initialize k to one.
+	  test_cmds=
+	  concat_cmds=
+	  objlist=
+	  last_robj=
+	  k=1
+
+	  if test -n "$save_libobjs" && test "X$skipped_export" != "X:" && test "$with_gnu_ld" = yes; then
+	    output=${output_objdir}/${output_la}.lnkscript
+	    func_verbose "creating GNU ld script: $output"
+	    $ECHO 'INPUT (' > $output
+	    for obj in $save_libobjs
+	    do
+	      $ECHO "$obj" >> $output
+	    done
+	    $ECHO ')' >> $output
+	    delfiles="$delfiles $output"
+	  elif test -n "$save_libobjs" && test "X$skipped_export" != "X:" && test "X$file_list_spec" != X; then
+	    output=${output_objdir}/${output_la}.lnk
+	    func_verbose "creating linker input file list: $output"
+	    : > $output
+	    set x $save_libobjs
+	    shift
+	    firstobj=
+	    if test "$compiler_needs_object" = yes; then
+	      firstobj="$1 "
+	      shift
+	    fi
+	    for obj
+	    do
+	      $ECHO "$obj" >> $output
+	    done
+	    delfiles="$delfiles $output"
+	    output=$firstobj\"$file_list_spec$output\"
+	  else
+	    if test -n "$save_libobjs"; then
+	      func_verbose "creating reloadable object files..."
+	      output=$output_objdir/$output_la-${k}.$objext
+	      eval test_cmds=\"$reload_cmds\"
+	      func_len " $test_cmds"
+	      len0=$func_len_result
+	      len=$len0
+
+	      # Loop over the list of objects to be linked.
+	      for obj in $save_libobjs
+	      do
+		func_len " $obj"
+		func_arith $len + $func_len_result
+		len=$func_arith_result
+		if test "X$objlist" = X ||
+		   test "$len" -lt "$max_cmd_len"; then
+		  func_append objlist " $obj"
+		else
+		  # The command $test_cmds is almost too long, add a
+		  # command to the queue.
+		  if test "$k" -eq 1 ; then
+		    # The first file doesn't have a previous command to add.
+		    eval concat_cmds=\"$reload_cmds $objlist $last_robj\"
+		  else
+		    # All subsequent reloadable object files will link in
+		    # the last one created.
+		    eval concat_cmds=\"\$concat_cmds~$reload_cmds $objlist $last_robj~\$RM $last_robj\"
+		  fi
+		  last_robj=$output_objdir/$output_la-${k}.$objext
+		  func_arith $k + 1
+		  k=$func_arith_result
+		  output=$output_objdir/$output_la-${k}.$objext
+		  objlist=$obj
+		  func_len " $last_robj"
+		  func_arith $len0 + $func_len_result
+		  len=$func_arith_result
+		fi
+	      done
+	      # Handle the remaining objects by creating one last
+	      # reloadable object file.  All subsequent reloadable object
+	      # files will link in the last one created.
+	      test -z "$concat_cmds" || concat_cmds=$concat_cmds~
+	      eval concat_cmds=\"\${concat_cmds}$reload_cmds $objlist $last_robj\"
+	      if test -n "$last_robj"; then
+	        eval concat_cmds=\"\${concat_cmds}~\$RM $last_robj\"
+	      fi
+	      delfiles="$delfiles $output"
+
+	    else
+	      output=
+	    fi
+
+	    if ${skipped_export-false}; then
+	      func_verbose "generating symbol list for \`$libname.la'"
+	      export_symbols="$output_objdir/$libname.exp"
+	      $opt_dry_run || $RM $export_symbols
+	      libobjs=$output
+	      # Append the command to create the export file.
+	      test -z "$concat_cmds" || concat_cmds=$concat_cmds~
+	      eval concat_cmds=\"\$concat_cmds$export_symbols_cmds\"
+	      if test -n "$last_robj"; then
+		eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\"
+	      fi
+	    fi
+
+	    test -n "$save_libobjs" &&
+	      func_verbose "creating a temporary reloadable object file: $output"
+
+	    # Loop through the commands generated above and execute them.
+	    save_ifs="$IFS"; IFS='~'
+	    for cmd in $concat_cmds; do
+	      IFS="$save_ifs"
+	      $opt_silent || {
+		  func_quote_for_expand "$cmd"
+		  eval "func_echo $func_quote_for_expand_result"
+	      }
+	      $opt_dry_run || eval "$cmd" || {
+		lt_exit=$?
+
+		# Restore the uninstalled library and exit
+		if test "$mode" = relink; then
+		  ( cd "$output_objdir" && \
+		    $RM "${realname}T" && \
+		    $MV "${realname}U" "$realname" )
+		fi
+
+		exit $lt_exit
+	      }
+	    done
+	    IFS="$save_ifs"
+
+	    if test -n "$export_symbols_regex" && ${skipped_export-false}; then
+	      func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"'
+	      func_show_eval '$MV "${export_symbols}T" "$export_symbols"'
+	    fi
+	  fi
+
+          if ${skipped_export-false}; then
+	    if test -n "$export_symbols" && test -n "$include_expsyms"; then
+	      tmp_export_symbols="$export_symbols"
+	      test -n "$orig_export_symbols" && tmp_export_symbols="$orig_export_symbols"
+	      $opt_dry_run || eval '$ECHO "X$include_expsyms" | $Xsed | $SP2NL >> "$tmp_export_symbols"'
+	    fi
+
+	    if test -n "$orig_export_symbols"; then
+	      # The given exports_symbols file has to be filtered, so filter it.
+	      func_verbose "filter symbol list for \`$libname.la' to tag DATA exports"
+	      # FIXME: $output_objdir/$libname.filter potentially contains lots of
+	      # 's' commands which not all seds can handle. GNU sed should be fine
+	      # though. Also, the filter scales superlinearly with the number of
+	      # global variables. join(1) would be nice here, but unfortunately
+	      # isn't a blessed tool.
+	      $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter
+	      delfiles="$delfiles $export_symbols $output_objdir/$libname.filter"
+	      export_symbols=$output_objdir/$libname.def
+	      $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols
+	    fi
+	  fi
+
+	  libobjs=$output
+	  # Restore the value of output.
+	  output=$save_output
+
+	  if test -n "$convenience" && test -n "$whole_archive_flag_spec"; then
+	    eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
+	    test "X$libobjs" = "X " && libobjs=
+	  fi
+	  # Expand the library linking commands again to reset the
+	  # value of $libobjs for piecewise linking.
+
+	  # Do each of the archive commands.
+	  if test "$module" = yes && test -n "$module_cmds" ; then
+	    if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then
+	      cmds=$module_expsym_cmds
+	    else
+	      cmds=$module_cmds
+	    fi
+	  else
+	    if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
+	      cmds=$archive_expsym_cmds
+	    else
+	      cmds=$archive_cmds
+	    fi
+	  fi
+	fi
+
+	if test -n "$delfiles"; then
+	  # Append the command to remove temporary files to $cmds.
+	  eval cmds=\"\$cmds~\$RM $delfiles\"
+	fi
+
+	# Add any objects from preloaded convenience libraries
+	if test -n "$dlprefiles"; then
+	  gentop="$output_objdir/${outputname}x"
+	  generated="$generated $gentop"
+
+	  func_extract_archives $gentop $dlprefiles
+	  libobjs="$libobjs $func_extract_archives_result"
+	  test "X$libobjs" = "X " && libobjs=
+	fi
+
+	save_ifs="$IFS"; IFS='~'
+	for cmd in $cmds; do
+	  IFS="$save_ifs"
+	  eval cmd=\"$cmd\"
+	  $opt_silent || {
+	    func_quote_for_expand "$cmd"
+	    eval "func_echo $func_quote_for_expand_result"
+	  }
+	  $opt_dry_run || eval "$cmd" || {
+	    lt_exit=$?
+
+	    # Restore the uninstalled library and exit
+	    if test "$mode" = relink; then
+	      ( cd "$output_objdir" && \
+	        $RM "${realname}T" && \
+		$MV "${realname}U" "$realname" )
+	    fi
+
+	    exit $lt_exit
+	  }
+	done
+	IFS="$save_ifs"
+
+	# Restore the uninstalled library and exit
+	if test "$mode" = relink; then
+	  $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}T && $MV $realname ${realname}T && $MV ${realname}U $realname)' || exit $?
+
+	  if test -n "$convenience"; then
+	    if test -z "$whole_archive_flag_spec"; then
+	      func_show_eval '${RM}r "$gentop"'
+	    fi
+	  fi
+
+	  exit $EXIT_SUCCESS
+	fi
+
+	# Create links to the real library.
+	for linkname in $linknames; do
+	  if test "$realname" != "$linkname"; then
+	    func_show_eval '(cd "$output_objdir" && $RM "$linkname" && $LN_S "$realname" "$linkname")' 'exit $?'
+	  fi
+	done
+
+	# If -module or -export-dynamic was specified, set the dlname.
+	if test "$module" = yes || test "$export_dynamic" = yes; then
+	  # On all known operating systems, these are identical.
+	  dlname="$soname"
+	fi
+      fi
+      ;;
+
+    obj)
+      if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
+	func_warning "\`-dlopen' is ignored for objects"
+      fi
+
+      case " $deplibs" in
+      *\ -l* | *\ -L*)
+	func_warning "\`-l' and \`-L' are ignored for objects" ;;
+      esac
+
+      test -n "$rpath" && \
+	func_warning "\`-rpath' is ignored for objects"
+
+      test -n "$xrpath" && \
+	func_warning "\`-R' is ignored for objects"
+
+      test -n "$vinfo" && \
+	func_warning "\`-version-info' is ignored for objects"
+
+      test -n "$release" && \
+	func_warning "\`-release' is ignored for objects"
+
+      case $output in
+      *.lo)
+	test -n "$objs$old_deplibs" && \
+	  func_fatal_error "cannot build library object \`$output' from non-libtool objects"
+
+	libobj=$output
+	func_lo2o "$libobj"
+	obj=$func_lo2o_result
+	;;
+      *)
+	libobj=
+	obj="$output"
+	;;
+      esac
+
+      # Delete the old objects.
+      $opt_dry_run || $RM $obj $libobj
+
+      # Objects from convenience libraries.  This assumes
+      # single-version convenience libraries.  Whenever we create
+      # different ones for PIC/non-PIC, this we'll have to duplicate
+      # the extraction.
+      reload_conv_objs=
+      gentop=
+      # reload_cmds runs $LD directly, so let us get rid of
+      # -Wl from whole_archive_flag_spec and hope we can get by with
+      # turning comma into space..
+      wl=
+
+      if test -n "$convenience"; then
+	if test -n "$whole_archive_flag_spec"; then
+	  eval tmp_whole_archive_flags=\"$whole_archive_flag_spec\"
+	  reload_conv_objs=$reload_objs\ `$ECHO "X$tmp_whole_archive_flags" | $Xsed -e 's|,| |g'`
+	else
+	  gentop="$output_objdir/${obj}x"
+	  generated="$generated $gentop"
+
+	  func_extract_archives $gentop $convenience
+	  reload_conv_objs="$reload_objs $func_extract_archives_result"
+	fi
+      fi
+
+      # Create the old-style object.
+      reload_objs="$objs$old_deplibs "`$ECHO "X$libobjs" | $SP2NL | $Xsed -e '/\.'${libext}$'/d' -e '/\.lib$/d' -e "$lo2o" | $NL2SP`" $reload_conv_objs" ### testsuite: skip nested quoting test
+
+      output="$obj"
+      func_execute_cmds "$reload_cmds" 'exit $?'
+
+      # Exit if we aren't doing a library object file.
+      if test -z "$libobj"; then
+	if test -n "$gentop"; then
+	  func_show_eval '${RM}r "$gentop"'
+	fi
+
+	exit $EXIT_SUCCESS
+      fi
+
+      if test "$build_libtool_libs" != yes; then
+	if test -n "$gentop"; then
+	  func_show_eval '${RM}r "$gentop"'
+	fi
+
+	# Create an invalid libtool object if no PIC, so that we don't
+	# accidentally link it into a program.
+	# $show "echo timestamp > $libobj"
+	# $opt_dry_run || eval "echo timestamp > $libobj" || exit $?
+	exit $EXIT_SUCCESS
+      fi
+
+      if test -n "$pic_flag" || test "$pic_mode" != default; then
+	# Only do commands if we really have different PIC objects.
+	reload_objs="$libobjs $reload_conv_objs"
+	output="$libobj"
+	func_execute_cmds "$reload_cmds" 'exit $?'
+      fi
+
+      if test -n "$gentop"; then
+	func_show_eval '${RM}r "$gentop"'
+      fi
+
+      exit $EXIT_SUCCESS
+      ;;
+
+    prog)
+      case $host in
+	*cygwin*) func_stripname '' '.exe' "$output"
+	          output=$func_stripname_result.exe;;
+      esac
+      test -n "$vinfo" && \
+	func_warning "\`-version-info' is ignored for programs"
+
+      test -n "$release" && \
+	func_warning "\`-release' is ignored for programs"
+
+      test "$preload" = yes \
+        && test "$dlopen_support" = unknown \
+	&& test "$dlopen_self" = unknown \
+	&& test "$dlopen_self_static" = unknown && \
+	  func_warning "\`LT_INIT([dlopen])' not used. Assuming no dlopen support."
+
+      case $host in
+      *-*-rhapsody* | *-*-darwin1.[012])
+	# On Rhapsody replace the C library is the System framework
+	compile_deplibs=`$ECHO "X $compile_deplibs" | $Xsed -e 's/ -lc / System.ltframework /'`
+	finalize_deplibs=`$ECHO "X $finalize_deplibs" | $Xsed -e 's/ -lc / System.ltframework /'`
+	;;
+      esac
+
+      case $host in
+      *-*-darwin*)
+	# Don't allow lazy linking, it breaks C++ global constructors
+	# But is supposedly fixed on 10.4 or later (yay!).
+	if test "$tagname" = CXX ; then
+	  case ${MACOSX_DEPLOYMENT_TARGET-10.0} in
+	    10.[0123])
+	      compile_command="$compile_command ${wl}-bind_at_load"
+	      finalize_command="$finalize_command ${wl}-bind_at_load"
+	    ;;
+	  esac
+	fi
+	# Time to change all our "foo.ltframework" stuff back to "-framework foo"
+	compile_deplibs=`$ECHO "X $compile_deplibs" | $Xsed -e 's% \([^ $]*\).ltframework% -framework \1%g'`
+	finalize_deplibs=`$ECHO "X $finalize_deplibs" | $Xsed -e 's% \([^ $]*\).ltframework% -framework \1%g'`
+	;;
+      esac
+
+
+      # move library search paths that coincide with paths to not yet
+      # installed libraries to the beginning of the library search list
+      new_libs=
+      for path in $notinst_path; do
+	case " $new_libs " in
+	*" -L$path/$objdir "*) ;;
+	*)
+	  case " $compile_deplibs " in
+	  *" -L$path/$objdir "*)
+	    new_libs="$new_libs -L$path/$objdir" ;;
+	  esac
+	  ;;
+	esac
+      done
+      for deplib in $compile_deplibs; do
+	case $deplib in
+	-L*)
+	  case " $new_libs " in
+	  *" $deplib "*) ;;
+	  *) new_libs="$new_libs $deplib" ;;
+	  esac
+	  ;;
+	*) new_libs="$new_libs $deplib" ;;
+	esac
+      done
+      compile_deplibs="$new_libs"
+
+
+      compile_command="$compile_command $compile_deplibs"
+      finalize_command="$finalize_command $finalize_deplibs"
+
+      if test -n "$rpath$xrpath"; then
+	# If the user specified any rpath flags, then add them.
+	for libdir in $rpath $xrpath; do
+	  # This is the magic to use -rpath.
+	  case "$finalize_rpath " in
+	  *" $libdir "*) ;;
+	  *) finalize_rpath="$finalize_rpath $libdir" ;;
+	  esac
+	done
+      fi
+
+      # Now hardcode the library paths
+      rpath=
+      hardcode_libdirs=
+      for libdir in $compile_rpath $finalize_rpath; do
+	if test -n "$hardcode_libdir_flag_spec"; then
+	  if test -n "$hardcode_libdir_separator"; then
+	    if test -z "$hardcode_libdirs"; then
+	      hardcode_libdirs="$libdir"
+	    else
+	      # Just accumulate the unique libdirs.
+	      case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
+	      *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
+		;;
+	      *)
+		hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir"
+		;;
+	      esac
+	    fi
+	  else
+	    eval flag=\"$hardcode_libdir_flag_spec\"
+	    rpath="$rpath $flag"
+	  fi
+	elif test -n "$runpath_var"; then
+	  case "$perm_rpath " in
+	  *" $libdir "*) ;;
+	  *) perm_rpath="$perm_rpath $libdir" ;;
+	  esac
+	fi
+	case $host in
+	*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
+	  testbindir=`${ECHO} "$libdir" | ${SED} -e 's*/lib$*/bin*'`
+	  case :$dllsearchpath: in
+	  *":$libdir:"*) ;;
+	  ::) dllsearchpath=$libdir;;
+	  *) dllsearchpath="$dllsearchpath:$libdir";;
+	  esac
+	  case :$dllsearchpath: in
+	  *":$testbindir:"*) ;;
+	  ::) dllsearchpath=$testbindir;;
+	  *) dllsearchpath="$dllsearchpath:$testbindir";;
+	  esac
+	  ;;
+	esac
+      done
+      # Substitute the hardcoded libdirs into the rpath.
+      if test -n "$hardcode_libdir_separator" &&
+	 test -n "$hardcode_libdirs"; then
+	libdir="$hardcode_libdirs"
+	eval rpath=\" $hardcode_libdir_flag_spec\"
+      fi
+      compile_rpath="$rpath"
+
+      rpath=
+      hardcode_libdirs=
+      for libdir in $finalize_rpath; do
+	if test -n "$hardcode_libdir_flag_spec"; then
+	  if test -n "$hardcode_libdir_separator"; then
+	    if test -z "$hardcode_libdirs"; then
+	      hardcode_libdirs="$libdir"
+	    else
+	      # Just accumulate the unique libdirs.
+	      case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
+	      *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
+		;;
+	      *)
+		hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir"
+		;;
+	      esac
+	    fi
+	  else
+	    eval flag=\"$hardcode_libdir_flag_spec\"
+	    rpath="$rpath $flag"
+	  fi
+	elif test -n "$runpath_var"; then
+	  case "$finalize_perm_rpath " in
+	  *" $libdir "*) ;;
+	  *) finalize_perm_rpath="$finalize_perm_rpath $libdir" ;;
+	  esac
+	fi
+      done
+      # Substitute the hardcoded libdirs into the rpath.
+      if test -n "$hardcode_libdir_separator" &&
+	 test -n "$hardcode_libdirs"; then
+	libdir="$hardcode_libdirs"
+	eval rpath=\" $hardcode_libdir_flag_spec\"
+      fi
+      finalize_rpath="$rpath"
+
+      if test -n "$libobjs" && test "$build_old_libs" = yes; then
+	# Transform all the library objects into standard objects.
+	compile_command=`$ECHO "X$compile_command" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP`
+	finalize_command=`$ECHO "X$finalize_command" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP`
+      fi
+
+      func_generate_dlsyms "$outputname" "@PROGRAM@" "no"
+
+      # template prelinking step
+      if test -n "$prelink_cmds"; then
+	func_execute_cmds "$prelink_cmds" 'exit $?'
+      fi
+
+      wrappers_required=yes
+      case $host in
+      *cygwin* | *mingw* )
+        if test "$build_libtool_libs" != yes; then
+          wrappers_required=no
+        fi
+        ;;
+      *cegcc)
+        # Disable wrappers for cegcc, we are cross compiling anyway.
+        wrappers_required=no
+        ;;
+      *)
+        if test "$need_relink" = no || test "$build_libtool_libs" != yes; then
+          wrappers_required=no
+        fi
+        ;;
+      esac
+      if test "$wrappers_required" = no; then
+	# Replace the output file specification.
+	compile_command=`$ECHO "X$compile_command" | $Xsed -e 's%@OUTPUT@%'"$output"'%g'`
+	link_command="$compile_command$compile_rpath"
+
+	# We have no uninstalled library dependencies, so finalize right now.
+	exit_status=0
+	func_show_eval "$link_command" 'exit_status=$?'
+
+	# Delete the generated files.
+	if test -f "$output_objdir/${outputname}S.${objext}"; then
+	  func_show_eval '$RM "$output_objdir/${outputname}S.${objext}"'
+	fi
+
+	exit $exit_status
+      fi
+
+      if test -n "$compile_shlibpath$finalize_shlibpath"; then
+	compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command"
+      fi
+      if test -n "$finalize_shlibpath"; then
+	finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command"
+      fi
+
+      compile_var=
+      finalize_var=
+      if test -n "$runpath_var"; then
+	if test -n "$perm_rpath"; then
+	  # We should set the runpath_var.
+	  rpath=
+	  for dir in $perm_rpath; do
+	    rpath="$rpath$dir:"
+	  done
+	  compile_var="$runpath_var=\"$rpath\$$runpath_var\" "
+	fi
+	if test -n "$finalize_perm_rpath"; then
+	  # We should set the runpath_var.
+	  rpath=
+	  for dir in $finalize_perm_rpath; do
+	    rpath="$rpath$dir:"
+	  done
+	  finalize_var="$runpath_var=\"$rpath\$$runpath_var\" "
+	fi
+      fi
+
+      if test "$no_install" = yes; then
+	# We don't need to create a wrapper script.
+	link_command="$compile_var$compile_command$compile_rpath"
+	# Replace the output file specification.
+	link_command=`$ECHO "X$link_command" | $Xsed -e 's%@OUTPUT@%'"$output"'%g'`
+	# Delete the old output file.
+	$opt_dry_run || $RM $output
+	# Link the executable and exit
+	func_show_eval "$link_command" 'exit $?'
+	exit $EXIT_SUCCESS
+      fi
+
+      if test "$hardcode_action" = relink; then
+	# Fast installation is not supported
+	link_command="$compile_var$compile_command$compile_rpath"
+	relink_command="$finalize_var$finalize_command$finalize_rpath"
+
+	func_warning "this platform does not like uninstalled shared libraries"
+	func_warning "\`$output' will be relinked during installation"
+      else
+	if test "$fast_install" != no; then
+	  link_command="$finalize_var$compile_command$finalize_rpath"
+	  if test "$fast_install" = yes; then
+	    relink_command=`$ECHO "X$compile_var$compile_command$compile_rpath" | $Xsed -e 's%@OUTPUT@%\$progdir/\$file%g'`
+	  else
+	    # fast_install is set to needless
+	    relink_command=
+	  fi
+	else
+	  link_command="$compile_var$compile_command$compile_rpath"
+	  relink_command="$finalize_var$finalize_command$finalize_rpath"
+	fi
+      fi
+
+      # Replace the output file specification.
+      link_command=`$ECHO "X$link_command" | $Xsed -e 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'`
+
+      # Delete the old output files.
+      $opt_dry_run || $RM $output $output_objdir/$outputname $output_objdir/lt-$outputname
+
+      func_show_eval "$link_command" 'exit $?'
+
+      # Now create the wrapper script.
+      func_verbose "creating $output"
+
+      # Quote the relink command for shipping.
+      if test -n "$relink_command"; then
+	# Preserve any variables that may affect compiler behavior
+	for var in $variables_saved_for_relink; do
+	  if eval test -z \"\${$var+set}\"; then
+	    relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command"
+	  elif eval var_value=\$$var; test -z "$var_value"; then
+	    relink_command="$var=; export $var; $relink_command"
+	  else
+	    func_quote_for_eval "$var_value"
+	    relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command"
+	  fi
+	done
+	relink_command="(cd `pwd`; $relink_command)"
+	relink_command=`$ECHO "X$relink_command" | $Xsed -e "$sed_quote_subst"`
+      fi
+
+      # Quote $ECHO for shipping.
+      if test "X$ECHO" = "X$SHELL $progpath --fallback-echo"; then
+	case $progpath in
+	[\\/]* | [A-Za-z]:[\\/]*) qecho="$SHELL $progpath --fallback-echo";;
+	*) qecho="$SHELL `pwd`/$progpath --fallback-echo";;
+	esac
+	qecho=`$ECHO "X$qecho" | $Xsed -e "$sed_quote_subst"`
+      else
+	qecho=`$ECHO "X$ECHO" | $Xsed -e "$sed_quote_subst"`
+      fi
+
+      # Only actually do things if not in dry run mode.
+      $opt_dry_run || {
+	# win32 will think the script is a binary if it has
+	# a .exe suffix, so we strip it off here.
+	case $output in
+	  *.exe) func_stripname '' '.exe' "$output"
+	         output=$func_stripname_result ;;
+	esac
+	# test for cygwin because mv fails w/o .exe extensions
+	case $host in
+	  *cygwin*)
+	    exeext=.exe
+	    func_stripname '' '.exe' "$outputname"
+	    outputname=$func_stripname_result ;;
+	  *) exeext= ;;
+	esac
+	case $host in
+	  *cygwin* | *mingw* )
+	    func_dirname_and_basename "$output" "" "."
+	    output_name=$func_basename_result
+	    output_path=$func_dirname_result
+	    cwrappersource="$output_path/$objdir/lt-$output_name.c"
+	    cwrapper="$output_path/$output_name.exe"
+	    $RM $cwrappersource $cwrapper
+	    trap "$RM $cwrappersource $cwrapper; exit $EXIT_FAILURE" 1 2 15
+
+	    func_emit_cwrapperexe_src > $cwrappersource
+
+	    # The wrapper executable is built using the $host compiler,
+	    # because it contains $host paths and files. If cross-
+	    # compiling, it, like the target executable, must be
+	    # executed on the $host or under an emulation environment.
+	    $opt_dry_run || {
+	      $LTCC $LTCFLAGS -o $cwrapper $cwrappersource
+	      $STRIP $cwrapper
+	    }
+
+	    # Now, create the wrapper script for func_source use:
+	    func_ltwrapper_scriptname $cwrapper
+	    $RM $func_ltwrapper_scriptname_result
+	    trap "$RM $func_ltwrapper_scriptname_result; exit $EXIT_FAILURE" 1 2 15
+	    $opt_dry_run || {
+	      # note: this script will not be executed, so do not chmod.
+	      if test "x$build" = "x$host" ; then
+		$cwrapper --lt-dump-script > $func_ltwrapper_scriptname_result
+	      else
+		func_emit_wrapper no > $func_ltwrapper_scriptname_result
+	      fi
+	    }
+	  ;;
+	  * )
+	    $RM $output
+	    trap "$RM $output; exit $EXIT_FAILURE" 1 2 15
+
+	    func_emit_wrapper no > $output
+	    chmod +x $output
+	  ;;
+	esac
+      }
+      exit $EXIT_SUCCESS
+      ;;
+    esac
+
+    # See if we need to build an old-fashioned archive.
+    for oldlib in $oldlibs; do
+
+      if test "$build_libtool_libs" = convenience; then
+	oldobjs="$libobjs_save $symfileobj"
+	addlibs="$convenience"
+	build_libtool_libs=no
+      else
+	if test "$build_libtool_libs" = module; then
+	  oldobjs="$libobjs_save"
+	  build_libtool_libs=no
+	else
+	  oldobjs="$old_deplibs $non_pic_objects"
+	  if test "$preload" = yes && test -f "$symfileobj"; then
+	    oldobjs="$oldobjs $symfileobj"
+	  fi
+	fi
+	addlibs="$old_convenience"
+      fi
+
+      if test -n "$addlibs"; then
+	gentop="$output_objdir/${outputname}x"
+	generated="$generated $gentop"
+
+	func_extract_archives $gentop $addlibs
+	oldobjs="$oldobjs $func_extract_archives_result"
+      fi
+
+      # Do each command in the archive commands.
+      if test -n "$old_archive_from_new_cmds" && test "$build_libtool_libs" = yes; then
+	cmds=$old_archive_from_new_cmds
+      else
+
+	# Add any objects from preloaded convenience libraries
+	if test -n "$dlprefiles"; then
+	  gentop="$output_objdir/${outputname}x"
+	  generated="$generated $gentop"
+
+	  func_extract_archives $gentop $dlprefiles
+	  oldobjs="$oldobjs $func_extract_archives_result"
+	fi
+
+	# POSIX demands no paths to be encoded in archives.  We have
+	# to avoid creating archives with duplicate basenames if we
+	# might have to extract them afterwards, e.g., when creating a
+	# static archive out of a convenience library, or when linking
+	# the entirety of a libtool archive into another (currently
+	# not supported by libtool).
+	if (for obj in $oldobjs
+	    do
+	      func_basename "$obj"
+	      $ECHO "$func_basename_result"
+	    done | sort | sort -uc >/dev/null 2>&1); then
+	  :
+	else
+	  $ECHO "copying selected object files to avoid basename conflicts..."
+	  gentop="$output_objdir/${outputname}x"
+	  generated="$generated $gentop"
+	  func_mkdir_p "$gentop"
+	  save_oldobjs=$oldobjs
+	  oldobjs=
+	  counter=1
+	  for obj in $save_oldobjs
+	  do
+	    func_basename "$obj"
+	    objbase="$func_basename_result"
+	    case " $oldobjs " in
+	    " ") oldobjs=$obj ;;
+	    *[\ /]"$objbase "*)
+	      while :; do
+		# Make sure we don't pick an alternate name that also
+		# overlaps.
+		newobj=lt$counter-$objbase
+		func_arith $counter + 1
+		counter=$func_arith_result
+		case " $oldobjs " in
+		*[\ /]"$newobj "*) ;;
+		*) if test ! -f "$gentop/$newobj"; then break; fi ;;
+		esac
+	      done
+	      func_show_eval "ln $obj $gentop/$newobj || cp $obj $gentop/$newobj"
+	      oldobjs="$oldobjs $gentop/$newobj"
+	      ;;
+	    *) oldobjs="$oldobjs $obj" ;;
+	    esac
+	  done
+	fi
+	eval cmds=\"$old_archive_cmds\"
+
+	func_len " $cmds"
+	len=$func_len_result
+	if test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then
+	  cmds=$old_archive_cmds
+	else
+	  # the command line is too long to link in one step, link in parts
+	  func_verbose "using piecewise archive linking..."
+	  save_RANLIB=$RANLIB
+	  RANLIB=:
+	  objlist=
+	  concat_cmds=
+	  save_oldobjs=$oldobjs
+	  oldobjs=
+	  # Is there a better way of finding the last object in the list?
+	  for obj in $save_oldobjs
+	  do
+	    last_oldobj=$obj
+	  done
+	  eval test_cmds=\"$old_archive_cmds\"
+	  func_len " $test_cmds"
+	  len0=$func_len_result
+	  len=$len0
+	  for obj in $save_oldobjs
+	  do
+	    func_len " $obj"
+	    func_arith $len + $func_len_result
+	    len=$func_arith_result
+	    func_append objlist " $obj"
+	    if test "$len" -lt "$max_cmd_len"; then
+	      :
+	    else
+	      # the above command should be used before it gets too long
+	      oldobjs=$objlist
+	      if test "$obj" = "$last_oldobj" ; then
+		RANLIB=$save_RANLIB
+	      fi
+	      test -z "$concat_cmds" || concat_cmds=$concat_cmds~
+	      eval concat_cmds=\"\${concat_cmds}$old_archive_cmds\"
+	      objlist=
+	      len=$len0
+	    fi
+	  done
+	  RANLIB=$save_RANLIB
+	  oldobjs=$objlist
+	  if test "X$oldobjs" = "X" ; then
+	    eval cmds=\"\$concat_cmds\"
+	  else
+	    eval cmds=\"\$concat_cmds~\$old_archive_cmds\"
+	  fi
+	fi
+      fi
+      func_execute_cmds "$cmds" 'exit $?'
+    done
+
+    test -n "$generated" && \
+      func_show_eval "${RM}r$generated"
+
+    # Now create the libtool archive.
+    case $output in
+    *.la)
+      old_library=
+      test "$build_old_libs" = yes && old_library="$libname.$libext"
+      func_verbose "creating $output"
+
+      # Preserve any variables that may affect compiler behavior
+      for var in $variables_saved_for_relink; do
+	if eval test -z \"\${$var+set}\"; then
+	  relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command"
+	elif eval var_value=\$$var; test -z "$var_value"; then
+	  relink_command="$var=; export $var; $relink_command"
+	else
+	  func_quote_for_eval "$var_value"
+	  relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command"
+	fi
+      done
+      # Quote the link command for shipping.
+      relink_command="(cd `pwd`; $SHELL $progpath $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)"
+      relink_command=`$ECHO "X$relink_command" | $Xsed -e "$sed_quote_subst"`
+      if test "$hardcode_automatic" = yes ; then
+	relink_command=
+      fi
+
+      # Only create the output if not a dry run.
+      $opt_dry_run || {
+	for installed in no yes; do
+	  if test "$installed" = yes; then
+	    if test -z "$install_libdir"; then
+	      break
+	    fi
+	    output="$output_objdir/$outputname"i
+	    # Replace all uninstalled libtool libraries with the installed ones
+	    newdependency_libs=
+	    for deplib in $dependency_libs; do
+	      case $deplib in
+	      *.la)
+		func_basename "$deplib"
+		name="$func_basename_result"
+		eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib`
+		test -z "$libdir" && \
+		  func_fatal_error "\`$deplib' is not a valid libtool archive"
+		newdependency_libs="$newdependency_libs $libdir/$name"
+		;;
+	      *) newdependency_libs="$newdependency_libs $deplib" ;;
+	      esac
+	    done
+	    dependency_libs="$newdependency_libs"
+	    newdlfiles=
+
+	    for lib in $dlfiles; do
+	      case $lib in
+	      *.la)
+	        func_basename "$lib"
+		name="$func_basename_result"
+		eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
+		test -z "$libdir" && \
+		  func_fatal_error "\`$lib' is not a valid libtool archive"
+		newdlfiles="$newdlfiles $libdir/$name"
+		;;
+	      *) newdlfiles="$newdlfiles $lib" ;;
+	      esac
+	    done
+	    dlfiles="$newdlfiles"
+	    newdlprefiles=
+	    for lib in $dlprefiles; do
+	      case $lib in
+	      *.la)
+		# Only pass preopened files to the pseudo-archive (for
+		# eventual linking with the app. that links it) if we
+		# didn't already link the preopened objects directly into
+		# the library:
+		func_basename "$lib"
+		name="$func_basename_result"
+		eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
+		test -z "$libdir" && \
+		  func_fatal_error "\`$lib' is not a valid libtool archive"
+		newdlprefiles="$newdlprefiles $libdir/$name"
+		;;
+	      esac
+	    done
+	    dlprefiles="$newdlprefiles"
+	  else
+	    newdlfiles=
+	    for lib in $dlfiles; do
+	      case $lib in
+		[\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;;
+		*) abs=`pwd`"/$lib" ;;
+	      esac
+	      newdlfiles="$newdlfiles $abs"
+	    done
+	    dlfiles="$newdlfiles"
+	    newdlprefiles=
+	    for lib in $dlprefiles; do
+	      case $lib in
+		[\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;;
+		*) abs=`pwd`"/$lib" ;;
+	      esac
+	      newdlprefiles="$newdlprefiles $abs"
+	    done
+	    dlprefiles="$newdlprefiles"
+	  fi
+	  $RM $output
+	  # place dlname in correct position for cygwin
+	  tdlname=$dlname
+	  case $host,$output,$installed,$module,$dlname in
+	    *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll | *cegcc*,*lai,yes,no,*.dll) tdlname=../bin/$dlname ;;
+	  esac
+	  $ECHO > $output "\
+# $outputname - a libtool library file
+# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
+#
+# Please DO NOT delete this file!
+# It is necessary for linking the library.
+
+# The name that we can dlopen(3).
+dlname='$tdlname'
+
+# Names of this library.
+library_names='$library_names'
+
+# The name of the static archive.
+old_library='$old_library'
+
+# Linker flags that can not go in dependency_libs.
+inherited_linker_flags='$new_inherited_linker_flags'
+
+# Libraries that this one depends upon.
+dependency_libs='$dependency_libs'
+
+# Names of additional weak libraries provided by this library
+weak_library_names='$weak_libs'
+
+# Version information for $libname.
+current=$current
+age=$age
+revision=$revision
+
+# Is this an already installed library?
+installed=$installed
+
+# Should we warn about portability when linking against -modules?
+shouldnotlink=$module
+
+# Files to dlopen/dlpreopen
+dlopen='$dlfiles'
+dlpreopen='$dlprefiles'
+
+# Directory that this library needs to be installed in:
+libdir='$install_libdir'"
+	  if test "$installed" = no && test "$need_relink" = yes; then
+	    $ECHO >> $output "\
+relink_command=\"$relink_command\""
+	  fi
+	done
+      }
+
+      # Do a symbolic link so that the libtool archive can be found in
+      # LD_LIBRARY_PATH before the program is installed.
+      func_show_eval '( cd "$output_objdir" && $RM "$outputname" && $LN_S "../$outputname" "$outputname" )' 'exit $?'
+      ;;
+    esac
+    exit $EXIT_SUCCESS
+}
+
+{ test "$mode" = link || test "$mode" = relink; } &&
+    func_mode_link ${1+"$@"}
+
+
+# func_mode_uninstall arg...
+func_mode_uninstall ()
+{
+    $opt_debug
+    RM="$nonopt"
+    files=
+    rmforce=
+    exit_status=0
+
+    # This variable tells wrapper scripts just to set variables rather
+    # than running their programs.
+    libtool_install_magic="$magic"
+
+    for arg
+    do
+      case $arg in
+      -f) RM="$RM $arg"; rmforce=yes ;;
+      -*) RM="$RM $arg" ;;
+      *) files="$files $arg" ;;
+      esac
+    done
+
+    test -z "$RM" && \
+      func_fatal_help "you must specify an RM program"
+
+    rmdirs=
+
+    origobjdir="$objdir"
+    for file in $files; do
+      func_dirname "$file" "" "."
+      dir="$func_dirname_result"
+      if test "X$dir" = X.; then
+	objdir="$origobjdir"
+      else
+	objdir="$dir/$origobjdir"
+      fi
+      func_basename "$file"
+      name="$func_basename_result"
+      test "$mode" = uninstall && objdir="$dir"
+
+      # Remember objdir for removal later, being careful to avoid duplicates
+      if test "$mode" = clean; then
+	case " $rmdirs " in
+	  *" $objdir "*) ;;
+	  *) rmdirs="$rmdirs $objdir" ;;
+	esac
+      fi
+
+      # Don't error if the file doesn't exist and rm -f was used.
+      if { test -L "$file"; } >/dev/null 2>&1 ||
+	 { test -h "$file"; } >/dev/null 2>&1 ||
+	 test -f "$file"; then
+	:
+      elif test -d "$file"; then
+	exit_status=1
+	continue
+      elif test "$rmforce" = yes; then
+	continue
+      fi
+
+      rmfiles="$file"
+
+      case $name in
+      *.la)
+	# Possibly a libtool archive, so verify it.
+	if func_lalib_p "$file"; then
+	  func_source $dir/$name
+
+	  # Delete the libtool libraries and symlinks.
+	  for n in $library_names; do
+	    rmfiles="$rmfiles $objdir/$n"
+	  done
+	  test -n "$old_library" && rmfiles="$rmfiles $objdir/$old_library"
+
+	  case "$mode" in
+	  clean)
+	    case "  $library_names " in
+	    # "  " in the beginning catches empty $dlname
+	    *" $dlname "*) ;;
+	    *) rmfiles="$rmfiles $objdir/$dlname" ;;
+	    esac
+	    test -n "$libdir" && rmfiles="$rmfiles $objdir/$name $objdir/${name}i"
+	    ;;
+	  uninstall)
+	    if test -n "$library_names"; then
+	      # Do each command in the postuninstall commands.
+	      func_execute_cmds "$postuninstall_cmds" 'test "$rmforce" = yes || exit_status=1'
+	    fi
+
+	    if test -n "$old_library"; then
+	      # Do each command in the old_postuninstall commands.
+	      func_execute_cmds "$old_postuninstall_cmds" 'test "$rmforce" = yes || exit_status=1'
+	    fi
+	    # FIXME: should reinstall the best remaining shared library.
+	    ;;
+	  esac
+	fi
+	;;
+
+      *.lo)
+	# Possibly a libtool object, so verify it.
+	if func_lalib_p "$file"; then
+
+	  # Read the .lo file
+	  func_source $dir/$name
+
+	  # Add PIC object to the list of files to remove.
+	  if test -n "$pic_object" &&
+	     test "$pic_object" != none; then
+	    rmfiles="$rmfiles $dir/$pic_object"
+	  fi
+
+	  # Add non-PIC object to the list of files to remove.
+	  if test -n "$non_pic_object" &&
+	     test "$non_pic_object" != none; then
+	    rmfiles="$rmfiles $dir/$non_pic_object"
+	  fi
+	fi
+	;;
+
+      *)
+	if test "$mode" = clean ; then
+	  noexename=$name
+	  case $file in
+	  *.exe)
+	    func_stripname '' '.exe' "$file"
+	    file=$func_stripname_result
+	    func_stripname '' '.exe' "$name"
+	    noexename=$func_stripname_result
+	    # $file with .exe has already been added to rmfiles,
+	    # add $file without .exe
+	    rmfiles="$rmfiles $file"
+	    ;;
+	  esac
+	  # Do a test to see if this is a libtool program.
+	  if func_ltwrapper_p "$file"; then
+	    if func_ltwrapper_executable_p "$file"; then
+	      func_ltwrapper_scriptname "$file"
+	      relink_command=
+	      func_source $func_ltwrapper_scriptname_result
+	      rmfiles="$rmfiles $func_ltwrapper_scriptname_result"
+	    else
+	      relink_command=
+	      func_source $dir/$noexename
+	    fi
+
+	    # note $name still contains .exe if it was in $file originally
+	    # as does the version of $file that was added into $rmfiles
+	    rmfiles="$rmfiles $objdir/$name $objdir/${name}S.${objext}"
+	    if test "$fast_install" = yes && test -n "$relink_command"; then
+	      rmfiles="$rmfiles $objdir/lt-$name"
+	    fi
+	    if test "X$noexename" != "X$name" ; then
+	      rmfiles="$rmfiles $objdir/lt-${noexename}.c"
+	    fi
+	  fi
+	fi
+	;;
+      esac
+      func_show_eval "$RM $rmfiles" 'exit_status=1'
+    done
+    objdir="$origobjdir"
+
+    # Try to remove the ${objdir}s in the directories where we deleted files
+    for dir in $rmdirs; do
+      if test -d "$dir"; then
+	func_show_eval "rmdir $dir >/dev/null 2>&1"
+      fi
+    done
+
+    exit $exit_status
+}
+
+{ test "$mode" = uninstall || test "$mode" = clean; } &&
+    func_mode_uninstall ${1+"$@"}
+
+test -z "$mode" && {
+  help="$generic_help"
+  func_fatal_help "you must specify a MODE"
+}
+
+test -z "$exec_cmd" && \
+  func_fatal_help "invalid operation mode \`$mode'"
+
+if test -n "$exec_cmd"; then
+  eval exec "$exec_cmd"
+  exit $EXIT_FAILURE
+fi
+
+exit $exit_status
+
+
+# The TAGs below are defined such that we never get into a situation
+# in which we disable both kinds of libraries.  Given conflicting
+# choices, we go for a static library, that is the most portable,
+# since we can't tell whether shared libraries were disabled because
+# the user asked for that or because the platform doesn't support
+# them.  This is particularly important on AIX, because we don't
+# support having both static and shared libraries enabled at the same
+# time on that platform, so we default to a shared-only configuration.
+# If a disable-shared tag is given, we'll fallback to a static-only
+# configuration.  But we'll never go from static-only to shared-only.
+
+# ### BEGIN LIBTOOL TAG CONFIG: disable-shared
+build_libtool_libs=no
+build_old_libs=yes
+# ### END LIBTOOL TAG CONFIG: disable-shared
+
+# ### BEGIN LIBTOOL TAG CONFIG: disable-static
+build_old_libs=`case $build_libtool_libs in yes) echo no;; *) echo yes;; esac`
+# ### END LIBTOOL TAG CONFIG: disable-static
+
+# Local Variables:
+# mode:shell-script
+# sh-indentation:2
+# End:
+# vi:sw=2
+
Index: configure.ac
===================================================================
--- configure.ac	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ configure.ac	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -6,7 +6,8 @@
 AC_CONFIG_AUX_DIR(config)
 AC_CONFIG_SRCDIR([src/builder.cpp])
-AC_CONFIG_HEADER([config.h])
+AC_CONFIG_HEADER([config.h libmolecuilder_config.h])
+AC_CONFIG_MACRO_DIR([m4])
 
-AM_INIT_AUTOMAKE(dist-bzip2)
+AM_INIT_AUTOMAKE(dist-bzip2 parallel-tests)
 
 # Checks for programs.
@@ -14,5 +15,6 @@
 AC_PROG_CXX
 AC_PROG_CC
-AC_PROG_RANLIB
+# obselete by LT_INIT
+#AC_PROG_RANLIB
 AC_PROG_INSTALL
 AC_CHECK_PROG([LATEX],[latex],[latex],[:])
@@ -23,6 +25,15 @@
 AM_MISSING_PROG([DOXYGEN], [doxygen])
 
+LT_INIT([disable-static])
+
+# Define these substitions here to keep all version information in one place.
+# For information on how to properly maintain the library version information,
+# refer to the libtool manual, section "Updating library version information":
+# http://www.gnu.org/software/libtool/manual/html_node/Updating-version-info.html
+AC_SUBST([MOLECUILDER_SO_VERSION], [1:2:0])
+AC_SUBST([MOLECUILDER_API_VERSION], [1.0])
+
 # Checks for libraries.
-AC_CHECK_LIB(m, sqrt, ,AC_MSG_ERROR([compatible libc math library not found]))
+AC_CHECK_LIB(m, sqrt, , AC_MSG_ERROR([compatible libc math library not found]))
 
 # Boost libraries
@@ -110,8 +121,14 @@
 	doc/molecuilder.xml])
 AC_CONFIG_FILES([
+  molecuilder-${MOLECUILDER_API_VERSION}.pc:molecuilder.pc.in])
+AC_CONFIG_FILES([
 	Makefile 
 	doc/Makefile 
 	src/Makefile 
 	src/Actions/Makefile
+  src/Exceptions/Makefile
+  src/Helpers/Makefile
+  src/LinearAlgebra/Makefile
+  src/Parser/Makefile
 	src/UIElements/Makefile
 	src/unittests/Makefile])
Index: m4/gwqt4.m4
===================================================================
--- m4/gwqt4.m4	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ m4/gwqt4.m4	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -147,5 +147,5 @@
         QT_LIBS="$QT_LIB"
         if test $QT_IS_STATIC = yes ; then
-            QT_LIBS="$QT_LIBS -L$x_libraries -lXext -lX11 -lm -lSM -lICE"
+            QT_LIBS="$QT_LIBS -lXext -lX11 -lm -lSM -lICE"
         fi
         ;;
@@ -154,5 +154,5 @@
         QT_LIBS="$QT_LIB"
         if test $QT_IS_STATIC = yes ; then
-            QT_LIBS="$QT_LIBS -L$x_libraries -lXext -lX11 -lm -lSM -lICE -ldl"
+            QT_LIBS="$QT_LIBS -lXext -lX11 -lm -lSM -lICE -ldl"
         fi
         ;;
@@ -162,5 +162,5 @@
         QT_LIBS="$QT_LIB"
         if test $QT_IS_STATIC = yes ; then
-            QT_LIBS="$QT_LIBS -L$x_libraries -lXext -lX11 -lm -lSM -lICE"
+            QT_LIBS="$QT_LIBS -lXext -lX11 -lm -lSM -lICE"
         fi
         ;;
@@ -169,5 +169,5 @@
         QT_LIBS="$QT_LIB"
         if test $QT_IS_STATIC = yes ; then
-            QT_LIBS="$QT_LIBS -L$x_libraries -lXext -lX11 -lm -lSM -lICE -lresolv -lsocket -lnsl"
+            QT_LIBS="$QT_LIBS -lXext -lX11 -lm -lSM -lICE -lresolv -lsocket -lnsl"
         fi
         ;;
Index: molecuilder.pc.in
===================================================================
--- molecuilder.pc.in	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
+++ molecuilder.pc.in	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -0,0 +1,11 @@
+prefix=@prefix@
+exec_prefix=@exec_prefix@
+libdir=@libdir@
+includedir=@includedir@
+
+Name: @PACKAGE_NAME@
+Description: MoleCuilder - a molecular builder
+Version: @PACKAGE_VERSION@
+URL: @PACKAGE_URL@
+Libs: -L${libdir} -lMolecuilderActions-@EXAMPLE_API_VERSION@ -lMolecuilderParser-@EXAMPLE_API_VERSION@
+Cflags: -I${includedir}/molecuilder-@EXAMPLE_API_VERSION@ -I${libdir}/molecuilder-@EXAMPLE_API_VERSION@/include
Index: src/Actions/Action.cpp
===================================================================
--- src/Actions/Action.cpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/Actions/Action.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -5,4 +5,9 @@
  *      Author: crueger
  */
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
 
 #include "Helpers/MemDebug.hpp"
@@ -13,5 +18,11 @@
 #include "Actions/ActionRegistry.hpp"
 #include "Actions/ActionHistory.hpp"
+#include "Exceptions/MissingValueException.hpp"
+#include "UIElements/Dialog.hpp"
 #include "Helpers/MemDebug.hpp"
+#include "UIElements/UIFactory.hpp"
+
+#include "Helpers/Log.hpp"
+#include "Helpers/Verbose.hpp"
 
 using namespace std;
@@ -29,5 +40,5 @@
 {
   if(_doRegister){
-    ActionRegistry::getInstance().registerAction(this);
+    ActionRegistry::getInstance().registerInstance(this);
   }
 }
@@ -40,10 +51,28 @@
 }
 
-void Action::call(){
+Dialog * Action::createDialog(){
+  Dialog *dialog = UIFactory::getInstance().makeDialog();
+  return fillDialog(dialog);
+}
+
+void Action::call(enum QueryOptions flag){
   if(!isActive()){
     return;
   }
   // forward to private virtual
-  state_ptr state = performCall();
+  if (flag == Interactive) {
+    Dialog* dialog = createDialog();
+    if (dialog->hasQueries()) {
+      dialog->display();
+    }
+    delete(dialog);
+  }
+  state_ptr state = Action::failure;
+//  try {
+    state = performCall();
+//  } catch(MissingValueException&) {
+//    DoeLog(0) && (eLog() << Verbose(0) << "There is a value missing for action " << getName() << endl);
+//  };
+
   if(shouldUndo() && state != failure){
     if(canUndo()){
Index: src/Actions/Action.hpp
===================================================================
--- src/Actions/Action.hpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/Actions/Action.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -16,4 +16,5 @@
 class ActionState;
 class ActionSequence;
+class Dialog;
 
 /**
@@ -44,4 +45,14 @@
  * hasRedo() method respectively.
  *
+ * Note that an Action always has two functions createDialog() and performCall(). The former
+ * returns a Dialog filled with query...() functions for all information that we need from the
+ * user. The latter must not contain any interaction but just uses these values (which are
+ * temporarily stored by class ValueStorage) to perform the Action.
+ *
+ * Furthermore, there is a global action function that makes the action callable with already
+ * present parameters (i.e. without user interaction and for internal use within the code only).
+ * This function is basically just a macro, that puts the parameters into the ValueStorage and
+ * calls Action::call(Action::NonInteractive).
+ *
  * Actions can be set to be active or inactive. If an action is set to inactive it is signaling, that
  * some condition necessary for this action to be executed is not currently met. For example the
@@ -78,6 +89,10 @@
  * Building actions is fairly easy. Simply derive from the abstract Action base class and implement
  * the virtual methods. The main code that needs to be executed upon call() should be implemented in
- * the performCall() method. You should also indicate whether the action supports undo by implementing
+ * the performCall() method. Any user interaction should be placed into the dialog returned by
+ * createDialog(). You should also indicate whether the action supports undo by implementing
  * the shouldUndo() and canUndo() methods to return the appropriate flags.
+ *
+ * Also, create the global function to allow for easy calling of your function internally (i.e.
+ * without user interaction). It should have the name of the Action class without the suffix Action.
  *
  * The constructor of your derived class also needs to call the Base constructor, passing it the
@@ -122,5 +137,6 @@
  *  <li/> derive YourAction from Action
  *  <li/> pass name and flag for registry to the base constructor
- *  <li/> implement performCall(), performUndo(), performRedo()
+ *  <li/> implement createDialog(), performCall(), performUndo(), performRedo()
+ *  <li/> implement the global function call/macro.
  *  <li/> implement the functions that return the flags for the undo mechanism
  *  <li/> Derive YourActionState from ActionState as necessary
@@ -130,6 +146,15 @@
  *
  * <ul>
+ *  <li/> createDialog():
+ *  <ul>
+ *   <li/> Call makeDialog() from the UIFactory.
+ *   <li/> Call any needed Dialog->Query...() for the values you need with specific keywords.
+ *   <li/> if the action needs to save a state return a custom state object
+ *   <li/> otherwise return Action::success
+ *  </ul>
  *  <li/> performCall():
  *  <ul>
+ *   <li/> obtain parameters you need by ValueStorage::getCurrentValue, matching
+ *         key words from createDialog().
  *   <li/> do whatever is needed to make the action work
  *   <li/> if the action was abborted return Action::failure
@@ -256,4 +281,6 @@
 public:
 
+  enum QueryOptions {Interactive, NonInteractive};
+
   /**
    * This type is used to store pointers to ActionStates while allowing multiple ownership
@@ -278,6 +305,11 @@
    * If the call needs to undone you have to use the History, to avoid destroying
    * invariants used by the History.
-   */
-  void call();
+   *
+   * Note that this call can be Interactive (i.e. a dialog will ask the user for
+   * necessary information) and NonInteractive (i.e. the information will have to
+   * be present already within the ValueStorage class or else a MissingArgumentException
+   * is thrown)
+   */
+  void call(enum QueryOptions state = Interactive);
 
   /**
@@ -337,7 +369,16 @@
   static state_ptr failure;
 
+  /**
+   * This creates the dialog requesting the information needed for this action from the user
+   * via means of the user interface.
+   */
+  Dialog * createDialog();
+
 private:
-  /**
-   * This is called internally when the call is being done. Implement this method to do the actuall
+
+  virtual Dialog * fillDialog(Dialog*)=0;
+
+  /**
+   * This is called internally when the call is being done. Implement this method to do the actual
    * work of the Action. Implement this in your Derived classes. Needs to return a state that can be
    * used to undo the action.
Index: src/Actions/ActionHistory.cpp
===================================================================
--- src/Actions/ActionHistory.cpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/Actions/ActionHistory.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -5,4 +5,9 @@
  *      Author: crueger
  */
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
 
 #include "Helpers/MemDebug.hpp"
@@ -67,6 +72,9 @@
 
 /****************** Contained actions *******************/
+
+const char ActionHistory::UndoAction::NAME[] = "undo";
+
 ActionHistory::UndoAction::UndoAction(ActionHistory *_hist) :
-  Action("Undo"),
+  Action(NAME),
   hist(_hist)
 {}
@@ -86,5 +94,11 @@
 }
 
+Dialog* ActionHistory::UndoAction::fillDialog(Dialog *dialog){
+  ASSERT(dialog,"No Dialog given when filling action dialog");
+  return dialog;
+}
+
 Action::state_ptr ActionHistory::UndoAction::performCall(){
+  std::cout << "Undo" << std::endl;
   hist->undoLast();
   return Action::success;
@@ -101,6 +115,8 @@
 }
 
+const char ActionHistory::RedoAction::NAME[] = "redo";
+
 ActionHistory::RedoAction::RedoAction(ActionHistory *_hist) :
-    Action("Redo"),
+    Action(NAME),
     hist(_hist)
 {}
@@ -117,5 +133,11 @@
 
 bool ActionHistory::RedoAction::isActive(){
+  std::cout << "Redo" << std::endl;
   return hist->hasRedo();
+}
+
+Dialog* ActionHistory::RedoAction::fillDialog(Dialog *dialog){
+  ASSERT(dialog,"No Dialog given when filling action dialog");
+  return dialog;
 }
 
Index: src/Actions/ActionHistory.hpp
===================================================================
--- src/Actions/ActionHistory.hpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/Actions/ActionHistory.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -38,5 +38,6 @@
 
     virtual bool isActive();
-
+  protected:
+    virtual Dialog * fillDialog(Dialog *dialog);
   private:
     virtual Action::state_ptr performCall();
@@ -45,4 +46,6 @@
 
     ActionHistory *hist;
+
+    static const char NAME[];
   };
 
@@ -57,4 +60,6 @@
     virtual bool isActive();
 
+  protected:
+    virtual Dialog * fillDialog(Dialog *dialog);
   private:
     virtual Action::state_ptr performCall();
@@ -63,4 +68,6 @@
 
     ActionHistory *hist;
+
+    static const char NAME[];
   };
 
Index: src/Actions/ActionRegistry.cpp
===================================================================
--- src/Actions/ActionRegistry.cpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/Actions/ActionRegistry.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -1,4 +1,4 @@
 /*
- * ActionRegistry.cpp
+ * Registry<Action>.cpp
  *
  *  Created on: Jan 7, 2010
@@ -6,121 +6,43 @@
  */
 
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
 #include "Helpers/MemDebug.hpp"
 
 #include "Actions/ActionRegistry.hpp"
-#include "Actions/Action.hpp"
-
 #include "Patterns/Singleton_impl.hpp"
-
-#include <string>
-#include "Helpers/Assert.hpp"
-#include <iostream>
-
-using namespace std;
+#include "Patterns/Registry_impl.hpp"
 
 /** Constructor for class ActionRegistry.
  */
 ActionRegistry::ActionRegistry()
-{
-}
+{}
 
 /** Destructor for class ActionRegistry.
  */
 ActionRegistry::~ActionRegistry()
+{}
+
+/** Just passes on call to Registry<Action>::getByName().
+ * \param name name of Action
+ * \return pointer to Action
+ */
+Action* ActionRegistry::getActionByName(const std::string name)
 {
-  map<const string,Action*>::iterator iter;
-  for(iter=actionMap.begin();iter!=actionMap.end();++iter) {
-    delete iter->second;
-  }
-  actionMap.clear();
+  return getByName(name);
 }
 
-/** Returns pointer to an action named by \a name.
- * \param name name of action
- * \return pointer to Action
+/** Just passes on call to Registry<Action>::isPresentByName().
+ * \param name name of Action
+ * \return true - Action instance present, false - not
  */
-Action* ActionRegistry::getActionByName(const std::string name){
-  map<const string,Action*>::iterator iter;
-  iter = actionMap.find(name);
-  ASSERT(iter!=actionMap.end(),"Query for an action not stored in registry");
-  return iter->second;
+bool ActionRegistry::isActionPresentByName(const std::string name)
+{
+  return isPresentByName(name);
 }
 
-/** States whether action is present or not.
- * \note This iss needed as ActionRegistry::getActionByName() ASSERT()s that action is in map.
- * \param name name of action
- * \return true - Action present, false - Action absent
- */
-bool ActionRegistry::isActionByNamePresent(const std::string name){
-  map<const string,Action*>::iterator iter;
-  iter = actionMap.find(name);
-  return iter!=actionMap.end();
-}
-
-/** Registers an Action with the ActionRegistry.
- * \param *action pointer to Action.
- */
-void ActionRegistry::registerAction(Action* action){
-  pair<map<const string,Action*>::iterator,bool> ret;
-  //cout << "Trying to register action with name " << action->getName() << "." << endl;
-  ret = actionMap.insert(pair<const string,Action*>(action->getName(),action));
-  ASSERT(ret.second,"Two actions with the same name added to registry");
-}
-
-/** Unregisters an Action.
- * \param *action pointer to Action.
- */
-void ActionRegistry::unregisterAction(Action* action){
-  //cout << "Unregistering action with name " << action->getName() << "." << endl;
-  actionMap.erase(action->getName());
-}
-
-/** Returns an iterator pointing to the start of the map of Action's.
- * \return begin iterator
- */
-std::map<const std::string,Action*>::iterator ActionRegistry::getBeginIter()
-{
-  return actionMap.begin();
-}
-
-/** Returns an iterator pointing to the end of the map of Action's.
- * \return end iterator
- */
-std::map<const std::string,Action*>::iterator ActionRegistry::getEndIter()
-{
-  return actionMap.end();
-}
-
-/** Returns a const iterator pointing to the start of the map of Action's.
- * \return constant begin iterator
- */
-std::map<const std::string,Action*>::const_iterator ActionRegistry::getBeginIter() const
-{
-  return actionMap.begin();
-}
-
-/** Returns a const iterator pointing to the end of the map of Action's.
- * \return constant end iterator
- */
-std::map<const std::string,Action*>::const_iterator ActionRegistry::getEndIter() const
-{
-  return actionMap.end();
-}
-
-/** Prints the contents of the ActionRegistry \a &m to \a &ost.
- * \param &ost output stream
- * \param &m reference to ActionRegistry
- * \return reference to the above out stream for concatenation
- */
-ostream& operator<<(ostream& ost, const ActionRegistry& m)
-{
-  ost << "ActionRegistry contains:" << endl;
-  for (std::map<const std::string,Action*>::const_iterator iter = m.getBeginIter(); iter != m.getEndIter(); ++iter) {
-    ost << "\t" << iter->first << " with pointer " << iter->second << endl;
-  }
-  return ost;
-};
-
-
-
 CONSTRUCT_SINGLETON(ActionRegistry)
+CONSTRUCT_REGISTRY(Action)
Index: src/Actions/ActionRegistry.hpp
===================================================================
--- src/Actions/ActionRegistry.hpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/Actions/ActionRegistry.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -1,4 +1,4 @@
 /*
- * ActionRegistry.hpp
+ * Registry<Action>.hpp
  *
  *  Created on: Jan 7, 2010
@@ -9,35 +9,31 @@
 #define ACTIONREGISTRY_HPP_
 
-#include <iostream>
+#include <iosfwd>
 #include <string>
 #include <map>
 
+#include "Patterns/Registry.hpp"
 #include "Patterns/Singleton.hpp"
+#include "Actions/Action.hpp"
 
-class Action;
-
-class ActionRegistry : public Singleton<ActionRegistry>
+/** Action Registry.
+ *
+ * The Action registry is a storage for any Action instance to retrieved by name.
+ * It is a singleton and can be called from anywhere.
+ *
+ */
+class ActionRegistry : public Singleton<ActionRegistry>, public Registry<Action>
 {
   friend class Singleton<ActionRegistry>;
+  //friend class Registry<Action>;
+
 public:
-  Action* getActionByName(const std::string);
-  bool isActionByNamePresent(const std::string name);
-  void registerAction(Action*);
-  void unregisterAction(Action*);
-
-  std::map<const std::string,Action*>::iterator getBeginIter();
-  std::map<const std::string,Action*>::const_iterator getBeginIter() const;
-  std::map<const std::string,Action*>::iterator getEndIter();
-  std::map<const std::string,Action*>::const_iterator getEndIter() const;
-
-private:
-  std::map<const std::string,Action*> actionMap;
+  Action* getActionByName(const std::string name);
+  bool isActionPresentByName(const std::string name);
 
 private:
   ActionRegistry();
-  virtual ~ActionRegistry();
+  ~ActionRegistry();
 };
 
-std::ostream& operator<<(std::ostream& ost, const ActionRegistry& m);
-
 #endif /* ACTIONREGISTRY_HPP_ */
Index: src/Actions/ActionSequence.cpp
===================================================================
--- src/Actions/ActionSequence.cpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/Actions/ActionSequence.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -6,8 +6,14 @@
  */
 
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
 #include "Helpers/MemDebug.hpp"
 
 #include "Actions/ActionSequence.hpp"
 #include "Actions/Action.hpp"
+#include "UIElements/Dialog.hpp"
 
 #include "Helpers/Assert.hpp"
@@ -36,4 +42,13 @@
     return theAction;
   }
+}
+
+// this method is used outside the ActionModule
+// Each action registers itself with the history
+Dialog* ActionSequence::fillAllDialogs(Dialog *dialog){
+  for(actionSet::iterator it=actions.begin(); it!=actions.end(); it++){
+    dialog = (*it)->fillDialog(dialog);
+  }
+  return dialog;
 }
 
Index: src/Actions/ActionSequence.hpp
===================================================================
--- src/Actions/ActionSequence.hpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/Actions/ActionSequence.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -36,4 +36,5 @@
 protected:
   stateSet callAll(bool); // Dummy parameter to allow overloading
+  Dialog* fillAllDialogs(Dialog *dialog);
   stateSet undoAll(stateSet);
   stateSet redoAll(stateSet);
Index: src/Actions/AnalysisAction/MolecularVolumeAction.cpp
===================================================================
--- src/Actions/AnalysisAction/MolecularVolumeAction.cpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/Actions/AnalysisAction/MolecularVolumeAction.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -6,13 +6,20 @@
  */
 
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
 #include "Helpers/MemDebug.hpp"
 
 #include "Actions/AnalysisAction/MolecularVolumeAction.hpp"
+#include "Actions/ActionRegistry.hpp"
 #include "boundary.hpp"
 #include "config.hpp"
 #include "molecule.hpp"
 #include "linkedcell.hpp"
-#include "log.hpp"
-#include "verbose.hpp"
+#include "Helpers/Log.hpp"
+#include "Helpers/Verbose.hpp"
+#include "tesselation.hpp"
 #include "World.hpp"
 
@@ -24,5 +31,5 @@
 #include "UIElements/UIFactory.hpp"
 #include "UIElements/Dialog.hpp"
-#include "Actions/MapOfActions.hpp"
+#include "Actions/ValueStorage.hpp"
 
 const char AnalysisMolecularVolumeAction::NAME[] = "molecular-volume";
@@ -35,11 +42,23 @@
 {}
 
+void AnalysisMolecularVolume() {
+  ActionRegistry::getInstance().getActionByName(AnalysisMolecularVolumeAction::NAME)->call(Action::NonInteractive);
+};
+
+Dialog * AnalysisMolecularVolumeAction::fillDialog(Dialog *dialog) {
+  ASSERT(dialog,"No Dialog given when filling action dialog");
+  dialog->queryEmpty(NAME, ValueStorage::getInstance().getDescription(NAME));
+
+  return dialog;
+}
+
 Action::state_ptr AnalysisMolecularVolumeAction::performCall() {
-  Dialog *dialog = UIFactory::getInstance().makeDialog();
-  molecule *mol = NULL;
+  int molID = -1;
+  // obtain information
+  ValueStorage::getInstance().queryCurrentValue(NAME, molID);
 
-  dialog->queryMolecule(NAME, &mol, MapOfActions::getInstance().getDescription(NAME));
-
-  if(dialog->display()) {
+  // execute action
+  for (World::MoleculeSelectionIterator iter = World::getInstance().beginMoleculeSelection(); iter != World::getInstance().endMoleculeSelection(); ++iter) {
+    molecule *mol = iter->second;
     class Tesselation *TesselStruct = NULL;
     const LinkedCell *LCList = NULL;
@@ -47,5 +66,5 @@
     LCList = new LinkedCell(mol, 10.);
     config * const configuration = World::getInstance().getConfig();
-    Boundaries *BoundaryPoints = NULL;
+    //Boundaries *BoundaryPoints = NULL;
     //FindConvexBorder(mol, BoundaryPoints, TesselStruct, LCList, argv[argptr]);
     FindNonConvexBorder(mol, TesselStruct, LCList, 5., NULL);
@@ -57,32 +76,22 @@
     delete(TesselStruct);
     delete(LCList);
-    delete dialog;
-    return Action::success;
-  } else {
-    delete dialog;
-    return Action::failure;
   }
+  return Action::success;
 }
 
 Action::state_ptr AnalysisMolecularVolumeAction::performUndo(Action::state_ptr _state) {
-//  ParserLoadXyzState *state = assert_cast<ParserLoadXyzState*>(_state.get());
-
-  return Action::failure;
-//  string newName = state->mol->getName();
-//  state->mol->setName(state->lastName);
-//
-//  return Action::state_ptr(new ParserLoadXyzState(state->mol,newName));
+  return Action::success;
 }
 
 Action::state_ptr AnalysisMolecularVolumeAction::performRedo(Action::state_ptr _state){
-  return Action::failure;
+  return Action::success;
 }
 
 bool AnalysisMolecularVolumeAction::canUndo() {
-  return false;
+  return true;
 }
 
 bool AnalysisMolecularVolumeAction::shouldUndo() {
-  return false;
+  return true;
 }
 
Index: src/Actions/AnalysisAction/MolecularVolumeAction.hpp
===================================================================
--- src/Actions/AnalysisAction/MolecularVolumeAction.hpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/Actions/AnalysisAction/MolecularVolumeAction.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -9,7 +9,15 @@
 #define MOLECULARVOLUMEACTION_HPP_
 
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
 #include "Actions/Action.hpp"
 
+void AnalysisMolecularVolume();
+
 class AnalysisMolecularVolumeAction : public Action {
+  friend void AnalysisMolecularVolume();
 public:
   AnalysisMolecularVolumeAction();
@@ -20,4 +28,7 @@
 
   virtual const std::string getName();
+
+protected:
+  virtual Dialog * fillDialog(Dialog*);
 private:
   virtual Action::state_ptr performCall();
Index: src/Actions/AnalysisAction/PairCorrelationAction.cpp
===================================================================
--- src/Actions/AnalysisAction/PairCorrelationAction.cpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/Actions/AnalysisAction/PairCorrelationAction.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -6,15 +6,22 @@
  */
 
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
 #include "Helpers/MemDebug.hpp"
 
 #include "Actions/AnalysisAction/PairCorrelationAction.hpp"
+#include "Actions/ActionRegistry.hpp"
 #include "analysis_correlation.hpp"
 #include "boundary.hpp"
 #include "linkedcell.hpp"
-#include "log.hpp"
+#include "Helpers/Verbose.hpp"
+#include "Helpers/Log.hpp"
 #include "element.hpp"
 #include "molecule.hpp"
 #include "periodentafel.hpp"
-#include "vector.hpp"
+#include "LinearAlgebra/Vector.hpp"
 #include "World.hpp"
 
@@ -26,5 +33,5 @@
 #include "UIElements/UIFactory.hpp"
 #include "UIElements/Dialog.hpp"
-#include "Actions/MapOfActions.hpp"
+#include "Actions/ValueStorage.hpp"
 
 const char AnalysisPairCorrelationAction::NAME[] = "pair-correlation";
@@ -37,11 +44,35 @@
 {}
 
+void AnalysisPairCorrelation(std::vector< element *> &elements, double BinStart, double BinWidth, double BinEnd, string &outputname, string &binoutputname, bool periodic) {
+  ValueStorage::getInstance().setCurrentValue("elements", elements);
+  ValueStorage::getInstance().setCurrentValue("bin-start", BinStart);
+  ValueStorage::getInstance().setCurrentValue("bin-width", BinWidth);
+  ValueStorage::getInstance().setCurrentValue("bin-end", BinEnd);
+  ValueStorage::getInstance().setCurrentValue("output-file", outputname);
+  ValueStorage::getInstance().setCurrentValue("bin-output-file", binoutputname);
+  ValueStorage::getInstance().setCurrentValue("periodic", periodic);
+  ActionRegistry::getInstance().getActionByName(AnalysisPairCorrelationAction::NAME)->call(Action::NonInteractive);
+};
+
+
+Dialog* AnalysisPairCorrelationAction::fillDialog(Dialog* dialog) {
+  ASSERT(dialog,"No Dialog given when filling action dialog");
+
+  dialog->queryElements("elements", ValueStorage::getInstance().getDescription("elements"));
+  dialog->queryDouble("bin-start", ValueStorage::getInstance().getDescription("bin-start"));
+  dialog->queryDouble("bin-width", ValueStorage::getInstance().getDescription("bin-width"));
+  dialog->queryDouble("bin-end", ValueStorage::getInstance().getDescription("bin-end"));
+  dialog->queryString("output-file", ValueStorage::getInstance().getDescription("output-file"));
+  dialog->queryString("bin-output-file", ValueStorage::getInstance().getDescription("bin-output-file"));
+  dialog->queryBoolean("periodic", ValueStorage::getInstance().getDescription("periodic"));
+
+  return dialog;
+}
+
 Action::state_ptr AnalysisPairCorrelationAction::performCall() {
-  Dialog *dialog = UIFactory::getInstance().makeDialog();
   int ranges[3] = {1, 1, 1};
   double BinEnd = 0.;
   double BinStart = 0.;
   double BinWidth = 0.;
-  molecule *Boundary = NULL;
   string outputname;
   string binoutputname;
@@ -49,141 +80,51 @@
   ofstream output;
   ofstream binoutput;
-  std::vector< element *> elements;
+  std::vector<const element *> elements;
   string type;
   Vector Point;
   BinPairMap *binmap = NULL;
-  MoleculeListClass *molecules = World::getInstance().getMolecules();
 
-  // first dialog: Obtain which type of correlation
-  dialog->queryString(NAME, &type, MapOfActions::getInstance().getDescription(NAME));
-  if(dialog->display()) {
-    delete dialog;
-  } else {
-    delete dialog;
-    return Action::failure;
-  }
+  // obtain information
+  ValueStorage::getInstance().queryCurrentValue("elements", elements);
+  ValueStorage::getInstance().queryCurrentValue("bin-start", BinStart);
+  ValueStorage::getInstance().queryCurrentValue("bin-width", BinWidth);
+  ValueStorage::getInstance().queryCurrentValue("bin-end", BinEnd);
+  ValueStorage::getInstance().queryCurrentValue("output-file", outputname);
+  ValueStorage::getInstance().queryCurrentValue("bin-output-file", binoutputname);
+  ValueStorage::getInstance().queryCurrentValue("periodic", periodic);
 
-  // second dialog: Obtain parameters specific to this type
-  dialog = UIFactory::getInstance().makeDialog();
-  if (type == "P")
-    dialog->queryVector("position", &Point, World::getInstance().getDomain(), false, MapOfActions::getInstance().getDescription("position"));
-  if (type == "S")
-    dialog->queryMolecule("molecule-by-id", &Boundary, MapOfActions::getInstance().getDescription("molecule-by-id"));
-  dialog->queryElement("elements", &elements, MapOfActions::getInstance().getDescription("elements"));
-  dialog->queryDouble("bin-start", &BinStart, MapOfActions::getInstance().getDescription("bin-start"));
-  dialog->queryDouble("bin-width", &BinWidth, MapOfActions::getInstance().getDescription("bin-width"));
-  dialog->queryDouble("bin-end", &BinEnd, MapOfActions::getInstance().getDescription("bin-end"));
-  dialog->queryString("output-file", &outputname, MapOfActions::getInstance().getDescription("output-file"));
-  dialog->queryString("bin-output-file", &binoutputname, MapOfActions::getInstance().getDescription("bin-output-file"));
-  dialog->queryBoolean("periodic", &periodic, MapOfActions::getInstance().getDescription("periodic"));
-
-  if(dialog->display()) {
-    output.open(outputname.c_str());
-    binoutput.open(binoutputname.c_str());
-    if (type == "E") {
-      PairCorrelationMap *correlationmap = NULL;
-      if (periodic)
-        correlationmap = PeriodicPairCorrelation(World::getInstance().getMolecules(), elements, ranges);
-      else
-        correlationmap = PairCorrelation(World::getInstance().getMolecules(), elements);
-      OutputPairCorrelation(&output, correlationmap);
-      binmap = BinData( correlationmap, BinWidth, BinStart, BinEnd );
-      OutputCorrelation ( &binoutput, binmap );
-      delete(binmap);
-      delete(correlationmap);
-    } else if (type == "P")  {
-      cout << "Point to correlate to is  " << Point << endl;
-      CorrelationToPointMap *correlationmap = NULL;
-      if (periodic)
-        correlationmap  = PeriodicCorrelationToPoint(molecules, elements, &Point, ranges);
-      else
-        correlationmap = CorrelationToPoint(molecules, elements, &Point);
-      OutputCorrelationToPoint(&output, correlationmap);
-      binmap = BinData( correlationmap, BinWidth, BinStart, BinEnd );
-      OutputCorrelation ( &binoutput, binmap );
-      delete(binmap);
-      delete(correlationmap);
-    } else if (type == "S") {
-      ASSERT(Boundary != NULL, "No molecule specified for SurfaceCorrelation.");
-      const double radius = 4.;
-      double LCWidth = 20.;
-      if (BinEnd > 0) {
-        if (BinEnd > 2.*radius)
-          LCWidth = BinEnd;
-        else
-          LCWidth = 2.*radius;
-      }
-
-      // get the boundary
-      class Tesselation *TesselStruct = NULL;
-      const LinkedCell *LCList = NULL;
-      // find biggest molecule
-      int counter  = molecules->ListOfMolecules.size();
-      bool *Actives = new bool[counter];
-      counter = 0;
-      for (MoleculeList::iterator BigFinder = molecules->ListOfMolecules.begin(); BigFinder != molecules->ListOfMolecules.end(); BigFinder++) {
-        Actives[counter++] = (*BigFinder)->ActiveFlag;
-        (*BigFinder)->ActiveFlag = (*BigFinder == Boundary) ? false : true;
-      }
-      LCList = new LinkedCell(Boundary, LCWidth);
-      FindNonConvexBorder(Boundary, TesselStruct, LCList, radius, NULL);
-      CorrelationToSurfaceMap *surfacemap = NULL;
-      if (periodic)
-        surfacemap = PeriodicCorrelationToSurface( molecules, elements, TesselStruct, LCList, ranges);
-      else
-        surfacemap = CorrelationToSurface( molecules, elements, TesselStruct, LCList);
-      delete LCList;
-      OutputCorrelationToSurface(&output, surfacemap);
-      // re-set ActiveFlag
-      counter = 0;
-      for (MoleculeList::iterator BigFinder = molecules->ListOfMolecules.begin(); BigFinder != molecules->ListOfMolecules.end(); BigFinder++) {
-        (*BigFinder)->ActiveFlag = Actives[counter++];
-      }
-      delete[] Actives;
-      // check whether radius was appropriate
-      {
-        double start; double end;
-        GetMinMax( surfacemap, start, end);
-        if (LCWidth < end)
-          DoeLog(1) && (eLog()<< Verbose(1) << "Linked Cell width is smaller than the found range of values! Bins can only be correct up to: " << radius << "." << endl);
-      }
-      binmap = BinData( surfacemap, BinWidth, BinStart, BinEnd );
-      OutputCorrelation ( &binoutput, binmap );
-      delete TesselStruct;  // surfacemap contains refs to triangles! delete here, not earlier!
-      delete(binmap);
-      delete(surfacemap);
-    } else {
-      return Action::failure;
-    }
-    output.close();
-    binoutput.close();
-    delete dialog;
-    return Action::success;
-  } else {
-    delete dialog;
-    return Action::failure;
-  }
+  // execute action
+  output.open(outputname.c_str());
+  binoutput.open(binoutputname.c_str());
+  PairCorrelationMap *correlationmap = NULL;
+  std::vector<molecule*> molecules = World::getInstance().getSelectedMolecules();
+  if (periodic)
+    correlationmap = PeriodicPairCorrelation(molecules, elements, ranges);
+  else
+    correlationmap = PairCorrelation(molecules, elements);
+  OutputPairCorrelation(&output, correlationmap);
+  binmap = BinData( correlationmap, BinWidth, BinStart, BinEnd );
+  OutputCorrelation ( &binoutput, binmap );
+  delete(binmap);
+  delete(correlationmap);
+  output.close();
+  binoutput.close();
+  return Action::success;
 }
 
 Action::state_ptr AnalysisPairCorrelationAction::performUndo(Action::state_ptr _state) {
-//  ParserLoadXyzState *state = assert_cast<ParserLoadXyzState*>(_state.get());
-
-  return Action::failure;
-//  string newName = state->mol->getName();
-//  state->mol->setName(state->lastName);
-//
-//  return Action::state_ptr(new ParserLoadXyzState(state->mol,newName));
+  return Action::success;
 }
 
 Action::state_ptr AnalysisPairCorrelationAction::performRedo(Action::state_ptr _state){
-  return Action::failure;
+  return Action::success;
 }
 
 bool AnalysisPairCorrelationAction::canUndo() {
-  return false;
+  return true;
 }
 
 bool AnalysisPairCorrelationAction::shouldUndo() {
-  return false;
+  return true;
 }
 
Index: src/Actions/AnalysisAction/PairCorrelationAction.hpp
===================================================================
--- src/Actions/AnalysisAction/PairCorrelationAction.hpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/Actions/AnalysisAction/PairCorrelationAction.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -9,7 +9,19 @@
 #define PAIRCORRELATIONACTION_HPP_
 
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
 #include "Actions/Action.hpp"
+#include <string>
+#include <vector>
+
+class element;
+
+void AnalysisPairCorrelation(std::vector< element *> &elements, double BinStart, double BinWidth, double BinEnd, std::string &outputname, std::string &binoutputname, bool periodic);
 
 class AnalysisPairCorrelationAction : public Action {
+  friend void AnalysisPairCorrelation(std::vector< element *> &elements, double BinStart, double BinWidth, double BinEnd, std::string &outputname, std::string &binoutputname, bool periodic);
 public:
   AnalysisPairCorrelationAction();
@@ -20,6 +32,8 @@
 
   virtual const std::string getName();
+protected:
+  virtual Dialog * fillDialog(Dialog*);
 private:
-  virtual Action::state_ptr performCall();
+   virtual Action::state_ptr performCall();
   virtual Action::state_ptr performUndo(Action::state_ptr);
   virtual Action::state_ptr performRedo(Action::state_ptr);
Index: src/Actions/AnalysisAction/PointCorrelationAction.cpp
===================================================================
--- src/Actions/AnalysisAction/PointCorrelationAction.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
+++ src/Actions/AnalysisAction/PointCorrelationAction.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -0,0 +1,138 @@
+/*
+ * PointCorrelationAction.cpp
+ *
+ *  Created on: May 9, 2010
+ *      Author: heber
+ */
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "Helpers/MemDebug.hpp"
+
+#include "Actions/AnalysisAction/PointCorrelationAction.hpp"
+#include "Actions/ActionRegistry.hpp"
+#include "analysis_correlation.hpp"
+#include "boundary.hpp"
+#include "linkedcell.hpp"
+#include "Helpers/Verbose.hpp"
+#include "Helpers/Log.hpp"
+#include "element.hpp"
+#include "molecule.hpp"
+#include "periodentafel.hpp"
+#include "LinearAlgebra/Vector.hpp"
+#include "World.hpp"
+
+#include <iostream>
+#include <string>
+
+using namespace std;
+
+#include "UIElements/UIFactory.hpp"
+#include "UIElements/Dialog.hpp"
+#include "Actions/ValueStorage.hpp"
+
+const char AnalysisPointCorrelationAction::NAME[] = "point-correlation";
+
+AnalysisPointCorrelationAction::AnalysisPointCorrelationAction() :
+  Action(NAME)
+{}
+
+AnalysisPointCorrelationAction::~AnalysisPointCorrelationAction()
+{}
+
+void AnalysisPointCorrelation(std::vector< element *> &elements, Vector &position, double BinStart, double BinWidth, double BinEnd, string &outputname, string &binoutputname, bool periodic) {
+  ValueStorage::getInstance().setCurrentValue("elements", elements);
+  ValueStorage::getInstance().setCurrentValue("position", position);
+  ValueStorage::getInstance().setCurrentValue("bin-start", BinStart);
+  ValueStorage::getInstance().setCurrentValue("bin-width", BinWidth);
+  ValueStorage::getInstance().setCurrentValue("bin-end", BinEnd);
+  ValueStorage::getInstance().setCurrentValue("output-file", outputname);
+  ValueStorage::getInstance().setCurrentValue("bin-output-file", binoutputname);
+  ValueStorage::getInstance().setCurrentValue("periodic", periodic);
+  ActionRegistry::getInstance().getActionByName(AnalysisPointCorrelationAction::NAME)->call(Action::NonInteractive);
+};
+
+Dialog* AnalysisPointCorrelationAction::fillDialog(Dialog *dialog) {
+  ASSERT(dialog,"No Dialog given when filling action dialog");
+
+  dialog->queryVector("position", false, ValueStorage::getInstance().getDescription("position"));
+  dialog->queryElements("elements", ValueStorage::getInstance().getDescription("elements"));
+  dialog->queryDouble("bin-start", ValueStorage::getInstance().getDescription("bin-start"));
+  dialog->queryDouble("bin-width", ValueStorage::getInstance().getDescription("bin-width"));
+  dialog->queryDouble("bin-end", ValueStorage::getInstance().getDescription("bin-end"));
+  dialog->queryString("output-file", ValueStorage::getInstance().getDescription("output-file"));
+  dialog->queryString("bin-output-file", ValueStorage::getInstance().getDescription("bin-output-file"));
+  dialog->queryBoolean("periodic", ValueStorage::getInstance().getDescription("periodic"));
+
+  return dialog;
+}
+
+Action::state_ptr AnalysisPointCorrelationAction::performCall() {
+  int ranges[3] = {1, 1, 1};
+  double BinEnd = 0.;
+  double BinStart = 0.;
+  double BinWidth = 0.;
+  string outputname;
+  string binoutputname;
+  bool periodic;
+  ofstream output;
+  ofstream binoutput;
+  std::vector<const element *> elements;
+  string type;
+  Vector Point;
+  BinPairMap *binmap = NULL;
+
+  // obtain information
+  ValueStorage::getInstance().queryCurrentValue("position", Point);
+  ValueStorage::getInstance().queryCurrentValue("elements", elements);
+  ValueStorage::getInstance().queryCurrentValue("bin-start", BinStart);
+  ValueStorage::getInstance().queryCurrentValue("bin-width", BinWidth);
+  ValueStorage::getInstance().queryCurrentValue("bin-end", BinEnd);
+  ValueStorage::getInstance().queryCurrentValue("output-file", outputname);
+  ValueStorage::getInstance().queryCurrentValue("bin-output-file", binoutputname);
+  ValueStorage::getInstance().queryCurrentValue("periodic", periodic);
+
+  // execute action
+  output.open(outputname.c_str());
+  binoutput.open(binoutputname.c_str());
+  cout << "Point to correlate to is  " << Point << endl;
+  CorrelationToPointMap *correlationmap = NULL;
+  for(std::vector<const element *>::iterator iter = elements.begin(); iter != elements.end(); ++iter)
+    cout << "element is " << (*iter)->getSymbol() << endl;
+  std::vector<molecule*> molecules = World::getInstance().getSelectedMolecules();
+  if (periodic)
+    correlationmap  = PeriodicCorrelationToPoint(molecules, elements, &Point, ranges);
+  else
+    correlationmap = CorrelationToPoint(molecules, elements, &Point);
+  OutputCorrelationToPoint(&output, correlationmap);
+  binmap = BinData( correlationmap, BinWidth, BinStart, BinEnd );
+  OutputCorrelation ( &binoutput, binmap );
+  delete(binmap);
+  delete(correlationmap);
+  output.close();
+  binoutput.close();
+  return Action::success;
+}
+
+Action::state_ptr AnalysisPointCorrelationAction::performUndo(Action::state_ptr _state) {
+  return Action::success;
+}
+
+Action::state_ptr AnalysisPointCorrelationAction::performRedo(Action::state_ptr _state){
+  return Action::success;
+}
+
+bool AnalysisPointCorrelationAction::canUndo() {
+  return true;
+}
+
+bool AnalysisPointCorrelationAction::shouldUndo() {
+  return true;
+}
+
+const string AnalysisPointCorrelationAction::getName() {
+  return NAME;
+}
Index: src/Actions/AnalysisAction/PointCorrelationAction.hpp
===================================================================
--- src/Actions/AnalysisAction/PointCorrelationAction.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
+++ src/Actions/AnalysisAction/PointCorrelationAction.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -0,0 +1,46 @@
+/*
+ * PointCorrelationAction.hpp
+ *
+ *  Created on: May 9, 2010
+ *      Author: heber
+ */
+
+#ifndef POINTCORRELATIONACTION_HPP_
+#define POINTCORRELATIONACTION_HPP_
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "Actions/Action.hpp"
+#include "LinearAlgebra/Vector.hpp"
+#include <vector>
+#include <string>
+
+class element;
+
+void AnalysisPointCorrelation(std::vector< element *> &elements, Vector &position, double BinStart, double BinWidth, double BinEnd, std::string &outputname, std::string &binoutputname, bool periodic);
+
+class AnalysisPointCorrelationAction : public Action {
+  friend void AnalysisPointCorrelation(std::vector< element *> &elements, Vector &position, double BinStart, double BinWidth, double BinEnd, std::string &outputname, std::string &binoutputname, bool periodic);
+
+public:
+  AnalysisPointCorrelationAction();
+  virtual ~AnalysisPointCorrelationAction();
+
+  bool canUndo();
+  bool shouldUndo();
+
+  virtual const std::string getName();
+protected:
+  virtual Dialog * fillDialog(Dialog*);
+private:
+  virtual Action::state_ptr performCall();
+  virtual Action::state_ptr performUndo(Action::state_ptr);
+  virtual Action::state_ptr performRedo(Action::state_ptr);
+
+  static const char NAME[];
+};
+
+#endif /* POINTCORRELATIONACTION_HPP_ */
Index: src/Actions/AnalysisAction/PrincipalAxisSystemAction.cpp
===================================================================
--- src/Actions/AnalysisAction/PrincipalAxisSystemAction.cpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/Actions/AnalysisAction/PrincipalAxisSystemAction.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -6,10 +6,19 @@
  */
 
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
 #include "Helpers/MemDebug.hpp"
 
 #include "Actions/AnalysisAction/PrincipalAxisSystemAction.hpp"
+#include "Actions/ActionRegistry.hpp"
+#include "Helpers/Log.hpp"
+#include "Helpers/Verbose.hpp"
+#include "LinearAlgebra/Matrix.hpp"
+#include "LinearAlgebra/Vector.hpp"
+#include "element.hpp"
 #include "molecule.hpp"
-#include "log.hpp"
-#include "verbose.hpp"
 
 #include <iostream>
@@ -20,5 +29,5 @@
 #include "UIElements/UIFactory.hpp"
 #include "UIElements/Dialog.hpp"
-#include "Actions/MapOfActions.hpp"
+#include "Actions/ValueStorage.hpp"
 
 const char AnalysisPrincipalAxisSystemAction::NAME[] = "principal-axis-system";
@@ -31,41 +40,64 @@
 {}
 
+void AnalysisPrincipalAxisSystem() {
+  ActionRegistry::getInstance().getActionByName(AnalysisPrincipalAxisSystemAction::NAME)->call(Action::NonInteractive);
+};
+
+Dialog* AnalysisPrincipalAxisSystemAction::fillDialog(Dialog *dialog) {
+  ASSERT(dialog,"No Dialog given when filling action dialog");
+
+  dialog->queryEmpty(NAME, ValueStorage::getInstance().getDescription(NAME));
+
+  return dialog;
+}
+
 Action::state_ptr AnalysisPrincipalAxisSystemAction::performCall() {
-  Dialog *dialog = UIFactory::getInstance().makeDialog();
   molecule *mol = NULL;
+  Matrix InertiaTensor;
 
-  dialog->queryMolecule(NAME, &mol, MapOfActions::getInstance().getDescription(NAME));
+  ValueStorage::getInstance().queryCurrentValue(NAME, mol);
+  DoLog(0) && (Log() << Verbose(0) << "Evaluating prinicipal axis." << endl);
+  for (World::MoleculeSelectionIterator iter = World::getInstance().beginMoleculeSelection(); iter != World::getInstance().endMoleculeSelection(); ++iter) {
+    molecule *mol = iter->second;
+    Vector *CenterOfGravity = mol->DetermineCenterOfGravity();
 
-  if(dialog->display()) {
-    DoLog(0) && (Log() << Verbose(0) << "Evaluating prinicipal axis." << endl);
-    mol->PrincipalAxisSystem(false);
-    delete dialog;
-    return Action::success;
-  } else {
-    delete dialog;
-    return Action::failure;
+    // reset inertia tensor
+    InertiaTensor.zero();
+
+    // sum up inertia tensor
+    for (molecule::const_iterator iter = mol->begin(); iter != mol->end(); ++iter) {
+      Vector x = (*iter)->getPosition();
+      x -= *CenterOfGravity;
+      const double mass = (*iter)->getType()->mass;
+      InertiaTensor.at(0,0) += mass*(x[1]*x[1] + x[2]*x[2]);
+      InertiaTensor.at(0,1) += mass*(-x[0]*x[1]);
+      InertiaTensor.at(0,2) += mass*(-x[0]*x[2]);
+      InertiaTensor.at(1,0) += mass*(-x[1]*x[0]);
+      InertiaTensor.at(1,1) += mass*(x[0]*x[0] + x[2]*x[2]);
+      InertiaTensor.at(1,2) += mass*(-x[1]*x[2]);
+      InertiaTensor.at(2,0) += mass*(-x[2]*x[0]);
+      InertiaTensor.at(2,1) += mass*(-x[2]*x[1]);
+      InertiaTensor.at(2,2) += mass*(x[0]*x[0] + x[1]*x[1]);
+    }
+    // print InertiaTensor for debugging
+    DoLog(0) && (Log() << Verbose(0) << "The inertia tensor is:" << InertiaTensor << endl);
   }
+  return Action::success;
 }
 
 Action::state_ptr AnalysisPrincipalAxisSystemAction::performUndo(Action::state_ptr _state) {
-//  ParserLoadXyzState *state = assert_cast<ParserLoadXyzState*>(_state.get());
-
-  return Action::failure;
-//  string newName = state->mol->getName();
-//  state->mol->setName(state->lastName);
-//
-//  return Action::state_ptr(new ParserLoadXyzState(state->mol,newName));
+  return Action::success;
 }
 
 Action::state_ptr AnalysisPrincipalAxisSystemAction::performRedo(Action::state_ptr _state){
-  return Action::failure;
+  return Action::success;
 }
 
 bool AnalysisPrincipalAxisSystemAction::canUndo() {
-  return false;
+  return true;
 }
 
 bool AnalysisPrincipalAxisSystemAction::shouldUndo() {
-  return false;
+  return true;
 }
 
Index: src/Actions/AnalysisAction/PrincipalAxisSystemAction.hpp
===================================================================
--- src/Actions/AnalysisAction/PrincipalAxisSystemAction.hpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/Actions/AnalysisAction/PrincipalAxisSystemAction.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -11,5 +11,9 @@
 #include "Actions/Action.hpp"
 
+void AnalysisPrincipalAxisSystem();
+
 class AnalysisPrincipalAxisSystemAction : public Action {
+  friend void AnalysisPrincipalAxisSystem();
+
 public:
   AnalysisPrincipalAxisSystemAction();
@@ -20,4 +24,6 @@
 
   virtual const std::string getName();
+protected:
+  virtual Dialog * fillDialog(Dialog *);
 private:
   virtual Action::state_ptr performCall();
Index: src/Actions/AnalysisAction/SurfaceCorrelationAction.cpp
===================================================================
--- src/Actions/AnalysisAction/SurfaceCorrelationAction.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
+++ src/Actions/AnalysisAction/SurfaceCorrelationAction.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -0,0 +1,164 @@
+/*
+ * SurfaceCorrelationAction.cpp
+ *
+ *  Created on: May 9, 2010
+ *      Author: heber
+ */
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "Helpers/MemDebug.hpp"
+
+#include "Actions/AnalysisAction/SurfaceCorrelationAction.hpp"
+#include "Actions/ActionRegistry.hpp"
+#include "analysis_correlation.hpp"
+#include "boundary.hpp"
+#include "linkedcell.hpp"
+#include "Helpers/Verbose.hpp"
+#include "Helpers/Log.hpp"
+#include "element.hpp"
+#include "molecule.hpp"
+#include "periodentafel.hpp"
+#include "tesselation.hpp"
+#include "LinearAlgebra/Vector.hpp"
+#include "World.hpp"
+
+#include <iostream>
+#include <string>
+
+using namespace std;
+
+#include "UIElements/UIFactory.hpp"
+#include "UIElements/Dialog.hpp"
+#include "Actions/ValueStorage.hpp"
+
+const char AnalysisSurfaceCorrelationAction::NAME[] = "surface-correlation";
+
+AnalysisSurfaceCorrelationAction::AnalysisSurfaceCorrelationAction() :
+  Action(NAME)
+{}
+
+AnalysisSurfaceCorrelationAction::~AnalysisSurfaceCorrelationAction()
+{}
+
+void AnalysisSurfaceCorrelation(std::vector< element *> &elements, molecule *mol, double BinStart, double BinWidth, double BinEnd, std::string &outputname, std::string &binoutputname, bool periodic) {
+  ValueStorage::getInstance().setCurrentValue("elements", elements);
+  ValueStorage::getInstance().setCurrentValue("molecule-by-id", mol);
+  ValueStorage::getInstance().setCurrentValue("bin-start", BinStart);
+  ValueStorage::getInstance().setCurrentValue("bin-width", BinWidth);
+  ValueStorage::getInstance().setCurrentValue("bin-end", BinEnd);
+  ValueStorage::getInstance().setCurrentValue("output-file", outputname);
+  ValueStorage::getInstance().setCurrentValue("bin-output-file", binoutputname);
+  ValueStorage::getInstance().setCurrentValue("periodic", periodic);
+  ActionRegistry::getInstance().getActionByName(AnalysisSurfaceCorrelationAction::NAME)->call(Action::NonInteractive);
+};
+
+
+Dialog* AnalysisSurfaceCorrelationAction::fillDialog(Dialog *dialog) {
+  ASSERT(dialog,"No Dialog given when filling action dialog");
+
+  dialog->queryMolecule("molecule-by-id", ValueStorage::getInstance().getDescription("molecule-by-id"));
+  dialog->queryElements("elements", ValueStorage::getInstance().getDescription("elements"));
+  dialog->queryDouble("bin-start", ValueStorage::getInstance().getDescription("bin-start"));
+  dialog->queryDouble("bin-width", ValueStorage::getInstance().getDescription("bin-width"));
+  dialog->queryDouble("bin-end", ValueStorage::getInstance().getDescription("bin-end"));
+  dialog->queryString("output-file", ValueStorage::getInstance().getDescription("output-file"));
+  dialog->queryString("bin-output-file", ValueStorage::getInstance().getDescription("bin-output-file"));
+  dialog->queryBoolean("periodic", ValueStorage::getInstance().getDescription("periodic"));
+
+  return dialog;
+}
+
+Action::state_ptr AnalysisSurfaceCorrelationAction::performCall() {
+  int ranges[3] = {1, 1, 1};
+  double BinEnd = 0.;
+  double BinStart = 0.;
+  double BinWidth = 0.;
+  molecule *Boundary = NULL;
+  string outputname;
+  string binoutputname;
+  bool periodic;
+  ofstream output;
+  ofstream binoutput;
+  std::vector<const element *> elements;
+  string type;
+  Vector Point;
+  BinPairMap *binmap = NULL;
+
+  // obtain information
+  ValueStorage::getInstance().queryCurrentValue("molecule-by-id", Boundary);
+  ValueStorage::getInstance().queryCurrentValue("elements", elements);
+  ValueStorage::getInstance().queryCurrentValue("bin-start", BinStart);
+  ValueStorage::getInstance().queryCurrentValue("bin-width", BinWidth);
+  ValueStorage::getInstance().queryCurrentValue("bin-end", BinEnd);
+  ValueStorage::getInstance().queryCurrentValue("output-file", outputname);
+  ValueStorage::getInstance().queryCurrentValue("bin-output-file", binoutputname);
+  ValueStorage::getInstance().queryCurrentValue("periodic", periodic);
+
+  // execute action
+  output.open(outputname.c_str());
+  binoutput.open(binoutputname.c_str());
+  ASSERT(Boundary != NULL, "No molecule specified for SurfaceCorrelation.");
+  const double radius = 4.;
+  double LCWidth = 20.;
+  if (BinEnd > 0) {
+    if (BinEnd > 2.*radius)
+      LCWidth = BinEnd;
+    else
+      LCWidth = 2.*radius;
+  }
+
+  // get the boundary
+  class Tesselation *TesselStruct = NULL;
+  const LinkedCell *LCList = NULL;
+  // find biggest molecule
+  std::vector<molecule*> molecules = World::getInstance().getSelectedMolecules();
+  std::cout << "There are " << molecules.size() << " selected molecules." << std::endl;
+  LCList = new LinkedCell(Boundary, LCWidth);
+  FindNonConvexBorder(Boundary, TesselStruct, LCList, radius, NULL);
+  CorrelationToSurfaceMap *surfacemap = NULL;
+  if (periodic)
+    surfacemap = PeriodicCorrelationToSurface( molecules, elements, TesselStruct, LCList, ranges);
+  else
+    surfacemap = CorrelationToSurface( molecules, elements, TesselStruct, LCList);
+  delete LCList;
+  OutputCorrelationToSurface(&output, surfacemap);
+  // check whether radius was appropriate
+  {
+    double start; double end;
+    GetMinMax( surfacemap, start, end);
+    if (LCWidth < end)
+      DoeLog(1) && (eLog()<< Verbose(1) << "Linked Cell width is smaller than the found range of values! Bins can only be correct up to: " << radius << "." << endl);
+  }
+  binmap = BinData( surfacemap, BinWidth, BinStart, BinEnd );
+  OutputCorrelation ( &binoutput, binmap );
+  delete TesselStruct;  // surfacemap contains refs to triangles! delete here, not earlier!
+  delete(binmap);
+  delete(surfacemap);
+  output.close();
+  binoutput.close();
+  return Action::success;
+}
+
+Action::state_ptr AnalysisSurfaceCorrelationAction::performUndo(Action::state_ptr _state) {
+  return Action::success;
+}
+
+Action::state_ptr AnalysisSurfaceCorrelationAction::performRedo(Action::state_ptr _state){
+  return Action::success;
+}
+
+bool AnalysisSurfaceCorrelationAction::canUndo() {
+  return true;
+}
+
+bool AnalysisSurfaceCorrelationAction::shouldUndo() {
+  return true;
+}
+
+const string AnalysisSurfaceCorrelationAction::getName() {
+  return NAME;
+}
Index: src/Actions/AnalysisAction/SurfaceCorrelationAction.hpp
===================================================================
--- src/Actions/AnalysisAction/SurfaceCorrelationAction.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
+++ src/Actions/AnalysisAction/SurfaceCorrelationAction.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -0,0 +1,40 @@
+/*
+ * SurfaceCorrelationAction.hpp
+ *
+ *  Created on: May 9, 2010
+ *      Author: heber
+ */
+
+#ifndef SURFACECORRELATIONACTION_HPP_
+#define SURFACECORRELATIONACTION_HPP_
+
+#include "Actions/Action.hpp"
+#include <string>
+#include <vector>
+
+class element;
+class molecule;
+
+void AnalysisSurfaceCorrelation(std::vector< element *> &elements, molecule *mol, double BinStart, double BinWidth, double BinEnd, std::string &outputname, std::string &binoutputname, bool periodic);
+
+class AnalysisSurfaceCorrelationAction : public Action {
+  friend void AnalysisSurfaceCorrelation(std::vector< element *> &elements, molecule *mol, double BinStart, double BinWidth, double BinEnd, std::string &outputname, std::string &binoutputname, bool periodic);
+public:
+  AnalysisSurfaceCorrelationAction();
+  virtual ~AnalysisSurfaceCorrelationAction();
+
+  bool canUndo();
+  bool shouldUndo();
+
+  virtual const std::string getName();
+protected:
+  virtual Dialog * fillDialog(Dialog*);
+private:
+  virtual Action::state_ptr performCall();
+  virtual Action::state_ptr performUndo(Action::state_ptr);
+  virtual Action::state_ptr performRedo(Action::state_ptr);
+
+  static const char NAME[];
+};
+
+#endif /* SURFACECORRELATIONACTION_HPP_ */
Index: src/Actions/AtomAction/AddAction.cpp
===================================================================
--- src/Actions/AtomAction/AddAction.cpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/Actions/AtomAction/AddAction.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -6,13 +6,20 @@
  */
 
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
 #include "Helpers/MemDebug.hpp"
 
 #include "Actions/AtomAction/AddAction.hpp"
+#include "Actions/ActionRegistry.hpp"
+#include "Descriptors/AtomIdDescriptor.hpp"
 #include "atom.hpp"
 #include "element.hpp"
-#include "log.hpp"
+#include "Helpers/Log.hpp"
 #include "molecule.hpp"
-#include "vector.hpp"
-#include "verbose.hpp"
+#include "LinearAlgebra/Vector.hpp"
+#include "Helpers/Verbose.hpp"
 #include "World.hpp"
 
@@ -24,5 +31,19 @@
 #include "UIElements/UIFactory.hpp"
 #include "UIElements/Dialog.hpp"
-#include "Actions/MapOfActions.hpp"
+#include "Actions/ValueStorage.hpp"
+
+// memento to remember the state when undoing
+
+class AtomAddState : public ActionState {
+public:
+  AtomAddState(const Vector &_position, const element *_elemental, const atomId_t _id) :
+    position(_position),
+    elemental(_elemental),
+    id(_id)
+  {}
+  Vector position;
+  const element *elemental;
+  atomId_t id;
+};
 
 const char AtomAddAction::NAME[] = "add-atom";
@@ -35,59 +56,75 @@
 {}
 
+void AtomAdd(element *elemental, Vector &position) {
+  ValueStorage::getInstance().setCurrentValue(AtomAddAction::NAME, elemental);
+  ValueStorage::getInstance().setCurrentValue("position", elemental);
+  ActionRegistry::getInstance().getActionByName(AtomAddAction::NAME)->call(Action::NonInteractive);
+};
+
+Dialog * AtomAddAction::fillDialog(Dialog *dialog) {
+  ASSERT(dialog,"No Dialog given when filling action dialog");
+
+  dialog->queryElement(NAME, ValueStorage::getInstance().getDescription(NAME));
+  dialog->queryVector("position", true, ValueStorage::getInstance().getDescription("position"));
+
+  return dialog;
+}
+
 Action::state_ptr AtomAddAction::performCall() {
-  Dialog *dialog = UIFactory::getInstance().makeDialog();
-  std::vector<element *> elements;
+  const element * elemental = NULL;
   Vector position;
 
-  dialog->queryElement(NAME, &elements, MapOfActions::getInstance().getDescription(NAME));
-  dialog->queryVector("position", &position, World::getInstance().getDomain(), true, MapOfActions::getInstance().getDescription("position"));
-  cout << "pre-dialog" << endl;
+  // obtain information
+  ValueStorage::getInstance().queryCurrentValue(NAME, elemental);
+  ValueStorage::getInstance().queryCurrentValue("position", position);
 
-  if(dialog->display()) {
-    cout << "post-dialog" << endl;
-    delete dialog;
-    if (elements.size() == 1) {
-      atom * first = World::getInstance().createAtom();
-      first->type = *(elements.begin());
-      first->x = position;
-      DoLog(1) && (Log() << Verbose(1) << "Adding new atom with element " << first->type->name << " at " << (first->x) << "." << endl);
-      // TODO: remove when all of World's atoms are stored.
-      std::vector<molecule *> molecules = World::getInstance().getAllMolecules();
-      if (!molecules.empty()) {
-        std::vector<molecule *>::iterator iter = molecules.begin();
-        (*iter)->AddAtom(first);
-      }
-      return Action::success;
-    } else {
-      DoeLog(1) && (eLog()<< Verbose(1) << "Could not find the specified element." << endl);
-      return Action::failure;
-    }
-  } else {
-    delete dialog;
-    return Action::failure;
+  // execute action
+  atom * first = World::getInstance().createAtom();
+  first->setType(elemental);
+  first->setPosition(position);
+  DoLog(1) && (Log() << Verbose(1) << "Adding new atom with element " << first->getType()->getName() << " at " << (first->getPosition()) << "." << endl);
+  // TODO: remove when all of World's atoms are stored.
+  std::vector<molecule *> molecules = World::getInstance().getAllMolecules();
+  if (!molecules.empty()) {
+    std::vector<molecule *>::iterator iter = molecules.begin();
+    (*iter)->AddAtom(first);
   }
-
+  return Action::state_ptr(new AtomAddState(position, elemental, first->getId()));
 }
 
 Action::state_ptr AtomAddAction::performUndo(Action::state_ptr _state) {
-//  ParserLoadXyzState *state = assert_cast<ParserLoadXyzState*>(_state.get());
+  AtomAddState *state = assert_cast<AtomAddState*>(_state.get());
 
-  return Action::failure;
-//  string newName = state->mol->getName();
-//  state->mol->setName(state->lastName);
-//
-//  return Action::state_ptr(new ParserLoadXyzState(state->mol,newName));
+  DoLog(1) && (Log() << Verbose(1) << "Removing atom with id " << state->id << "." << endl);
+  World::getInstance().destroyAtom(state->id);
+
+  return Action::state_ptr(_state);
 }
 
 Action::state_ptr AtomAddAction::performRedo(Action::state_ptr _state){
-  return Action::failure;
+  AtomAddState *state = assert_cast<AtomAddState*>(_state.get());
+
+  atom * first = World::getInstance().createAtom();
+  first->setType(state->elemental);
+  first->setPosition(state->position);
+  DoLog(1) && (Log() << Verbose(1) << "Re-adding new atom with element " << state->elemental->getName() << " at " << state->position << "." << endl);
+  // TODO: remove when all of World's atoms are stored.
+  std::vector<molecule *> molecules = World::getInstance().getAllMolecules();
+  if (!molecules.empty()) {
+    std::vector<molecule *>::iterator iter = molecules.begin();
+    (*iter)->AddAtom(first);
+  }
+  if (first->getId() != state->id)
+    if (!first->changeId(state->id))
+      return Action::failure;
+  return Action::state_ptr(_state);
 }
 
 bool AtomAddAction::canUndo() {
-  return false;
+  return true;
 }
 
 bool AtomAddAction::shouldUndo() {
-  return false;
+  return true;
 }
 
Index: src/Actions/AtomAction/AddAction.hpp
===================================================================
--- src/Actions/AtomAction/AddAction.hpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/Actions/AtomAction/AddAction.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -10,6 +10,13 @@
 
 #include "Actions/Action.hpp"
+#include "LinearAlgebra/Vector.hpp"
+
+class element;
+
+void AtomAdd(element *elemental, Vector &position);
 
 class AtomAddAction : public Action {
+  friend void AtomAdd(element *elemental, Vector &position);
+
 public:
   AtomAddAction();
@@ -20,4 +27,6 @@
 
   virtual const std::string getName();
+protected:
+  virtual Dialog * fillDialog(Dialog *);
 private:
   virtual Action::state_ptr performCall();
Index: src/Actions/AtomAction/ChangeElementAction.cpp
===================================================================
--- src/Actions/AtomAction/ChangeElementAction.cpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/Actions/AtomAction/ChangeElementAction.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -6,14 +6,24 @@
  */
 
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
 #include "Helpers/MemDebug.hpp"
 
 #include "Actions/AtomAction/ChangeElementAction.hpp"
+#include "Actions/ActionRegistry.hpp"
+#include "Descriptors/AtomIdDescriptor.hpp"
 #include "atom.hpp"
-#include "log.hpp"
-#include "vector.hpp"
-#include "verbose.hpp"
+#include "element.hpp"
+#include "Helpers/Log.hpp"
+#include "LinearAlgebra/Vector.hpp"
+#include "Helpers/Verbose.hpp"
+#include "molecule.hpp"
 #include "World.hpp"
 
 #include <iostream>
+#include <map>
 #include <string>
 
@@ -22,5 +32,19 @@
 #include "UIElements/UIFactory.hpp"
 #include "UIElements/Dialog.hpp"
-#include "Actions/MapOfActions.hpp"
+#include "Actions/ValueStorage.hpp"
+
+typedef std::map<int, const element *> ElementMap;
+
+// memento to remember the state when undoing
+
+class AtomChangeElementState : public ActionState {
+public:
+  AtomChangeElementState(ElementMap _Elements, const element *_elemental) :
+    Elements(_Elements),
+    elemental(_elemental)
+  {}
+  ElementMap Elements;
+  const element *elemental;
+};
 
 const char AtomChangeElementAction::NAME[] = "change-element";
@@ -33,49 +57,80 @@
 {}
 
+void AtomChangeElement(element *elemental) {
+  ValueStorage::getInstance().setCurrentValue(AtomChangeElementAction::NAME, elemental);
+  ActionRegistry::getInstance().getActionByName(AtomChangeElementAction::NAME)->call(Action::NonInteractive);
+};
+
+Dialog* AtomChangeElementAction::fillDialog(Dialog *dialog) {
+  ASSERT(dialog,"No Dialog given when filling action dialog");
+
+  dialog->queryElement(NAME, ValueStorage::getInstance().getDescription(NAME));
+
+return dialog;
+}
+
 Action::state_ptr AtomChangeElementAction::performCall() {
-  Dialog *dialog = UIFactory::getInstance().makeDialog();
   atom *first = NULL;
-  std::vector<element *> elements;
+  const element *elemental;
+  molecule *mol = NULL;
 
-  dialog->queryElement(NAME, &elements, MapOfActions::getInstance().getDescription(NAME));
-  dialog->queryAtom("atom-by-id", &first, MapOfActions::getInstance().getDescription("atom-by-id"));
+  ValueStorage::getInstance().queryCurrentValue(NAME, elemental);
 
-  if(dialog->display()) {
-    delete dialog;
-    ASSERT(elements.size() == 1, "Unequal to one element specified when changing an atom's element");
-    ASSERT(first != NULL, "No valid atom specified");
-    DoLog(1) && (Log() << Verbose(1) << "Changing atom " << *first << " to element " << elements.at(0) << "." << endl);
-    if (elements.at(0) != NULL) {
-      first->type = elements.at(0);
-      return Action::success;
-    } else
-      return Action::failure;
-  } else {
-    delete dialog;
-    return Action::failure;
+  // create undo state
+  ElementMap Elements;
+  for (World::AtomSelectionIterator iter = World::getInstance().beginAtomSelection(); iter != World::getInstance().endAtomSelection(); ++iter) {
+    Elements.insert(std::pair<int, const element *> (iter->second->getId(), iter->second->getType()));
   }
+  AtomChangeElementState *UndoState = new AtomChangeElementState(Elements, elemental);
 
+  for (World::AtomSelectionIterator iter = World::getInstance().beginAtomSelection(); iter != World::getInstance().endAtomSelection(); ++iter) {
+    first = iter->second;
+    DoLog(1) && (Log() << Verbose(1) << "Changing atom " << *first << " to element " << *elemental << "." << endl);
+    mol = first->getMolecule();
+    first->removeFromMolecule(); // remove atom
+    first->setType(elemental);
+    mol->AddAtom(first);  // add atom to ensure correctness of formula
+  }
+  return Action::state_ptr(UndoState);
 }
 
 Action::state_ptr AtomChangeElementAction::performUndo(Action::state_ptr _state) {
-//  ParserLoadXyzState *state = assert_cast<ParserLoadXyzState*>(_state.get());
+  AtomChangeElementState *state = assert_cast<AtomChangeElementState*>(_state.get());
+  atom *first = NULL;
+  molecule *mol = NULL;
 
-  return Action::failure;
-//  string newName = state->mol->getName();
-//  state->mol->setName(state->lastName);
-//
-//  return Action::state_ptr(new ParserLoadXyzState(state->mol,newName));
+  for(ElementMap::const_iterator iter = state->Elements.begin(); iter != state->Elements.end(); ++iter) {
+    first = World::getInstance().getAtom(AtomById(iter->first));
+    mol = first->getMolecule();
+    first->removeFromMolecule(); // remove atom
+    first->setType(iter->second);
+    mol->AddAtom(first);  // add atom to ensure correctness of formula
+  }
+
+  return Action::state_ptr(_state);
 }
 
 Action::state_ptr AtomChangeElementAction::performRedo(Action::state_ptr _state){
-  return Action::failure;
+  AtomChangeElementState *state = assert_cast<AtomChangeElementState*>(_state.get());
+  atom *first = NULL;
+  molecule *mol = NULL;
+
+  for(ElementMap::const_iterator iter = state->Elements.begin(); iter != state->Elements.end(); ++iter) {
+    first = World::getInstance().getAtom(AtomById(iter->first));
+    mol = first->getMolecule();
+    first->removeFromMolecule(); // remove atom
+    first->setType(state->elemental);
+    mol->AddAtom(first);  // add atom to ensure correctness of formula
+  }
+
+  return Action::state_ptr(_state);
 }
 
 bool AtomChangeElementAction::canUndo() {
-  return false;
+  return true;
 }
 
 bool AtomChangeElementAction::shouldUndo() {
-  return false;
+  return true;
 }
 
Index: src/Actions/AtomAction/ChangeElementAction.hpp
===================================================================
--- src/Actions/AtomAction/ChangeElementAction.hpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/Actions/AtomAction/ChangeElementAction.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -11,5 +11,11 @@
 #include "Actions/Action.hpp"
 
+class element;
+
+void AtomChangeElement(element *elemental);
+
 class AtomChangeElementAction : public Action {
+  friend void AtomChangeElement(element *elemental);
+
 public:
   AtomChangeElementAction();
@@ -20,4 +26,6 @@
 
   virtual const std::string getName();
+protected:
+  virtual Dialog * fillDialog(Dialog*);
 private:
   virtual Action::state_ptr performCall();
Index: src/Actions/AtomAction/RemoveAction.cpp
===================================================================
--- src/Actions/AtomAction/RemoveAction.cpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/Actions/AtomAction/RemoveAction.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -6,12 +6,19 @@
  */
 
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
 #include "Helpers/MemDebug.hpp"
 
 #include "Actions/AtomAction/RemoveAction.hpp"
+#include "Actions/ActionRegistry.hpp"
 #include "atom.hpp"
+#include "AtomicInfo.hpp"
 #include "Descriptors/AtomDescriptor.hpp"
-#include "log.hpp"
+#include "Helpers/Log.hpp"
 #include "molecule.hpp"
-#include "verbose.hpp"
+#include "Helpers/Verbose.hpp"
 #include "World.hpp"
 
@@ -23,5 +30,15 @@
 #include "UIElements/UIFactory.hpp"
 #include "UIElements/Dialog.hpp"
-#include "Actions/MapOfActions.hpp"
+#include "Actions/ValueStorage.hpp"
+
+// memento to remember the state when undoing
+
+class AtomRemoveState : public ActionState {
+public:
+  AtomRemoveState(std::vector<AtomicInfo> _Walkers) :
+    Walkers(_Walkers)
+  {}
+  std::vector<AtomicInfo> Walkers;
+};
 
 const char AtomRemoveAction::NAME[] = "remove-atom";
@@ -34,48 +51,83 @@
 {}
 
+void AtomRemove() {
+  ActionRegistry::getInstance().getActionByName(AtomRemoveAction::NAME)->call(Action::NonInteractive);
+};
+
+Dialog* AtomRemoveAction::fillDialog(Dialog *dialog) {
+  ASSERT(dialog,"No Dialog given when filling action dialog");
+
+  dialog->queryEmpty(NAME, ValueStorage::getInstance().getDescription(NAME));
+
+  return dialog;
+}
+
 Action::state_ptr AtomRemoveAction::performCall() {
-  Dialog *dialog = UIFactory::getInstance().makeDialog();
   atom *first = NULL;
 
-  dialog->queryAtom(NAME, &first, MapOfActions::getInstance().getDescription(NAME));
+  // create undo state
+  std::vector<AtomicInfo> Walkers;
+  for (World::AtomSelectionIterator iter = World::getInstance().beginAtomSelection(); iter != World::getInstance().endAtomSelection(); ++iter) {
+    Walkers.push_back(AtomicInfo(*(iter->second)));
+  }
+  AtomRemoveState *UndoState = new AtomRemoveState(Walkers);
 
-  if(dialog->display()) {
-    delete dialog;
+  // remove all selected atoms
+//  std::vector<molecule *> molecules = World::getInstance().getAllMolecules();
+  for (World::AtomSelectionIterator iter = World::getInstance().beginAtomSelection(); iter != World::getInstance().endAtomSelection(); ++iter) {
+    first = iter->second;
     DoLog(1) && (Log() << Verbose(1) << "Removing atom " << first->getId() << "." << endl);
-    // TODO: this is not necessary when atoms and their storing to file are handled by the World
-    // simply try to erase in every molecule found
-    std::vector<molecule *> molecules = World::getInstance().getAllMolecules();
-    for (std::vector<molecule *>::iterator iter = molecules.begin();iter != molecules.end(); ++iter) {
-      (*iter)->erase(first);
-    }
+//    // TODO: this is not necessary when atoms and their storing to file are handled by the World
+//    // simply try to erase in every molecule found
+//    for (std::vector<molecule *>::iterator iter = molecules.begin();iter != molecules.end(); ++iter) {
+//      (*iter)->erase(first);
+//    }
     World::getInstance().destroyAtom(first);
-    return Action::success;
-  } else {
-    delete dialog;
-    return Action::failure;
   }
-
+  return Action::state_ptr(UndoState);
 }
 
 Action::state_ptr AtomRemoveAction::performUndo(Action::state_ptr _state) {
-//  ParserLoadXyzState *state = assert_cast<ParserLoadXyzState*>(_state.get());
+  AtomRemoveState *state = assert_cast<AtomRemoveState*>(_state.get());
 
-  return Action::failure;
-//  string newName = state->mol->getName();
-//  state->mol->setName(state->lastName);
-//
-//  return Action::state_ptr(new ParserLoadXyzState(state->mol,newName));
+  size_t i=0;
+  for (; i<state->Walkers.size(); ++i) {
+    // re-create the atom
+    DoLog(1) && (Log() << Verbose(1) << "Re-adding atom " << state->Walkers[i].getId() << "." << endl);
+    atom *Walker = World::getInstance().createAtom();
+    if (!state->Walkers[i].setAtom(*Walker)) {
+      DoeLog(1) && (eLog() << Verbose(1) << "Failed to set id." << endl);
+      World::getInstance().destroyAtom(Walker);
+      break;
+    }
+  }
+  if (i<state->Walkers.size()) {
+    // remove all previous ones, too
+    for (size_t j=0;j<i;++j)
+      World::getInstance().destroyAtom(state->Walkers[j].getId());
+    // and announce the failure of the undo
+    return Action::failure;
+  }
+  return Action::state_ptr(_state);
 }
 
 Action::state_ptr AtomRemoveAction::performRedo(Action::state_ptr _state){
-  return Action::failure;
+  AtomRemoveState *state = assert_cast<AtomRemoveState*>(_state.get());
+
+  // simple remove again all previously added atoms
+  for (size_t i=0; i<state->Walkers.size(); ++i) {
+    DoLog(1) && (Log() << Verbose(1) << "Re-removing atom " << state->Walkers[i].getId() << "." << endl);
+    World::getInstance().destroyAtom(state->Walkers[i].getId());
+  }
+
+  return Action::state_ptr(_state);
 }
 
 bool AtomRemoveAction::canUndo() {
-  return false;
+  return true;
 }
 
 bool AtomRemoveAction::shouldUndo() {
-  return false;
+  return true;
 }
 
Index: src/Actions/AtomAction/RemoveAction.hpp
===================================================================
--- src/Actions/AtomAction/RemoveAction.hpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/Actions/AtomAction/RemoveAction.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -11,5 +11,9 @@
 #include "Actions/Action.hpp"
 
+void AtomRemove();
+
 class AtomRemoveAction : public Action {
+  friend void AtomRemove();
+
 public:
   AtomRemoveAction();
@@ -20,4 +24,6 @@
 
   virtual const std::string getName();
+protected:
+  virtual Dialog * fillDialog(Dialog*);
 private:
   virtual Action::state_ptr performCall();
Index: src/Actions/AtomAction/RotateAroundOriginByAngleAction.cpp
===================================================================
--- src/Actions/AtomAction/RotateAroundOriginByAngleAction.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
+++ src/Actions/AtomAction/RotateAroundOriginByAngleAction.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -0,0 +1,138 @@
+/*
+ * RotateAroundOriginByAngleAction.cpp
+ *
+ *  Created on: Aug 06, 2010
+ *      Author: heber
+ */
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "Helpers/MemDebug.hpp"
+
+#include "Actions/AtomAction/RotateAroundOriginByAngleAction.hpp"
+#include "Actions/ActionRegistry.hpp"
+#include "Helpers/Log.hpp"
+#include "Helpers/Verbose.hpp"
+#include "LinearAlgebra/Line.hpp"
+#include "LinearAlgebra/Vector.hpp"
+#include "molecule.hpp"
+
+
+#include <iostream>
+#include <fstream>
+#include <string>
+
+using namespace std;
+
+#include "UIElements/UIFactory.hpp"
+#include "UIElements/Dialog.hpp"
+#include "Actions/ValueStorage.hpp"
+
+/****** AtomRotateAroundOriginByAngleAction *****/
+
+// memento to remember the state when undoing
+
+class AtomRotateAroundOriginByAngleState : public ActionState {
+public:
+  AtomRotateAroundOriginByAngleState(std::vector<atom*> _selectedAtoms, const Vector &_Axis, const double _alpha) :
+    selectedAtoms(_selectedAtoms),
+    Axis(_Axis),
+    alpha(_alpha)
+  {}
+  std::vector<atom*> selectedAtoms;
+  Vector Axis;
+  double alpha;
+};
+
+const char AtomRotateAroundOriginByAngleAction::NAME[] = "rotate-origin";
+
+AtomRotateAroundOriginByAngleAction::AtomRotateAroundOriginByAngleAction() :
+  Action(NAME)
+{}
+
+AtomRotateAroundOriginByAngleAction::~AtomRotateAroundOriginByAngleAction()
+{}
+
+void AtomRotateAroundOriginByAngle(const Vector &Axis, double angle) {
+  ValueStorage::getInstance().setCurrentValue(AtomRotateAroundOriginByAngleAction::NAME, angle);
+  ValueStorage::getInstance().setCurrentValue("position", Axis);
+  ActionRegistry::getInstance().getActionByName(AtomRotateAroundOriginByAngleAction::NAME)->call(Action::NonInteractive);
+};
+
+Dialog* AtomRotateAroundOriginByAngleAction::fillDialog(Dialog *dialog) {
+  ASSERT(dialog,"No Dialog given when filling action dialog");
+
+  dialog->queryDouble(NAME, ValueStorage::getInstance().getDescription(NAME));
+  dialog->queryVector("position", false, ValueStorage::getInstance().getDescription("position"));
+
+  return dialog;
+}
+
+Action::state_ptr AtomRotateAroundOriginByAngleAction::performCall() {
+  double alpha = 0.;
+  Vector Axis;
+  std::vector<atom *> selectedAtoms = World::getInstance().getSelectedAtoms();
+
+  // obtain axis to rotate to
+  ValueStorage::getInstance().queryCurrentValue(NAME, alpha);
+  ValueStorage::getInstance().queryCurrentValue("position", Axis);
+
+  // check whether Axis is valid
+  if (Axis.IsZero())
+    return Action::failure;
+
+  // convert from degrees to radian
+  alpha *= M_PI/180.;
+
+  // Creation Line that is the rotation axis
+  Line RotationAxis(Vector(0.,0.,0.), Axis);
+
+  DoLog(0) && (Log() << Verbose(0) << "Rotate around origin by " << alpha << " radian, axis from origin to " << Axis << "." << endl);
+  // TODO: use AtomSet::rotate?
+  for (std::vector<atom *>::iterator iter = selectedAtoms.begin(); iter != selectedAtoms.end(); ++iter) {
+    (*iter)->setPosition(RotationAxis.rotateVector((*iter)->getPosition(), alpha));
+  }
+  DoLog(0) && (Log() << Verbose(0) << "done." << endl);
+  return Action::state_ptr(new AtomRotateAroundOriginByAngleState(World::getInstance().getSelectedAtoms(), Axis, alpha));
+}
+
+Action::state_ptr AtomRotateAroundOriginByAngleAction::performUndo(Action::state_ptr _state) {
+  AtomRotateAroundOriginByAngleState *state = assert_cast<AtomRotateAroundOriginByAngleState*>(_state.get());
+
+  // Creation Line that is the rotation axis
+  Line RotationAxis(Vector(0.,0.,0.), state->Axis);
+
+  for (std::vector<atom *>::iterator iter = state->selectedAtoms.begin(); iter != state->selectedAtoms.end(); ++iter) {
+    (*iter)->setPosition(RotationAxis.rotateVector((*iter)->getPosition(), -state->alpha));
+  }
+
+  return Action::state_ptr(_state);
+}
+
+Action::state_ptr AtomRotateAroundOriginByAngleAction::performRedo(Action::state_ptr _state){
+  AtomRotateAroundOriginByAngleState *state = assert_cast<AtomRotateAroundOriginByAngleState*>(_state.get());
+
+  // Creation Line that is the rotation axis
+  Line RotationAxis(Vector(0.,0.,0.), state->Axis);
+
+  for (std::vector<atom *>::iterator iter = state->selectedAtoms.begin(); iter != state->selectedAtoms.end(); ++iter) {
+    (*iter)->setPosition(RotationAxis.rotateVector((*iter)->getPosition(), state->alpha));
+  }
+
+  return Action::state_ptr(_state);
+}
+
+bool AtomRotateAroundOriginByAngleAction::canUndo() {
+  return true;
+}
+
+bool AtomRotateAroundOriginByAngleAction::shouldUndo() {
+  return true;
+}
+
+const string AtomRotateAroundOriginByAngleAction::getName() {
+  return NAME;
+}
Index: src/Actions/AtomAction/RotateAroundOriginByAngleAction.hpp
===================================================================
--- src/Actions/AtomAction/RotateAroundOriginByAngleAction.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
+++ src/Actions/AtomAction/RotateAroundOriginByAngleAction.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -0,0 +1,39 @@
+/*
+ * RotateAroundOriginByAngleAction.hpp
+ *
+ *  Created on: Aug 06, 2010
+ *      Author: heber
+ */
+
+#ifndef ROTATEAROUNDORIGINBYANGLEACTION_HPP
+#define ROTATEAROUNDORIGINBYANGLEACTION_HPP
+
+#include "Actions/Action.hpp"
+
+class Vector;
+
+void AtomRotateOrigin(Vector &Axis);
+
+class AtomRotateAroundOriginByAngleAction : public Action {
+  friend void AtomRotateAroundOriginByAngle(const Vector &Axis, double angle);
+
+public:
+  AtomRotateAroundOriginByAngleAction();
+  virtual ~AtomRotateAroundOriginByAngleAction();
+
+  bool canUndo();
+  bool shouldUndo();
+
+  virtual const std::string getName();
+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);
+
+  static const char NAME[];
+};
+
+
+#endif // ROTATEAROUNDORIGINBYANGLEACTION_HPP
Index: src/Actions/AtomAction/TranslateAction.cpp
===================================================================
--- src/Actions/AtomAction/TranslateAction.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
+++ src/Actions/AtomAction/TranslateAction.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -0,0 +1,129 @@
+/*
+ * TranslateAction.cpp
+ *
+ *  Created on: May 10, 2010
+ *      Author: heber
+ */
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "Helpers/MemDebug.hpp"
+
+#include "Actions/AtomAction/TranslateAction.hpp"
+#include "Actions/ActionRegistry.hpp"
+#include "Helpers/Log.hpp"
+#include "atom.hpp"
+#include "LinearAlgebra/Vector.hpp"
+#include "Helpers/Verbose.hpp"
+#include "World.hpp"
+
+#include <iostream>
+#include <fstream>
+#include <string>
+
+using namespace std;
+
+#include "UIElements/UIFactory.hpp"
+#include "UIElements/Dialog.hpp"
+#include "Actions/ValueStorage.hpp"
+
+/****** AtomTranslateAction *****/
+
+// memento to remember the state when undoing
+
+class AtomTranslateState : public ActionState {
+public:
+  AtomTranslateState(const std::vector<atom*> &_selectedAtoms, const Vector &_v, const bool _periodic) :
+    selectedAtoms(_selectedAtoms),
+    v(_v),
+    periodic(_periodic)
+  {}
+  std::vector<atom*> selectedAtoms;
+  Vector v;
+  bool periodic;
+};
+
+const char AtomTranslateAction::NAME[] = "translate-atoms";
+
+AtomTranslateAction::AtomTranslateAction() :
+  Action(NAME)
+{}
+
+AtomTranslateAction::~AtomTranslateAction()
+{}
+
+void AtomTranslate(Vector &x, bool periodic = false) {
+  ValueStorage::getInstance().setCurrentValue(AtomTranslateAction::NAME, x);
+  ValueStorage::getInstance().setCurrentValue("periodic", periodic);
+  ActionRegistry::getInstance().getActionByName(AtomTranslateAction::NAME)->call(Action::NonInteractive);
+};
+
+Dialog* AtomTranslateAction::fillDialog(Dialog *dialog) {
+  ASSERT(dialog,"No Dialog given when filling action dialog");
+
+  dialog->queryVector(NAME, false, ValueStorage::getInstance().getDescription(NAME));
+  dialog->queryBoolean("periodic", ValueStorage::getInstance().getDescription("periodic"));
+
+  return dialog;
+}
+
+Action::state_ptr AtomTranslateAction::performCall() {
+  Vector v;
+  bool periodic = false;
+  Box &domain = World::getInstance().getDomain();
+  std::vector<atom *> selectedAtoms = World::getInstance().getSelectedAtoms();
+
+  ValueStorage::getInstance().queryCurrentValue(NAME, v);
+  if (!ValueStorage::getInstance().queryCurrentValue("periodic", periodic, true))
+    periodic = false;
+
+  // TODO: use AtomSet::translate
+  for (std::vector<atom *>::iterator iter = selectedAtoms.begin(); iter != selectedAtoms.end(); ++iter) {
+    *(*iter) += v;
+    if (periodic)
+      (*iter)->setPosition(domain.WrapPeriodically((*iter)->getPosition()));
+  }
+
+  return Action::state_ptr(new AtomTranslateState(selectedAtoms, v, periodic));
+}
+
+Action::state_ptr AtomTranslateAction::performUndo(Action::state_ptr _state) {
+  AtomTranslateState *state = assert_cast<AtomTranslateState*>(_state.get());
+  Box &domain = World::getInstance().getDomain();
+
+  for (std::vector<atom *>::iterator iter = state->selectedAtoms.begin(); iter != state->selectedAtoms.end(); ++iter) {
+    *(*iter) -= state->v;
+    if (state->periodic)
+      (*iter)->setPosition(domain.WrapPeriodically((*iter)->getPosition()));
+  }
+
+  return Action::state_ptr(_state);
+}
+
+Action::state_ptr AtomTranslateAction::performRedo(Action::state_ptr _state){
+  AtomTranslateState *state = assert_cast<AtomTranslateState*>(_state.get());
+  Box &domain = World::getInstance().getDomain();
+
+  for (std::vector<atom *>::iterator iter = state->selectedAtoms.begin(); iter != state->selectedAtoms.end(); ++iter) {
+    *(*iter) += state->v;
+    if (state->periodic)
+      (*iter)->setPosition(domain.WrapPeriodically((*iter)->getPosition()));
+  }
+
+  return Action::state_ptr(_state);
+}
+
+bool AtomTranslateAction::canUndo() {
+  return true;
+}
+
+bool AtomTranslateAction::shouldUndo() {
+  return true;
+}
+
+const string AtomTranslateAction::getName() {
+  return NAME;
+}
Index: src/Actions/AtomAction/TranslateAction.hpp
===================================================================
--- src/Actions/AtomAction/TranslateAction.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
+++ src/Actions/AtomAction/TranslateAction.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -0,0 +1,38 @@
+/*
+ * TranslateAction.hpp
+ *
+ *  Created on: May 10, 2010
+ *      Author: heber
+ */
+
+#ifndef TRANSLATEACTION_HPP
+#define TRANSLATEACTION_HPP
+
+#include "Actions/Action.hpp"
+#include "LinearAlgebra/Vector.hpp"
+
+void AtomTranslate(Vector &x, bool periodic);
+
+class AtomTranslateAction : public Action {
+  friend void AtomTranslate(Vector &x, bool periodic);
+
+public:
+  AtomTranslateAction();
+  virtual ~AtomTranslateAction();
+
+  bool canUndo();
+  bool shouldUndo();
+
+  virtual const std::string getName();
+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);
+
+  static const char NAME[];
+};
+
+
+#endif // TRANSLATEACTION_HPP
Index: src/Actions/AtomsCalculation.hpp
===================================================================
--- src/Actions/AtomsCalculation.hpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/Actions/AtomsCalculation.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -11,4 +11,6 @@
 #include "Actions/Calculation.hpp"
 
+class Dialog;
+
 template<typename T>
 class AtomsCalculation : public Calculation<std::vector<T> >
@@ -20,4 +22,5 @@
 protected:
   virtual std::vector<T>* doCalc();
+  virtual Dialog *fillDialog(Dialog *dialog);
 
 private:
Index: src/Actions/AtomsCalculation_impl.hpp
===================================================================
--- src/Actions/AtomsCalculation_impl.hpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/Actions/AtomsCalculation_impl.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -11,6 +11,4 @@
 #include "Actions/AtomsCalculation.hpp"
 #include "Actions/Calculation_impl.hpp"
-
-#include <iostream>
 
 using namespace std;
@@ -35,5 +33,9 @@
   Process::setMaxSteps(steps);
   Process::start();
-  for(World::AtomIterator iter=world->getAtomIter(descr);iter!=world->atomEnd();++iter){
+  for(World::internal_AtomIterator
+      iter=world->getAtomIter_internal(descr);
+      iter!=world->atomEnd_internal();
+      ++iter){
+
     Process::setCurrStep(iter.getCount());
     res->push_back(op(*iter));
@@ -43,4 +45,9 @@
 }
 
+template<typename T>
+Dialog *AtomsCalculation<T>::fillDialog(Dialog *dialog){
+  ASSERT(dialog,"No Dialog given when filling action dialog");
+  return dialog;
+}
 
 #endif /* ATOMSCALCULATION_IMPL_HPP_ */
Index: src/Actions/CmdAction/BondLengthTableAction.cpp
===================================================================
--- src/Actions/CmdAction/BondLengthTableAction.cpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/Actions/CmdAction/BondLengthTableAction.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -6,11 +6,17 @@
  */
 
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
 #include "Helpers/MemDebug.hpp"
 
 #include "Actions/CmdAction/BondLengthTableAction.hpp"
+#include "Actions/ActionRegistry.hpp"
 #include "bondgraph.hpp"
 #include "config.hpp"
-#include "log.hpp"
-#include "verbose.hpp"
+#include "Helpers/Log.hpp"
+#include "Helpers/Verbose.hpp"
 #include "World.hpp"
 
@@ -22,5 +28,5 @@
 #include "UIElements/UIFactory.hpp"
 #include "UIElements/Dialog.hpp"
-#include "Actions/MapOfActions.hpp"
+#include "Actions/ValueStorage.hpp"
 
 const char CommandLineBondLengthTableAction::NAME[] = "bond-table";
@@ -33,20 +39,24 @@
 {}
 
+void CommandBondLengthTable(std::string &BondGraphFileName) {
+  ValueStorage::getInstance().setCurrentValue(CommandLineBondLengthTableAction::NAME, BondGraphFileName);
+  ActionRegistry::getInstance().getActionByName(CommandLineBondLengthTableAction::NAME)->call(Action::NonInteractive);
+};
+
+Dialog* CommandLineBondLengthTableAction::fillDialog(Dialog *dialog) {
+  ASSERT(dialog,"No Dialog given when filling action dialog");
+
+  dialog->queryString(NAME, ValueStorage::getInstance().getDescription(NAME));
+
+  return dialog;
+}
+
 Action::state_ptr CommandLineBondLengthTableAction::performCall() {
   ostringstream usage;
   string BondGraphFileName;
-  Dialog *dialog = UIFactory::getInstance().makeDialog();
 
+  ValueStorage::getInstance().queryCurrentValue(NAME, BondGraphFileName);
+  DoLog(0) && (Log() << Verbose(0) << "Using " << BondGraphFileName << " as bond length table." << endl);
   config *configuration = World::getInstance().getConfig();
-  dialog->queryString(NAME, &BondGraphFileName, MapOfActions::getInstance().getDescription(NAME));
-
-  if(dialog->display()) {
-    DoLog(0) && (Log() << Verbose(0) << "Using " << BondGraphFileName << " as bond length table." << endl);
-    delete dialog;
-  } else {
-    delete dialog;
-    return Action::failure;
-  }
-
   if (configuration->BG == NULL) {
     configuration->BG = new BondGraph(configuration->GetIsAngstroem());
Index: src/Actions/CmdAction/BondLengthTableAction.hpp
===================================================================
--- src/Actions/CmdAction/BondLengthTableAction.hpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/Actions/CmdAction/BondLengthTableAction.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -11,5 +11,9 @@
 #include "Actions/Action.hpp"
 
+void CommandBondLengthTable(std::string &BondGraphFileName);
+
 class CommandLineBondLengthTableAction : public Action {
+  friend void CommandBondLengthTable(std::string &BondGraphFileName);
+
 public:
   CommandLineBondLengthTableAction();
@@ -20,4 +24,6 @@
 
   virtual const std::string getName();
+protected:
+  virtual Dialog * fillDialog(Dialog *dialog);
 private:
   virtual Action::state_ptr performCall();
Index: src/Actions/CmdAction/ElementDbAction.cpp
===================================================================
--- src/Actions/CmdAction/ElementDbAction.cpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/Actions/CmdAction/ElementDbAction.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -6,11 +6,17 @@
  */
 
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
 #include "Helpers/MemDebug.hpp"
 
 #include "Actions/CmdAction/ElementDbAction.hpp"
+#include "Actions/ActionRegistry.hpp"
 #include "config.hpp"
-#include "log.hpp"
+#include "Helpers/Log.hpp"
 #include "periodentafel.hpp"
-#include "verbose.hpp"
+#include "Helpers/Verbose.hpp"
 #include "World.hpp"
 
@@ -22,5 +28,5 @@
 #include "UIElements/UIFactory.hpp"
 #include "UIElements/Dialog.hpp"
-#include "Actions/MapOfActions.hpp"
+#include "Actions/ValueStorage.hpp"
 
 const char CommandLineElementDbAction::NAME[] = "element-db";
@@ -33,21 +39,26 @@
 {}
 
+void CommandElementDb(std::string &databasepath) {
+  ValueStorage::getInstance().setCurrentValue(CommandLineElementDbAction::NAME, databasepath);
+  ActionRegistry::getInstance().getActionByName(CommandLineElementDbAction::NAME)->call(Action::NonInteractive);
+};
+
+Dialog* CommandLineElementDbAction::fillDialog(Dialog *dialog) {
+  ASSERT(dialog,"No Dialog given when filling action dialog");
+
+  dialog->queryString(NAME, ValueStorage::getInstance().getDescription(NAME));
+
+  return dialog;
+}
+
 Action::state_ptr CommandLineElementDbAction::performCall() {
   ostringstream usage;
   string databasepath;
-  Dialog *dialog = UIFactory::getInstance().makeDialog();
 
   // get the path
   // TODO: Make databasepath a std::string
   config *configuration = World::getInstance().getConfig();
-  dialog->queryString(NAME, &databasepath, MapOfActions::getInstance().getDescription(NAME));
-
-  if(dialog->display()) {
-    strcpy(configuration->databasepath, databasepath.c_str());
-    delete dialog;
-  } else {
-    delete dialog;
-    return Action::failure;
-  }
+  ValueStorage::getInstance().queryCurrentValue(NAME, databasepath);
+  strcpy(configuration->databasepath, databasepath.c_str());
 
   // load table
Index: src/Actions/CmdAction/ElementDbAction.hpp
===================================================================
--- src/Actions/CmdAction/ElementDbAction.hpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/Actions/CmdAction/ElementDbAction.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -11,5 +11,9 @@
 #include "Actions/Action.hpp"
 
+void CommandElementDb(std::string &databasepath);
+
 class CommandLineElementDbAction : public Action {
+  friend void CommandElementDb(std::string &databasepath);
+
 public:
   CommandLineElementDbAction();
@@ -20,4 +24,6 @@
 
   virtual const std::string getName();
+protected:
+  virtual Dialog * fillDialog(Dialog *dialog);
 private:
   virtual Action::state_ptr performCall();
Index: src/Actions/CmdAction/FastParsingAction.cpp
===================================================================
--- src/Actions/CmdAction/FastParsingAction.cpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/Actions/CmdAction/FastParsingAction.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -6,10 +6,16 @@
  */
 
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
 #include "Helpers/MemDebug.hpp"
 
 #include "Actions/CmdAction/FastParsingAction.hpp"
+#include "Actions/ActionRegistry.hpp"
 #include "config.hpp"
-#include "log.hpp"
-#include "verbose.hpp"
+#include "Helpers/Log.hpp"
+#include "Helpers/Verbose.hpp"
 #include "World.hpp"
 
@@ -21,5 +27,18 @@
 #include "UIElements/UIFactory.hpp"
 #include "UIElements/Dialog.hpp"
-#include "Actions/MapOfActions.hpp"
+#include "Actions/ValueStorage.hpp"
+
+// memento to remember the state when undoing
+
+class CommandLineFastParsingState : public ActionState {
+public:
+  CommandLineFastParsingState(const bool _oldvalue, const bool _newvalue) :
+    oldvalue(_oldvalue),
+    newvalue(_newvalue)
+  {}
+  bool oldvalue;
+  bool newvalue;
+};
+
 
 const char CommandLineFastParsingAction::NAME[] = "fastparsing";
@@ -32,43 +51,62 @@
 {}
 
+void CommandFastParsing(bool fastparsing) {
+  ValueStorage::getInstance().setCurrentValue(CommandLineFastParsingAction::NAME, fastparsing);
+  ActionRegistry::getInstance().getActionByName(CommandLineFastParsingAction::NAME)->call(Action::NonInteractive);
+};
+
+Dialog* CommandLineFastParsingAction::fillDialog(Dialog *dialog) {
+  ASSERT(dialog,"No Dialog given when filling action dialog");
+
+  dialog->queryBoolean(NAME, ValueStorage::getInstance().getDescription(NAME));
+
+  return dialog;
+}
+
 Action::state_ptr CommandLineFastParsingAction::performCall() {
-  Dialog *dialog = UIFactory::getInstance().makeDialog();
-
   config *configuration = World::getInstance().getConfig();
-  dialog->queryBoolean(NAME, &configuration->FastParsing, MapOfActions::getInstance().getDescription(NAME));
-
-  if(dialog->display()) {
-    if (configuration->FastParsing)
-      DoLog(0) && (Log() << Verbose(0) << "I won't parse trajectories." << endl);
-    else
-      DoLog(0) && (Log() << Verbose(0) << "I will parse trajectories." << endl);
-    delete dialog;
-    return Action::success;
-  } else {
-    delete dialog;
-    return Action::failure;
-  }
+  bool oldvalue = configuration->FastParsing;
+  bool newvalue;
+  ValueStorage::getInstance().queryCurrentValue(NAME, newvalue);
+  configuration->FastParsing = newvalue;
+  if (configuration->FastParsing)
+    DoLog(0) && (Log() << Verbose(0) << "I won't parse trajectories." << endl);
+  else
+    DoLog(0) && (Log() << Verbose(0) << "I will parse trajectories." << endl);
+  return Action::state_ptr(new CommandLineFastParsingState(oldvalue, newvalue));
 }
 
 Action::state_ptr CommandLineFastParsingAction::performUndo(Action::state_ptr _state) {
-//  ParserLoadXyzState *state = assert_cast<ParserLoadXyzState*>(_state.get());
+  CommandLineFastParsingState *state = assert_cast<CommandLineFastParsingState*>(_state.get());
 
-  return Action::failure;
-//  string newName = state->mol->getName();
-//  state->mol->setName(state->lastName);
-//
-//  return Action::state_ptr(new ParserLoadXyzState(state->mol,newName));
+  config *configuration = World::getInstance().getConfig();
+  configuration->FastParsing = state->oldvalue;
+  if (configuration->FastParsing)
+    DoLog(0) && (Log() << Verbose(0) << "I won't parse trajectories." << endl);
+  else
+    DoLog(0) && (Log() << Verbose(0) << "I will parse trajectories." << endl);
+
+  return Action::state_ptr(_state);
 }
 
 Action::state_ptr CommandLineFastParsingAction::performRedo(Action::state_ptr _state){
-  return Action::failure;
+  CommandLineFastParsingState *state = assert_cast<CommandLineFastParsingState*>(_state.get());
+
+  config *configuration = World::getInstance().getConfig();
+  configuration->FastParsing = state->newvalue;
+  if (configuration->FastParsing)
+    DoLog(0) && (Log() << Verbose(0) << "I won't parse trajectories." << endl);
+  else
+    DoLog(0) && (Log() << Verbose(0) << "I will parse trajectories." << endl);
+
+  return Action::state_ptr(_state);
 }
 
 bool CommandLineFastParsingAction::canUndo() {
-  return false;
+  return true;
 }
 
 bool CommandLineFastParsingAction::shouldUndo() {
-  return false;
+  return true;
 }
 
Index: src/Actions/CmdAction/FastParsingAction.hpp
===================================================================
--- src/Actions/CmdAction/FastParsingAction.hpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/Actions/CmdAction/FastParsingAction.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -11,5 +11,9 @@
 #include "Actions/Action.hpp"
 
+void CommandFastParsing(bool fastparsing);
+
 class CommandLineFastParsingAction : public Action {
+  friend void CommandFastParsing(bool fastparsing);
+
 public:
   CommandLineFastParsingAction();
@@ -20,4 +24,6 @@
 
   virtual const std::string getName();
+protected:
+  virtual Dialog * fillDialog(Dialog *dialog);
 private:
   virtual Action::state_ptr performCall();
Index: src/Actions/CmdAction/HelpAction.cpp
===================================================================
--- src/Actions/CmdAction/HelpAction.cpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/Actions/CmdAction/HelpAction.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -6,7 +6,13 @@
  */
 
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
 #include "Helpers/MemDebug.hpp"
 
 #include "Actions/CmdAction/HelpAction.hpp"
+#include "Actions/ActionRegistry.hpp"
 #include "CommandLineParser.hpp"
 
@@ -18,5 +24,5 @@
 #include "UIElements/UIFactory.hpp"
 #include "UIElements/Dialog.hpp"
-#include "Actions/MapOfActions.hpp"
+#include "Actions/ValueStorage.hpp"
 
 const char CommandLineHelpAction::NAME[] = "help";
@@ -29,36 +35,32 @@
 {}
 
-Action::state_ptr CommandLineHelpAction::performCall() {
+void CommandHelp() {
+  ActionRegistry::getInstance().getActionByName(CommandLineHelpAction::NAME)->call(Action::NonInteractive);
+};
+
+Dialog* CommandLineHelpAction::fillDialog(Dialog *dialog) {
+  ASSERT(dialog,"No Dialog given when filling action dialog");
+
   ostringstream usage;
-  Dialog *dialog = UIFactory::getInstance().makeDialog();
-
   usage << CommandLineParser::getInstance().visible << endl;
   dialog->queryEmpty(NAME, usage.str());
 
-  if(dialog->display()) {
-    delete dialog;
-    return Action::success;
-  } else {
-    delete dialog;
-    return Action::failure;
-  }
+  return dialog;
+}
+
+Action::state_ptr CommandLineHelpAction::performCall() {
+  return Action::success;
 }
 
 Action::state_ptr CommandLineHelpAction::performUndo(Action::state_ptr _state) {
-//  ParserLoadXyzState *state = assert_cast<ParserLoadXyzState*>(_state.get());
-
-  return Action::failure;
-//  string newName = state->mol->getName();
-//  state->mol->setName(state->lastName);
-//
-//  return Action::state_ptr(new ParserLoadXyzState(state->mol,newName));
+  return Action::success;
 }
 
 Action::state_ptr CommandLineHelpAction::performRedo(Action::state_ptr _state){
-  return Action::failure;
+  return Action::success;
 }
 
 bool CommandLineHelpAction::canUndo() {
-  return false;
+  return true;
 }
 
Index: src/Actions/CmdAction/HelpAction.hpp
===================================================================
--- src/Actions/CmdAction/HelpAction.hpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/Actions/CmdAction/HelpAction.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -11,5 +11,9 @@
 #include "Actions/Action.hpp"
 
+void CommandHelp();
+
 class CommandLineHelpAction : public Action {
+  friend void CommandHelp();
+
 public:
   CommandLineHelpAction();
@@ -20,4 +24,6 @@
 
   virtual const std::string getName();
+protected:
+  virtual Dialog * fillDialog(Dialog *dialog);
 private:
   virtual Action::state_ptr performCall();
Index: src/Actions/CmdAction/VerboseAction.cpp
===================================================================
--- src/Actions/CmdAction/VerboseAction.cpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/Actions/CmdAction/VerboseAction.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -6,9 +6,15 @@
  */
 
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
 #include "Helpers/MemDebug.hpp"
 
 #include "Actions/CmdAction/VerboseAction.hpp"
-#include "log.hpp"
-#include "verbose.hpp"
+#include "Actions/ActionRegistry.hpp"
+#include "Helpers/Log.hpp"
+#include "Helpers/Verbose.hpp"
 
 #include <iostream>
@@ -19,5 +25,18 @@
 #include "UIElements/UIFactory.hpp"
 #include "UIElements/Dialog.hpp"
-#include "Actions/MapOfActions.hpp"
+#include "Actions/ValueStorage.hpp"
+
+// memento to remember the state when undoing
+
+class CommandLineVerboseState : public ActionState {
+public:
+  CommandLineVerboseState(const int _oldverbosity, const int _newverbosity) :
+    oldverbosity(_oldverbosity),
+    newverbosity(_newverbosity)
+  {}
+  int oldverbosity;
+  int newverbosity;
+};
+
 
 const char CommandLineVerboseAction::NAME[] = "verbose";
@@ -30,17 +49,30 @@
 {}
 
+void CommandVerbose(int verbosity) {
+  ValueStorage::getInstance().setCurrentValue(CommandLineVerboseAction::NAME, verbosity);
+  ActionRegistry::getInstance().getActionByName(CommandLineVerboseAction::NAME)->call(Action::NonInteractive);
+};
+
+Dialog* CommandLineVerboseAction::fillDialog(Dialog *dialog) {
+  ASSERT(dialog,"No Dialog given when filling action dialog");
+
+  dialog->queryInt(NAME, ValueStorage::getInstance().getDescription(NAME));
+
+  return dialog;
+}
+
 Action::state_ptr CommandLineVerboseAction::performCall() {
-  Dialog *dialog = UIFactory::getInstance().makeDialog();
-  int verbosity = 2;
+  int oldverbosity = getVerbosity();
+  int newverbosity = 2;
 
-  dialog->queryInt(NAME, &verbosity, MapOfActions::getInstance().getDescription(NAME));
+  ValueStorage::getInstance().queryCurrentValue(NAME, newverbosity);
 
-  if(dialog->display()) {
-    setVerbosity(verbosity);
-    DoLog(0) && (Log() << Verbose(0) << "Setting verbosity to " << verbosity << "." << endl);
-    delete dialog;
-    return Action::success;
+  if (oldverbosity != newverbosity) {
+    CommandLineVerboseState *UndoState = new CommandLineVerboseState(oldverbosity, newverbosity);
+    setVerbosity(newverbosity);
+    DoLog(0) && (Log() << Verbose(0) << "Setting verbosity from " << oldverbosity << " to " << newverbosity << "." << endl);
+    return Action::state_ptr(UndoState);
   } else {
-    delete dialog;
+    DoLog(0) && (Log() << Verbose(0) << "Verbosity remains unchanged at " << oldverbosity << "." << endl);
     return Action::failure;
   }
@@ -48,23 +80,27 @@
 
 Action::state_ptr CommandLineVerboseAction::performUndo(Action::state_ptr _state) {
-//  ParserLoadXyzState *state = assert_cast<ParserLoadXyzState*>(_state.get());
+  CommandLineVerboseState *state = assert_cast<CommandLineVerboseState*>(_state.get());
 
-  return Action::failure;
-//  string newName = state->mol->getName();
-//  state->mol->setName(state->lastName);
-//
-//  return Action::state_ptr(new ParserLoadXyzState(state->mol,newName));
+  DoLog(0) && (Log() << Verbose(0) << "Setting verbosity from " << state->newverbosity << " to " << state->oldverbosity << "." << endl);
+  setVerbosity(state->oldverbosity);
+
+  return Action::state_ptr(_state);
 }
 
 Action::state_ptr CommandLineVerboseAction::performRedo(Action::state_ptr _state){
-  return Action::failure;
+  CommandLineVerboseState *state = assert_cast<CommandLineVerboseState*>(_state.get());
+
+  DoLog(0) && (Log() << Verbose(0) << "Setting verbosity from " << state->oldverbosity << " to " << state->newverbosity << "." << endl);
+  setVerbosity(state->newverbosity);
+
+  return Action::state_ptr(_state);
 }
 
 bool CommandLineVerboseAction::canUndo() {
-  return false;
+  return true;
 }
 
 bool CommandLineVerboseAction::shouldUndo() {
-  return false;
+  return true;
 }
 
Index: src/Actions/CmdAction/VerboseAction.hpp
===================================================================
--- src/Actions/CmdAction/VerboseAction.hpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/Actions/CmdAction/VerboseAction.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -11,5 +11,9 @@
 #include "Actions/Action.hpp"
 
+void CommandVerbose(int verbosity);
+
 class CommandLineVerboseAction : public Action {
+  friend void CommandVerbose(int verbosity);
+
 public:
   CommandLineVerboseAction();
@@ -20,4 +24,6 @@
 
   virtual const std::string getName();
+protected:
+  virtual Dialog * fillDialog(Dialog *dialog);
 private:
   virtual Action::state_ptr performCall();
Index: src/Actions/CmdAction/VersionAction.cpp
===================================================================
--- src/Actions/CmdAction/VersionAction.cpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/Actions/CmdAction/VersionAction.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -6,7 +6,14 @@
  */
 
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
 #include "Helpers/MemDebug.hpp"
 
 #include "Actions/CmdAction/VersionAction.hpp"
+#include "Actions/ActionRegistry.hpp"
+#include "version.h"
 
 #include <iostream>
@@ -17,5 +24,5 @@
 #include "UIElements/UIFactory.hpp"
 #include "UIElements/Dialog.hpp"
-#include "Actions/MapOfActions.hpp"
+#include "Actions/ValueStorage.hpp"
 
 const char CommandLineVersionAction::NAME[] = "version";
@@ -28,34 +35,30 @@
 {}
 
-Action::state_ptr CommandLineVersionAction::performCall() {
-  Dialog *dialog = UIFactory::getInstance().makeDialog();
+void CommandVersion() {
+  ActionRegistry::getInstance().getActionByName(CommandLineVersionAction::NAME)->call(Action::NonInteractive);
+};
+
+Dialog* CommandLineVersionAction::fillDialog(Dialog *dialog) {
+  ASSERT(dialog,"No Dialog given when filling action dialog");
 
   dialog->queryEmpty(NAME, ESPACKVersion);
 
-  if(dialog->display()) {
-    delete dialog;
-    return Action::success;
-  } else {
-    delete dialog;
-    return Action::failure;
-  }
+  return dialog;
+}
+
+Action::state_ptr CommandLineVersionAction::performCall() {
+  return Action::success;
 }
 
 Action::state_ptr CommandLineVersionAction::performUndo(Action::state_ptr _state) {
-//  ParserLoadXyzState *state = assert_cast<ParserLoadXyzState*>(_state.get());
-
-  return Action::failure;
-//  string newName = state->mol->getName();
-//  state->mol->setName(state->lastName);
-//
-//  return Action::state_ptr(new ParserLoadXyzState(state->mol,newName));
+  return Action::success;
 }
 
 Action::state_ptr CommandLineVersionAction::performRedo(Action::state_ptr _state){
-  return Action::failure;
+  return Action::success;
 }
 
 bool CommandLineVersionAction::canUndo() {
-  return false;
+  return true;
 }
 
Index: src/Actions/CmdAction/VersionAction.hpp
===================================================================
--- src/Actions/CmdAction/VersionAction.hpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/Actions/CmdAction/VersionAction.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -12,5 +12,9 @@
 #include "version.h"
 
+void CommandVersion();
+
 class CommandLineVersionAction : public Action {
+  friend void CommandVersion();
+
 public:
   CommandLineVersionAction();
@@ -21,4 +25,6 @@
 
   virtual const std::string getName();
+protected:
+  virtual Dialog * fillDialog(Dialog *dialog);
 private:
   virtual Action::state_ptr performCall();
Index: src/Actions/ErrorAction.cpp
===================================================================
--- src/Actions/ErrorAction.cpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/Actions/ErrorAction.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -6,4 +6,9 @@
  */
 
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
 #include "Helpers/MemDebug.hpp"
 
@@ -11,6 +16,6 @@
 
 #include "Actions/ErrorAction.hpp"
-#include "log.hpp"
-#include "verbose.hpp"
+#include "Helpers/Log.hpp"
+#include "Helpers/Verbose.hpp"
 #include "Helpers/Assert.hpp"
 
@@ -25,4 +30,8 @@
 ErrorAction::~ErrorAction()
 {
+}
+
+Dialog* ErrorAction::createDialog() {
+  return NULL;
 }
 
Index: src/Actions/ErrorAction.hpp
===================================================================
--- src/Actions/ErrorAction.hpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/Actions/ErrorAction.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -22,5 +22,5 @@
 
 private:
-
+  virtual Dialog * createDialog();
   virtual Action::state_ptr performCall();
   virtual Action::state_ptr performUndo(Action::state_ptr);
Index: src/Actions/FragmentationAction/DepthFirstSearchAction.cpp
===================================================================
--- src/Actions/FragmentationAction/DepthFirstSearchAction.cpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/Actions/FragmentationAction/DepthFirstSearchAction.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -6,16 +6,22 @@
  */
 
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
 #include "Helpers/MemDebug.hpp"
 
 #include "Actions/FragmentationAction/DepthFirstSearchAction.hpp"
+#include "Actions/ActionRegistry.hpp"
 #include "atom.hpp"
 #include "bondgraph.hpp"
 #include "config.hpp"
-#include "log.hpp"
+#include "Helpers/Log.hpp"
 #include "molecule.hpp"
 #include "Descriptors/MoleculeDescriptor.hpp"
 #include "Descriptors/MoleculeIdDescriptor.hpp"
 #include "stackclass.hpp"
-#include "verbose.hpp"
+#include "Helpers/Verbose.hpp"
 #include "World.hpp"
 
@@ -27,5 +33,5 @@
 #include "UIElements/UIFactory.hpp"
 #include "UIElements/Dialog.hpp"
-#include "Actions/MapOfActions.hpp"
+#include "Actions/ValueStorage.hpp"
 
 const char FragmentationDepthFirstSearchAction::NAME[] = "depth-first-search";
@@ -38,66 +44,66 @@
 {}
 
+void FragmentationDepthFirstSearch(double distance) {
+  ValueStorage::getInstance().setCurrentValue(FragmentationDepthFirstSearchAction::NAME, distance);
+  ActionRegistry::getInstance().getActionByName(FragmentationDepthFirstSearchAction::NAME)->call(Action::NonInteractive);
+};
+
+Dialog* FragmentationDepthFirstSearchAction::fillDialog(Dialog *dialog) {
+  ASSERT(dialog,"No Dialog given when filling action dialog");
+
+  dialog->queryDouble(NAME, ValueStorage::getInstance().getDescription(NAME));
+
+  return dialog;
+}
+
 Action::state_ptr FragmentationDepthFirstSearchAction::performCall() {
-  Dialog *dialog = UIFactory::getInstance().makeDialog();
   double distance;
 
-  dialog->queryDouble(NAME, &distance, MapOfActions::getInstance().getDescription(NAME));
+  ValueStorage::getInstance().queryCurrentValue(NAME, distance);
 
-  if(dialog->display()) {
-    DoLog(1) && (Log() << Verbose(1) << "Depth-First-Search Analysis." << endl);
-    molecule * const mol = World::getInstance().getMolecule(MoleculeById(0));
-    MoleculeLeafClass *Subgraphs = NULL;      // list of subgraphs from DFS analysis
-    int *MinimumRingSize = new int[mol->getAtomCount()];
-    atom **ListOfAtoms = NULL;
-    class StackClass<bond *> *BackEdgeStack = NULL;
-    class StackClass<bond *> *LocalBackEdgeStack = NULL;
-    mol->CreateAdjacencyList(distance, World::getInstance().getConfig()->GetIsAngstroem(), &BondGraph::CovalentMinMaxDistance, NULL);
-    Subgraphs = mol->DepthFirstSearchAnalysis(BackEdgeStack);
-    if (Subgraphs != NULL) {
-      int FragmentCounter = 0;
-      while (Subgraphs->next != NULL) {
-        Subgraphs = Subgraphs->next;
-        ListOfAtoms = NULL;
-        Subgraphs->FillBondStructureFromReference(mol, ListOfAtoms, false);  // we want to keep the created ListOfLocalAtoms
-        LocalBackEdgeStack = new StackClass<bond *> (Subgraphs->Leaf->BondCount);
-        Subgraphs->Leaf->PickLocalBackEdges(ListOfAtoms, BackEdgeStack, LocalBackEdgeStack);
-        Subgraphs->Leaf->CyclicStructureAnalysis(LocalBackEdgeStack, MinimumRingSize);
-        delete(LocalBackEdgeStack);
-        delete(Subgraphs->previous);
-        delete[](ListOfAtoms);  // and here we remove it
-        FragmentCounter++;
-      }
-      delete(Subgraphs);
+  DoLog(1) && (Log() << Verbose(1) << "Depth-First-Search Analysis." << endl);
+  molecule * const mol = World::getInstance().getMolecule(MoleculeById(0));
+  MoleculeLeafClass *Subgraphs = NULL;      // list of subgraphs from DFS analysis
+  int *MinimumRingSize = new int[mol->getAtomCount()];
+  atom **ListOfAtoms = NULL;
+  class StackClass<bond *> *BackEdgeStack = NULL;
+  class StackClass<bond *> *LocalBackEdgeStack = NULL;
+  mol->CreateAdjacencyList(distance, World::getInstance().getConfig()->GetIsAngstroem(), &BondGraph::CovalentMinMaxDistance, NULL);
+  Subgraphs = mol->DepthFirstSearchAnalysis(BackEdgeStack);
+  if (Subgraphs != NULL) {
+    int FragmentCounter = 0;
+    while (Subgraphs->next != NULL) {
+      Subgraphs = Subgraphs->next;
+      ListOfAtoms = NULL;
+      Subgraphs->FillBondStructureFromReference(mol, ListOfAtoms, false);  // we want to keep the created ListOfLocalAtoms
+      LocalBackEdgeStack = new StackClass<bond *> (Subgraphs->Leaf->BondCount);
+      Subgraphs->Leaf->PickLocalBackEdges(ListOfAtoms, BackEdgeStack, LocalBackEdgeStack);
+      Subgraphs->Leaf->CyclicStructureAnalysis(LocalBackEdgeStack, MinimumRingSize);
+      delete(LocalBackEdgeStack);
+      delete(Subgraphs->previous);
+      delete[](ListOfAtoms);  // and here we remove it
+      FragmentCounter++;
     }
-    delete(BackEdgeStack);
-    delete[](MinimumRingSize);
-    delete dialog;
-    return Action::success;
-  } else {
-    delete dialog;
-    return Action::failure;
+    delete(Subgraphs);
   }
+  delete(BackEdgeStack);
+  delete[](MinimumRingSize);
+  return Action::success;
 }
 
 Action::state_ptr FragmentationDepthFirstSearchAction::performUndo(Action::state_ptr _state) {
-//  ParserLoadXyzState *state = assert_cast<ParserLoadXyzState*>(_state.get());
-
-  return Action::failure;
-//  string newName = state->mol->getName();
-//  state->mol->setName(state->lastName);
-//
-//  return Action::state_ptr(new ParserLoadXyzState(state->mol,newName));
+  return Action::success;
 }
 
 Action::state_ptr FragmentationDepthFirstSearchAction::performRedo(Action::state_ptr _state){
-  return Action::failure;
+  return Action::success;
 }
 
 bool FragmentationDepthFirstSearchAction::canUndo() {
-  return false;
+  return true;
 }
 
 bool FragmentationDepthFirstSearchAction::shouldUndo() {
-  return false;
+  return true;
 }
 
Index: src/Actions/FragmentationAction/DepthFirstSearchAction.hpp
===================================================================
--- src/Actions/FragmentationAction/DepthFirstSearchAction.hpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/Actions/FragmentationAction/DepthFirstSearchAction.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -11,5 +11,9 @@
 #include "Actions/Action.hpp"
 
+void FragmentationDepthFirstSearch(double distance);
+
 class FragmentationDepthFirstSearchAction : public Action {
+  friend void FragmentationDepthFirstSearch(double distance);
+
 public:
   FragmentationDepthFirstSearchAction();
@@ -20,4 +24,6 @@
 
   virtual const std::string getName();
+protected:
+  virtual Dialog * fillDialog(Dialog *dialog);
 private:
   virtual Action::state_ptr performCall();
Index: src/Actions/FragmentationAction/FragmentationAction.cpp
===================================================================
--- src/Actions/FragmentationAction/FragmentationAction.cpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/Actions/FragmentationAction/FragmentationAction.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -6,11 +6,17 @@
  */
 
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
 #include "Helpers/MemDebug.hpp"
 
 #include "Actions/FragmentationAction/FragmentationAction.hpp"
+#include "Actions/ActionRegistry.hpp"
 #include "atom.hpp"
 #include "bondgraph.hpp"
 #include "config.hpp"
-#include "log.hpp"
+#include "Helpers/Log.hpp"
 #include "molecule.hpp"
 #include "Descriptors/MoleculeDescriptor.hpp"
@@ -25,5 +31,5 @@
 #include "UIElements/UIFactory.hpp"
 #include "UIElements/Dialog.hpp"
-#include "Actions/MapOfActions.hpp"
+#include "Actions/ValueStorage.hpp"
 
 const char FragmentationFragmentationAction::NAME[] = "fragment-mol";
@@ -36,6 +42,22 @@
 {}
 
+void FragmentationFragmentation(std::string &path, double distance, int order) {
+  ValueStorage::getInstance().setCurrentValue(FragmentationFragmentationAction::NAME, path);
+  ValueStorage::getInstance().setCurrentValue("distance", distance);
+  ValueStorage::getInstance().setCurrentValue("order", order);
+  ActionRegistry::getInstance().getActionByName(FragmentationFragmentationAction::NAME)->call(Action::NonInteractive);
+};
+
+Dialog* FragmentationFragmentationAction::fillDialog(Dialog *dialog) {
+  ASSERT(dialog,"No Dialog given when filling action dialog");
+
+  dialog->queryString(NAME, ValueStorage::getInstance().getDescription(NAME));
+  dialog->queryDouble("distance", ValueStorage::getInstance().getDescription("distance"));
+  dialog->queryInt("order", ValueStorage::getInstance().getDescription("order"));
+
+  return dialog;
+}
+
 Action::state_ptr FragmentationFragmentationAction::performCall() {
-  Dialog *dialog = UIFactory::getInstance().makeDialog();
   clock_t start,end;
   molecule *mol = NULL;
@@ -46,12 +68,10 @@
   int ExitFlag = 0;
 
-  cout << "pre-dialog"<< endl;
-  dialog->queryString(NAME, &path, MapOfActions::getInstance().getDescription(NAME));
-  dialog->queryMolecule("molecule-by-id", &mol, MapOfActions::getInstance().getDescription("molecule-by-id"));
-  dialog->queryDouble("distance", &distance, MapOfActions::getInstance().getDescription("distance"));
-  dialog->queryInt("order", &order, MapOfActions::getInstance().getDescription("order"));
+  ValueStorage::getInstance().queryCurrentValue(NAME, path);
+  ValueStorage::getInstance().queryCurrentValue("distance", distance);
+  ValueStorage::getInstance().queryCurrentValue("order", order);
 
-  if(dialog->display()) {
-    cout << "POST-dialog"<< endl;
+  for (World::MoleculeSelectionIterator iter = World::getInstance().beginMoleculeSelection(); iter != World::getInstance().endMoleculeSelection(); ++iter) {
+    mol = iter->second;
     ASSERT(mol != NULL, "No molecule has been picked for fragmentation.");
     DoLog(0) && (Log() << Verbose(0) << "Fragmenting molecule with bond distance " << distance << " angstroem, order of " << order << "." << endl);
@@ -66,32 +86,22 @@
     end = clock();
     DoLog(0) && (Log() << Verbose(0) << "Clocks for this operation: " << (end-start) << ", time: " << ((double)(end-start)/CLOCKS_PER_SEC) << "s." << endl);
-    delete dialog;
-    return Action::success;
-  } else {
-    delete dialog;
-    return Action::failure;
   }
+  return Action::success;
 }
 
 Action::state_ptr FragmentationFragmentationAction::performUndo(Action::state_ptr _state) {
-//  ParserLoadXyzState *state = assert_cast<ParserLoadXyzState*>(_state.get());
-
-  return Action::failure;
-//  string newName = state->mol->getName();
-//  state->mol->setName(state->lastName);
-//
-//  return Action::state_ptr(new ParserLoadXyzState(state->mol,newName));
+  return Action::success;
 }
 
 Action::state_ptr FragmentationFragmentationAction::performRedo(Action::state_ptr _state){
-  return Action::failure;
+  return Action::success;
 }
 
 bool FragmentationFragmentationAction::canUndo() {
-  return false;
+  return true;
 }
 
 bool FragmentationFragmentationAction::shouldUndo() {
-  return false;
+  return true;
 }
 
Index: src/Actions/FragmentationAction/FragmentationAction.hpp
===================================================================
--- src/Actions/FragmentationAction/FragmentationAction.hpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/Actions/FragmentationAction/FragmentationAction.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -11,5 +11,9 @@
 #include "Actions/Action.hpp"
 
+void FragmentationFragmentation(std::string &path, double distance, int order);
+
 class FragmentationFragmentationAction : public Action {
+  friend void FragmentationFragmentation(std::string &path, double distance, int order);
+
 public:
   FragmentationFragmentationAction();
@@ -20,4 +24,6 @@
 
   virtual const std::string getName();
+protected:
+  virtual Dialog * fillDialog(Dialog *dialog);
 private:
   virtual Action::state_ptr performCall();
Index: src/Actions/FragmentationAction/SubgraphDissectionAction.cpp
===================================================================
--- src/Actions/FragmentationAction/SubgraphDissectionAction.cpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/Actions/FragmentationAction/SubgraphDissectionAction.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -6,12 +6,23 @@
  */
 
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
 #include "Helpers/MemDebug.hpp"
 
 #include "Actions/FragmentationAction/SubgraphDissectionAction.hpp"
+#include "Actions/ActionRegistry.hpp"
+#include "Descriptors/AtomIdDescriptor.hpp"
+#include "Descriptors/MoleculeDescriptor.hpp"
+
 #include "atom.hpp"
+#include "bond.hpp"
+#include "bondgraph.hpp"
 #include "config.hpp"
-#include "log.hpp"
+#include "Helpers/Log.hpp"
+#include "Helpers/Verbose.hpp"
 #include "molecule.hpp"
-#include "Descriptors/MoleculeDescriptor.hpp"
 #include "stackclass.hpp"
 #include "World.hpp"
@@ -24,5 +35,17 @@
 #include "UIElements/UIFactory.hpp"
 #include "UIElements/Dialog.hpp"
-#include "Actions/MapOfActions.hpp"
+#include "Actions/ValueStorage.hpp"
+
+// memento to remember the state when undoing
+
+typedef std::map< moleculeId_t, std::vector<atomId_t> > MolAtomList;
+
+class FragmentationSubgraphDissectionState : public ActionState {
+public:
+  FragmentationSubgraphDissectionState(const MolAtomList &_moleculelist) :
+   moleculelist(_moleculelist)
+  {}
+  MolAtomList moleculelist;
+};
 
 const char FragmentationSubgraphDissectionAction::NAME[] = "subgraph-dissect";
@@ -35,42 +58,144 @@
 {}
 
+/** Dissects given \a *mol into connected subgraphs and inserts them as new molecules but with old atoms into \a this.
+ */
+void FragmentationSubgraphDissection() {
+  ActionRegistry::getInstance().getActionByName(FragmentationSubgraphDissectionAction::NAME)->call(Action::NonInteractive);
+};
+
+Dialog* FragmentationSubgraphDissectionAction::fillDialog(Dialog *dialog) {
+  ASSERT(dialog,"No Dialog given when filling action dialog");
+
+  dialog->queryEmpty(NAME, MapOfActions::getInstance().getDescription(NAME));
+
+  return dialog;
+}
+
+
 Action::state_ptr FragmentationSubgraphDissectionAction::performCall() {
-  Dialog *dialog = UIFactory::getInstance().makeDialog();
-
-  dialog->queryEmpty(NAME, MapOfActions::getInstance().getDescription(NAME));
-
-  if(dialog->display()) {
-    DoLog(1) && (Log() << Verbose(1) << "Dissecting molecular system into a set of disconnected subgraphs ... " << endl);
-    // @TODO rather do the dissection afterwards
+  DoLog(1) && (Log() << Verbose(1) << "Dissecting molecular system into a set of disconnected subgraphs ... " << endl);
+
+  // first create 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));
+  }
+  FragmentationSubgraphDissectionState *UndoState = new FragmentationSubgraphDissectionState(moleculelist);
+
+  MoleculeListClass *molecules = World::getInstance().getMolecules();
+  config * const configuration = World::getInstance().getConfig();
+
+  // 0a. remove all present molecules
+  for (vector<molecule *>::iterator MolRunner = allmolecules.begin(); MolRunner != allmolecules.end(); ++MolRunner) {
+    molecules->erase(*MolRunner);
+    World::getInstance().destroyMolecule(*MolRunner);
+  }
+
+  // 0b. remove all bonds and construct a molecule with all atoms
+  molecule *mol = World::getInstance().createMolecule();
+  {
+    vector <atom *> allatoms = World::getInstance().getAllAtoms();
+    for(vector<atom *>::iterator AtomRunner = allatoms.begin(); AtomRunner != allatoms.end(); ++AtomRunner) {
+      for(BondList::iterator BondRunner = (*AtomRunner)->ListOfBonds.begin(); !(*AtomRunner)->ListOfBonds.empty(); BondRunner = (*AtomRunner)->ListOfBonds.begin())
+        delete(*BondRunner);
+      mol->AddAtom(*AtomRunner);
+    }
+  }
+
+  // 1. create the bond structure of the single molecule
+  if (configuration->BG != NULL) {
+    if (!configuration->BG->ConstructBondGraph(mol)) {
+      World::getInstance().destroyMolecule(mol);
+      DoeLog(1) && (eLog()<< Verbose(1) << "There are no bonds." << endl);
+      return Action::failure;
+    }
+  } else {
+    DoeLog(1) && (eLog()<< Verbose(1) << "There is no BondGraph class present to create bonds." << endl);
+    return Action::failure;
+  }
+
+  // 2. scan for connected subgraphs
+  MoleculeLeafClass *Subgraphs = NULL;      // list of subgraphs from DFS analysis
+  class StackClass<bond *> *BackEdgeStack = NULL;
+  Subgraphs = mol->DepthFirstSearchAnalysis(BackEdgeStack);
+  delete(BackEdgeStack);
+  if ((Subgraphs == NULL) || (Subgraphs->next == NULL)) {
+    //World::getInstance().destroyMolecule(mol);
+    DoeLog(1) && (eLog()<< Verbose(1) << "There are no atoms." << endl);
+    return Action::failure;
+  }
+  int FragmentCounter = Subgraphs->next->Count();
+
+  // TODO: When DepthFirstSearchAnalysis does not use AddCopyAtom() anymore, we don't need to delete all original atoms
+  {
+    // 3a. destroy the original molecule
+    for (molecule::iterator AtomRunner = mol->begin(); !mol->empty(); AtomRunner = mol->begin())
+      World::getInstance().destroyAtom(*AtomRunner);
+    World::getInstance().destroyMolecule(mol);
+    // 3b. correct fathers (AddCopyAtom sets father to original atom, which has been destroyed).
+    vector <atom *> allatoms = World::getInstance().getAllAtoms();
+    for(vector<atom *>::iterator AtomRunner = allatoms.begin(); AtomRunner != allatoms.end(); ++AtomRunner) {
+      (*AtomRunner)->father = *AtomRunner;
+    }
+  }
+
+  // 4. free Leafs
+  MoleculeLeafClass *MolecularWalker = Subgraphs;
+  while (MolecularWalker->next != NULL) {
+    MolecularWalker->Leaf = NULL;
+    MolecularWalker = MolecularWalker->next;
+    delete(MolecularWalker->previous);
+  }
+  MolecularWalker->Leaf = NULL;
+  delete(MolecularWalker);
+  DoLog(1) && (Log() << Verbose(1) << "I scanned " << FragmentCounter << " molecules." << endl);
+
+  return Action::state_ptr(UndoState);
+}
+
+Action::state_ptr FragmentationSubgraphDissectionAction::performUndo(Action::state_ptr _state) {
+  FragmentationSubgraphDissectionState *state = assert_cast<FragmentationSubgraphDissectionState*>(_state.get());
+
+  {
+    // remove all present molecules
     MoleculeListClass *molecules = World::getInstance().getMolecules();
-    molecules->DissectMoleculeIntoConnectedSubgraphs(World::getInstance().getPeriode(), World::getInstance().getConfig());
-    delete dialog;
-    return Action::success;
-  } else {
-    delete dialog;
-    return Action::failure;
-  }
-}
-
-Action::state_ptr FragmentationSubgraphDissectionAction::performUndo(Action::state_ptr _state) {
-//  ParserLoadXyzState *state = assert_cast<ParserLoadXyzState*>(_state.get());
-
-  return Action::failure;
-//  string newName = state->mol->getName();
-//  state->mol->setName(state->lastName);
-//
-//  return Action::state_ptr(new ParserLoadXyzState(state->mol,newName));
+    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
+    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)
+        mol->AddAtom(World::getInstance().getAtom(AtomById(*atomiter)));
+    }
+  }
+
+  return Action::state_ptr(_state);
 }
 
 Action::state_ptr FragmentationSubgraphDissectionAction::performRedo(Action::state_ptr _state){
-  return Action::failure;
+  return performCall();
 }
 
 bool FragmentationSubgraphDissectionAction::canUndo() {
-  return false;
+  return true;
 }
 
 bool FragmentationSubgraphDissectionAction::shouldUndo() {
-  return false;
+  return true;
 }
 
Index: src/Actions/FragmentationAction/SubgraphDissectionAction.hpp
===================================================================
--- src/Actions/FragmentationAction/SubgraphDissectionAction.hpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/Actions/FragmentationAction/SubgraphDissectionAction.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -7,9 +7,13 @@
 
 #ifndef SUBGRAPHDISSECTIONACTION_HPP_
-#define SUBGRAPHDISSECTIONACTION_HPP_f
+#define SUBGRAPHDISSECTIONACTION_HPP_
 
 #include "Actions/Action.hpp"
 
+void FragmentationSubgraphDissection();
+
 class FragmentationSubgraphDissectionAction : public Action {
+  friend void FragmentationSubgraphDissection();
+
 public:
   FragmentationSubgraphDissectionAction();
@@ -20,4 +24,6 @@
 
   virtual const std::string getName();
+protected:
+  virtual Dialog * fillDialog(Dialog *dialog);
 private:
   virtual Action::state_ptr performCall();
Index: src/Actions/Makefile.am
===================================================================
--- src/Actions/Makefile.am	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/Actions/Makefile.am	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -6,7 +6,4 @@
 AM_LDFLAGS = $(CPPUNIT_LIBS) -ldl
 AM_CXXFLAGS = $(CPPUNIT_CFLAGS)
-
-noinst_LIBRARIES = libMolecuilderActions.a
-libMolecuilderActions_a_SOURCES = ${ACTIONSSOURCE} ${ACTIONSHEADER}
 
 ACTIONSSOURCE = \
@@ -17,7 +14,9 @@
   ${MOLECULEACTIONSOURCE} \
   ${PARSERACTIONSOURCE} \
+  ${SELECTIONACTIONSOURCE} \
   ${TESSELATIONACTIONSOURCE} \
   ${WORLDACTIONSOURCE} \
-  MapOfActions.cpp
+  MapOfActions.cpp \
+  ValueStorage.cpp
 
 ACTIONSHEADER = \
@@ -28,7 +27,9 @@
   ${MOLECULEACTIONHEADER} \
   ${PARSERACTIONHEADER} \
+  ${SELECTIONACTIONHEADER} \
   ${TESSELATIONACTIONHEADER} \
   ${WORLDACTIONHEADER} \
   MapOfActions.hpp \
+  ValueStorage.hpp \
   Values.hpp
   
@@ -36,18 +37,26 @@
   AnalysisAction/MolecularVolumeAction.cpp \
   AnalysisAction/PairCorrelationAction.cpp \
-  AnalysisAction/PrincipalAxisSystemAction.cpp
+  AnalysisAction/PointCorrelationAction.cpp \
+  AnalysisAction/PrincipalAxisSystemAction.cpp \
+  AnalysisAction/SurfaceCorrelationAction.cpp
 ANALYSISACTIONHEADER = \
   AnalysisAction/MolecularVolumeAction.hpp \
   AnalysisAction/PairCorrelationAction.hpp \
-  AnalysisAction/PrincipalAxisSystemAction.hpp
+  AnalysisAction/PointCorrelationAction.hpp \
+  AnalysisAction/PrincipalAxisSystemAction.hpp \
+  AnalysisAction/SurfaceCorrelationAction.hpp
 
 ATOMACTIONSOURCE = \
   AtomAction/AddAction.cpp \
   AtomAction/ChangeElementAction.cpp \
-  AtomAction/RemoveAction.cpp
+  AtomAction/RemoveAction.cpp \
+  AtomAction/RotateAroundOriginByAngleAction.cpp \
+  AtomAction/TranslateAction.cpp
 ATOMACTIONHEADER = \
   AtomAction/AddAction.hpp \
   AtomAction/ChangeElementAction.hpp \
-  AtomAction/RemoveAction.cpp
+  AtomAction/RemoveAction.cpp \
+  AtomAction/RotateAroundOriginByAngleAction.hpp \
+  AtomAction/TranslateAction.hpp
 
 CMDACTIONSOURCE = \
@@ -80,4 +89,5 @@
   MoleculeAction/FillWithMoleculeAction.cpp \
   MoleculeAction/LinearInterpolationofTrajectoriesAction.cpp \
+  MoleculeAction/RotateAroundSelfByAngleAction.cpp \
   MoleculeAction/RotateToPrincipalAxisSystemAction.cpp \
   MoleculeAction/SaveAdjacencyAction.cpp \
@@ -85,5 +95,4 @@
   MoleculeAction/SaveTemperatureAction.cpp \
   MoleculeAction/SuspendInWaterAction.cpp \
-  MoleculeAction/TranslateAction.cpp \
   MoleculeAction/VerletIntegrationAction.cpp
 MOLECULEACTIONHEADER = \
@@ -92,4 +101,5 @@
   MoleculeAction/FillWithMoleculeAction.hpp \
   MoleculeAction/LinearInterpolationofTrajectoriesAction.hpp \
+  MoleculeAction/RotateAroundSelfByAngleAction.hpp \
   MoleculeAction/RotateToPrincipalAxisSystemAction.hpp \
   MoleculeAction/SaveAdjacencyAction.hpp \
@@ -97,5 +107,4 @@
   MoleculeAction/SaveTemperatureAction.hpp \
   MoleculeAction/SuspendInWaterAction.hpp \
-  MoleculeAction/TranslateAction.hpp \
   MoleculeAction/VerletIntegrationAction.hpp
                  
@@ -107,4 +116,51 @@
   ParserAction/SaveXyzAction.hpp
 
+SELECTIONACTIONSOURCE = \
+	SelectionAction/AllAtomsAction.cpp \
+	SelectionAction/AllAtomsInsideCuboidAction.cpp \
+	SelectionAction/AllAtomsInsideSphereAction.cpp \
+	SelectionAction/AllAtomsOfMoleculeAction.cpp \
+	SelectionAction/AllMoleculesAction.cpp \
+	SelectionAction/AtomByElementAction.cpp \
+	SelectionAction/AtomByIdAction.cpp \
+	SelectionAction/ClearAllAtomsAction.cpp \
+	SelectionAction/ClearAllMoleculesAction.cpp \
+	SelectionAction/MoleculeByFormulaAction.cpp \
+	SelectionAction/MoleculeByIdAction.cpp \
+	SelectionAction/MoleculeOfAtomAction.cpp \
+	SelectionAction/NotAllAtomsAction.cpp \
+	SelectionAction/NotAllAtomsInsideCuboidAction.cpp \
+	SelectionAction/NotAllAtomsInsideSphereAction.cpp \
+	SelectionAction/NotAllAtomsOfMoleculeAction.cpp \
+	SelectionAction/NotAllMoleculesAction.cpp \
+	SelectionAction/NotAtomByElementAction.cpp \
+	SelectionAction/NotAtomByIdAction.cpp \
+	SelectionAction/NotMoleculeByFormulaAction.cpp \
+	SelectionAction/NotMoleculeByIdAction.cpp \
+	SelectionAction/NotMoleculeOfAtomAction.cpp
+SELECTIONACTIONHEADER = \
+	SelectionAction/AllAtomsAction.hpp \
+	SelectionAction/AllAtomsInsideCuboidAction.hpp \
+	SelectionAction/AllAtomsInsideSphereAction.hpp \
+	SelectionAction/AllAtomsOfMoleculeAction.hpp \
+	SelectionAction/AllMoleculesAction.hpp \
+	SelectionAction/AtomByElementAction.hpp \
+	SelectionAction/AtomByIdAction.hpp \
+	SelectionAction/ClearAllAtomsAction.hpp \
+	SelectionAction/ClearAllMoleculesAction.hpp \
+	SelectionAction/MoleculeByFormulaAction.hpp \
+	SelectionAction/MoleculeByIdAction.hpp \
+	SelectionAction/MoleculeOfAtomAction.hpp \
+	SelectionAction/NotAllAtomsAction.hpp \
+	SelectionAction/NotAllAtomsInsideCuboidAction.hpp \
+	SelectionAction/NotAllAtomsInsideSphereAction.hpp \
+	SelectionAction/NotAllAtomsOfMoleculeAction.hpp \
+	SelectionAction/NotAllMoleculesAction.hpp \
+	SelectionAction/NotAtomByElementAction.hpp \
+	SelectionAction/NotAtomByIdAction.hpp \
+	SelectionAction/NotMoleculeByFormulaAction.hpp \
+	SelectionAction/NotMoleculeByIdAction.hpp \
+	SelectionAction/NotMoleculeOfAtomAction.cpp
+
 TESSELATIONACTIONSOURCE = \
   TesselationAction/ConvexEnvelopeAction.cpp \
@@ -122,5 +178,4 @@
   WorldAction/InputAction.cpp \
   WorldAction/OutputAction.cpp \
-  WorldAction/RemoveSphereOfAtomsAction.cpp \
   WorldAction/RepeatBoxAction.cpp \
   WorldAction/ScaleBoxAction.cpp \
@@ -136,5 +191,4 @@
   WorldAction/InputAction.hpp \
   WorldAction/OutputAction.hpp \
-  WorldAction/RemoveSphereOfAtomsAction.hpp \
   WorldAction/RepeatBoxAction.hpp \
   WorldAction/ScaleBoxAction.hpp \
@@ -143,2 +197,51 @@
   WorldAction/SetOutputFormatsAction.hpp               
 
+
+lib_LTLIBRARIES = libMolecuilderActions-@MOLECUILDER_API_VERSION@.la
+libMolecuilderActions_includedir = $(includedir)/molecuilder-$(MOLECUILDER_API_VERSION)/Actions/
+libMolecuilderActions_libs = ../Parser/libMolecuilderParser-@MOLECUILDER_API_VERSION@.la
+nobase_libMolecuilderActions_include_HEADERS = ${ACTIONSHEADER}
+
+## Define the source file list for the "libexample-@MOLECUILDER_API_VERSION@.la"
+## target.  Note that @MOLECUILDER_API_VERSION@ is not interpreted by Automake and
+## will therefore be treated as if it were literally part of the target name,
+## and the variable name derived from that.
+## The file extension .cc is recognized by Automake, and makes it produce
+## rules which invoke the C++ compiler to produce a libtool object file (.lo)
+## from each source file.  Note that it is not necessary to list header files
+## which are already listed elsewhere in a _HEADERS variable assignment.
+libMolecuilderActions_@MOLECUILDER_API_VERSION@_la_SOURCES = ${ACTIONSSOURCE}
+
+## Instruct libtool to include ABI version information in the generated shared
+## library file (.so).  The library ABI version is defined in configure.ac, so
+## that all version information is kept in one place.
+libMolecuilderActions_@MOLECUILDER_API_VERSION@_la_LDFLAGS = -version-info $(MOLECUILDER_SO_VERSION)
+
+## The generated configuration header is installed in its own subdirectory of
+## $(libdir).  The reason for this is that the configuration information put
+## into this header file describes the target platform the installed library
+## has been built for.  Thus the file must not be installed into a location
+## intended for architecture-independent files, as defined by the Filesystem
+## Hierarchy Standard (FHS).
+## The nodist_ prefix instructs Automake to not generate rules for including
+## the listed files in the distribution on 'make dist'.  Files that are listed
+## in _HEADERS variables are normally included in the distribution, but the
+## configuration header file is generated at configure time and should not be
+## shipped with the source tarball.
+libMolecuilderActions_libincludedir = $(libdir)/molecuilder-$(MOLECUILDER_API_VERSION)/include
+nodist_libMolecuilderActions_libinclude_HEADERS = $(top_builddir)/libmolecuilder_config.h
+
+## Install the generated pkg-config file (.pc) into the expected location for
+## architecture-dependent package configuration information.  Occasionally,
+## pkg-config files are also used for architecture-independent data packages,
+## in which case the correct install location would be $(datadir)/pkgconfig.
+pkgconfigdir = $(libdir)/pkgconfig
+pkgconfig_DATA = $(top_builddir)/molecuilder-$(MOLECUILDER_API_VERSION).pc
+
+unity.cpp:
+	echo "" >  unity.cpp; \
+	list='$(ACTIONSSOURCE)'; for file in $$list; do \
+	  echo "#include \"$(srcdir)/$$file\"" >> unity.cpp; \
+	done;
+	
+MOSTLYCLEANFILES = unity.cpp
Index: src/Actions/MakroAction.cpp
===================================================================
--- src/Actions/MakroAction.cpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/Actions/MakroAction.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -5,4 +5,9 @@
  *      Author: crueger
  */
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
 
 #include "Helpers/MemDebug.hpp"
@@ -44,4 +49,7 @@
 }
 
+Dialog* MakroAction::fillDialog(Dialog *dialog) {
+  return actions->fillAllDialogs(dialog);
+}
 
 Action::state_ptr MakroAction::performCall(){
Index: src/Actions/MakroAction.hpp
===================================================================
--- src/Actions/MakroAction.hpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/Actions/MakroAction.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -29,4 +29,6 @@
   bool shouldUndo();
 
+protected:
+  virtual Dialog *fillDialog(Dialog *dialog);
 private:
   virtual Action::state_ptr performCall();
Index: src/Actions/ManipulateAtomsProcess.cpp
===================================================================
--- src/Actions/ManipulateAtomsProcess.cpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/Actions/ManipulateAtomsProcess.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -5,4 +5,9 @@
  *      Author: crueger
  */
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
 
 #include "Helpers/MemDebug.hpp"
@@ -26,4 +31,9 @@
 ManipulateAtomsProcess::~ManipulateAtomsProcess()
 {}
+
+Dialog* ManipulateAtomsProcess::fillDialog(Dialog *dialog){
+  ASSERT(dialog,"No Dialog given when filling action dialog");
+  return dialog;
+}
 
 Action::state_ptr ManipulateAtomsProcess::performCall(){
@@ -53,5 +63,9 @@
   setMaxSteps(world->numAtoms());
   start();
-  for(World::AtomIterator iter=world->getAtomIter(descr);iter!=world->atomEnd();++iter){
+  for(World::internal_AtomIterator
+      iter=world->getAtomIter_internal(descr);
+      iter!=world->atomEnd_internal();
+      ++iter){
+
     setCurrStep(iter.getCount());
     operation(*iter);
Index: src/Actions/ManipulateAtomsProcess.hpp
===================================================================
--- src/Actions/ManipulateAtomsProcess.hpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/Actions/ManipulateAtomsProcess.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -27,6 +27,8 @@
 
   virtual void doManipulate(World *);
+
+protected:
+  virtual Dialog * fillDialog(Dialog*);
 private:
-
   virtual Action::state_ptr performCall();
   virtual Action::state_ptr performUndo(Action::state_ptr);
Index: src/Actions/MapOfActions.cpp
===================================================================
--- src/Actions/MapOfActions.cpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/Actions/MapOfActions.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -6,11 +6,18 @@
  */
 
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
 #include "Helpers/MemDebug.hpp"
 
 using namespace std;
 
+#include "Actions/MapOfActions.hpp"
+#include "Descriptors/AtomIdDescriptor.hpp"
+#include "Descriptors/MoleculeIdDescriptor.hpp"
+#include "Helpers/Assert.hpp"
 #include "Patterns/Singleton_impl.hpp"
-#include "Actions/MapOfActions.hpp"
-#include "Helpers/Assert.hpp"
 
 #include <boost/lexical_cast.hpp>
@@ -18,15 +25,28 @@
 #include <boost/program_options.hpp>
 
+#include <iostream>
+
+#include "atom.hpp"
+#include "Box.hpp"
 #include "CommandLineParser.hpp"
-#include "log.hpp"
-#include "verbose.hpp"
+#include "element.hpp"
+#include "Helpers/Log.hpp"
+#include "LinearAlgebra/Matrix.hpp"
+#include "molecule.hpp"
+#include "periodentafel.hpp"
+#include "LinearAlgebra/Vector.hpp"
+#include "Helpers/Verbose.hpp"
 
 #include "Actions/ActionRegistry.hpp"
 #include "Actions/AnalysisAction/MolecularVolumeAction.hpp"
 #include "Actions/AnalysisAction/PairCorrelationAction.hpp"
+#include "Actions/AnalysisAction/PointCorrelationAction.hpp"
 #include "Actions/AnalysisAction/PrincipalAxisSystemAction.hpp"
+#include "Actions/AnalysisAction/SurfaceCorrelationAction.hpp"
 #include "Actions/AtomAction/AddAction.hpp"
 #include "Actions/AtomAction/ChangeElementAction.hpp"
 #include "Actions/AtomAction/RemoveAction.hpp"
+#include "Actions/AtomAction/RotateAroundOriginByAngleAction.hpp"
+#include "Actions/AtomAction/TranslateAction.hpp"
 #include "Actions/CmdAction/BondLengthTableAction.hpp"
 #include "Actions/CmdAction/ElementDbAction.hpp"
@@ -42,4 +62,5 @@
 #include "Actions/MoleculeAction/FillWithMoleculeAction.hpp"
 #include "Actions/MoleculeAction/LinearInterpolationofTrajectoriesAction.hpp"
+#include "Actions/MoleculeAction/RotateAroundSelfByAngleAction.hpp"
 #include "Actions/MoleculeAction/RotateToPrincipalAxisSystemAction.hpp"
 #include "Actions/MoleculeAction/SaveAdjacencyAction.hpp"
@@ -47,8 +68,29 @@
 #include "Actions/MoleculeAction/SaveTemperatureAction.hpp"
 #include "Actions/MoleculeAction/SuspendInWaterAction.hpp"
-#include "Actions/MoleculeAction/TranslateAction.hpp"
 #include "Actions/MoleculeAction/VerletIntegrationAction.hpp"
 #include "Actions/ParserAction/LoadXyzAction.hpp"
 #include "Actions/ParserAction/SaveXyzAction.hpp"
+#include "Actions/SelectionAction/AllAtomsAction.hpp"
+#include "Actions/SelectionAction/AllAtomsInsideCuboidAction.hpp"
+#include "Actions/SelectionAction/AllAtomsInsideSphereAction.hpp"
+#include "Actions/SelectionAction/AllAtomsOfMoleculeAction.hpp"
+#include "Actions/SelectionAction/AllMoleculesAction.hpp"
+#include "Actions/SelectionAction/AtomByElementAction.hpp"
+#include "Actions/SelectionAction/AtomByIdAction.hpp"
+#include "Actions/SelectionAction/ClearAllAtomsAction.hpp"
+#include "Actions/SelectionAction/ClearAllMoleculesAction.hpp"
+#include "Actions/SelectionAction/MoleculeByFormulaAction.hpp"
+#include "Actions/SelectionAction/MoleculeByIdAction.hpp"
+#include "Actions/SelectionAction/MoleculeOfAtomAction.hpp"
+#include "Actions/SelectionAction/NotAllAtomsAction.hpp"
+#include "Actions/SelectionAction/NotAllAtomsInsideCuboidAction.hpp"
+#include "Actions/SelectionAction/NotAllAtomsInsideSphereAction.hpp"
+#include "Actions/SelectionAction/NotAllAtomsOfMoleculeAction.hpp"
+#include "Actions/SelectionAction/NotAllMoleculesAction.hpp"
+#include "Actions/SelectionAction/NotAtomByElementAction.hpp"
+#include "Actions/SelectionAction/NotAtomByIdAction.hpp"
+#include "Actions/SelectionAction/NotMoleculeByFormulaAction.hpp"
+#include "Actions/SelectionAction/NotMoleculeByIdAction.hpp"
+#include "Actions/SelectionAction/NotMoleculeOfAtomAction.hpp"
 #include "Actions/TesselationAction/ConvexEnvelopeAction.hpp"
 #include "Actions/TesselationAction/NonConvexEnvelopeAction.hpp"
@@ -60,5 +102,4 @@
 #include "Actions/WorldAction/InputAction.hpp"
 #include "Actions/WorldAction/OutputAction.hpp"
-#include "Actions/WorldAction/RemoveSphereOfAtomsAction.hpp"
 #include "Actions/WorldAction/RepeatBoxAction.hpp"
 #include "Actions/WorldAction/ScaleBoxAction.hpp"
@@ -131,8 +172,8 @@
   }
   BV.xx = boost::lexical_cast<double>(components.at(0));
-  BV.xy = boost::lexical_cast<double>(components.at(1));
-  BV.xz = boost::lexical_cast<double>(components.at(2));
-  BV.yy = boost::lexical_cast<double>(components.at(3));
-  BV.yz = boost::lexical_cast<double>(components.at(4));
+  BV.yx = boost::lexical_cast<double>(components.at(1));
+  BV.yy = boost::lexical_cast<double>(components.at(2));
+  BV.zx = boost::lexical_cast<double>(components.at(3));
+  BV.zy = boost::lexical_cast<double>(components.at(4));
   BV.zz = boost::lexical_cast<double>(components.at(5));
   v = boost::any(BoxValue(BV));
@@ -161,4 +202,6 @@
   DescriptionMap["change-element"] = "change the element of an atom";
   DescriptionMap["change-molname"] = "change the name of a molecule";
+  DescriptionMap["clear-atom-selection"] = "clear the atom selection";
+  DescriptionMap["clear-molecule-selection"] = "clear the molecule selection";
   DescriptionMap["convex-envelope"] = "create the convex envelope for a molecule";
   DescriptionMap["default-molname"] = "set the default name of new molecules";
@@ -175,10 +218,13 @@
   DescriptionMap["output"] = "write output files";
   DescriptionMap["set-output"] = "specify output formats";
-  DescriptionMap["pair-correlation"] = "pair correlation analysis between two elements, element and point or element and surface";
+  DescriptionMap["pair-correlation"] = "pair correlation analysis between two elements";
   DescriptionMap["parse-xyz"] = "parse xyz file into World";
+  DescriptionMap["point-correlation"] = "pair correlation analysis between element and point";
   DescriptionMap["principal-axis-system"] = "calculate the principal axis system of the specified molecule";
+  DescriptionMap["redo"] = "redo last action";
   DescriptionMap["remove-atom"] = "remove a specified atom";
-  DescriptionMap["remove-sphere"] = "remove sphere of atoms of around a specified atom";
   DescriptionMap["repeat-box"] = "create periodic copies of the simulation box per axis";
+  DescriptionMap["rotate-origin"] = "rotate selected atoms by a specific angle around origin";
+  DescriptionMap["rotate-self"] = "rotates molecules by a specific angle around own center of gravity";
   DescriptionMap["rotate-to-pas"] = "calculate the principal axis system of the specified molecule and rotate specified axis to align with main axis";
   DescriptionMap["save-adjacency"] = "name of the adjacency file to write to";
@@ -187,14 +233,38 @@
   DescriptionMap["SaveXyz"] = "save world as xyz file";
   DescriptionMap["scale-box"] = "scale box and atomic positions inside";
+  DescriptionMap["select-all-atoms"] = "select all atoms";
+  DescriptionMap["select-all-molecules"] = "select all molecules";
+  DescriptionMap["select-atom-by-element"] = "select an atom by element";
+  DescriptionMap["select-atom-by-id"] = "select an atom by index";
+  DescriptionMap["select-atoms-inside-cuboid"] = "select all atoms inside a cuboid";
+  DescriptionMap["select-atoms-inside-sphere"] = "select all atoms inside a sphere";
+  DescriptionMap["select-molecule-by-id"] = "select a molecule by index";
+  DescriptionMap["select-molecule-by-formula"] = "select a molecule by chemical formula";
+  DescriptionMap["select-molecule-of-atom"] = "select a molecule to which a given atom belongs";
+  DescriptionMap["select-molecules-atoms"] = "select all atoms of a molecule";
   DescriptionMap["set-basis"] = "set the name of the gaussian basis set for MPQC";
   DescriptionMap["set-output"] = "specify output formats";
   DescriptionMap["subgraph-dissect"] = "dissect the molecular system into molecules representing disconnected subgraphs";
+  DescriptionMap["surface-correlation"] = "pair correlation analysis between element and surface";
   DescriptionMap["suspend-in-water"] = "suspend the given molecule in water such that in the domain the mean density is as specified";
-  DescriptionMap["translate-mol"] = "translate molecule by given vector";
+  DescriptionMap["translate-atoms"] = "translate all selected atoms by given vector";
+  DescriptionMap["undo"] = "undo last action";
+  DescriptionMap["unselect-all-atoms"] = "unselect all atoms";
+  DescriptionMap["unselect-all-molecules"] = "unselect all molecules";
+  DescriptionMap["unselect-atom-by-element"] = "unselect an atom by element";
+  DescriptionMap["unselect-atom-by-id"] = "unselect an atom by index";
+  DescriptionMap["unselect-atoms-inside-cuboid"] = "unselect all atoms inside a cuboid";
+  DescriptionMap["unselect-atoms-inside-sphere"] = "unselect all atoms inside a sphere";
+  DescriptionMap["unselect-molecule-by-formula"] = "unselect a molecule by chemical formula";
+  DescriptionMap["unselect-molecule-by-id"] = "unselect a molecule by index";
+  DescriptionMap["unselect-molecule-of-atom"] = "unselect a molecule to which a given atom belongs";
+  DescriptionMap["unselect-molecules-atoms"] = "unselect all atoms of a molecule";
   DescriptionMap["verbose"] = "set verbosity level";
   DescriptionMap["verlet-integrate"] = "perform verlet integration of a given force file";
   DescriptionMap["version"] = "show version";
   // keys for values
-  DescriptionMap["atom-by-id"] = "index of an atom";
+  DescriptionMap["angle-x"] = "angle of a rotation around x axis";
+  DescriptionMap["angle-y"] = "angle of a rotation around y axis";
+  DescriptionMap["angle-z"] = "angle of a rotation around z axis";
   DescriptionMap["bin-output-file"] = "name of the bin output file";
   DescriptionMap["bin-end"] = "start of the last bin";
@@ -214,5 +284,4 @@
   DescriptionMap["MaxDistance"] = "maximum distance in space";
   DescriptionMap["molecule-by-id"] = "index of a molecule";
-  DescriptionMap["molecule-by-name"] = "name of a molecule";
   DescriptionMap["nonconvex-file"] = "filename of the non-convex envelope";
   DescriptionMap["order"] = "order of a discretization, dissection, ...";
@@ -220,5 +289,4 @@
   DescriptionMap["periodic"] = "system is constraint to periodic boundary conditions (y/n)";
   DescriptionMap["position"] = "position in R^3 space";
-  DescriptionMap["sphere-radius"] = "radius of tesselation sphere";
   DescriptionMap["start-step"] = "first or start step";
 
@@ -244,8 +312,7 @@
   ShortFormMap["nonconvex-envelope"] = "N";
 //  ShortFormMap["output"] = "o";
-  ShortFormMap["pair-correlation"] = "C";
+//  ShortFormMap["pair-correlation"] = "C";
   ShortFormMap["parse-xyz"] = "p";
   ShortFormMap["remove-atom"] = "r";
-  ShortFormMap["remove-sphere"] = "R";
   ShortFormMap["repeat-box"] = "d";
   ShortFormMap["rotate-to-pas"] = "m";
@@ -258,5 +325,5 @@
   ShortFormMap["subgraph-dissect"] = "I";
   ShortFormMap["suspend-in-water"] = "u";
-  ShortFormMap["translate-mol"] = "t";
+  ShortFormMap["translate-atoms"] = "t";
   ShortFormMap["verbose"] = "v";
   ShortFormMap["verlet-integrate"] = "P";
@@ -264,89 +331,135 @@
 
   // value types for the actions
-  TypeMap["add-atom"] = Element;
-  TypeMap["bond-file"] = String;
-  TypeMap["bond-table"] = String;
-  TypeMap["boundary"] = Vector;
-  TypeMap["center-in-box"] = Box;
-  TypeMap["change-box"] = Box;
-  TypeMap["change-element"] = Element;
-  TypeMap["change-molname"] = String;
-  TypeMap["convex-envelope"] = Molecule;
-  TypeMap["default-molname"] = String;
-  TypeMap["depth-first-search"] = Double;
-  TypeMap["element-db"] = String;
-  TypeMap["fastparsing"] = Boolean;
-  TypeMap["fill-molecule"] = String;
-  TypeMap["fragment-mol"] = String;
-  TypeMap["input"] = String;
-  TypeMap["linear-interpolate"] = String;
-  TypeMap["molecular-volume"] = Molecule;
-  TypeMap["nonconvex-envelope"] = Molecule;
-  TypeMap["output"] = None;
-  TypeMap["parse-xyz"] = String;
-  TypeMap["pair-correlation"] = String;
-  TypeMap["principal-axis-system"] = Molecule;
-  TypeMap["remove-atom"] = Atom;
-  TypeMap["remove-sphere"] = Double;
-  TypeMap["repeat-box"] = Vector;
-  TypeMap["rotate-to-pas"] = Molecule;
-  TypeMap["save-adjacency"] = String;
-  TypeMap["save-bonds"] = String;
-  TypeMap["save-temperature"] = String;
-  TypeMap["scale-box"] = Vector;
-  TypeMap["set-basis"] = String;
-  TypeMap["set-output"] = ListOfString;
-  TypeMap["subgraph-dissect"] = None;
-  TypeMap["suspend-in-water"] = Double;
-  TypeMap["translate-mol"] = Vector;
-  TypeMap["verlet-integrate"] = String;
-  TypeMap["verbose"] = Integer;
+  TypeMap["add-atom"] = &typeid(const element);
+  TypeMap["bond-file"] = &typeid(std::string);
+  TypeMap["bond-table"] = &typeid(std::string);
+  TypeMap["boundary"] = &typeid(VectorValue);
+  TypeMap["center-in-box"] = &typeid(BoxValue);
+  TypeMap["change-box"] = &typeid(BoxValue);
+  TypeMap["change-element"] = &typeid(const element);
+  TypeMap["change-molname"] = &typeid(std::string);
+  TypeMap["clear-atom-selection"] = &typeid(void);
+  TypeMap["clear-molecule-selection"] = &typeid(void);
+  TypeMap["convex-envelope"] = &typeid(void);
+  TypeMap["default-molname"] = &typeid(std::string);
+  TypeMap["depth-first-search"] = &typeid(double);
+  TypeMap["element-db"] = &typeid(std::string);
+  TypeMap["fastparsing"] = &typeid(bool);
+  TypeMap["fill-molecule"] = &typeid(std::string);
+  TypeMap["fragment-mol"] = &typeid(std::string);
+  TypeMap["input"] = &typeid(std::string);
+  TypeMap["linear-interpolate"] = &typeid(std::string);
+  TypeMap["molecular-volume"] = &typeid(molecule);
+  TypeMap["nonconvex-envelope"] = &typeid(double);
+  TypeMap["output"] = &typeid(void);
+  TypeMap["parse-xyz"] = &typeid(std::string);
+  TypeMap["pair-correlation"] = &typeid(void);
+  TypeMap["point-correlation"] = &typeid(void);
+  TypeMap["principal-axis-system"] = &typeid(void);
+  TypeMap["redo"] = &typeid(void);
+  TypeMap["remove-atom"] = &typeid(void);
+  TypeMap["repeat-box"] = &typeid(VectorValue);
+  TypeMap["rotate-origin"] = &typeid(double);
+  TypeMap["rotate-self"] = &typeid(double);
+  TypeMap["rotate-to-pas"] = &typeid(VectorValue);
+  TypeMap["save-adjacency"] = &typeid(std::string);
+  TypeMap["save-bonds"] = &typeid(std::string);
+  TypeMap["save-temperature"] = &typeid(std::string);
+  TypeMap["scale-box"] = &typeid(VectorValue);
+  TypeMap["select-all-atoms"] = &typeid(void);
+  TypeMap["select-all-molecules"] = &typeid(void);
+  TypeMap["select-atom-by-element"] = &typeid(const element);
+  TypeMap["select-atom-by-id"] = &typeid(atom);
+  TypeMap["select-atoms-inside-cuboid"] = &typeid(VectorValue);
+  TypeMap["select-atoms-inside-sphere"] = &typeid(double);
+  TypeMap["select-molecule-by-formula"] = &typeid(std::string);
+  TypeMap["select-molecule-by-id"] = &typeid(molecule);
+  TypeMap["select-molecule-of-atom"] = &typeid(atom);
+  TypeMap["select-molecules-atoms"] = &typeid(molecule);
+  TypeMap["set-basis"] = &typeid(std::string);
+  TypeMap["set-output"] = &typeid(std::vector<std::string>);
+  TypeMap["subgraph-dissect"] = &typeid(void);
+  TypeMap["surface-correlation"] = &typeid(void);
+  TypeMap["suspend-in-water"] = &typeid(double);
+  TypeMap["translate-atoms"] = &typeid(VectorValue);
+  TypeMap["undo"] = &typeid(void);
+  TypeMap["unselect-all-atoms"] = &typeid(void);
+  TypeMap["unselect-all-molecules"] = &typeid(void);
+  TypeMap["unselect-atom-by-element"] = &typeid(const element);
+  TypeMap["unselect-atom-by-id"] = &typeid(atom);
+  TypeMap["unselect-atoms-inside-cuboid"] = &typeid(VectorValue);
+  TypeMap["unselect-atoms-inside-sphere"] = &typeid(double);
+  TypeMap["unselect-molecule-by-formula"] = &typeid(std::string);
+  TypeMap["unselect-molecule-by-id"] = &typeid(molecule);
+  TypeMap["unselect-molecule-of-atom"] = &typeid(atom);
+  TypeMap["unselect-molecules-atoms"] = &typeid(molecule);
+  TypeMap["verlet-integrate"] = &typeid(std::string);
+  TypeMap["verbose"] = &typeid(int);
 
   // value types for the values
-  TypeMap["atom-by-id"] = Atom;
-  TypeMap["bin-output-file"] = String;
-  TypeMap["bin-end"] = Double;
-  TypeMap["bin-start"] = Double;
-  TypeMap["bin-width"] = Double;
-  TypeMap["convex-file"] = String;
-  TypeMap["distance"] = Double;
-  TypeMap["distances"] = Vector;
-  TypeMap["DoRotate"] = Boolean;
-  TypeMap["element"] = Element;
-  TypeMap["elements"] = ListOfElements;
-  TypeMap["end-step"] = Integer;
-  TypeMap["id-mapping"] = Boolean;
-  TypeMap["length"] = Double;
-  TypeMap["lengths"] = Vector;
-  TypeMap["MaxDistance"] = Double;
-  TypeMap["molecule-by-id"] = Molecule;
-  TypeMap["molecule-by-name"] = Molecule;
-  TypeMap["nonconvex-file"] = String;
-  TypeMap["order"] = Integer;
-  TypeMap["output-file"] = String;
-  TypeMap["periodic"] = Boolean;
-  TypeMap["position"] = Vector;
-  TypeMap["sphere-radius"] = Double;
-  TypeMap["start-step"] = Integer;
+  TypeMap["angle-x"] = &typeid(double);
+  TypeMap["angle-y"] = &typeid(double);
+  TypeMap["angle-z"] = &typeid(double);
+  TypeMap["bin-output-file"] = &typeid(std::string);
+  TypeMap["bin-end"] = &typeid(double);
+  TypeMap["bin-start"] = &typeid(double);
+  TypeMap["bin-width"] = &typeid(double);
+  TypeMap["convex-file"] = &typeid(std::string);
+  TypeMap["distance"] = &typeid(double);
+  TypeMap["distances"] = &typeid(VectorValue);
+  TypeMap["DoRotate"] = &typeid(bool);
+  TypeMap["element"] = &typeid(const element);
+  TypeMap["elements"] = &typeid(std::vector<const element *>);
+  TypeMap["end-step"] = &typeid(int);
+  TypeMap["id-mapping"] = &typeid(bool);
+  TypeMap["length"] = &typeid(double);
+  TypeMap["lengths"] = &typeid(VectorValue);
+  TypeMap["MaxDistance"] = &typeid(double);
+  TypeMap["molecule-by-id"] = &typeid(molecule);
+  TypeMap["nonconvex-file"] = &typeid(std::string);
+  TypeMap["order"] = &typeid(int);
+  TypeMap["output-file"] = &typeid(std::string);
+  TypeMap["periodic"] = &typeid(bool);
+  TypeMap["position"] = &typeid(VectorValue);
+  TypeMap["start-step"] = &typeid(int);
+
+  TypeEnumMap[&typeid(void)] = None;
+  TypeEnumMap[&typeid(bool)] = Boolean;
+  TypeEnumMap[&typeid(int)] = Integer;
+  TypeEnumMap[&typeid(std::vector<int>)] = ListOfIntegers;
+  TypeEnumMap[&typeid(double)] = Double;
+  TypeEnumMap[&typeid(std::vector<double>)] = ListOfDoubles;
+  TypeEnumMap[&typeid(std::string)] = String;
+  TypeEnumMap[&typeid(std::vector<std::string>)] = ListOfStrings;
+  TypeEnumMap[&typeid(VectorValue)] = Vector;
+  TypeEnumMap[&typeid(std::vector<VectorValue>)] = ListOfVectors;
+  TypeEnumMap[&typeid(BoxValue)] = Box;
+  TypeEnumMap[&typeid(molecule)] = Molecule;
+  TypeEnumMap[&typeid(std::vector<molecule *>)] = ListOfMolecules;
+  TypeEnumMap[&typeid(atom)] = Atom;
+  TypeEnumMap[&typeid(std::vector<atom *>)] = ListOfAtoms;
+  TypeEnumMap[&typeid(const element)] = Element;
+  TypeEnumMap[&typeid(std::vector<const element *>)] = ListOfElements;
 
   // default values for any action that needs one (always string!)
-  DefaultValue["bin-width"] = "0.5";
-  DefaultValue["fastparsing"] = "0";
-  DefaultValue["atom-by-id"] = "-1";
-  DefaultValue["molecule-by-id"] = "-1";
-  DefaultValue["periodic"] = "0";
+  CurrentValue["bin-width"] = "0.5";
+  CurrentValue["fastparsing"] = "0";
+  CurrentValue["periodic"] = "0";
 
   // put action into each menu category
   MenuDescription["analysis"] = pair<std::string,std::string>("Analysis (pair correlation, volume)", "Analysis");
-  MenuDescription["atom"] = pair<std::string,std::string>("Edit atoms", "Edit atoms");
-  MenuDescription["command"] = pair<std::string,std::string>("Configuration", "Configuration");
+  MenuDescription["atom"] = pair<std::string,std::string>("Edit atoms", "Atoms");
+  MenuDescription["command"] = pair<std::string,std::string>("Configuration", "configuration options");
   MenuDescription["fragmentation"] = pair<std::string,std::string>("Fragmentation", "Fragmentation");
-  MenuDescription["molecule"] = pair<std::string,std::string>("Parse files into system", "Parse files");
-  MenuDescription["parser"] = pair<std::string,std::string>("Edit molecules (load, parse, save)", "Edit molecules");
-  MenuDescription["tesselation"] = pair<std::string,std::string>("Tesselate molecules", "Tesselate molecules");
-  MenuDescription["world"] = pair<std::string,std::string>("Edit world", "Edit world");
+  MenuDescription["molecule"] = pair<std::string,std::string>("Parse files into system", "Molecules");
+  MenuDescription["parser"] = pair<std::string,std::string>("Edit molecules (load, parse, save)", "Input/Output");
+  MenuDescription["selection"] = pair<std::string,std::string>("Select atoms/molecules", "Selection");
+  MenuDescription["tesselation"] = pair<std::string,std::string>("Tesselate molecules", "Tesselation");
+  MenuDescription["world"] = pair<std::string,std::string>("Edit world", "Globals");
 
   MenuContainsActionMap.insert( pair<std::string, std::string> ("analysis", "molecular-volume") );
   MenuContainsActionMap.insert( pair<std::string, std::string> ("analysis", "pair-correlation") );
+  MenuContainsActionMap.insert( pair<std::string, std::string> ("analysis", "point-correlation") );
+  MenuContainsActionMap.insert( pair<std::string, std::string> ("analysis", "surface-correlation") );
   MenuContainsActionMap.insert( pair<std::string, std::string> ("analysis", "principal-axis-system") );
 
@@ -354,4 +467,5 @@
   MenuContainsActionMap.insert( pair<std::string, std::string> ("atom", "change-element") );
   MenuContainsActionMap.insert( pair<std::string, std::string> ("atom", "remove-atom") );
+  MenuContainsActionMap.insert( pair<std::string, std::string> ("atom", "translate-atoms") );
 
   MenuContainsActionMap.insert( pair<std::string, std::string> ("command", "bond-table") );
@@ -369,4 +483,6 @@
   MenuContainsActionMap.insert( pair<std::string, std::string> ("molecule", "fill-molecule") );
   MenuContainsActionMap.insert( pair<std::string, std::string> ("molecule", "linear-interpolate") );
+  MenuContainsActionMap.insert( pair<std::string, std::string> ("molecule", "rotate-origin") );
+  MenuContainsActionMap.insert( pair<std::string, std::string> ("molecule", "rotate-self") );
   MenuContainsActionMap.insert( pair<std::string, std::string> ("molecule", "rotate-to-pas") );
   MenuContainsActionMap.insert( pair<std::string, std::string> ("molecule", "save-adjacency") );
@@ -374,9 +490,31 @@
   MenuContainsActionMap.insert( pair<std::string, std::string> ("molecule", "save-temperature") );
   MenuContainsActionMap.insert( pair<std::string, std::string> ("molecule", "suspend-in-water") );
-  MenuContainsActionMap.insert( pair<std::string, std::string> ("molecule", "translate-mol") );
   MenuContainsActionMap.insert( pair<std::string, std::string> ("molecule", "verlet-integrate") );
 
   MenuContainsActionMap.insert( pair<std::string, std::string> ("parser", "parse-xyz") );
   MenuContainsActionMap.insert( pair<std::string, std::string> ("parser", "SaveXyz") );
+
+  MenuContainsActionMap.insert( pair<std::string, std::string> ("selection", "clear-atom-selection") );
+  MenuContainsActionMap.insert( pair<std::string, std::string> ("selection", "clear-molecule-selection") );
+  MenuContainsActionMap.insert( pair<std::string, std::string> ("selection", "select-all-atoms") );
+  MenuContainsActionMap.insert( pair<std::string, std::string> ("selection", "select-all-molecules") );
+  MenuContainsActionMap.insert( pair<std::string, std::string> ("selection", "select-atom-by-element") );
+  MenuContainsActionMap.insert( pair<std::string, std::string> ("selection", "select-atom-by-id") );
+  MenuContainsActionMap.insert( pair<std::string, std::string> ("selection", "select-atoms-inside-cuboid") );
+  MenuContainsActionMap.insert( pair<std::string, std::string> ("selection", "select-atoms-inside-sphere") );
+  MenuContainsActionMap.insert( pair<std::string, std::string> ("selection", "select-molecule-by-id") );
+  MenuContainsActionMap.insert( pair<std::string, std::string> ("selection", "select-molecule-by-formula") );
+  MenuContainsActionMap.insert( pair<std::string, std::string> ("selection", "select-molecule-of-atom") );
+  MenuContainsActionMap.insert( pair<std::string, std::string> ("selection", "select-molecules-atoms") );
+  MenuContainsActionMap.insert( pair<std::string, std::string> ("selection", "unselect-all-atoms") );
+  MenuContainsActionMap.insert( pair<std::string, std::string> ("selection", "unselect-all-molecules") );
+  MenuContainsActionMap.insert( pair<std::string, std::string> ("selection", "unselect-atom-by-element") );
+  MenuContainsActionMap.insert( pair<std::string, std::string> ("selection", "unselect-atom-by-id") );
+  MenuContainsActionMap.insert( pair<std::string, std::string> ("selection", "unselect-atoms-inside-cuboid") );
+  MenuContainsActionMap.insert( pair<std::string, std::string> ("selection", "unselect-atoms-inside-sphere") );
+  MenuContainsActionMap.insert( pair<std::string, std::string> ("selection", "unselect-molecule-by-formula") );
+  MenuContainsActionMap.insert( pair<std::string, std::string> ("selection", "unselect-molecule-by-id") );
+  MenuContainsActionMap.insert( pair<std::string, std::string> ("selection", "unselect-molecule-of-atom") );
+  MenuContainsActionMap.insert( pair<std::string, std::string> ("selection", "unselect-molecules-atoms") );
 
   MenuContainsActionMap.insert( pair<std::string, std::string> ("tesselation", "convex-envelope") );
@@ -390,5 +528,4 @@
   MenuContainsActionMap.insert( pair<std::string, std::string> ("world", "input") );
   MenuContainsActionMap.insert( pair<std::string, std::string> ("world", "output") );
-  MenuContainsActionMap.insert( pair<std::string, std::string> ("world", "remove-sphere") );
   MenuContainsActionMap.insert( pair<std::string, std::string> ("world", "repeat-box") );
   MenuContainsActionMap.insert( pair<std::string, std::string> ("world", "scale-box") );
@@ -407,5 +544,7 @@
 	generic.insert("change-box");
 //  generic.insert("change-molname");
-	generic.insert("change-element");
+  generic.insert("change-element");
+  generic.insert("clear-atom-selection");
+  generic.insert("clear-molecule-selection");
   generic.insert("convex-envelope");
 	generic.insert("default-molname");
@@ -423,8 +562,11 @@
 	generic.insert("pair-correlation");
 	generic.insert("parse-xyz");
+  generic.insert("point-correlation");
 //  generic.insert("principal-axis-system");
+  generic.insert("redo");
   generic.insert("remove-atom");
-  generic.insert("remove-sphere");
   generic.insert("repeat-box");
+  generic.insert("rotate-origin");
+  generic.insert("rotate-self");
   generic.insert("rotate-to-pas");
 	generic.insert("save-adjacency");
@@ -432,9 +574,31 @@
   generic.insert("save-temperature");
   generic.insert("scale-box");
+  generic.insert("select-all-atoms");
+  generic.insert("select-all-molecules");
+  generic.insert("select-atom-by-element");
+  generic.insert("select-atom-by-id");
+  generic.insert("select-atoms-inside-cuboid");
+  generic.insert("select-atoms-inside-sphere");
+  generic.insert("select-molecule-by-id");
+  generic.insert("select-molecule-by-formula");
+  generic.insert("select-molecule-of-atom");
+  generic.insert("select-molecules-atoms");
   generic.insert("set-basis");
   generic.insert("set-output");
 	generic.insert("subgraph-dissect");
+  generic.insert("surface-correlation");
   generic.insert("suspend-in-water");
-  generic.insert("translate-mol");
+  generic.insert("translate-atoms");
+  generic.insert("undo");
+  generic.insert("unselect-all-atoms");
+  generic.insert("unselect-all-molecules");
+  generic.insert("unselect-atom-by-element");
+  generic.insert("unselect-atom-by-id");
+  generic.insert("unselect-atoms-inside-cuboid");
+  generic.insert("unselect-atoms-inside-sphere");
+  generic.insert("unselect-molecule-by-formula");
+  generic.insert("unselect-molecule-by-id");
+  generic.insert("unselect-molecule-of-atom");
+  generic.insert("unselect-molecules-atoms");
 	generic.insert("verbose");
   generic.insert("verlet-integrate");
@@ -443,31 +607,30 @@
     // positional arguments
   generic.insert("input");
-  inputfile.insert("input");
 
     // hidden arguments
-  generic.insert("atom-by-id");
-  generic.insert("bin-end");
-  generic.insert("bin-output-file");
-  generic.insert("bin-start");
-  generic.insert("bin-width");
-  generic.insert("convex-file");
-  generic.insert("distance");
-  generic.insert("DoRotate");
-  generic.insert("distances");
-  generic.insert("element");
-  generic.insert("elements");
-  generic.insert("end-step");
-  generic.insert("id-mapping");
-  generic.insert("lengths");
-  generic.insert("MaxDistance");
-  generic.insert("molecule-by-id");
-  generic.insert("molecule-by-name");
-  generic.insert("nonconvex-file");
-  generic.insert("order");
-  generic.insert("output-file");
-  generic.insert("periodic");
-  generic.insert("position");
-  generic.insert("sphere-radius");
-  generic.insert("start-step");
+  hidden.insert("angle-x");
+  hidden.insert("angle-y");
+  hidden.insert("angle-z");
+  hidden.insert("bin-end");
+  hidden.insert("bin-output-file");
+  hidden.insert("bin-start");
+  hidden.insert("bin-width");
+  hidden.insert("convex-file");
+  hidden.insert("distance");
+  hidden.insert("DoRotate");
+  hidden.insert("distances");
+  hidden.insert("element");
+  hidden.insert("elements");
+  hidden.insert("end-step");
+  hidden.insert("id-mapping");
+  hidden.insert("lengths");
+  hidden.insert("MaxDistance");
+  hidden.insert("molecule-by-id");
+  hidden.insert("nonconvex-file");
+  hidden.insert("order");
+  hidden.insert("output-file");
+  hidden.insert("periodic");
+  hidden.insert("position");
+  hidden.insert("start-step");
 }
 
@@ -480,4 +643,243 @@
 }
 
+bool MapOfActions::isCurrentValuePresent(const char *name) const
+{
+  return (CurrentValue.find(name) != CurrentValue.end());
+}
+
+void MapOfActions::queryCurrentValue(const char * name, class atom * &_T)
+{
+  int atomID = -1;
+  if (typeid( atom ) == *TypeMap[name]) {
+    if (CurrentValue.find(name) == CurrentValue.end())
+      throw MissingValueException(__FILE__, __LINE__);
+    atomID = lexical_cast<int>(CurrentValue[name].c_str());
+    CurrentValue.erase(name);
+  } else
+    throw IllegalTypeException(__FILE__,__LINE__);
+  _T = World::getInstance().getAtom(AtomById(atomID));
+}
+
+void MapOfActions::queryCurrentValue(const char * name, const element * &_T)  {
+  int Z = -1;
+  if (typeid(const element ) == *TypeMap[name]) {
+    if (CurrentValue.find(name) == CurrentValue.end())
+      throw MissingValueException(__FILE__, __LINE__);
+    Z = lexical_cast<int>(CurrentValue[name].c_str());
+    CurrentValue.erase(name);
+  } else
+    throw IllegalTypeException(__FILE__,__LINE__);
+  _T = World::getInstance().getPeriode()->FindElement(Z);
+}
+
+void MapOfActions::queryCurrentValue(const char * name, class molecule * &_T) {
+  int molID = -1;
+  if (typeid( molecule ) == *TypeMap[name]) {
+    if (CurrentValue.find(name) == CurrentValue.end())
+      throw MissingValueException(__FILE__, __LINE__);
+    molID = lexical_cast<int>(CurrentValue[name].c_str());
+    CurrentValue.erase(name);
+  } else
+    throw IllegalTypeException(__FILE__,__LINE__);
+  _T = World::getInstance().getMolecule(MoleculeById(molID));
+}
+
+void MapOfActions::queryCurrentValue(const char * name, class Box &_T) {
+  Matrix M;
+  double tmp;
+  if (typeid( BoxValue ) == *TypeMap[name]) {
+    if (CurrentValue.find(name) == CurrentValue.end())
+      throw MissingValueException(__FILE__, __LINE__);
+    std::istringstream stream(CurrentValue[name]);
+    stream >> tmp;
+    M.set(0,0,tmp);
+    stream >> tmp;
+    M.set(0,1,tmp);
+    M.set(1,0,tmp);
+    stream >> tmp;
+    M.set(0,2,tmp);
+    M.set(2,0,tmp);
+    stream >> tmp;
+    M.set(1,1,tmp);
+    stream >> tmp;
+    M.set(1,2,tmp);
+    M.set(2,1,tmp);
+    stream >> tmp;
+    M.set(2,2,tmp);
+    _T = M;
+    CurrentValue.erase(name);
+  } else
+    throw IllegalTypeException(__FILE__,__LINE__);
+}
+
+void MapOfActions::queryCurrentValue(const char * name, class Vector &_T) {
+  if (typeid( VectorValue ) == *TypeMap[name]) {
+    std::istringstream stream(CurrentValue[name]);
+    CurrentValue.erase(name);
+    stream >> _T[0];
+    stream >> _T[1];
+    stream >> _T[2];
+  } else
+    throw IllegalTypeException(__FILE__,__LINE__);
+}
+
+void MapOfActions::queryCurrentValue(const char * name, std::vector<atom *>&_T)
+{
+  int atomID = -1;
+  atom *Walker = NULL;
+  if (typeid( std::vector<atom *> ) == *TypeMap[name]) {
+    if (CurrentValue.find(name) == CurrentValue.end())
+      throw MissingValueException(__FILE__, __LINE__);
+    std::istringstream stream(CurrentValue[name]);
+    CurrentValue.erase(name);
+    while (!stream.fail()) {
+      stream >> atomID >> ws;
+      Walker = World::getInstance().getAtom(AtomById(atomID));
+      if (Walker != NULL)
+        _T.push_back(Walker);
+      atomID = -1;
+      Walker = NULL;
+    }
+  } else
+    throw IllegalTypeException(__FILE__,__LINE__);
+}
+
+void MapOfActions::queryCurrentValue(const char * name, std::vector<const element *>&_T)
+{
+  int Z = -1;
+  const element *elemental = NULL;
+  if (typeid( std::vector<const element *> ) == *TypeMap[name]) {
+    if (CurrentValue.find(name) == CurrentValue.end())
+      throw MissingValueException(__FILE__, __LINE__);
+    std::istringstream stream(CurrentValue[name]);
+    CurrentValue.erase(name);
+    while (!stream.fail()) {
+      stream >> Z >> ws;
+      elemental = World::getInstance().getPeriode()->FindElement(Z);
+      if (elemental != NULL)
+        _T.push_back(elemental);
+      Z = -1;
+    }
+  } else
+    throw IllegalTypeException(__FILE__,__LINE__);
+}
+
+void MapOfActions::queryCurrentValue(const char * name, std::vector<molecule *>&_T)
+{
+  int molID = -1;
+  molecule *mol = NULL;
+  if (typeid( std::vector<molecule *> ) == *TypeMap[name]) {
+    if (CurrentValue.find(name) == CurrentValue.end())
+      throw MissingValueException(__FILE__, __LINE__);
+    std::istringstream stream(CurrentValue[name]);
+    CurrentValue.erase(name);
+    while (!stream.fail()) {
+      stream >> molID >> ws;
+      mol = World::getInstance().getMolecule(MoleculeById(molID));
+      if (mol != NULL)
+        _T.push_back(mol);
+      molID = -1;
+      mol = NULL;
+    }
+  } else
+    throw IllegalTypeException(__FILE__,__LINE__);
+}
+
+
+void MapOfActions::setCurrentValue(const char * name, class atom * &_T)
+{
+  if (typeid( atom ) == *TypeMap[name]) {
+    std::ostringstream stream;
+    stream << _T->getId();
+    CurrentValue[name] = stream.str();
+  } else
+    throw IllegalTypeException(__FILE__,__LINE__);
+}
+
+void MapOfActions::setCurrentValue(const char * name, const element * &_T)
+{
+  if (typeid(const element ) == *TypeMap[name]) {
+    std::ostringstream stream;
+    stream << _T->Z;
+    CurrentValue[name] = stream.str();
+  } else
+    throw IllegalTypeException(__FILE__,__LINE__);
+}
+
+void MapOfActions::setCurrentValue(const char * name, class molecule * &_T)
+{
+  if (typeid( molecule ) == *TypeMap[name]) {
+    std::ostringstream stream;
+    stream << _T->getId();
+    CurrentValue[name] = stream.str();
+  } else
+    throw IllegalTypeException(__FILE__,__LINE__);
+}
+
+void MapOfActions::setCurrentValue(const char * name, class Box &_T)
+{
+  const Matrix &M = _T.getM();
+  if (typeid( BoxValue ) == *TypeMap[name]) {
+    std::ostringstream stream;
+    stream << M.at(0,0) << " ";
+    stream << M.at(0,1) << " ";
+    stream << M.at(0,2) << " ";
+    stream << M.at(1,1) << " ";
+    stream << M.at(1,2) << " ";
+    stream << M.at(2,2) << " ";
+    CurrentValue[name] = stream.str();
+  } else
+    throw IllegalTypeException(__FILE__,__LINE__);
+}
+
+void MapOfActions::setCurrentValue(const char * name, class Vector &_T)
+{
+  if (typeid( VectorValue ) == *TypeMap[name]){
+    std::ostringstream stream;
+    stream << _T[0] << " ";
+    stream << _T[1] << " ";
+    stream << _T[2] << " ";
+    CurrentValue[name] = stream.str();
+  } else
+    throw IllegalTypeException(__FILE__,__LINE__);
+}
+
+void MapOfActions::setCurrentValue(const char * name, std::vector<atom *>&_T)
+{
+  if (typeid( std::vector<atom *> ) == *TypeMap[name]) {
+    std::ostringstream stream;
+    for (std::vector<atom *>::iterator iter = _T.begin(); iter != _T.end(); ++iter) {
+      stream << (*iter)->getId() << " ";
+    }
+    CurrentValue[name] = stream.str();
+  } else
+    throw IllegalTypeException(__FILE__,__LINE__);
+}
+
+void MapOfActions::setCurrentValue(const char * name, std::vector<const element *>&_T)
+{
+  if (typeid( std::vector<const element *> ) == *TypeMap[name]) {
+    std::ostringstream stream;
+    for (std::vector<const element *>::iterator iter = _T.begin(); iter != _T.end(); ++iter) {
+      stream << (*iter)->Z << " ";
+    }
+    CurrentValue[name] = stream.str();
+  } else
+    throw IllegalTypeException(__FILE__,__LINE__);
+}
+
+void MapOfActions::setCurrentValue(const char * name, std::vector<molecule *>&_T)
+{
+  if (typeid( std::vector<molecule *> ) == *TypeMap[name]) {
+    std::ostringstream stream;
+    for (std::vector<molecule *>::iterator iter = _T.begin(); iter != _T.end(); ++iter) {
+      stream << (*iter)->getId() << " ";
+    }
+    CurrentValue[name] = stream.str();
+  } else
+    throw IllegalTypeException(__FILE__,__LINE__);
+}
+
+
 
 void MapOfActions::populateActions()
@@ -485,9 +887,13 @@
   new AnalysisMolecularVolumeAction();
   new AnalysisPairCorrelationAction();
+  new AnalysisPointCorrelationAction();
   new AnalysisPrincipalAxisSystemAction();
+  new AnalysisSurfaceCorrelationAction();
 
   new AtomAddAction();
   new AtomChangeElementAction();
   new AtomRemoveAction();
+  new AtomRotateAroundOriginByAngleAction();
+  new AtomTranslateAction();
 
   new CommandLineBondLengthTableAction();
@@ -506,4 +912,5 @@
   new MoleculeFillWithMoleculeAction();
   new MoleculeLinearInterpolationofTrajectoriesAction();
+  new MoleculeRotateAroundSelfByAngleAction();
   new MoleculeRotateToPrincipalAxisSystemAction();
   new MoleculeSaveAdjacencyAction();
@@ -511,9 +918,31 @@
   new MoleculeSaveTemperatureAction();
   new MoleculeSuspendInWaterAction();
-  new MoleculeTranslateAction();
   new MoleculeVerletIntegrationAction();
 
   new ParserLoadXyzAction();
   new ParserSaveXyzAction();
+
+  new SelectionClearAllAtomsAction();
+  new SelectionClearAllMoleculesAction();
+  new SelectionAllAtomsAction();
+  new SelectionAllAtomsInsideCuboidAction();
+  new SelectionAllAtomsInsideSphereAction();
+  new SelectionAllAtomsOfMoleculeAction();
+  new SelectionAllMoleculesAction();
+  new SelectionAtomByElementAction();
+  new SelectionAtomByIdAction();
+  new SelectionMoleculeByIdAction();
+  new SelectionMoleculeByFormulaAction();
+  new SelectionMoleculeOfAtomAction();
+  new SelectionNotAllAtomsAction();
+  new SelectionNotAllAtomsInsideCuboidAction();
+  new SelectionNotAllAtomsInsideSphereAction();
+  new SelectionNotAllAtomsOfMoleculeAction();
+  new SelectionNotAllMoleculesAction();
+  new SelectionNotAtomByElementAction();
+  new SelectionNotAtomByIdAction();
+  new SelectionNotMoleculeByFormulaAction();
+  new SelectionNotMoleculeByIdAction();
+  new SelectionNotMoleculeOfAtomAction();
 
   new TesselationConvexEnvelopeAction();
@@ -527,5 +956,4 @@
   new WorldInputAction();
   new WorldOutputAction();
-  new WorldRemoveSphereOfAtomsAction();
   new WorldRepeatBoxAction();
   new WorldScaleBoxAction();
@@ -535,5 +963,4 @@
 }
 
-
 /** Adds all options to the CommandLineParser.
  *
@@ -545,6 +972,6 @@
     for (set<string>::iterator OptionRunner = ListRunner->first->begin(); OptionRunner != ListRunner->first->end(); ++OptionRunner) {
       if (hasValue(*OptionRunner)) {
-        DoLog(0) && (Log() << Verbose(0) << "Adding option " << *OptionRunner << " with type " << TypeMap[*OptionRunner] << " to CommandLineParser." << endl);
-           switch((enum OptionTypes) TypeMap[*OptionRunner]) {
+        DoLog(1) && (Log() << Verbose(1) << "Adding option " << *OptionRunner << " with type " << TypeMap[*OptionRunner]->name() << " to CommandLineParser." << endl);
+           switch(TypeEnumMap[TypeMap[*OptionRunner]]) {
           default:
           case None:
@@ -556,6 +983,6 @@
             ListRunner->second->add_options()
               (getKeyAndShortForm(*OptionRunner).c_str(),
-                  DefaultValue.find(*OptionRunner) != DefaultValue.end() ?
-                        po::value< bool >()->default_value(atoi(DefaultValue[*OptionRunner].c_str())) :
+                  CurrentValue.find(*OptionRunner) != CurrentValue.end() ?
+                        po::value< bool >()->default_value(lexical_cast<int>(CurrentValue[*OptionRunner].c_str())) :
                         po::value< bool >(),
                   getDescription(*OptionRunner).c_str())
@@ -565,5 +992,5 @@
             ListRunner->second->add_options()
               (getKeyAndShortForm(*OptionRunner).c_str(),
-                  po::value<BoxValue>()->multitoken(),
+                  po::value<BoxValue>(),
                   getDescription(*OptionRunner).c_str())
               ;
@@ -572,11 +999,11 @@
             ListRunner->second->add_options()
               (getKeyAndShortForm(*OptionRunner).c_str(),
-                  DefaultValue.find(*OptionRunner) != DefaultValue.end() ?
-                        po::value< int >()->default_value(atoi(DefaultValue[*OptionRunner].c_str())) :
+                  CurrentValue.find(*OptionRunner) != CurrentValue.end() ?
+                        po::value< int >()->default_value(lexical_cast<int>(CurrentValue[*OptionRunner].c_str())) :
                         po::value< int >(),
                   getDescription(*OptionRunner).c_str())
               ;
             break;
-          case ListOfInts:
+          case ListOfIntegers:
             ListRunner->second->add_options()
               (getKeyAndShortForm(*OptionRunner).c_str(),
@@ -588,6 +1015,6 @@
             ListRunner->second->add_options()
               (getKeyAndShortForm(*OptionRunner).c_str(),
-                  DefaultValue.find(*OptionRunner) != DefaultValue.end() ?
-                        po::value< double >()->default_value(atof(DefaultValue[*OptionRunner].c_str())) :
+                  CurrentValue.find(*OptionRunner) != CurrentValue.end() ?
+                        po::value< double >()->default_value(lexical_cast<double>(CurrentValue[*OptionRunner].c_str())) :
                         po::value< double >(),
                   getDescription(*OptionRunner).c_str())
@@ -604,11 +1031,11 @@
             ListRunner->second->add_options()
               (getKeyAndShortForm(*OptionRunner).c_str(),
-                  DefaultValue.find(*OptionRunner) != DefaultValue.end() ?
-                        po::value< std::string >()->default_value(DefaultValue[*OptionRunner]) :
+                  CurrentValue.find(*OptionRunner) != CurrentValue.end() ?
+                        po::value< std::string >()->default_value(CurrentValue[*OptionRunner]) :
                         po::value< std::string >(),
                   getDescription(*OptionRunner).c_str())
               ;
             break;
-          case ListOfString:
+          case ListOfStrings:
             ListRunner->second->add_options()
               (getKeyAndShortForm(*OptionRunner).c_str(),
@@ -617,30 +1044,44 @@
               ;
             break;
-          case Axis:
-            ListRunner->second->add_options()
-              (getKeyAndShortForm(*OptionRunner).c_str(),
-                  DefaultValue.find(*OptionRunner) != DefaultValue.end() ?
-                        po::value< int >()->default_value(atoi(DefaultValue[*OptionRunner].c_str())) :
+          case Vector:
+            ListRunner->second->add_options()
+              (getKeyAndShortForm(*OptionRunner).c_str(),
+                  po::value<VectorValue>(),
+                  getDescription(*OptionRunner).c_str())
+              ;
+            break;
+          case ListOfVectors:
+            ListRunner->second->add_options()
+              (getKeyAndShortForm(*OptionRunner).c_str(),
+                  po::value< vector<VectorValue> >()->multitoken(),
+                  getDescription(*OptionRunner).c_str())
+              ;
+            break;
+          case Molecule:
+            ListRunner->second->add_options()
+              (getKeyAndShortForm(*OptionRunner).c_str(),
+                  CurrentValue.find(*OptionRunner) != CurrentValue.end() ?
+                        po::value< int >()->default_value(lexical_cast<int>(CurrentValue[*OptionRunner].c_str())) :
                         po::value< int >(),
                   getDescription(*OptionRunner).c_str())
               ;
             break;
-          case Vector:
-            ListRunner->second->add_options()
-              (getKeyAndShortForm(*OptionRunner).c_str(),
-                  po::value<VectorValue>(),
-                  getDescription(*OptionRunner).c_str())
-              ;
-            break;
-          case Molecule:
-            ListRunner->second->add_options()
-              (getKeyAndShortForm(*OptionRunner).c_str(),
-                  DefaultValue.find(*OptionRunner) != DefaultValue.end() ?
-                        po::value< int >()->default_value(atoi(DefaultValue[*OptionRunner].c_str())) :
+          case ListOfMolecules:
+            ListRunner->second->add_options()
+              (getKeyAndShortForm(*OptionRunner).c_str(),
+                  po::value< vector<int> >()->multitoken(),
+                  getDescription(*OptionRunner).c_str())
+              ;
+            break;
+          case Atom:
+            ListRunner->second->add_options()
+              (getKeyAndShortForm(*OptionRunner).c_str(),
+                  CurrentValue.find(*OptionRunner) != CurrentValue.end() ?
+                        po::value< int >()->default_value(lexical_cast<int>(CurrentValue[*OptionRunner].c_str())) :
                         po::value< int >(),
                   getDescription(*OptionRunner).c_str())
               ;
             break;
-          case ListOfMolecules:
+          case ListOfAtoms:
             ListRunner->second->add_options()
               (getKeyAndShortForm(*OptionRunner).c_str(),
@@ -649,24 +1090,8 @@
               ;
             break;
-          case Atom:
-            ListRunner->second->add_options()
-              (getKeyAndShortForm(*OptionRunner).c_str(),
-                  DefaultValue.find(*OptionRunner) != DefaultValue.end() ?
-                        po::value< int >()->default_value(atoi(DefaultValue[*OptionRunner].c_str())) :
-                        po::value< int >(),
-                  getDescription(*OptionRunner).c_str())
-              ;
-            break;
-          case ListOfAtoms:
-            ListRunner->second->add_options()
-              (getKeyAndShortForm(*OptionRunner).c_str(),
-                  po::value< vector<int> >()->multitoken(),
-                  getDescription(*OptionRunner).c_str())
-              ;
-            break;
           case Element:
             ListRunner->second->add_options()
               (getKeyAndShortForm(*OptionRunner).c_str(),
-                  po::value< vector<int> >(),
+                  po::value< int >(),
                   getDescription(*OptionRunner).c_str())
               ;
@@ -681,5 +1106,5 @@
         }
       } else {
-        DoLog(0) && (Log() << Verbose(0) << "Adding option " << *OptionRunner << " to CommandLineParser." << endl);
+        DoLog(3) && (Log() << Verbose(3) << "Adding option " << *OptionRunner << " to CommandLineParser." << endl);
         ListRunner->second->add_options()
           (getKeyAndShortForm(*OptionRunner).c_str(), getDescription(*OptionRunner).c_str())
@@ -688,10 +1113,4 @@
     }
   }
-  // add positional arguments
-  for (set<string>::iterator OptionRunner = inputfile.begin(); OptionRunner != inputfile.end(); ++OptionRunner) {
-    DoLog(0) && (Log() << Verbose(0) << "Adding option " << *OptionRunner << " to positional CommandLineParser." << endl);
-    CommandLineParser::getInstance().inputfile.add((*OptionRunner).c_str(), -1);
-  }
-  cout << "Name for position 1: " << CommandLineParser::getInstance().inputfile.name_for_position(1) << endl;
 }
 
@@ -749,7 +1168,7 @@
  * \return type of the action
  */
-enum MapOfActions::OptionTypes MapOfActions::getValueType(string actionname)
-{
-  return TypeMap[actionname];
+std::string MapOfActions::getValueType(string actionname)
+{
+  return TypeMap[actionname]->name();
 }
 
Index: src/Actions/MapOfActions.hpp
===================================================================
--- src/Actions/MapOfActions.hpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/Actions/MapOfActions.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -9,15 +9,28 @@
 #define MAPOFACTIONS_HPP_
 
-#include "Helpers/Assert.hpp"
 #include <boost/program_options.hpp>
+#include <boost/lexical_cast.hpp>
 
 #include <map>
 #include <set>
+#include <vector>
+#include <typeinfo>
+
+#include "Exceptions/IllegalTypeException.hpp"
+#include "Exceptions/MissingValueException.hpp"
+#include "Helpers/Assert.hpp"
+#include "Patterns/Singleton.hpp"
 
 class MapOfActionsTest;
 
-#include "Patterns/Singleton.hpp"
+class Box;
+class atom;
+class element;
+class molecule;
+class Vector;
 
 namespace po = boost::program_options;
+
+using boost::lexical_cast;
 
 /** Central class for adding functionality to the code.
@@ -123,5 +136,5 @@
   friend class MapOfActionsTest;
 public:
-  enum OptionTypes { None, Boolean, Integer, ListOfInts, Double, ListOfDoubles, String, ListOfString, Axis, Vector, Box, Molecule, ListOfMolecules, Atom, ListOfAtoms, Element, ListOfElements };
+  enum OptionTypes { None, Boolean, Integer, ListOfIntegers, Double, ListOfDoubles, String, ListOfStrings, Vector, ListOfVectors, Box, Molecule, ListOfMolecules, Atom, ListOfAtoms, Element, ListOfElements };
 
   // getter for the action descriptions and short forms
@@ -136,5 +149,5 @@
   bool hasValue(std::string actionname);
   bool isShortFormPresent(std::string shortform);
-  enum OptionTypes getValueType(std::string actionname);
+  std::string  getValueType(std::string actionname);
 
   std::set<std::string> generic;
@@ -150,4 +163,70 @@
   void populateActions();
 
+  bool isCurrentValuePresent(const char *name) const;
+  void queryCurrentValue(const char * name, class atom * &_T);
+  void queryCurrentValue(const char * name, const element * &_T);
+  void queryCurrentValue(const char * name, class molecule * &_T);
+  void queryCurrentValue(const char * name, class Box &_T);
+  void queryCurrentValue(const char * name, class Vector &_T);
+  void queryCurrentValue(const char * name, std::vector<atom *>&_T);
+  void queryCurrentValue(const char * name, std::vector<const element *>&_T);
+  void queryCurrentValue(const char * name, std::vector<molecule *>&_T);
+  template<typename T> void queryCurrentValue(const char * name, T &_T)
+  {
+    if (typeid( T ) == *TypeMap[name]) { // constructor of type_info is private, hence can only store by ref or ptr
+      if (CurrentValue.find(name) == CurrentValue.end())
+        throw MissingValueException(__FILE__, __LINE__);
+      _T = lexical_cast<T>(CurrentValue[name].c_str());
+      CurrentValue.erase(name);
+    } else
+      throw IllegalTypeException(__FILE__,__LINE__);
+  }
+  template<typename T> void queryCurrentValue(const char * name, std::vector<T> &_T)
+  {
+    T temp;
+    if (typeid( std::vector<T> ) == *TypeMap[name]) { // constructor of type_info is private, hence can only store by ref or ptr
+      if (CurrentValue.find(name) == CurrentValue.end())
+        throw MissingValueException(__FILE__, __LINE__);
+      std::istringstream stream(CurrentValue[name]);
+      CurrentValue.erase(name);
+      while (!stream.fail()) {
+        stream >> temp >> std::ws;
+        _T.push_back(temp);
+      }
+    } else
+      throw IllegalTypeException(__FILE__,__LINE__);
+  }
+
+  void setCurrentValue(const char * name, class atom * &_T);
+  void setCurrentValue(const char * name, const element * &_T);
+  void setCurrentValue(const char * name, class molecule * &_T);
+  void setCurrentValue(const char * name, class Box &_T);
+  void setCurrentValue(const char * name, class Vector &_T);
+  void setCurrentValue(const char * name, std::vector<atom *>&_T);
+  void setCurrentValue(const char * name, std::vector<const element *>&_T);
+  void setCurrentValue(const char * name, std::vector<molecule *>&_T);
+  template<class T> void setCurrentValue(const char * name, T &_T)
+  {
+    std::ostringstream stream;
+    if (typeid( T ) == *TypeMap[name]) {  // constructor of type_info is private, hence can only store by ref or ptr
+      stream << _T;
+      CurrentValue[name] = stream.str();
+    } else
+      throw IllegalTypeException(__FILE__,__LINE__);
+  }
+  template<class T> void setCurrentValue(const char * name, std::vector<T> &_T)
+  {
+    std::ostringstream stream;
+    if (typeid( std::vector<T> ) == *TypeMap[name]) {  // constructor of type_info is private, hence can only store by ref or ptr
+      std::ostringstream stream;
+      for (typename std::vector<T>::iterator iter = _T.begin(); iter != _T.end(); ++iter) {
+        stream << (*iter) << " ";
+      }
+      CurrentValue[name] = stream.str();
+    } else
+      throw IllegalTypeException(__FILE__,__LINE__);
+  }
+
+
 private:
   // private constructor and destructor
@@ -159,8 +238,9 @@
 
   // map of the action names and their description
-  std::map<std::string, std::string> DefaultValue;
+  std::map<std::string, std::string> CurrentValue;
   std::map<std::string, std::string> DescriptionMap;
   std::map<std::string, std::string> ShortFormMap;
-  std::map<std::string, enum OptionTypes > TypeMap;
+  std::map<std::string, const std::type_info * > TypeMap;
+  std::map<const std::type_info *, enum OptionTypes > TypeEnumMap;
 };
 
Index: src/Actions/MethodAction.cpp
===================================================================
--- src/Actions/MethodAction.cpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/Actions/MethodAction.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -5,4 +5,9 @@
  *      Author: crueger
  */
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
 
 #include "Helpers/MemDebug.hpp"
@@ -25,4 +30,9 @@
 MethodAction::~MethodAction()
 {}
+
+Dialog* MethodAction::fillDialog(Dialog *dialog) {
+  ASSERT(dialog,"No Dialog given when filling action dialog");
+  return dialog;
+}
 
 
Index: src/Actions/MethodAction.hpp
===================================================================
--- src/Actions/MethodAction.hpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/Actions/MethodAction.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -25,4 +25,6 @@
   virtual bool shouldUndo();
 
+protected:
+  virtual Dialog * fillDialog(Dialog *dialog);
 private:
   virtual Action::state_ptr performCall();
Index: src/Actions/MoleculeAction/BondFileAction.cpp
===================================================================
--- src/Actions/MoleculeAction/BondFileAction.cpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/Actions/MoleculeAction/BondFileAction.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -6,7 +6,17 @@
  */
 
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
 #include "Helpers/MemDebug.hpp"
 
 #include "Actions/MoleculeAction/BondFileAction.hpp"
+#include "Actions/ActionRegistry.hpp"
+#include "Helpers/Log.hpp"
+#include "molecule.hpp"
+#include "Helpers/Verbose.hpp"
+#include "World.hpp"
 
 #include <iostream>
@@ -18,14 +28,6 @@
 #include "UIElements/UIFactory.hpp"
 #include "UIElements/Dialog.hpp"
-#include "Actions/MapOfActions.hpp"
+#include "Actions/ValueStorage.hpp"
 
-#include "atom.hpp"
-#include "bondgraph.hpp"
-#include "config.hpp"
-#include "defs.hpp"
-#include "log.hpp"
-#include "molecule.hpp"
-#include "vector.hpp"
-#include "World.hpp"
 
 /****** MoleculeBondFileAction *****/
@@ -52,22 +54,32 @@
 {}
 
+void MoleculeBondFile(std::string &bondfile) {
+  ValueStorage::getInstance().setCurrentValue(MoleculeBondFileAction::NAME, bondfile);
+  ActionRegistry::getInstance().getActionByName(MoleculeBondFileAction::NAME)->call(Action::NonInteractive);
+};
+
+Dialog* MoleculeBondFileAction::fillDialog(Dialog *dialog) {
+  ASSERT(dialog,"No Dialog given when filling action dialog");
+
+  dialog->queryString(NAME, ValueStorage::getInstance().getDescription(NAME));
+
+  return dialog;
+}
+
 Action::state_ptr MoleculeBondFileAction::performCall() {
   string filename;
-  Dialog *dialog = UIFactory::getInstance().makeDialog();
   molecule *mol = NULL;
 
-  dialog->queryString(NAME, &filename, MapOfActions::getInstance().getDescription(NAME));
-  dialog->queryMolecule("molecule-by-id", &mol, MapOfActions::getInstance().getDescription("molecule-by-id"));
+  ValueStorage::getInstance().queryCurrentValue(NAME, filename);
 
-  if(dialog->display()) {
+  if(World::getInstance().countSelectedMolecules() == 1) {
+    mol = World::getInstance().beginMoleculeSelection()->second;
     DoLog(0) && (Log() << Verbose(0) << "Parsing bonds from " << filename << "." << endl);
     ifstream input(filename.c_str());
     mol->CreateAdjacencyListFromDbondFile(&input);
     input.close();
-    delete dialog;
     return Action::success;
-  }
-  delete dialog;
-  return Action::failure;
+  } else
+    return Action::failure;
 }
 
Index: src/Actions/MoleculeAction/BondFileAction.hpp
===================================================================
--- src/Actions/MoleculeAction/BondFileAction.hpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/Actions/MoleculeAction/BondFileAction.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -10,9 +10,13 @@
 
 #include "Actions/Action.hpp"
-#include "Actions/Process.hpp"
+
 
 class MoleculeListClass;
 
+void MoleculeBondFile(std::string &bondfile);
+
 class MoleculeBondFileAction : public Action {
+  friend void MoleculeBondFile(std::string &bondfile);
+
 public:
   MoleculeBondFileAction();
@@ -23,4 +27,6 @@
 
   virtual const std::string getName();
+protected:
+  virtual Dialog * fillDialog(Dialog *dialog);
 private:
   virtual Action::state_ptr performCall();
Index: src/Actions/MoleculeAction/ChangeNameAction.cpp
===================================================================
--- src/Actions/MoleculeAction/ChangeNameAction.cpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/Actions/MoleculeAction/ChangeNameAction.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -6,7 +6,15 @@
  */
 
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
 #include "Helpers/MemDebug.hpp"
 
 #include "Actions/MoleculeAction/ChangeNameAction.hpp"
+#include "Actions/ActionRegistry.hpp"
+#include "atom.hpp"
+#include "molecule.hpp"
 
 #include <iostream>
@@ -17,8 +25,5 @@
 #include "UIElements/UIFactory.hpp"
 #include "UIElements/Dialog.hpp"
-#include "Actions/MapOfActions.hpp"
-
-#include "atom.hpp"
-#include "molecule.hpp"
+#include "Actions/ValueStorage.hpp"
 
 /****** MoleculeChangeNameAction *****/
@@ -45,20 +50,30 @@
 {}
 
+void MoleculeChangeName(std::string &name) {
+  ValueStorage::getInstance().setCurrentValue(MoleculeChangeNameAction::NAME, name);
+  ActionRegistry::getInstance().getActionByName(MoleculeChangeNameAction::NAME)->call(Action::NonInteractive);
+};
+
+Dialog* MoleculeChangeNameAction::fillDialog(Dialog *dialog) {
+  ASSERT(dialog,"No Dialog given when filling action dialog");
+
+  dialog->queryString(NAME, ValueStorage::getInstance().getDescription(NAME));
+
+  return dialog;
+}
+
 Action::state_ptr MoleculeChangeNameAction::performCall() {
   string filename;
   molecule *mol = NULL;
-  Dialog *dialog = UIFactory::getInstance().makeDialog();
 
-  dialog->queryMolecule(NAME, &mol, MapOfActions::getInstance().getDescription(NAME));
-  dialog->queryString("Enter name: ",&filename);
+  ValueStorage::getInstance().queryCurrentValue(NAME, filename);
 
-  if(dialog->display()) {
+  if (World::getInstance().countSelectedMolecules() == 1) {
+    mol = World::getInstance().beginMoleculeSelection()->second;
     string oldName = mol->getName();
     mol->setName(filename);
-    delete dialog;
     return Action::state_ptr(new MoleculeChangeNameState(mol,oldName));
-  }
-  delete dialog;
-  return Action::failure;
+  } else
+    return Action::failure;
 }
 
Index: src/Actions/MoleculeAction/ChangeNameAction.hpp
===================================================================
--- src/Actions/MoleculeAction/ChangeNameAction.hpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/Actions/MoleculeAction/ChangeNameAction.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -10,9 +10,13 @@
 
 #include "Actions/Action.hpp"
-#include "Actions/Process.hpp"
+
 
 class MoleculeListClass;
 
+void MoleculeChangeName(std::string &name);
+
 class MoleculeChangeNameAction : public Action {
+  friend void MoleculeChangeName(std::string &name);
+
 public:
   MoleculeChangeNameAction();
@@ -23,4 +27,6 @@
 
   virtual const std::string getName();
+protected:
+  virtual Dialog * fillDialog(Dialog *dialog);
 private:
   virtual Action::state_ptr performCall();
Index: src/Actions/MoleculeAction/FillWithMoleculeAction.cpp
===================================================================
--- src/Actions/MoleculeAction/FillWithMoleculeAction.cpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/Actions/MoleculeAction/FillWithMoleculeAction.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -6,7 +6,21 @@
  */
 
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
 #include "Helpers/MemDebug.hpp"
 
 #include "Actions/MoleculeAction/FillWithMoleculeAction.hpp"
+#include "Actions/ActionRegistry.hpp"
+#include "atom.hpp"
+#include "bondgraph.hpp"
+#include "boundary.hpp"
+#include "config.hpp"
+#include "molecule.hpp"
+#include "Helpers/Verbose.hpp"
+#include "World.hpp"
+
 
 #include <iostream>
@@ -17,16 +31,5 @@
 #include "UIElements/UIFactory.hpp"
 #include "UIElements/Dialog.hpp"
-#include "Actions/MapOfActions.hpp"
-
-#include "atom.hpp"
-#include "bondgraph.hpp"
-#include "boundary.hpp"
-#include "config.hpp"
-#include "defs.hpp"
-#include "molecule.hpp"
-#include "periodentafel.hpp"
-#include "vector.hpp"
-#include "verbose.hpp"
-#include "World.hpp"
+#include "Actions/ValueStorage.hpp"
 
 /****** MoleculeFillWithMoleculeAction *****/
@@ -53,7 +56,27 @@
 {}
 
+void MoleculeFillWithMolecule(std::string &fillername, Vector &distances, Vector &lengths, double MaxDistance, bool DoRotate) {
+  ValueStorage::getInstance().setCurrentValue(MoleculeFillWithMoleculeAction::NAME, fillername);
+  ValueStorage::getInstance().setCurrentValue("distances", distances);
+  ValueStorage::getInstance().setCurrentValue("lengths", lengths);
+  ValueStorage::getInstance().setCurrentValue("DoRotate", MaxDistance);
+  ValueStorage::getInstance().setCurrentValue("MaxDistance", DoRotate);
+  ActionRegistry::getInstance().getActionByName(MoleculeFillWithMoleculeAction::NAME)->call(Action::NonInteractive);
+};
+
+Dialog* MoleculeFillWithMoleculeAction::fillDialog(Dialog *dialog) {
+  ASSERT(dialog,"No Dialog given when filling action dialog");
+
+  dialog->queryString(NAME, ValueStorage::getInstance().getDescription(NAME));
+  dialog->queryVector("distances", false, ValueStorage::getInstance().getDescription("distances"));
+  dialog->queryVector("lengths", false, ValueStorage::getInstance().getDescription("lengths"));
+  dialog->queryBoolean("DoRotate", ValueStorage::getInstance().getDescription("DoRotate"));
+  dialog->queryDouble("MaxDistance", ValueStorage::getInstance().getDescription("MaxDistance"));
+
+  return dialog;
+}
+
 Action::state_ptr MoleculeFillWithMoleculeAction::performCall() {
   string filename;
-  Dialog *dialog = UIFactory::getInstance().makeDialog();
   Vector distances;
   Vector lengths;
@@ -61,19 +84,18 @@
   bool DoRotate = false;
 
-  dialog->queryString(NAME, &filename, MapOfActions::getInstance().getDescription(NAME));
-  dialog->queryVector("distances", &distances, World::getInstance().getDomain(), false, MapOfActions::getInstance().getDescription("distances"));
-  dialog->queryVector("lengths", &lengths, World::getInstance().getDomain(), false, MapOfActions::getInstance().getDescription("lengths"));
-  dialog->queryBoolean("DoRotate", &DoRotate, MapOfActions::getInstance().getDescription("DoRotate"));
-  dialog->queryDouble("MaxDistance", &MaxDistance, MapOfActions::getInstance().getDescription("MaxDistance"));
+  ValueStorage::getInstance().queryCurrentValue(NAME, filename);
+  ValueStorage::getInstance().queryCurrentValue("distances", distances);
+  ValueStorage::getInstance().queryCurrentValue("lengths", lengths);
+  ValueStorage::getInstance().queryCurrentValue("DoRotate", DoRotate);
+  ValueStorage::getInstance().queryCurrentValue("MaxDistance", MaxDistance);
 
-  if(dialog->display()) {
-    DoLog(1) && (Log() << Verbose(1) << "Filling Box with water molecules, lengths(" << lengths[0] << "," << lengths[1] << "," << lengths[2] << "), distances (" << distances[0] << "," << distances[1] << "," << distances[2] << "), MaxDistance " << MaxDistance << ", DoRotate " << DoRotate << "." << endl);
-    // construct water molecule
-    molecule *filler = World::getInstance().createMolecule();
-    if (!filler->AddXYZFile(filename)) {
-      DoeLog(0) && (eLog()<< Verbose(0) << "Could not parse filler molecule from " << filename << "." << endl);
-    }
-    filler->SetNameFromFilename(filename.c_str());
-    molecule *Filling = NULL;
+  DoLog(1) && (Log() << Verbose(1) << "Filling Box with water molecules, lengths(" << lengths[0] << "," << lengths[1] << "," << lengths[2] << "), distances (" << distances[0] << "," << distances[1] << "," << distances[2] << "), MaxDistance " << MaxDistance << ", DoRotate " << DoRotate << "." << endl);
+  // construct water molecule
+  molecule *filler = World::getInstance().createMolecule();
+  if (!filler->AddXYZFile(filename)) {
+    DoeLog(0) && (eLog()<< Verbose(0) << "Could not parse filler molecule from " << filename << "." << endl);
+  }
+  filler->SetNameFromFilename(filename.c_str());
+  molecule *Filling = NULL;
 //    atom *first = NULL, *second = NULL, *third = NULL;
 //    first = World::getInstance().createAtom();
@@ -91,27 +113,23 @@
 //    filler->AddBond(first, third, 1);
 //    filler->AddBond(second, third, 1);
-    World::getInstance().getConfig()->BG->ConstructBondGraph(filler);
+  World::getInstance().getConfig()->BG->ConstructBondGraph(filler);
 //    filler->SetNameFromFilename("water");
-    // call routine
-    double distance[NDIM];
-    for (int i=0;i<NDIM;i++)
-      distance[i] = distances[i];
-    Filling = FillBoxWithMolecule(World::getInstance().getMolecules(), filler, *(World::getInstance().getConfig()), MaxDistance, distance, lengths[0], lengths[1], lengths[2], DoRotate);
-    if (Filling != NULL) {
-      Filling->ActiveFlag = false;
-      World::getInstance().getMolecules()->insert(Filling);
-    }
-    for (molecule::iterator iter = filler->begin(); !filler->empty(); iter = filler->begin()) {
-      atom *Walker = *iter;
-      filler->erase(iter);
-      World::getInstance().destroyAtom(Walker);
-    }
-    World::getInstance().destroyMolecule(filler);
+  // call routine
+  double distance[NDIM];
+  for (int i=0;i<NDIM;i++)
+    distance[i] = distances[i];
+  Filling = FillBoxWithMolecule(World::getInstance().getMolecules(), filler, *(World::getInstance().getConfig()), MaxDistance, distance, lengths[0], lengths[1], lengths[2], DoRotate);
+  if (Filling != NULL) {
+    Filling->ActiveFlag = false;
+    World::getInstance().getMolecules()->insert(Filling);
+  }
+  for (molecule::iterator iter = filler->begin(); !filler->empty(); iter = filler->begin()) {
+    atom *Walker = *iter;
+    filler->erase(iter);
+    World::getInstance().destroyAtom(Walker);
+  }
+  World::getInstance().destroyMolecule(filler);
 
-    delete dialog;
-    return Action::success;
-  }
-  delete dialog;
-  return Action::failure;
+  return Action::success;
 }
 
Index: src/Actions/MoleculeAction/FillWithMoleculeAction.hpp
===================================================================
--- src/Actions/MoleculeAction/FillWithMoleculeAction.hpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/Actions/MoleculeAction/FillWithMoleculeAction.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -10,9 +10,13 @@
 
 #include "Actions/Action.hpp"
-#include "Actions/Process.hpp"
+#include "LinearAlgebra/Vector.hpp"
 
 class MoleculeListClass;
 
+void MoleculeFillWithMolecule(std::string &fillername, Vector &distances, Vector &lengths, double MaxDistance, bool DoRotate);
+
 class MoleculeFillWithMoleculeAction : public Action {
+  friend void MoleculeFillWithMolecule(std::string &fillername, Vector &distances, Vector &lengths, double MaxDistance, bool DoRotate);
+
 public:
   MoleculeFillWithMoleculeAction();
@@ -23,4 +27,6 @@
 
   virtual const std::string getName();
+protected:
+  virtual Dialog * fillDialog(Dialog *dialog);
 private:
   virtual Action::state_ptr performCall();
Index: src/Actions/MoleculeAction/LinearInterpolationofTrajectoriesAction.cpp
===================================================================
--- src/Actions/MoleculeAction/LinearInterpolationofTrajectoriesAction.cpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/Actions/MoleculeAction/LinearInterpolationofTrajectoriesAction.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -6,7 +6,19 @@
  */
 
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
 #include "Helpers/MemDebug.hpp"
 
 #include "Actions/MoleculeAction/LinearInterpolationofTrajectoriesAction.hpp"
+#include "Actions/ActionRegistry.hpp"
+#include "atom.hpp"
+#include "defs.hpp"
+#include "Helpers/Log.hpp"
+#include "molecule.hpp"
+#include "Helpers/Verbose.hpp"
+#include "World.hpp"
 
 #include <iostream>
@@ -18,12 +30,6 @@
 #include "UIElements/UIFactory.hpp"
 #include "UIElements/Dialog.hpp"
-#include "Actions/MapOfActions.hpp"
+#include "Actions/ValueStorage.hpp"
 
-#include "atom.hpp"
-#include "defs.hpp"
-#include "log.hpp"
-#include "molecule.hpp"
-#include "verbose.hpp"
-#include "World.hpp"
 
 /****** MoleculeLinearInterpolationofTrajectoriesAction *****/
@@ -50,7 +56,25 @@
 {}
 
+void MoleculeLinearInterpolationofTrajectories(std::string &filename, int start, int end, bool IdMapping) {
+  ValueStorage::getInstance().setCurrentValue(MoleculeLinearInterpolationofTrajectoriesAction::NAME, filename);
+  ValueStorage::getInstance().setCurrentValue("start-step", start);
+  ValueStorage::getInstance().setCurrentValue("end-step", end);
+  ValueStorage::getInstance().setCurrentValue("id-mapping", IdMapping);
+  ActionRegistry::getInstance().getActionByName(MoleculeLinearInterpolationofTrajectoriesAction::NAME)->call(Action::NonInteractive);
+};
+
+Dialog* MoleculeLinearInterpolationofTrajectoriesAction::fillDialog(Dialog *dialog) {
+  ASSERT(dialog,"No Dialog given when filling action dialog");
+
+  dialog->queryString(NAME, ValueStorage::getInstance().getDescription(NAME));
+  dialog->queryInt("start-step", ValueStorage::getInstance().getDescription("start-step"));
+  dialog->queryInt("end-step", ValueStorage::getInstance().getDescription("end-step"));
+  dialog->queryBoolean("id-mapping", ValueStorage::getInstance().getDescription("id-mapping"));
+
+  return dialog;
+}
+
 Action::state_ptr MoleculeLinearInterpolationofTrajectoriesAction::performCall() {
   string filename;
-  Dialog *dialog = UIFactory::getInstance().makeDialog();
   molecule *mol = NULL;
   int start = -1;
@@ -58,12 +82,11 @@
   bool IdMapping = true;
 
+  ValueStorage::getInstance().queryCurrentValue(NAME, filename);
+  ValueStorage::getInstance().queryCurrentValue("start-step", start);
+  ValueStorage::getInstance().queryCurrentValue("end-step", end);
+  ValueStorage::getInstance().queryCurrentValue("id-mapping", IdMapping);
 
-  dialog->queryString(NAME, &filename, MapOfActions::getInstance().getDescription(NAME));
-  dialog->queryInt("start-step", &start, MapOfActions::getInstance().getDescription("start-step"));
-  dialog->queryInt("end-step", &end, MapOfActions::getInstance().getDescription("end-step"));
-  dialog->queryMolecule("molecule-by-id", &mol, MapOfActions::getInstance().getDescription("molecule-by-id"));
-  dialog->queryBoolean("id-mapping", &IdMapping, MapOfActions::getInstance().getDescription("id-mapping"));
-
-  if(dialog->display()) {
+  for (World::MoleculeSelectionIterator iter = World::getInstance().beginMoleculeSelection(); iter != World::getInstance().endMoleculeSelection(); ++iter) {
+    mol = iter->second;
     DoLog(1) && (Log() << Verbose(1) << "Linear interpolation between configuration " << start << " and " << end << "." << endl);
     if (IdMapping)
@@ -73,9 +96,6 @@
     else
       DoLog(2) && (Log() << Verbose(2) << "Steps created and " << filename << " files stored." << endl);
-    delete dialog;
-    return Action::success;
   }
-  delete dialog;
-  return Action::failure;
+  return Action::success;
 }
 
Index: src/Actions/MoleculeAction/LinearInterpolationofTrajectoriesAction.hpp
===================================================================
--- src/Actions/MoleculeAction/LinearInterpolationofTrajectoriesAction.hpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/Actions/MoleculeAction/LinearInterpolationofTrajectoriesAction.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -10,9 +10,13 @@
 
 #include "Actions/Action.hpp"
-#include "Actions/Process.hpp"
+
 
 class MoleculeListClass;
 
+void MoleculeLinearInterpolationofTrajectories(std::string &filename, int start, int end, bool IdMapping);
+
 class MoleculeLinearInterpolationofTrajectoriesAction : public Action {
+  friend void MoleculeLinearInterpolationofTrajectories(std::string &filename, int start, int end, bool IdMapping);
+
 public:
   MoleculeLinearInterpolationofTrajectoriesAction();
@@ -23,4 +27,6 @@
 
   virtual const std::string getName();
+protected:
+  virtual Dialog * fillDialog(Dialog *dialog);
 private:
   virtual Action::state_ptr performCall();
Index: src/Actions/MoleculeAction/RotateAroundSelfByAngleAction.cpp
===================================================================
--- src/Actions/MoleculeAction/RotateAroundSelfByAngleAction.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
+++ src/Actions/MoleculeAction/RotateAroundSelfByAngleAction.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -0,0 +1,148 @@
+/*
+ * RotateAroundSelfByAngleAction.cpp
+ *
+ *  Created on: Aug 06, 2010
+ *      Author: heber
+ */
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "Helpers/MemDebug.hpp"
+
+#include "Actions/MoleculeAction/RotateAroundSelfByAngleAction.hpp"
+#include "Actions/ActionRegistry.hpp"
+#include "Helpers/Log.hpp"
+#include "Helpers/Verbose.hpp"
+#include "LinearAlgebra/Line.hpp"
+#include "LinearAlgebra/Vector.hpp"
+#include "atom.hpp"
+#include "molecule.hpp"
+
+
+#include <iostream>
+#include <fstream>
+#include <string>
+
+using namespace std;
+
+#include "UIElements/UIFactory.hpp"
+#include "UIElements/Dialog.hpp"
+#include "Actions/ValueStorage.hpp"
+
+/****** MoleculeRotateAroundSelfByAngleAction *****/
+
+// memento to remember the state when undoing
+
+class MoleculeRotateAroundSelfByAngleState : public ActionState {
+public:
+    MoleculeRotateAroundSelfByAngleState(molecule * const _mol, const Vector &_Axis, const double _alpha) :
+      mol(_mol),
+      Axis(_Axis),
+      alpha(_alpha)
+    {}
+    molecule* const mol;
+    Vector Axis;
+    double alpha;
+};
+
+const char MoleculeRotateAroundSelfByAngleAction::NAME[] = "rotate-self";
+
+MoleculeRotateAroundSelfByAngleAction::MoleculeRotateAroundSelfByAngleAction() :
+  Action(NAME)
+{}
+
+MoleculeRotateAroundSelfByAngleAction::~MoleculeRotateAroundSelfByAngleAction()
+{}
+
+void MoleculeRotateAroundSelfByAngle(const Vector &Axis, const double angle) {
+  ValueStorage::getInstance().setCurrentValue(MoleculeRotateAroundSelfByAngleAction::NAME, angle);
+  ValueStorage::getInstance().setCurrentValue("position", Axis);
+  ActionRegistry::getInstance().getActionByName(MoleculeRotateAroundSelfByAngleAction::NAME)->call(Action::NonInteractive);
+};
+
+Dialog* MoleculeRotateAroundSelfByAngleAction::fillDialog(Dialog *dialog) {
+  ASSERT(dialog,"No Dialog given when filling action dialog");
+
+  dialog->queryDouble(NAME, ValueStorage::getInstance().getDescription(NAME));
+  dialog->queryVector("position", false, ValueStorage::getInstance().getDescription(NAME));
+
+  return dialog;
+}
+
+Action::state_ptr MoleculeRotateAroundSelfByAngleAction::performCall() {
+  molecule *mol = NULL;
+  double alpha = 0.;
+  Vector Axis;
+
+  // obtain angle and axis around which rotate
+  ValueStorage::getInstance().queryCurrentValue(NAME, alpha);
+  ValueStorage::getInstance().queryCurrentValue("position", Axis);
+
+  // check whether a single atom and molecule is selected
+  if (World::getInstance().getSelectedMolecules().size() != 1)
+    return Action::failure;
+  mol = World::getInstance().beginMoleculeSelection()->second;
+
+  // check whether Axis is valid
+  if (Axis.IsZero())
+    return Action::failure;
+
+  // convert from degrees to radian
+  alpha *= M_PI/180.;
+
+  // Creation Line that is the rotation axis
+  Vector *CenterOfGravity = mol->DetermineCenterOfGravity();
+  Line RotationAxis(*CenterOfGravity, Axis);
+  delete(CenterOfGravity);
+  DoLog(0) && (Log() << Verbose(0) << "Rotate around self by " << alpha << " along " << RotationAxis << "." << endl);
+
+  for (molecule::iterator iter = mol->begin(); iter != mol->end(); ++iter) {
+    (*iter)->setPosition(RotationAxis.rotateVector((*iter)->getPosition(), alpha));
+  }
+  DoLog(0) && (Log() << Verbose(0) << "done." << endl);
+
+  return Action::state_ptr(new MoleculeRotateAroundSelfByAngleState(mol, Axis, alpha));
+}
+
+Action::state_ptr MoleculeRotateAroundSelfByAngleAction::performUndo(Action::state_ptr _state) {
+  MoleculeRotateAroundSelfByAngleState *state = assert_cast<MoleculeRotateAroundSelfByAngleState*>(_state.get());
+
+  Vector *CenterOfGravity = state->mol->DetermineCenterOfGravity();
+  Line RotationAxis(*CenterOfGravity, state->Axis);
+  delete(CenterOfGravity);
+
+  for (molecule::iterator iter = state->mol->begin(); iter != state->mol->end(); ++iter) {
+    (*iter)->setPosition(RotationAxis.rotateVector((*iter)->getPosition(), -state->alpha));
+  }
+
+  return Action::state_ptr(_state);
+}
+
+Action::state_ptr MoleculeRotateAroundSelfByAngleAction::performRedo(Action::state_ptr _state){
+  MoleculeRotateAroundSelfByAngleState *state = assert_cast<MoleculeRotateAroundSelfByAngleState*>(_state.get());
+
+  Vector *CenterOfGravity = state->mol->DetermineCenterOfGravity();
+  Line RotationAxis(*CenterOfGravity, state->Axis);
+  delete(CenterOfGravity);
+
+  for (molecule::iterator iter = state->mol->begin(); iter != state->mol->end(); ++iter) {
+    (*iter)->setPosition(RotationAxis.rotateVector((*iter)->getPosition(), state->alpha));
+  }
+
+  return Action::state_ptr(_state);
+}
+
+bool MoleculeRotateAroundSelfByAngleAction::canUndo() {
+  return true;
+}
+
+bool MoleculeRotateAroundSelfByAngleAction::shouldUndo() {
+  return true;
+}
+
+const string MoleculeRotateAroundSelfByAngleAction::getName() {
+  return NAME;
+}
Index: src/Actions/MoleculeAction/RotateAroundSelfByAngleAction.hpp
===================================================================
--- src/Actions/MoleculeAction/RotateAroundSelfByAngleAction.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
+++ src/Actions/MoleculeAction/RotateAroundSelfByAngleAction.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -0,0 +1,40 @@
+/*
+ * RotateAroundSelfByAngleAction.hpp
+ *
+ *  Created on: Aug 06, 2010
+ *      Author: heber
+ */
+
+#ifndef ROTATEAROUNDSELFBYANGLEACTION_HPP
+#define ROTATEAROUNDSELFBYANGLEACTION_HPP
+
+#include "Actions/Action.hpp"
+
+class MoleculeListClass;
+class Vector;
+
+void MoleculeRotateOrigin(Vector &Axis);
+
+class MoleculeRotateAroundSelfByAngleAction : public Action {
+  friend void MoleculeRotateAroundSelfByAngle(const Vector &Axis, const double angle);
+
+public:
+  MoleculeRotateAroundSelfByAngleAction();
+  virtual ~MoleculeRotateAroundSelfByAngleAction();
+
+  bool canUndo();
+  bool shouldUndo();
+
+  virtual const std::string getName();
+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);
+
+  static const char NAME[];
+};
+
+
+#endif // ROTATEAROUNDSELFBYANGLEACTION_HPP
Index: src/Actions/MoleculeAction/RotateToPrincipalAxisSystemAction.cpp
===================================================================
--- src/Actions/MoleculeAction/RotateToPrincipalAxisSystemAction.cpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/Actions/MoleculeAction/RotateToPrincipalAxisSystemAction.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -6,7 +6,21 @@
  */
 
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
 #include "Helpers/MemDebug.hpp"
 
 #include "Actions/MoleculeAction/RotateToPrincipalAxisSystemAction.hpp"
+#include "Actions/ActionRegistry.hpp"
+#include "Helpers/Log.hpp"
+#include "Helpers/Verbose.hpp"
+#include "LinearAlgebra/Line.hpp"
+#include "LinearAlgebra/Matrix.hpp"
+#include "LinearAlgebra/Vector.hpp"
+#include "element.hpp"
+#include "molecule.hpp"
+
 
 #include <iostream>
@@ -18,9 +32,5 @@
 #include "UIElements/UIFactory.hpp"
 #include "UIElements/Dialog.hpp"
-#include "Actions/MapOfActions.hpp"
-
-#include "log.hpp"
-#include "molecule.hpp"
-#include "verbose.hpp"
+#include "Actions/ValueStorage.hpp"
 
 /****** MoleculeRotateToPrincipalAxisSystemAction *****/
@@ -47,18 +57,106 @@
 {}
 
+void MoleculeRotateToPrincipalAxisSystem(Vector &Axis) {
+  ValueStorage::getInstance().setCurrentValue(MoleculeRotateToPrincipalAxisSystemAction::NAME, Axis);
+  ActionRegistry::getInstance().getActionByName(MoleculeRotateToPrincipalAxisSystemAction::NAME)->call(Action::NonInteractive);
+};
+
+Dialog* MoleculeRotateToPrincipalAxisSystemAction::fillDialog(Dialog *dialog) {
+  ASSERT(dialog,"No Dialog given when filling action dialog");
+
+  dialog->queryVector(NAME, false, ValueStorage::getInstance().getDescription(NAME));
+
+  return dialog;
+}
+
 Action::state_ptr MoleculeRotateToPrincipalAxisSystemAction::performCall() {
-  Dialog *dialog = UIFactory::getInstance().makeDialog();
   molecule *mol = NULL;
+  Vector Axis;
 
-  dialog->queryMolecule(NAME, &mol, MapOfActions::getInstance().getDescription(NAME));
+  // obtain axis to rotate to
+  ValueStorage::getInstance().queryCurrentValue(NAME, Axis);
 
-  if(dialog->display()) {
+  for (World::MoleculeSelectionIterator iter = World::getInstance().beginMoleculeSelection(); iter != World::getInstance().endMoleculeSelection(); ++iter) {
+    mol = iter->second;
     DoLog(0) && (Log() << Verbose(0) << "Converting to prinicipal axis system." << endl);
-    mol->PrincipalAxisSystem(true);
-    delete dialog;
-    return Action::success;
+    Matrix InertiaTensor;
+    Vector *CenterOfGravity = mol->DetermineCenterOfGravity();
+
+    // reset inertia tensor
+    InertiaTensor.zero();
+
+    // sum up inertia tensor
+    for (molecule::const_iterator iter = mol->begin(); iter != mol->end(); ++iter) {
+      Vector x = (*iter)->getPosition();
+      x -= *CenterOfGravity;
+      const double mass = (*iter)->getType()->mass;
+      InertiaTensor.at(0,0) += mass*(x[1]*x[1] + x[2]*x[2]);
+      InertiaTensor.at(0,1) += mass*(-x[0]*x[1]);
+      InertiaTensor.at(0,2) += mass*(-x[0]*x[2]);
+      InertiaTensor.at(1,0) += mass*(-x[1]*x[0]);
+      InertiaTensor.at(1,1) += mass*(x[0]*x[0] + x[2]*x[2]);
+      InertiaTensor.at(1,2) += mass*(-x[1]*x[2]);
+      InertiaTensor.at(2,0) += mass*(-x[2]*x[0]);
+      InertiaTensor.at(2,1) += mass*(-x[2]*x[1]);
+      InertiaTensor.at(2,2) += mass*(x[0]*x[0] + x[1]*x[1]);
+    }
+    // print InertiaTensor for debugging
+    DoLog(0) && (Log() << Verbose(0) << "The inertia tensor is:" << InertiaTensor << endl);
+
+    // diagonalize to determine principal axis system
+    Vector Eigenvalues = InertiaTensor.transformToEigenbasis();
+
+    for(int i=0;i<NDIM;i++)
+      DoLog(0) && (Log() << Verbose(0) << "eigenvalue = " << Eigenvalues[i] << ", eigenvector = " << InertiaTensor.column(i) << endl);
+
+    // check whether we rotate or not
+    DoLog(0) && (Log() << Verbose(0) << "Transforming molecule into PAS ... ");
+
+    // obtain first column, eigenvector to biggest eigenvalue
+    Vector BiggestEigenvector(InertiaTensor.column(Eigenvalues.SmallestComponent()));
+    Vector DesiredAxis(Axis);
+
+    // Creation Line that is the rotation axis
+    DesiredAxis.VectorProduct(BiggestEigenvector);
+    Line RotationAxis(Vector(0.,0.,0.), DesiredAxis);
+
+    // determine angle
+    const double alpha = BiggestEigenvector.Angle(Axis);
+
+    DoLog(0) && (Log() << Verbose(0) << alpha << endl);
+
+    for (molecule::iterator iter = mol->begin(); iter != mol->end(); ++iter) {
+      *(*iter) -= *CenterOfGravity;
+      (*iter)->setPosition(RotationAxis.rotateVector((*iter)->getPosition(), alpha));
+      *(*iter) += *CenterOfGravity;
+    }
+    DoLog(0) && (Log() << Verbose(0) << "done." << endl);
+
+    // summing anew for debugging (resulting matrix has to be diagonal!)
+    // reset inertia tensor
+    InertiaTensor.zero();
+
+    // sum up inertia tensor
+    for (molecule::const_iterator iter = mol->begin(); iter != mol->end(); ++iter) {
+      Vector x = (*iter)->getPosition();
+      x -= *CenterOfGravity;
+      const double mass = (*iter)->getType()->mass;
+      InertiaTensor.at(0,0) += mass*(x[1]*x[1] + x[2]*x[2]);
+      InertiaTensor.at(0,1) += mass*(-x[0]*x[1]);
+      InertiaTensor.at(0,2) += mass*(-x[0]*x[2]);
+      InertiaTensor.at(1,0) += mass*(-x[1]*x[0]);
+      InertiaTensor.at(1,1) += mass*(x[0]*x[0] + x[2]*x[2]);
+      InertiaTensor.at(1,2) += mass*(-x[1]*x[2]);
+      InertiaTensor.at(2,0) += mass*(-x[2]*x[0]);
+      InertiaTensor.at(2,1) += mass*(-x[2]*x[1]);
+      InertiaTensor.at(2,2) += mass*(x[0]*x[0] + x[1]*x[1]);
+      // print InertiaTensor for debugging
+      DoLog(0) && (Log() << Verbose(0) << "The inertia tensor is:" << InertiaTensor << endl);
+    }
+
+    // free everything
+    delete(CenterOfGravity);
   }
-  delete dialog;
-  return Action::failure;
+  return Action::success;
 }
 
Index: src/Actions/MoleculeAction/RotateToPrincipalAxisSystemAction.hpp
===================================================================
--- src/Actions/MoleculeAction/RotateToPrincipalAxisSystemAction.hpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/Actions/MoleculeAction/RotateToPrincipalAxisSystemAction.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -10,9 +10,13 @@
 
 #include "Actions/Action.hpp"
-#include "Actions/Process.hpp"
 
 class MoleculeListClass;
+class Vector;
+
+void MoleculeRotateToPrincipalAxisSystem(Vector &Axis);
 
 class MoleculeRotateToPrincipalAxisSystemAction : public Action {
+  friend void MoleculeRotateToPrincipalAxisSystem(Vector &Axis);
+
 public:
   MoleculeRotateToPrincipalAxisSystemAction();
@@ -23,4 +27,6 @@
 
   virtual const std::string getName();
+protected:
+  virtual Dialog * fillDialog(Dialog *dialog);
 private:
   virtual Action::state_ptr performCall();
Index: src/Actions/MoleculeAction/SaveAdjacencyAction.cpp
===================================================================
--- src/Actions/MoleculeAction/SaveAdjacencyAction.cpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/Actions/MoleculeAction/SaveAdjacencyAction.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -6,7 +6,20 @@
  */
 
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
 #include "Helpers/MemDebug.hpp"
 
 #include "Actions/MoleculeAction/SaveAdjacencyAction.hpp"
+#include "Actions/ActionRegistry.hpp"
+#include "bondgraph.hpp"
+#include "config.hpp"
+#include "Helpers/Log.hpp"
+#include "molecule.hpp"
+#include "Helpers/Verbose.hpp"
+#include "World.hpp"
+
 
 #include <iostream>
@@ -18,15 +31,5 @@
 #include "UIElements/UIFactory.hpp"
 #include "UIElements/Dialog.hpp"
-#include "Actions/MapOfActions.hpp"
-
-#include "atom.hpp"
-#include "bondgraph.hpp"
-#include "config.hpp"
-#include "defs.hpp"
-#include "log.hpp"
-#include "molecule.hpp"
-#include "vector.hpp"
-#include "verbose.hpp"
-#include "World.hpp"
+#include "Actions/ValueStorage.hpp"
 
 /****** MoleculeSaveAdjacencyAction *****/
@@ -53,22 +56,31 @@
 {}
 
+void MoleculeSaveAdjacency(std::string &adjacencyfile) {
+  ValueStorage::getInstance().setCurrentValue(MoleculeSaveAdjacencyAction::NAME, adjacencyfile);
+  ActionRegistry::getInstance().getActionByName(MoleculeSaveAdjacencyAction::NAME)->call(Action::NonInteractive);
+};
+
+Dialog* MoleculeSaveAdjacencyAction::fillDialog(Dialog *dialog) {
+  ASSERT(dialog,"No Dialog given when filling action dialog");
+
+  dialog->queryString(NAME, ValueStorage::getInstance().getDescription(NAME));
+
+  return dialog;
+}
+
 Action::state_ptr MoleculeSaveAdjacencyAction::performCall() {
   string filename;
-  Dialog *dialog = UIFactory::getInstance().makeDialog();
   molecule *mol = NULL;
 
-  dialog->queryString(NAME, &filename, MapOfActions::getInstance().getDescription(NAME));
-  dialog->queryMolecule("molecule-by-id", &mol, MapOfActions::getInstance().getDescription("molecule-by-id"));
+  ValueStorage::getInstance().queryCurrentValue(NAME, filename);
 
-  if(dialog->display()) {
+  for (World::MoleculeSelectionIterator iter = World::getInstance().beginMoleculeSelection(); iter != World::getInstance().endMoleculeSelection(); ++iter) {
+    mol = iter->second;
     DoLog(0) && (Log() << Verbose(0) << "Storing adjacency to path " << filename << "." << endl);
     World::getInstance().getConfig()->BG->ConstructBondGraph(mol);
     // TODO: sollte stream nicht filename benutzen, besser fuer unit test
     mol->StoreAdjacencyToFile(filename);
-    delete dialog;
-    return Action::success;
   }
-  delete dialog;
-  return Action::failure;
+  return Action::success;
 }
 
Index: src/Actions/MoleculeAction/SaveAdjacencyAction.hpp
===================================================================
--- src/Actions/MoleculeAction/SaveAdjacencyAction.hpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/Actions/MoleculeAction/SaveAdjacencyAction.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -10,9 +10,13 @@
 
 #include "Actions/Action.hpp"
-#include "Actions/Process.hpp"
+
 
 class MoleculeListClass;
 
+void MoleculeSaveAdjacency(std::string &adjacencyfile);
+
 class MoleculeSaveAdjacencyAction : public Action {
+  friend void MoleculeSaveAdjacency(std::string &adjacencyfile);
+
 public:
   MoleculeSaveAdjacencyAction();
@@ -23,4 +27,6 @@
 
   virtual const std::string getName();
+protected:
+  virtual Dialog * fillDialog(Dialog *dialog);
 private:
   virtual Action::state_ptr performCall();
Index: src/Actions/MoleculeAction/SaveBondsAction.cpp
===================================================================
--- src/Actions/MoleculeAction/SaveBondsAction.cpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/Actions/MoleculeAction/SaveBondsAction.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -6,7 +6,20 @@
  */
 
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
 #include "Helpers/MemDebug.hpp"
 
 #include "Actions/MoleculeAction/SaveBondsAction.hpp"
+#include "Actions/ActionRegistry.hpp"
+#include "bondgraph.hpp"
+#include "config.hpp"
+#include "Helpers/Log.hpp"
+#include "molecule.hpp"
+#include "Helpers/Verbose.hpp"
+#include "World.hpp"
+
 
 #include <iostream>
@@ -18,15 +31,5 @@
 #include "UIElements/UIFactory.hpp"
 #include "UIElements/Dialog.hpp"
-#include "Actions/MapOfActions.hpp"
-
-#include "atom.hpp"
-#include "bondgraph.hpp"
-#include "config.hpp"
-#include "defs.hpp"
-#include "log.hpp"
-#include "molecule.hpp"
-#include "vector.hpp"
-#include "verbose.hpp"
-#include "World.hpp"
+#include "Actions/ValueStorage.hpp"
 
 /****** MoleculeSaveBondsAction *****/
@@ -53,22 +56,31 @@
 {}
 
+void MoleculeSaveBonds(std::string &bondsfile) {
+  ValueStorage::getInstance().setCurrentValue(MoleculeSaveBondsAction::NAME, bondsfile);
+  ActionRegistry::getInstance().getActionByName(MoleculeSaveBondsAction::NAME)->call(Action::NonInteractive);
+};
+
+Dialog* MoleculeSaveBondsAction::fillDialog(Dialog *dialog) {
+  ASSERT(dialog,"No Dialog given when filling action dialog");
+
+  dialog->queryString(NAME, ValueStorage::getInstance().getDescription(NAME));
+
+  return dialog;
+}
+
 Action::state_ptr MoleculeSaveBondsAction::performCall() {
   string filename;
-  Dialog *dialog = UIFactory::getInstance().makeDialog();
   molecule *mol = NULL;
 
-  dialog->queryString(NAME, &filename, MapOfActions::getInstance().getDescription(NAME));
-  dialog->queryMolecule("molecule-by-id", &mol, MapOfActions::getInstance().getDescription("molecule-by-id"));
+  ValueStorage::getInstance().queryCurrentValue(NAME, filename);
 
-  if(dialog->display()) {
+  for (World::MoleculeSelectionIterator iter = World::getInstance().beginMoleculeSelection(); iter != World::getInstance().endMoleculeSelection(); ++iter) {
+    mol = iter->second;
     DoLog(0) && (Log() << Verbose(0) << "Storing bonds to path " << filename << "." << endl);
     World::getInstance().getConfig()->BG->ConstructBondGraph(mol);
     // TODO: sollte stream, nicht filenamen direkt nutzen, besser fuer unit tests
     mol->StoreBondsToFile(filename);
-    delete dialog;
-    return Action::success;
   }
-  delete dialog;
-  return Action::failure;
+  return Action::success;
 }
 
Index: src/Actions/MoleculeAction/SaveBondsAction.hpp
===================================================================
--- src/Actions/MoleculeAction/SaveBondsAction.hpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/Actions/MoleculeAction/SaveBondsAction.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -10,9 +10,13 @@
 
 #include "Actions/Action.hpp"
-#include "Actions/Process.hpp"
+
 
 class MoleculeListClass;
 
+void MoleculeSaveBonds(std::string &bondsfile);
+
 class MoleculeSaveBondsAction : public Action {
+  friend void MoleculeSaveBonds(std::string &bondsfile);
+
 public:
   MoleculeSaveBondsAction();
@@ -23,4 +27,6 @@
 
   virtual const std::string getName();
+protected:
+  virtual Dialog * fillDialog(Dialog *dialog);
 private:
   virtual Action::state_ptr performCall();
Index: src/Actions/MoleculeAction/SaveTemperatureAction.cpp
===================================================================
--- src/Actions/MoleculeAction/SaveTemperatureAction.cpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/Actions/MoleculeAction/SaveTemperatureAction.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -6,7 +6,17 @@
  */
 
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
 #include "Helpers/MemDebug.hpp"
 
 #include "Actions/MoleculeAction/SaveTemperatureAction.hpp"
+#include "Actions/ActionRegistry.hpp"
+#include "Helpers/Log.hpp"
+#include "molecule.hpp"
+#include "Helpers/Verbose.hpp"
+#include "World.hpp"
 
 #include <iostream>
@@ -18,11 +28,5 @@
 #include "UIElements/UIFactory.hpp"
 #include "UIElements/Dialog.hpp"
-#include "Actions/MapOfActions.hpp"
-
-#include "atom.hpp"
-#include "log.hpp"
-#include "molecule.hpp"
-#include "verbose.hpp"
-#include "World.hpp"
+#include "Actions/ValueStorage.hpp"
 
 /****** MoleculeSaveTemperatureAction *****/
@@ -49,13 +53,25 @@
 {}
 
+void MoleculeSaveTemperature(std::string &temperaturefile) {
+  ValueStorage::getInstance().setCurrentValue(MoleculeSaveTemperatureAction::NAME, temperaturefile);
+  ActionRegistry::getInstance().getActionByName(MoleculeSaveTemperatureAction::NAME)->call(Action::NonInteractive);
+};
+
+Dialog* MoleculeSaveTemperatureAction::fillDialog(Dialog *dialog) {
+  ASSERT(dialog,"No Dialog given when filling action dialog");
+
+  dialog->queryString(NAME, ValueStorage::getInstance().getDescription(NAME));
+
+  return dialog;
+}
+
 Action::state_ptr MoleculeSaveTemperatureAction::performCall() {
   string filename;
-  Dialog *dialog = UIFactory::getInstance().makeDialog();
   molecule *mol = NULL;
 
-  dialog->queryString(NAME, &filename, MapOfActions::getInstance().getDescription(NAME));
-  dialog->queryMolecule("molecule-by-id", &mol, MapOfActions::getInstance().getDescription("molecule-by-id"));
+  ValueStorage::getInstance().queryCurrentValue(NAME, filename);
 
-  if(dialog->display()) {
+  for (World::MoleculeSelectionIterator iter = World::getInstance().beginMoleculeSelection(); iter != World::getInstance().endMoleculeSelection(); ++iter) {
+    mol = iter->second;
     DoLog(1) && (Log() << Verbose(1) << "Storing temperatures in " << filename << "." << endl);
     ofstream output;
@@ -66,9 +82,6 @@
       DoLog(2) && (Log() << Verbose(2) << "File stored." << endl);
     output.close();
-    delete dialog;
-    return Action::success;
   }
-  delete dialog;
-  return Action::failure;
+  return Action::success;
 }
 
Index: src/Actions/MoleculeAction/SaveTemperatureAction.hpp
===================================================================
--- src/Actions/MoleculeAction/SaveTemperatureAction.hpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/Actions/MoleculeAction/SaveTemperatureAction.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -10,9 +10,13 @@
 
 #include "Actions/Action.hpp"
-#include "Actions/Process.hpp"
+
 
 class MoleculeListClass;
 
+void MoleculeSaveTemperature(std::string &temperaturefile);
+
 class MoleculeSaveTemperatureAction : public Action {
+  friend void MoleculeSaveTemperature(std::string &temperaturefile);
+
 public:
   MoleculeSaveTemperatureAction();
@@ -23,4 +27,6 @@
 
   virtual const std::string getName();
+protected:
+  virtual Dialog * fillDialog(Dialog *dialog);
 private:
   virtual Action::state_ptr performCall();
Index: src/Actions/MoleculeAction/SuspendInWaterAction.cpp
===================================================================
--- src/Actions/MoleculeAction/SuspendInWaterAction.cpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/Actions/MoleculeAction/SuspendInWaterAction.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -6,7 +6,18 @@
  */
 
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
 #include "Helpers/MemDebug.hpp"
 
 #include "Actions/MoleculeAction/SuspendInWaterAction.hpp"
+#include "Actions/ActionRegistry.hpp"
+#include "boundary.hpp"
+#include "config.hpp"
+#include "Helpers/Log.hpp"
+#include "Helpers/Verbose.hpp"
+#include "World.hpp"
 
 #include <iostream>
@@ -17,12 +28,5 @@
 #include "UIElements/UIFactory.hpp"
 #include "UIElements/Dialog.hpp"
-#include "Actions/MapOfActions.hpp"
-
-#include "atom.hpp"
-#include "boundary.hpp"
-#include "config.hpp"
-#include "log.hpp"
-#include "config.hpp"
-#include "World.hpp"
+#include "Actions/ValueStorage.hpp"
 
 /****** MoleculeSuspendInWaterAction *****/
@@ -49,14 +53,26 @@
 {}
 
+void MoleculeSuspendInWater(double density) {
+  ValueStorage::getInstance().setCurrentValue(MoleculeSuspendInWaterAction::NAME, density);
+  ActionRegistry::getInstance().getActionByName(MoleculeSuspendInWaterAction::NAME)->call(Action::NonInteractive);
+};
+
+Dialog* MoleculeSuspendInWaterAction::fillDialog(Dialog *dialog) {
+  ASSERT(dialog,"No Dialog given when filling action dialog");
+
+  dialog->queryDouble(NAME, ValueStorage::getInstance().getDescription(NAME));
+
+  return dialog;
+}
+
 Action::state_ptr MoleculeSuspendInWaterAction::performCall() {
   molecule *mol = NULL;
-  Dialog *dialog = UIFactory::getInstance().makeDialog();
   double density;
   double volume = 0.;
 
-  dialog->queryDouble(NAME, &density, MapOfActions::getInstance().getDescription(NAME));
-  dialog->queryMolecule("molecule-by-id", &mol, MapOfActions::getInstance().getDescription("molecule-by-id"));
+  ValueStorage::getInstance().queryCurrentValue(NAME, density);
 
-  if(dialog->display()) {
+  for (World::MoleculeSelectionIterator iter = World::getInstance().beginMoleculeSelection(); iter != World::getInstance().endMoleculeSelection(); ++iter) {
+    mol = iter->second;
     DoLog(0) && (Log() << Verbose(0) << "Evaluating necessary cell volume for a cluster suspended in water.");
     if (density < 1.0) {
@@ -64,10 +80,7 @@
     } else {
       PrepareClustersinWater(World::getInstance().getConfig(), mol, volume, density);  // if volume == 0, will calculate from ConvexEnvelope
-      delete dialog;
-      return Action::success;
     }
   }
-  delete dialog;
-  return Action::failure;
+  return Action::success;
 }
 
Index: src/Actions/MoleculeAction/SuspendInWaterAction.hpp
===================================================================
--- src/Actions/MoleculeAction/SuspendInWaterAction.hpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/Actions/MoleculeAction/SuspendInWaterAction.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -10,9 +10,13 @@
 
 #include "Actions/Action.hpp"
-#include "Actions/Process.hpp"
+
 
 class MoleculeListClass;
 
+void MoleculeSuspendInWater(double density);
+
 class MoleculeSuspendInWaterAction : public Action {
+  friend void MoleculeSuspendInWater(double density);
+
 public:
   MoleculeSuspendInWaterAction();
@@ -23,4 +27,6 @@
 
   virtual const std::string getName();
+protected:
+  virtual Dialog * fillDialog(Dialog *dialog);
 private:
   virtual Action::state_ptr performCall();
Index: c/Actions/MoleculeAction/TranslateAction.cpp
===================================================================
--- src/Actions/MoleculeAction/TranslateAction.cpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ 	(revision )
@@ -1,100 +1,0 @@
-/*
- * TranslateAction.cpp
- *
- *  Created on: May 10, 2010
- *      Author: heber
- */
-
-#include "Helpers/MemDebug.hpp"
-
-#include "Actions/MoleculeAction/TranslateAction.hpp"
-
-#include <iostream>
-#include <fstream>
-#include <string>
-
-using namespace std;
-
-#include "UIElements/UIFactory.hpp"
-#include "UIElements/Dialog.hpp"
-#include "Actions/MapOfActions.hpp"
-
-#include "atom.hpp"
-#include "log.hpp"
-#include "molecule.hpp"
-#include "verbose.hpp"
-#include "World.hpp"
-
-/****** MoleculeTranslateAction *****/
-
-// memento to remember the state when undoing
-
-//class MoleculeTranslateState : public ActionState {
-//public:
-//  MoleculeTranslateState(molecule* _mol,std::string _lastName) :
-//    mol(_mol),
-//    lastName(_lastName)
-//  {}
-//  molecule* mol;
-//  std::string lastName;
-//};
-
-const char MoleculeTranslateAction::NAME[] = "translate-mol";
-
-MoleculeTranslateAction::MoleculeTranslateAction() :
-  Action(NAME)
-{}
-
-MoleculeTranslateAction::~MoleculeTranslateAction()
-{}
-
-Action::state_ptr MoleculeTranslateAction::performCall() {
-  Dialog *dialog = UIFactory::getInstance().makeDialog();
-  molecule *mol = NULL;
-  Vector x;
-  bool periodic = false;
-
-  dialog->queryVector(NAME, &x, World::getInstance().getDomain(), false, MapOfActions::getInstance().getDescription(NAME));
-  dialog->queryMolecule("molecule-by-id", &mol, MapOfActions::getInstance().getDescription("molecule-by-id"));
-  dialog->queryBoolean("periodic", &periodic, MapOfActions::getInstance().getDescription("periodic"));
-  cout << "pre-dialog" << endl;
-
-  if(dialog->display()) {
-    cout << "post-dialog" << endl;
-    DoLog(1) && (Log() << Verbose(1) << "Translating all ions by given vector." << endl);
-    if (periodic)
-      mol->TranslatePeriodically((const Vector *)&x);
-    else
-      mol->Translate((const Vector *)&x);
-    delete dialog;
-    return Action::success;
-  }
-  delete dialog;
-  return Action::failure;
-}
-
-Action::state_ptr MoleculeTranslateAction::performUndo(Action::state_ptr _state) {
-//  MoleculeTranslateState *state = assert_cast<MoleculeTranslateState*>(_state.get());
-
-//  string newName = state->mol->getName();
-//  state->mol->setName(state->lastName);
-
-  return Action::failure;
-}
-
-Action::state_ptr MoleculeTranslateAction::performRedo(Action::state_ptr _state){
-  // Undo and redo have to do the same for this action
-  return performUndo(_state);
-}
-
-bool MoleculeTranslateAction::canUndo() {
-  return false;
-}
-
-bool MoleculeTranslateAction::shouldUndo() {
-  return false;
-}
-
-const string MoleculeTranslateAction::getName() {
-  return NAME;
-}
Index: c/Actions/MoleculeAction/TranslateAction.hpp
===================================================================
--- src/Actions/MoleculeAction/TranslateAction.hpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ 	(revision )
@@ -1,34 +1,0 @@
-/*
- * TranslateAction.hpp
- *
- *  Created on: May 10, 2010
- *      Author: heber
- */
-
-#ifndef TRANSLATEACTION_HPP
-#define TRANSLATEACTION_HPP
-
-#include "Actions/Action.hpp"
-#include "Actions/Process.hpp"
-
-class MoleculeListClass;
-
-class MoleculeTranslateAction : public Action {
-public:
-  MoleculeTranslateAction();
-  virtual ~MoleculeTranslateAction();
-
-  bool canUndo();
-  bool shouldUndo();
-
-  virtual const std::string getName();
-private:
-  virtual Action::state_ptr performCall();
-  virtual Action::state_ptr performUndo(Action::state_ptr);
-  virtual Action::state_ptr performRedo(Action::state_ptr);
-
-  static const char NAME[];
-};
-
-
-#endif // TRANSLATEACTION_HPP
Index: src/Actions/MoleculeAction/VerletIntegrationAction.cpp
===================================================================
--- src/Actions/MoleculeAction/VerletIntegrationAction.cpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/Actions/MoleculeAction/VerletIntegrationAction.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -6,7 +6,17 @@
  */
 
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
 #include "Helpers/MemDebug.hpp"
 
 #include "Actions/MoleculeAction/VerletIntegrationAction.hpp"
+#include "Actions/ActionRegistry.hpp"
+#include "Helpers/Log.hpp"
+#include "molecule.hpp"
+#include "Helpers/Verbose.hpp"
+#include "World.hpp"
 
 #include <iostream>
@@ -18,11 +28,5 @@
 #include "UIElements/UIFactory.hpp"
 #include "UIElements/Dialog.hpp"
-#include "Actions/MapOfActions.hpp"
-
-#include "atom.hpp"
-#include "log.hpp"
-#include "molecule.hpp"
-#include "verbose.hpp"
-#include "World.hpp"
+#include "Actions/ValueStorage.hpp"
 
 /****** MoleculeVerletIntegrationAction *****/
@@ -49,13 +53,25 @@
 {}
 
+void MoleculeVerletIntegration(std::string &forcesfile) {
+  ValueStorage::getInstance().setCurrentValue(MoleculeVerletIntegrationAction::NAME, forcesfile);
+  ActionRegistry::getInstance().getActionByName(MoleculeVerletIntegrationAction::NAME)->call(Action::NonInteractive);
+};
+
+Dialog* MoleculeVerletIntegrationAction::fillDialog(Dialog *dialog) {
+  ASSERT(dialog,"No Dialog given when filling action dialog");
+
+  dialog->queryString(NAME, ValueStorage::getInstance().getDescription(NAME));
+
+  return dialog;
+}
+
 Action::state_ptr MoleculeVerletIntegrationAction::performCall() {
   string filename;
-  Dialog *dialog = UIFactory::getInstance().makeDialog();
   molecule *mol = NULL;
 
-  dialog->queryString(NAME, &filename, MapOfActions::getInstance().getDescription(NAME));
-  dialog->queryMolecule("molecule-by-id", &mol, MapOfActions::getInstance().getDescription("molecule-by-id"));
+  ValueStorage::getInstance().queryCurrentValue(NAME, filename);
 
-  if(dialog->display()) {
+  for (World::MoleculeSelectionIterator iter = World::getInstance().beginMoleculeSelection(); iter != World::getInstance().endMoleculeSelection(); ++iter) {
+    mol = iter->second;
     DoLog(1) && (Log() << Verbose(1) << "Parsing forces file and Verlet integrating." << endl);
     // TODO: sollte besser stream nutzen, nicht filename direkt (es sei denn, ist prefix), besser fuer unit test
@@ -66,10 +82,6 @@
     else
       DoLog(2) && (Log() << Verbose(2) << "File found and parsed." << endl);
-
-    delete dialog;
-    return Action::success;
   }
-  delete dialog;
-  return Action::failure;
+  return Action::success;
 }
 
Index: src/Actions/MoleculeAction/VerletIntegrationAction.hpp
===================================================================
--- src/Actions/MoleculeAction/VerletIntegrationAction.hpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/Actions/MoleculeAction/VerletIntegrationAction.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -10,9 +10,13 @@
 
 #include "Actions/Action.hpp"
-#include "Actions/Process.hpp"
+
 
 class MoleculeListClass;
 
+void MoleculeVerletIntegration(std::string &forcesfile);
+
 class MoleculeVerletIntegrationAction : public Action {
+  friend void MoleculeVerletIntegration(std::string &forcesfile);
+
 public:
   MoleculeVerletIntegrationAction();
@@ -23,4 +27,6 @@
 
   virtual const std::string getName();
+protected:
+  virtual Dialog * fillDialog(Dialog *dialog);
 private:
   virtual Action::state_ptr performCall();
Index: src/Actions/ParserAction/LoadXyzAction.cpp
===================================================================
--- src/Actions/ParserAction/LoadXyzAction.cpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/Actions/ParserAction/LoadXyzAction.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -6,4 +6,9 @@
  */
 
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
 #include "Helpers/MemDebug.hpp"
 
@@ -11,5 +16,11 @@
 
 #include "Actions/ParserAction/LoadXyzAction.hpp"
+#include "Actions/ActionRegistry.hpp"
 #include "Parser/XyzParser.hpp"
+#include "atom.hpp"
+#include "Helpers/Log.hpp"
+#include "molecule.hpp"
+#include "Helpers/Verbose.hpp"
+#include "World.hpp"
 
 #include <iostream>
@@ -18,14 +29,7 @@
 #include <vector>
 
-
 #include "UIElements/UIFactory.hpp"
 #include "UIElements/Dialog.hpp"
-#include "Actions/MapOfActions.hpp"
-
-#include "atom.hpp"
-#include "log.hpp"
-#include "molecule.hpp"
-#include "verbose.hpp"
-#include "World.hpp"
+#include "Actions/ValueStorage.hpp"
 
 /****** ParserLoadXyzAction *****/
@@ -52,51 +56,34 @@
 {}
 
+void ParserLoadXyz(std::string &filename) {
+  ValueStorage::getInstance().setCurrentValue(ParserLoadXyzAction::NAME, filename);
+  ActionRegistry::getInstance().getActionByName(ParserLoadXyzAction::NAME)->call(Action::NonInteractive);
+};
+
+Dialog* ParserLoadXyzAction::fillDialog(Dialog *dialog) {
+  ASSERT(dialog,"No Dialog given when filling action dialog");
+
+  dialog->queryString(NAME, ValueStorage::getInstance().getDescription(NAME));
+
+  return dialog;
+}
+
 Action::state_ptr ParserLoadXyzAction::performCall() {
   string filename;
-  Dialog *dialog = UIFactory::getInstance().makeDialog();
 
-  dialog->queryString(NAME,&filename, NAME);
+  ValueStorage::getInstance().queryCurrentValue(NAME, filename);
 
-  if(dialog->display()) {
-    DoLog(1) && (Log() << Verbose(1) << "Parsing xyz file for new atoms." << endl);
-    // parse xyz file
-    ifstream input;
-    input.open(filename.c_str());
-    if (!input.fail()) {
-      // TODO: Remove the insertion into molecule when saving does not depend on them anymore. Also, remove molecule.hpp include
-      set <atom*> UniqueList;
-      {
-        vector<atom *> ListBefore = World::getInstance().getAllAtoms();
-        for (vector<atom *>::iterator runner = ListBefore.begin();runner != ListBefore.end(); ++runner)
-          UniqueList.insert(*runner);
-      }
-      XyzParser parser; // briefly instantiate a parser which is removed at end of focus
-      parser.load(&input);
-      {
-        vector<atom *> ListAfter = World::getInstance().getAllAtoms();
-        pair< set<atom *>::iterator, bool > Inserter;
-        if (UniqueList.size() != ListAfter.size()) { // only create if new atoms have been parsed
-          MoleculeListClass *molecules = World::getInstance().getMolecules();
-          molecule *mol = World::getInstance().createMolecule();
-          molecules->insert(mol);
-          for (vector<atom *>::iterator runner = ListAfter.begin(); runner != ListAfter.end(); ++runner) {
-            Inserter = UniqueList.insert(*runner);
-            if (Inserter.second) { // if not present, then new (just parsed) atom, add ...
-              cout << "Adding new atom " << **runner << " to new mol." << endl;
-              mol->AddAtom(*runner);
-            }
-          }
-          mol->doCountAtoms();
-        } else {
-          cout << "No atoms parsed?" << endl;
-        }
-      }
-    } else {
-      DoeLog(1) && (eLog() << Verbose(1) << "Could not open file " << filename << "." << endl);
-    }
-    input.close();
+  DoLog(1) && (Log() << Verbose(1) << "Parsing xyz file for new atoms." << endl);
+  // parse xyz file
+  ifstream input;
+  input.open(filename.c_str());
+  if (!input.fail()) {
+    XyzParser parser; // briefly instantiate a parser which is removed at end of focus
+    parser.load(&input);
+  } else {
+    DoeLog(1) && (eLog() << Verbose(1) << "Could not open file " << filename << "." << endl);
   }
-  delete dialog;
-  return Action::failure;
+  input.close();
+  return Action::success;
 }
 
Index: src/Actions/ParserAction/LoadXyzAction.hpp
===================================================================
--- src/Actions/ParserAction/LoadXyzAction.hpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/Actions/ParserAction/LoadXyzAction.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -10,7 +10,11 @@
 
 #include "Actions/Action.hpp"
-#include "Actions/Process.hpp"
+
+
+void ParserLoadXyz(std::string &filename);
 
 class ParserLoadXyzAction : public Action {
+  friend void ParserLoadXyz(std::string &filename);
+
 public:
   ParserLoadXyzAction();
@@ -21,4 +25,6 @@
 
   virtual const std::string getName();
+protected:
+  virtual Dialog * fillDialog(Dialog *dialog);
 private:
   virtual Action::state_ptr performCall();
Index: src/Actions/ParserAction/SaveXyzAction.cpp
===================================================================
--- src/Actions/ParserAction/SaveXyzAction.cpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/Actions/ParserAction/SaveXyzAction.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -6,8 +6,16 @@
  */
 
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
 #include "Helpers/MemDebug.hpp"
 
 #include "Actions/ParserAction/SaveXyzAction.hpp"
+#include "Actions/ActionRegistry.hpp"
 #include "Parser/XyzParser.hpp"
+#include "atom.hpp"
+#include "molecule.hpp"
 
 #include <iostream>
@@ -18,8 +26,6 @@
 #include "UIElements/UIFactory.hpp"
 #include "UIElements/Dialog.hpp"
-#include "Actions/MapOfActions.hpp"
+#include "Actions/ValueStorage.hpp"
 
-#include "atom.hpp"
-#include "molecule.hpp"
 
 /****** ParserSaveXyzAction *****/
@@ -46,20 +52,29 @@
 {}
 
+void ParserSaveXyz(std::string &filename) {
+  ValueStorage::getInstance().setCurrentValue(ParserSaveXyzAction::NAME, filename);
+  ActionRegistry::getInstance().getActionByName(ParserSaveXyzAction::NAME)->call(Action::NonInteractive);
+};
+
+Dialog* ParserSaveXyzAction::fillDialog(Dialog *dialog) {
+  ASSERT(dialog,"No Dialog given when filling action dialog");
+
+  dialog->queryString(NAME, ValueStorage::getInstance().getDescription(NAME));
+
+  return dialog;
+}
+
 Action::state_ptr ParserSaveXyzAction::performCall() {
   string filename;
   XyzParser parser;
-  Dialog *dialog = UIFactory::getInstance().makeDialog();
 
-  dialog->queryString("filename",&filename, "Filename of the xyz file");
+  ValueStorage::getInstance().queryCurrentValue(NAME, filename);
 
-  if(dialog->display()) {
-    // store xyz file
-    ofstream output;
-    output.open(filename.c_str());
-    if (!output.fail())
-      parser.save(&output);
-    output.close();
-  }
-  delete dialog;
+  // store xyz file
+  ofstream output;
+  output.open(filename.c_str());
+  if (!output.fail())
+    parser.save(&output);
+  output.close();
   return Action::failure;
 }
Index: src/Actions/ParserAction/SaveXyzAction.hpp
===================================================================
--- src/Actions/ParserAction/SaveXyzAction.hpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/Actions/ParserAction/SaveXyzAction.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -10,7 +10,11 @@
 
 #include "Actions/Action.hpp"
-#include "Actions/Process.hpp"
+
+
+void ParserSaveXyz(std::string &filename);
 
 class ParserSaveXyzAction : public Action {
+  friend void ParserSaveXyz(std::string &filename);
+
 public:
   ParserSaveXyzAction();
@@ -21,4 +25,6 @@
 
   virtual const std::string getName();
+protected:
+  virtual Dialog * fillDialog(Dialog *dialog);
 private:
   virtual Action::state_ptr performCall();
Index: src/Actions/Process.cpp
===================================================================
--- src/Actions/Process.cpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/Actions/Process.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -5,4 +5,9 @@
  *      Author: crueger
  */
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
 
 #include "Helpers/MemDebug.hpp"
Index: src/Actions/SelectionAction/AllAtomsAction.cpp
===================================================================
--- src/Actions/SelectionAction/AllAtomsAction.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
+++ src/Actions/SelectionAction/AllAtomsAction.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -0,0 +1,99 @@
+/*
+ * AllAtomsAction.cpp
+ *
+ *  Created on: May 12, 2010
+ *      Author: heber
+ */
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "Helpers/MemDebug.hpp"
+
+#include "Actions/SelectionAction/AllAtomsAction.hpp"
+#include "Actions/ActionRegistry.hpp"
+#include "Descriptors/AtomDescriptor.hpp"
+#include "atom.hpp"
+#include "Helpers/Log.hpp"
+#include "Helpers/Verbose.hpp"
+#include "World.hpp"
+
+#include <iostream>
+#include <string>
+
+using namespace std;
+
+#include "UIElements/UIFactory.hpp"
+#include "UIElements/Dialog.hpp"
+#include "Actions/ValueStorage.hpp"
+
+
+// memento to remember the state when undoing
+
+class SelectionAllAtomsState : public ActionState {
+public:
+  SelectionAllAtomsState(std::vector<atom*> _selectedAtoms) :
+    selectedAtoms(_selectedAtoms)
+  {}
+  std::vector<atom*> selectedAtoms;
+};
+
+const char SelectionAllAtomsAction::NAME[] = "select-all-atoms";
+
+SelectionAllAtomsAction::SelectionAllAtomsAction() :
+  Action(NAME)
+{}
+
+SelectionAllAtomsAction::~SelectionAllAtomsAction()
+{}
+
+void SelectionAllAtoms() {
+  ActionRegistry::getInstance().getActionByName(SelectionAllAtomsAction::NAME)->call(Action::NonInteractive);
+};
+
+Dialog* SelectionAllAtomsAction::fillDialog(Dialog *dialog) {
+  ASSERT(dialog,"No Dialog given when filling action dialog");
+
+  dialog->queryEmpty(NAME, ValueStorage::getInstance().getDescription(NAME));
+
+  return dialog;
+}
+
+Action::state_ptr SelectionAllAtomsAction::performCall() {
+  std::vector<atom *> selectedAtoms = World::getInstance().getSelectedAtoms();
+  DoLog(1) && (Log() << Verbose(1) << "Selecting all atoms." << endl);
+  World::getInstance().selectAllAtoms(AllAtoms());
+  return Action::state_ptr(new SelectionAllAtomsState(selectedAtoms));
+}
+
+Action::state_ptr SelectionAllAtomsAction::performUndo(Action::state_ptr _state) {
+  SelectionAllAtomsState *state = assert_cast<SelectionAllAtomsState*>(_state.get());
+
+  World::getInstance().clearAtomSelection();
+  for(std::vector<atom *>::iterator iter = state->selectedAtoms.begin(); iter != state->selectedAtoms.end(); ++iter)
+    World::getInstance().selectAtom(*iter);
+
+  return Action::state_ptr(new SelectionAllAtomsState(state->selectedAtoms));
+}
+
+Action::state_ptr SelectionAllAtomsAction::performRedo(Action::state_ptr _state){
+  SelectionAllAtomsState *state = assert_cast<SelectionAllAtomsState*>(_state.get());
+
+  World::getInstance().selectAllAtoms(AllAtoms());
+
+  return Action::state_ptr(new SelectionAllAtomsState(state->selectedAtoms));
+}
+
+bool SelectionAllAtomsAction::canUndo() {
+  return true;
+}
+
+bool SelectionAllAtomsAction::shouldUndo() {
+  return true;
+}
+
+const string SelectionAllAtomsAction::getName() {
+  return NAME;
+}
Index: src/Actions/SelectionAction/AllAtomsAction.hpp
===================================================================
--- src/Actions/SelectionAction/AllAtomsAction.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
+++ src/Actions/SelectionAction/AllAtomsAction.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -0,0 +1,36 @@
+/*
+ * AllAtomsAction.hpp
+ *
+ *  Created on: May 12, 2010
+ *      Author: heber
+ */
+
+#ifndef ALLATOMSACTION_HPP_
+#define ALLATOMSACTION_HPP_
+
+#include "Actions/Action.hpp"
+
+void SelectionAllAtoms();
+
+class SelectionAllAtomsAction : public Action {
+  friend void SelectionAllAtoms();
+
+public:
+  SelectionAllAtomsAction();
+  virtual ~SelectionAllAtomsAction();
+
+  bool canUndo();
+  bool shouldUndo();
+
+  virtual const std::string getName();
+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);
+
+  static const char NAME[];
+};
+
+#endif /* ALLATOMSACTION_HPP_ */
Index: src/Actions/SelectionAction/AllAtomsInsideCuboidAction.cpp
===================================================================
--- src/Actions/SelectionAction/AllAtomsInsideCuboidAction.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
+++ src/Actions/SelectionAction/AllAtomsInsideCuboidAction.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -0,0 +1,149 @@
+/*
+ * AllAtomsInsideCuboidAction.cpp
+ *
+ *  Created on: Aug 9, 2010
+ *      Author: heber
+ */
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "Helpers/MemDebug.hpp"
+
+#include "Actions/SelectionAction/AllAtomsInsideCuboidAction.hpp"
+#include "Actions/ActionRegistry.hpp"
+#include "Descriptors/AtomDescriptor.hpp"
+#include "Descriptors/AtomShapeDescriptor.hpp"
+#include "atom.hpp"
+#include "Helpers/Log.hpp"
+#include "Helpers/Verbose.hpp"
+#include "LinearAlgebra/Matrix.hpp"
+#include "LinearAlgebra/Vector.hpp"
+#include "Shapes/BaseShapes.hpp"
+#include "Shapes/Shape.hpp"
+#include "Shapes/ShapeOps.hpp"
+#include "World.hpp"
+
+#include <iostream>
+#include <string>
+
+using namespace std;
+
+#include "UIElements/UIFactory.hpp"
+#include "UIElements/Dialog.hpp"
+#include "Actions/ValueStorage.hpp"
+
+
+// memento to remember the state when undoing
+
+class SelectionAllAtomsInsideCuboidState : public ActionState {
+public:
+  SelectionAllAtomsInsideCuboidState(std::vector<atom*> _selectedAtoms, const Vector &_position, const Vector &_extension, const double _Xangle, const double _Yangle, const double _Zangle) :
+    selectedAtoms(_selectedAtoms),
+    position(_position),
+    extension(_extension),
+    Xangle(_Xangle),
+    Yangle(_Yangle),
+    Zangle(_Zangle)
+  {}
+  std::vector<atom*> selectedAtoms;
+  Vector position;
+  Vector extension;
+  double Xangle;
+  double Yangle;
+  double Zangle;
+};
+
+const char SelectionAllAtomsInsideCuboidAction::NAME[] = "select-atoms-inside-cuboid";
+
+SelectionAllAtomsInsideCuboidAction::SelectionAllAtomsInsideCuboidAction() :
+  Action(NAME)
+{}
+
+SelectionAllAtomsInsideCuboidAction::~SelectionAllAtomsInsideCuboidAction()
+{}
+
+void SelectionAllAtomsInsideCuboid(const Vector &position, const Vector &extension) {
+  ValueStorage::getInstance().setCurrentValue(SelectionAllAtomsInsideCuboidAction::NAME, extension);
+  ValueStorage::getInstance().setCurrentValue("position", position);
+  ActionRegistry::getInstance().getActionByName(SelectionAllAtomsInsideCuboidAction::NAME)->call(Action::NonInteractive);
+};
+
+void SelectionAllAtomsInsideCuboid(const Vector &position, const Vector &extension, const double Xangle, const double Yangle, const double Zangle) {
+  ValueStorage::getInstance().setCurrentValue(SelectionAllAtomsInsideCuboidAction::NAME, extension);
+  ValueStorage::getInstance().setCurrentValue("position", position);
+  ValueStorage::getInstance().setCurrentValue("angle-x", Xangle);
+  ValueStorage::getInstance().setCurrentValue("angle-y", Yangle);
+  ValueStorage::getInstance().setCurrentValue("angle-z", Zangle);
+  ActionRegistry::getInstance().getActionByName(SelectionAllAtomsInsideCuboidAction::NAME)->call(Action::NonInteractive);
+};
+
+Dialog* SelectionAllAtomsInsideCuboidAction::fillDialog(Dialog *dialog) {
+  ASSERT(dialog,"No Dialog given when filling action dialog");
+
+  dialog->queryVector(NAME, false, ValueStorage::getInstance().getDescription(NAME));
+  dialog->queryVector("position", false, ValueStorage::getInstance().getDescription("position"));
+
+  return dialog;
+}
+
+Action::state_ptr SelectionAllAtomsInsideCuboidAction::performCall() {
+  std::vector<atom *> selectedAtoms = World::getInstance().getSelectedAtoms();
+  Vector position;
+  Vector extension;
+  double Xangle = 0.;
+  double Yangle = 0.;
+  double Zangle = 0.;
+  Matrix RotationMatrix;
+
+  ValueStorage::getInstance().queryCurrentValue("position", position);
+  ValueStorage::getInstance().queryCurrentValue(NAME, extension);
+  // check whether a rotation is given.
+  if (ValueStorage::getInstance().queryCurrentValue("angle-x", Xangle, true))
+    Xangle = 0.;
+  if (ValueStorage::getInstance().queryCurrentValue("angle-y", Yangle, true))
+    Yangle = 0.;
+  if (ValueStorage::getInstance().queryCurrentValue("angle-z", Zangle, true))
+    Zangle = 0.;
+  RotationMatrix.rotation(Xangle, Yangle, Zangle);
+
+  DoLog(1) && (Log() << Verbose(1) << "Selecting all atoms inside a rotated " << RotationMatrix << " cuboid at " << position << " and extension of " << extension << "." << endl);
+  Shape s = translate(transform(stretch(Cuboid(),extension),RotationMatrix),position);
+  World::getInstance().selectAllAtoms(AtomByShape(s));
+  return Action::state_ptr(new SelectionAllAtomsInsideCuboidState(selectedAtoms, position, extension, Xangle, Yangle, Zangle));
+}
+
+Action::state_ptr SelectionAllAtomsInsideCuboidAction::performUndo(Action::state_ptr _state) {
+  SelectionAllAtomsInsideCuboidState *state = assert_cast<SelectionAllAtomsInsideCuboidState*>(_state.get());
+
+  World::getInstance().clearAtomSelection();
+  for(std::vector<atom *>::iterator iter = state->selectedAtoms.begin(); iter != state->selectedAtoms.end(); ++iter)
+    World::getInstance().selectAtom(*iter);
+
+  return Action::state_ptr(_state);
+}
+
+Action::state_ptr SelectionAllAtomsInsideCuboidAction::performRedo(Action::state_ptr _state){
+  SelectionAllAtomsInsideCuboidState *state = assert_cast<SelectionAllAtomsInsideCuboidState*>(_state.get());
+  Matrix RotationMatrix;
+
+  RotationMatrix.rotation(state->Xangle, state->Yangle, state->Zangle);
+  Shape s = translate(transform(stretch(Cuboid(),state->extension),RotationMatrix),state->position);
+  World::getInstance().selectAllAtoms(AtomByShape(s));
+
+  return Action::state_ptr(_state);
+}
+
+bool SelectionAllAtomsInsideCuboidAction::canUndo() {
+  return true;
+}
+
+bool SelectionAllAtomsInsideCuboidAction::shouldUndo() {
+  return true;
+}
+
+const string SelectionAllAtomsInsideCuboidAction::getName() {
+  return NAME;
+}
Index: src/Actions/SelectionAction/AllAtomsInsideCuboidAction.hpp
===================================================================
--- src/Actions/SelectionAction/AllAtomsInsideCuboidAction.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
+++ src/Actions/SelectionAction/AllAtomsInsideCuboidAction.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -0,0 +1,39 @@
+/*
+ * AllAtomsInsideCuboidAction.hpp
+ *
+ *  Created on: Aug 9, 2010
+ *      Author: heber
+ */
+
+#ifndef ALLATOMSINSIDECUBOIDACTION_HPP_
+#define ALLATOMSINSIDECUBOIDACTION_HPP_
+
+#include "Actions/Action.hpp"
+
+class Vector;
+
+void SelectionAllAtomsInsideCuboid();
+
+class SelectionAllAtomsInsideCuboidAction : public Action {
+  friend void SelectionAllAtomsInsideCuboid(const Vector &position, const Vector &extension);
+  friend void SelectionAllAtomsInsideCuboid(const Vector &position, const Vector &extension, const double Xangle, const double Yangle, const double Zangle);
+
+public:
+  SelectionAllAtomsInsideCuboidAction();
+  virtual ~SelectionAllAtomsInsideCuboidAction();
+
+  bool canUndo();
+  bool shouldUndo();
+
+  virtual const std::string getName();
+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);
+
+  static const char NAME[];
+};
+
+#endif /* ALLATOMSINSIDECUBOIDACTION_HPP_ */
Index: src/Actions/SelectionAction/AllAtomsInsideSphereAction.cpp
===================================================================
--- src/Actions/SelectionAction/AllAtomsInsideSphereAction.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
+++ src/Actions/SelectionAction/AllAtomsInsideSphereAction.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -0,0 +1,119 @@
+/*
+ * AllAtomsInsideSphereAction.cpp
+ *
+ *  Created on: Aug 9, 2010
+ *      Author: heber
+ */
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "Helpers/MemDebug.hpp"
+
+#include "Actions/SelectionAction/AllAtomsInsideSphereAction.hpp"
+#include "Actions/ActionRegistry.hpp"
+#include "Descriptors/AtomDescriptor.hpp"
+#include "Descriptors/AtomShapeDescriptor.hpp"
+#include "atom.hpp"
+#include "Helpers/Log.hpp"
+#include "Helpers/Verbose.hpp"
+#include "LinearAlgebra/Vector.hpp"
+#include "Shapes/BaseShapes.hpp"
+#include "Shapes/Shape.hpp"
+#include "Shapes/ShapeOps.hpp"
+#include "World.hpp"
+
+#include <iostream>
+#include <string>
+
+using namespace std;
+
+#include "UIElements/UIFactory.hpp"
+#include "UIElements/Dialog.hpp"
+#include "Actions/ValueStorage.hpp"
+
+
+// memento to remember the state when undoing
+
+class SelectionAllAtomsInsideSphereState : public ActionState {
+public:
+  SelectionAllAtomsInsideSphereState(std::vector<atom*> _selectedAtoms, const Vector &_position, const double _radius) :
+    selectedAtoms(_selectedAtoms),
+    position(_position),
+    radius(_radius)
+  {}
+  std::vector<atom*> selectedAtoms;
+  Vector position;
+  double radius;
+};
+
+const char SelectionAllAtomsInsideSphereAction::NAME[] = "select-atoms-inside-sphere";
+
+SelectionAllAtomsInsideSphereAction::SelectionAllAtomsInsideSphereAction() :
+  Action(NAME)
+{}
+
+SelectionAllAtomsInsideSphereAction::~SelectionAllAtomsInsideSphereAction()
+{}
+
+void SelectionAllAtomsInsideSphere(const Vector &position, const double radius) {
+  ValueStorage::getInstance().setCurrentValue(SelectionAllAtomsInsideSphereAction::NAME, radius);
+  ValueStorage::getInstance().setCurrentValue("position", position);
+  ActionRegistry::getInstance().getActionByName(SelectionAllAtomsInsideSphereAction::NAME)->call(Action::NonInteractive);
+};
+
+Dialog* SelectionAllAtomsInsideSphereAction::fillDialog(Dialog *dialog) {
+  ASSERT(dialog,"No Dialog given when filling action dialog");
+
+  dialog->queryDouble(NAME, ValueStorage::getInstance().getDescription(NAME));
+  dialog->queryVector("position", false, ValueStorage::getInstance().getDescription("position"));
+
+  return dialog;
+}
+
+Action::state_ptr SelectionAllAtomsInsideSphereAction::performCall() {
+  std::vector<atom *> selectedAtoms = World::getInstance().getSelectedAtoms();
+  double radius = 0.;
+  Vector position;
+
+  ValueStorage::getInstance().queryCurrentValue(NAME, radius);
+  ValueStorage::getInstance().queryCurrentValue("position", position);
+
+  DoLog(1) && (Log() << Verbose(1) << "Selecting all atoms inside a sphere at " << position << " with radius " << radius << "." << endl);
+  Shape s = translate(resize(Sphere(),radius),position);
+  World::getInstance().selectAllAtoms(AtomByShape(s));
+  return Action::state_ptr(new SelectionAllAtomsInsideSphereState(selectedAtoms, position, radius));
+}
+
+Action::state_ptr SelectionAllAtomsInsideSphereAction::performUndo(Action::state_ptr _state) {
+  SelectionAllAtomsInsideSphereState *state = assert_cast<SelectionAllAtomsInsideSphereState*>(_state.get());
+
+  World::getInstance().clearAtomSelection();
+  for(std::vector<atom *>::iterator iter = state->selectedAtoms.begin(); iter != state->selectedAtoms.end(); ++iter)
+    World::getInstance().selectAtom(*iter);
+
+  return Action::state_ptr(new SelectionAllAtomsInsideSphereState(state->selectedAtoms, state->position, state->radius));
+}
+
+Action::state_ptr SelectionAllAtomsInsideSphereAction::performRedo(Action::state_ptr _state){
+  SelectionAllAtomsInsideSphereState *state = assert_cast<SelectionAllAtomsInsideSphereState*>(_state.get());
+
+  Shape s = translate(resize(Sphere(),state->radius),state->position);
+  World::getInstance().selectAllAtoms(AtomByShape(s));
+
+  return Action::state_ptr(new SelectionAllAtomsInsideSphereState(state->selectedAtoms, state->position, state->radius));
+}
+
+bool SelectionAllAtomsInsideSphereAction::canUndo() {
+  return true;
+}
+
+bool SelectionAllAtomsInsideSphereAction::shouldUndo() {
+  return true;
+}
+
+const string SelectionAllAtomsInsideSphereAction::getName() {
+  return NAME;
+}
Index: src/Actions/SelectionAction/AllAtomsInsideSphereAction.hpp
===================================================================
--- src/Actions/SelectionAction/AllAtomsInsideSphereAction.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
+++ src/Actions/SelectionAction/AllAtomsInsideSphereAction.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -0,0 +1,38 @@
+/*
+ * AllAtomsInsideSphereAction.hpp
+ *
+ *  Created on: Aug 9, 2010
+ *      Author: heber
+ */
+
+#ifndef ALLATOMSINSIDESPHEREACTION_HPP_
+#define ALLATOMSINSIDESPHEREACTION_HPP_
+
+#include "Actions/Action.hpp"
+
+class Vector;
+
+void SelectionAllAtomsInsideSphere();
+
+class SelectionAllAtomsInsideSphereAction : public Action {
+  friend void SelectionAllAtomsInsideSphere(const Vector &position, const double radius);
+
+public:
+  SelectionAllAtomsInsideSphereAction();
+  virtual ~SelectionAllAtomsInsideSphereAction();
+
+  bool canUndo();
+  bool shouldUndo();
+
+  virtual const std::string getName();
+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);
+
+  static const char NAME[];
+};
+
+#endif /* ALLATOMSINSIDESPHEREACTION_HPP_ */
Index: src/Actions/SelectionAction/AllAtomsOfMoleculeAction.cpp
===================================================================
--- src/Actions/SelectionAction/AllAtomsOfMoleculeAction.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
+++ src/Actions/SelectionAction/AllAtomsOfMoleculeAction.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -0,0 +1,106 @@
+/*
+ * AllAtomsOfMoleculeAction.cpp
+ *
+ *  Created on: May 12, 2010
+ *      Author: heber
+ */
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "Helpers/MemDebug.hpp"
+
+#include "Actions/SelectionAction/AllAtomsOfMoleculeAction.hpp"
+#include "Actions/ActionRegistry.hpp"
+#include "Descriptors/AtomDescriptor.hpp"
+#include "atom.hpp"
+#include "molecule.hpp"
+#include "Helpers/Log.hpp"
+#include "Helpers/Verbose.hpp"
+#include "World.hpp"
+
+#include <iostream>
+#include <string>
+
+using namespace std;
+
+#include "UIElements/UIFactory.hpp"
+#include "UIElements/Dialog.hpp"
+#include "Actions/ValueStorage.hpp"
+
+
+// memento to remember the state when undoing
+
+class SelectionAllAtomsOfMoleculeState : public ActionState {
+public:
+  SelectionAllAtomsOfMoleculeState(std::vector<atom*> _selectedAtoms, molecule *_mol) :
+    selectedAtoms(_selectedAtoms),
+    mol(_mol)
+  {}
+  std::vector<atom*> selectedAtoms;
+  molecule *mol;
+};
+
+const char SelectionAllAtomsOfMoleculeAction::NAME[] = "select-molecules-atoms";
+
+SelectionAllAtomsOfMoleculeAction::SelectionAllAtomsOfMoleculeAction() :
+  Action(NAME)
+{}
+
+SelectionAllAtomsOfMoleculeAction::~SelectionAllAtomsOfMoleculeAction()
+{}
+
+void SelectionAllAtomsOfMolecule() {
+  ActionRegistry::getInstance().getActionByName(SelectionAllAtomsOfMoleculeAction::NAME)->call(Action::NonInteractive);
+};
+
+Dialog* SelectionAllAtomsOfMoleculeAction::fillDialog(Dialog *dialog) {
+  ASSERT(dialog,"No Dialog given when filling action dialog");
+
+  dialog->queryMolecule(NAME, ValueStorage::getInstance().getDescription(NAME));
+
+  return dialog;
+}
+
+Action::state_ptr SelectionAllAtomsOfMoleculeAction::performCall() {
+  molecule *mol = NULL;
+  std::vector<atom *> selectedAtoms = World::getInstance().getSelectedAtoms();
+
+  ValueStorage::getInstance().queryCurrentValue(NAME, mol);
+
+  DoLog(1) && (Log() << Verbose(1) << "Selecting all atoms of molecule " << mol->getName() << "." << endl);
+  World::getInstance().selectAtomsOfMolecule(mol);
+  return Action::state_ptr(new SelectionAllAtomsOfMoleculeState(selectedAtoms, mol));
+}
+
+Action::state_ptr SelectionAllAtomsOfMoleculeAction::performUndo(Action::state_ptr _state) {
+  SelectionAllAtomsOfMoleculeState *state = assert_cast<SelectionAllAtomsOfMoleculeState*>(_state.get());
+
+  World::getInstance().clearAtomSelection();
+  for(std::vector<atom *>::iterator iter = state->selectedAtoms.begin(); iter != state->selectedAtoms.end(); ++iter)
+    World::getInstance().selectAtom(*iter);
+
+  return Action::state_ptr(new SelectionAllAtomsOfMoleculeState(state->selectedAtoms, state->mol));
+}
+
+Action::state_ptr SelectionAllAtomsOfMoleculeAction::performRedo(Action::state_ptr _state){
+  SelectionAllAtomsOfMoleculeState *state = assert_cast<SelectionAllAtomsOfMoleculeState*>(_state.get());
+
+  World::getInstance().selectAtomsOfMolecule(state->mol);
+
+  return Action::state_ptr(new SelectionAllAtomsOfMoleculeState(state->selectedAtoms, state->mol));
+}
+
+bool SelectionAllAtomsOfMoleculeAction::canUndo() {
+  return true;
+}
+
+bool SelectionAllAtomsOfMoleculeAction::shouldUndo() {
+  return true;
+}
+
+const string SelectionAllAtomsOfMoleculeAction::getName() {
+  return NAME;
+}
Index: src/Actions/SelectionAction/AllAtomsOfMoleculeAction.hpp
===================================================================
--- src/Actions/SelectionAction/AllAtomsOfMoleculeAction.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
+++ src/Actions/SelectionAction/AllAtomsOfMoleculeAction.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -0,0 +1,36 @@
+/*
+ * AllAtomsOfMoleculeAction.hpp
+ *
+ *  Created on: Aug 09, 2010
+ *      Author: heber
+ */
+
+#ifndef ALLATOMSOFMOLECULEACTION_HPP_
+#define ALLATOMSOFMOLECULEACTION_HPP_
+
+#include "Actions/Action.hpp"
+
+void SelectionAllAtomsOfMolecule();
+
+class SelectionAllAtomsOfMoleculeAction : public Action {
+  friend void SelectionAllAtomsOfMolecule();
+
+public:
+  SelectionAllAtomsOfMoleculeAction();
+  virtual ~SelectionAllAtomsOfMoleculeAction();
+
+  bool canUndo();
+  bool shouldUndo();
+
+  virtual const std::string getName();
+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);
+
+  static const char NAME[];
+};
+
+#endif /* ALLATOMSOFMOLECULEACTION_HPP_ */
Index: src/Actions/SelectionAction/AllMoleculesAction.cpp
===================================================================
--- src/Actions/SelectionAction/AllMoleculesAction.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
+++ src/Actions/SelectionAction/AllMoleculesAction.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -0,0 +1,99 @@
+/*
+ * AllMoleculesAction.cpp
+ *
+ *  Created on: May 12, 2010
+ *      Author: heber
+ */
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "Helpers/MemDebug.hpp"
+
+#include "Actions/SelectionAction/AllMoleculesAction.hpp"
+#include "Actions/ActionRegistry.hpp"
+#include "Descriptors/MoleculeDescriptor.hpp"
+#include "atom.hpp"
+#include "Helpers/Log.hpp"
+#include "Helpers/Verbose.hpp"
+#include "World.hpp"
+
+#include <iostream>
+#include <string>
+
+using namespace std;
+
+#include "UIElements/UIFactory.hpp"
+#include "UIElements/Dialog.hpp"
+#include "Actions/ValueStorage.hpp"
+
+
+// memento to remember the state when undoing
+
+class SelectionAllMoleculesState : public ActionState {
+public:
+  SelectionAllMoleculesState(std::vector<molecule*> selectedMolecules) :
+    selectedMolecules(selectedMolecules)
+  {}
+  std::vector<molecule*> selectedMolecules;
+};
+
+const char SelectionAllMoleculesAction::NAME[] = "select-all-molecules";
+
+SelectionAllMoleculesAction::SelectionAllMoleculesAction() :
+  Action(NAME)
+{}
+
+SelectionAllMoleculesAction::~SelectionAllMoleculesAction()
+{}
+
+void SelectionAllMolecules() {
+  ActionRegistry::getInstance().getActionByName(SelectionAllMoleculesAction::NAME)->call(Action::NonInteractive);
+};
+
+Dialog* SelectionAllMoleculesAction::fillDialog(Dialog *dialog) {
+  ASSERT(dialog,"No Dialog given when filling action dialog");
+
+  dialog->queryEmpty(NAME, ValueStorage::getInstance().getDescription(NAME));
+
+  return dialog;
+}
+
+Action::state_ptr SelectionAllMoleculesAction::performCall() {
+  std::vector<molecule *> selectedMolecules = World::getInstance().getSelectedMolecules();
+  DoLog(1) && (Log() << Verbose(1) << "Selecting all molecules." << endl);
+  World::getInstance().selectAllMolecules(AllMolecules());
+  return Action::state_ptr(new SelectionAllMoleculesState(selectedMolecules));
+}
+
+Action::state_ptr SelectionAllMoleculesAction::performUndo(Action::state_ptr _state) {
+  SelectionAllMoleculesState *state = assert_cast<SelectionAllMoleculesState*>(_state.get());
+
+  World::getInstance().clearMoleculeSelection();
+  for(std::vector<molecule *>::iterator iter = state->selectedMolecules.begin(); iter != state->selectedMolecules.end(); ++iter)
+    World::getInstance().selectMolecule(*iter);
+
+  return Action::state_ptr(new SelectionAllMoleculesState(state->selectedMolecules));
+}
+
+Action::state_ptr SelectionAllMoleculesAction::performRedo(Action::state_ptr _state){
+  SelectionAllMoleculesState *state = assert_cast<SelectionAllMoleculesState*>(_state.get());
+
+  World::getInstance().selectAllMolecules(AllMolecules());
+
+  return Action::state_ptr(new SelectionAllMoleculesState(state->selectedMolecules));
+}
+
+bool SelectionAllMoleculesAction::canUndo() {
+  return true;
+}
+
+bool SelectionAllMoleculesAction::shouldUndo() {
+  return true;
+}
+
+const string SelectionAllMoleculesAction::getName() {
+  return NAME;
+}
Index: src/Actions/SelectionAction/AllMoleculesAction.hpp
===================================================================
--- src/Actions/SelectionAction/AllMoleculesAction.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
+++ src/Actions/SelectionAction/AllMoleculesAction.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -0,0 +1,36 @@
+/*
+ * AllMoleculesAction.hpp
+ *
+ *  Created on: May 12, 2010
+ *      Author: heber
+ */
+
+#ifndef ALLMOLECULESSACTION_HPP_
+#define ALLMOLECULESSACTION_HPP_
+
+#include "Actions/Action.hpp"
+
+void SelectionAllMolecules();
+
+class SelectionAllMoleculesAction : public Action {
+  friend void SelectionAllMolecules();
+
+public:
+  SelectionAllMoleculesAction();
+  virtual ~SelectionAllMoleculesAction();
+
+  bool canUndo();
+  bool shouldUndo();
+
+  virtual const std::string getName();
+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);
+
+  static const char NAME[];
+};
+
+#endif /* ALLMOLECULESSACTION_HPP_ */
Index: src/Actions/SelectionAction/AtomByElementAction.cpp
===================================================================
--- src/Actions/SelectionAction/AtomByElementAction.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
+++ src/Actions/SelectionAction/AtomByElementAction.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -0,0 +1,107 @@
+/*
+ * AtomByElementAction.cpp
+ *
+ *  Created on: May 12, 2010
+ *      Author: heber
+ */
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "Helpers/MemDebug.hpp"
+
+#include "Actions/SelectionAction/AtomByElementAction.hpp"
+#include "Actions/ActionRegistry.hpp"
+#include "Descriptors/AtomTypeDescriptor.hpp"
+#include "atom.hpp"
+#include "element.hpp"
+#include "Helpers/Log.hpp"
+#include "Helpers/Verbose.hpp"
+#include "World.hpp"
+
+#include <iostream>
+#include <string>
+
+using namespace std;
+
+#include "UIElements/UIFactory.hpp"
+#include "UIElements/Dialog.hpp"
+#include "Actions/ValueStorage.hpp"
+
+
+// memento to remember the state when undoing
+
+class SelectionAtomByElementState : public ActionState {
+public:
+  SelectionAtomByElementState(std::vector<atom*> _selectedAtoms, const element *_elemental) :
+    selectedAtoms(_selectedAtoms),
+    elemental(_elemental)
+  {}
+  std::vector<atom*> selectedAtoms;
+  const element *elemental;
+};
+
+const char SelectionAtomByElementAction::NAME[] = "select-atom-by-element";
+
+SelectionAtomByElementAction::SelectionAtomByElementAction() :
+  Action(NAME)
+{}
+
+SelectionAtomByElementAction::~SelectionAtomByElementAction()
+{}
+
+void SelectionAtomByElement(const element &_element) {
+  ValueStorage::getInstance().setCurrentValue(SelectionAtomByElementAction::NAME, _element);
+  ActionRegistry::getInstance().getActionByName(SelectionAtomByElementAction::NAME)->call(Action::NonInteractive);
+};
+
+Dialog* SelectionAtomByElementAction::fillDialog(Dialog *dialog) {
+  ASSERT(dialog,"No Dialog given when filling action dialog");
+
+  dialog->queryElement(NAME, ValueStorage::getInstance().getDescription(NAME));
+
+  return dialog;
+}
+
+Action::state_ptr SelectionAtomByElementAction::performCall() {
+  const element *elemental;
+  std::vector<atom *> selectedAtoms = World::getInstance().getSelectedAtoms();
+
+  ValueStorage::getInstance().queryCurrentValue(NAME, elemental);
+
+  DoLog(1) && (Log() << Verbose(1) << "Selecting atoms of type " << *elemental << endl);
+  World::getInstance().selectAllAtoms(AtomByType(elemental));
+  return Action::state_ptr(new SelectionAtomByElementState(selectedAtoms,elemental));
+}
+
+Action::state_ptr SelectionAtomByElementAction::performUndo(Action::state_ptr _state) {
+  SelectionAtomByElementState *state = assert_cast<SelectionAtomByElementState*>(_state.get());
+
+  World::getInstance().clearAtomSelection();
+  for(std::vector<atom *>::iterator iter = state->selectedAtoms.begin(); iter != state->selectedAtoms.end(); ++iter)
+    World::getInstance().selectAtom(*iter);
+
+  return Action::state_ptr(_state);
+}
+
+Action::state_ptr SelectionAtomByElementAction::performRedo(Action::state_ptr _state){
+  SelectionAtomByElementState *state = assert_cast<SelectionAtomByElementState*>(_state.get());
+
+  World::getInstance().selectAllAtoms(AtomByType(state->elemental));
+
+  return Action::state_ptr(_state);
+}
+
+bool SelectionAtomByElementAction::canUndo() {
+  return true;
+}
+
+bool SelectionAtomByElementAction::shouldUndo() {
+  return true;
+}
+
+const string SelectionAtomByElementAction::getName() {
+  return NAME;
+}
Index: src/Actions/SelectionAction/AtomByElementAction.hpp
===================================================================
--- src/Actions/SelectionAction/AtomByElementAction.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
+++ src/Actions/SelectionAction/AtomByElementAction.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -0,0 +1,38 @@
+/*
+ * AtomByElementAction.hpp
+ *
+ *  Created on: May 12, 2010
+ *      Author: heber
+ */
+
+#ifndef ATOMBYELEMENTACTION_HPP_
+#define ATOMBYELEMENTACTION_HPP_
+
+#include "Actions/Action.hpp"
+
+class element;
+
+void SelectionAtomByElement(const element &_element);
+
+class SelectionAtomByElementAction : public Action {
+  friend void SelectionAtomByElement(const element &_element);
+
+public:
+  SelectionAtomByElementAction();
+  virtual ~SelectionAtomByElementAction();
+
+  bool canUndo();
+  bool shouldUndo();
+
+  virtual const std::string getName();
+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);
+
+  static const char NAME[];
+};
+
+#endif /* ATOMBYELEMENTACTION_HPP_ */
Index: src/Actions/SelectionAction/AtomByIdAction.cpp
===================================================================
--- src/Actions/SelectionAction/AtomByIdAction.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
+++ src/Actions/SelectionAction/AtomByIdAction.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -0,0 +1,106 @@
+/*
+ * AtomByIdAction.cpp
+ *
+ *  Created on: May 12, 2010
+ *      Author: heber
+ */
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "Helpers/MemDebug.hpp"
+
+#include "Actions/SelectionAction/AtomByIdAction.hpp"
+#include "Actions/ActionRegistry.hpp"
+#include "atom.hpp"
+#include "Helpers/Log.hpp"
+#include "Helpers/Verbose.hpp"
+#include "World.hpp"
+
+#include <iostream>
+#include <string>
+
+using namespace std;
+
+#include "UIElements/UIFactory.hpp"
+#include "UIElements/Dialog.hpp"
+#include "Actions/ValueStorage.hpp"
+
+
+// memento to remember the state when undoing
+
+class SelectionAtomByIdState : public ActionState {
+public:
+  SelectionAtomByIdState(atom* _walker) :
+    walker(_walker)
+  {}
+  atom* walker;
+};
+
+const char SelectionAtomByIdAction::NAME[] = "select-atom-by-id";
+
+SelectionAtomByIdAction::SelectionAtomByIdAction() :
+  Action(NAME)
+{}
+
+SelectionAtomByIdAction::~SelectionAtomByIdAction()
+{}
+
+void SelectionAtomById(atom *_atom) {
+  ValueStorage::getInstance().setCurrentValue(SelectionAtomByIdAction::NAME, _atom);
+  ActionRegistry::getInstance().getActionByName(SelectionAtomByIdAction::NAME)->call(Action::NonInteractive);
+};
+
+Dialog* SelectionAtomByIdAction::fillDialog(Dialog *dialog) {
+  ASSERT(dialog,"No Dialog given when filling action dialog");
+
+  dialog->queryAtom(NAME, ValueStorage::getInstance().getDescription(NAME));
+
+  return dialog;
+}
+
+Action::state_ptr SelectionAtomByIdAction::performCall() {
+  atom *Walker = NULL;
+
+  ValueStorage::getInstance().queryCurrentValue(NAME, Walker);
+
+  if (!World::getInstance().isSelected(Walker)) {
+    DoLog(1) && (Log() << Verbose(1) << "Selecting atom " << *Walker << endl);
+    World::getInstance().selectAtom(Walker);
+    return Action::state_ptr(new SelectionAtomByIdState(Walker));
+  } else {
+    return Action::success;
+  }
+}
+
+Action::state_ptr SelectionAtomByIdAction::performUndo(Action::state_ptr _state) {
+  SelectionAtomByIdState *state = assert_cast<SelectionAtomByIdState*>(_state.get());
+
+  if (state->walker != NULL)
+    World::getInstance().unselectAtom(state->walker);
+
+  return Action::state_ptr(new SelectionAtomByIdState(state->walker));
+}
+
+Action::state_ptr SelectionAtomByIdAction::performRedo(Action::state_ptr _state){
+  SelectionAtomByIdState *state = assert_cast<SelectionAtomByIdState*>(_state.get());
+
+  if (state->walker != NULL)
+    World::getInstance().selectAtom(state->walker);
+
+  return Action::state_ptr(new SelectionAtomByIdState(state->walker));
+}
+
+bool SelectionAtomByIdAction::canUndo() {
+  return true;
+}
+
+bool SelectionAtomByIdAction::shouldUndo() {
+  return true;
+}
+
+const string SelectionAtomByIdAction::getName() {
+  return NAME;
+}
Index: src/Actions/SelectionAction/AtomByIdAction.hpp
===================================================================
--- src/Actions/SelectionAction/AtomByIdAction.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
+++ src/Actions/SelectionAction/AtomByIdAction.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -0,0 +1,38 @@
+/*
+ * AtomByIdAction.hpp
+ *
+ *  Created on: May 12, 2010
+ *      Author: heber
+ */
+
+#ifndef ATOMBYIDACTION_HPP_
+#define ATOMBYIDACTION_HPP_
+
+#include "Actions/Action.hpp"
+
+class atom;
+
+void SelectionAtomById(atom *_atom);
+
+class SelectionAtomByIdAction : public Action {
+  friend void SelectionAtomById(atom *_atom);
+
+public:
+  SelectionAtomByIdAction();
+  virtual ~SelectionAtomByIdAction();
+
+  bool canUndo();
+  bool shouldUndo();
+
+  virtual const std::string getName();
+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);
+
+  static const char NAME[];
+};
+
+#endif /* ATOMBYIDACTION_HPP_ */
Index: src/Actions/SelectionAction/ClearAllAtomsAction.cpp
===================================================================
--- src/Actions/SelectionAction/ClearAllAtomsAction.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
+++ src/Actions/SelectionAction/ClearAllAtomsAction.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -0,0 +1,99 @@
+/*
+ * ClearAllAtomsAction.cpp
+ *
+ *  Created on: Aug 09, 2010
+ *      Author: heber
+ */
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "Helpers/MemDebug.hpp"
+
+#include "Actions/SelectionAction/ClearAllAtomsAction.hpp"
+#include "Actions/ActionRegistry.hpp"
+#include "Descriptors/AtomDescriptor.hpp"
+#include "atom.hpp"
+#include "Helpers/Log.hpp"
+#include "Helpers/Verbose.hpp"
+#include "World.hpp"
+
+#include <iostream>
+#include <string>
+
+using namespace std;
+
+#include "UIElements/UIFactory.hpp"
+#include "UIElements/Dialog.hpp"
+#include "Actions/ValueStorage.hpp"
+
+
+// memento to remember the state when undoing
+
+class SelectionClearAllAtomsState : public ActionState {
+public:
+  SelectionClearAllAtomsState(std::vector<atom*> _selectedAtoms) :
+    selectedAtoms(_selectedAtoms)
+  {}
+  std::vector<atom*> selectedAtoms;
+};
+
+const char SelectionClearAllAtomsAction::NAME[] = "clear-atom-selection";
+
+SelectionClearAllAtomsAction::SelectionClearAllAtomsAction() :
+  Action(NAME)
+{}
+
+SelectionClearAllAtomsAction::~SelectionClearAllAtomsAction()
+{}
+
+void SelectionClearAllAtoms() {
+  ActionRegistry::getInstance().getActionByName(SelectionClearAllAtomsAction::NAME)->call(Action::NonInteractive);
+};
+
+Dialog* SelectionClearAllAtomsAction::fillDialog(Dialog *dialog) {
+  ASSERT(dialog,"No Dialog given when filling action dialog");
+
+  dialog->queryEmpty(NAME, ValueStorage::getInstance().getDescription(NAME));
+
+  return dialog;
+}
+
+Action::state_ptr SelectionClearAllAtomsAction::performCall() {
+  std::vector<atom *> selectedAtoms = World::getInstance().getSelectedAtoms();
+  DoLog(1) && (Log() << Verbose(1) << "Clearing atoms selection." << endl);
+  World::getInstance().clearAtomSelection();
+  return Action::state_ptr(new SelectionClearAllAtomsState(selectedAtoms));
+}
+
+Action::state_ptr SelectionClearAllAtomsAction::performUndo(Action::state_ptr _state) {
+  SelectionClearAllAtomsState *state = assert_cast<SelectionClearAllAtomsState*>(_state.get());
+
+  World::getInstance().clearAtomSelection();
+  for(std::vector<atom *>::iterator iter = state->selectedAtoms.begin(); iter != state->selectedAtoms.end(); ++iter)
+    World::getInstance().selectAtom(*iter);
+
+  return Action::state_ptr(new SelectionClearAllAtomsState(state->selectedAtoms));
+}
+
+Action::state_ptr SelectionClearAllAtomsAction::performRedo(Action::state_ptr _state){
+  SelectionClearAllAtomsState *state = assert_cast<SelectionClearAllAtomsState*>(_state.get());
+
+  World::getInstance().clearAtomSelection();
+
+  return Action::state_ptr(new SelectionClearAllAtomsState(state->selectedAtoms));
+}
+
+bool SelectionClearAllAtomsAction::canUndo() {
+  return true;
+}
+
+bool SelectionClearAllAtomsAction::shouldUndo() {
+  return true;
+}
+
+const string SelectionClearAllAtomsAction::getName() {
+  return NAME;
+}
Index: src/Actions/SelectionAction/ClearAllAtomsAction.hpp
===================================================================
--- src/Actions/SelectionAction/ClearAllAtomsAction.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
+++ src/Actions/SelectionAction/ClearAllAtomsAction.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -0,0 +1,36 @@
+/*
+ * ClearAllAtomsAction.hpp
+ *
+ *  Created on: Aug 09, 2010
+ *      Author: heber
+ */
+
+#ifndef CLEARALLATOMSACTION_HPP_
+#define CLEARALLATOMSACTION_HPP_
+
+#include "Actions/Action.hpp"
+
+void SelectionAllAtoms();
+
+class SelectionClearAllAtomsAction : public Action {
+  friend void SelectionClearAllAtoms();
+
+public:
+  SelectionClearAllAtomsAction();
+  virtual ~SelectionClearAllAtomsAction();
+
+  bool canUndo();
+  bool shouldUndo();
+
+  virtual const std::string getName();
+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);
+
+  static const char NAME[];
+};
+
+#endif /* CLEARALLATOMSACTION_HPP_ */
Index: src/Actions/SelectionAction/ClearAllMoleculesAction.cpp
===================================================================
--- src/Actions/SelectionAction/ClearAllMoleculesAction.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
+++ src/Actions/SelectionAction/ClearAllMoleculesAction.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -0,0 +1,99 @@
+/*
+ * ClearAllMoleculesAction.cpp
+ *
+ *  Created on: Aug 09, 2010
+ *      Author: heber
+ */
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "Helpers/MemDebug.hpp"
+
+#include "Actions/SelectionAction/ClearAllMoleculesAction.hpp"
+#include "Actions/ActionRegistry.hpp"
+#include "Descriptors/MoleculeDescriptor.hpp"
+#include "atom.hpp"
+#include "Helpers/Log.hpp"
+#include "Helpers/Verbose.hpp"
+#include "World.hpp"
+
+#include <iostream>
+#include <string>
+
+using namespace std;
+
+#include "UIElements/UIFactory.hpp"
+#include "UIElements/Dialog.hpp"
+#include "Actions/ValueStorage.hpp"
+
+
+// memento to remember the state when undoing
+
+class SelectionClearAllMoleculesState : public ActionState {
+public:
+  SelectionClearAllMoleculesState(std::vector<molecule*> selectedMolecules) :
+    selectedMolecules(selectedMolecules)
+  {}
+  std::vector<molecule*> selectedMolecules;
+};
+
+const char SelectionClearAllMoleculesAction::NAME[] = "clear-molecule-selection";
+
+SelectionClearAllMoleculesAction::SelectionClearAllMoleculesAction() :
+  Action(NAME)
+{}
+
+SelectionClearAllMoleculesAction::~SelectionClearAllMoleculesAction()
+{}
+
+void SelectionClearAllMolecules() {
+  ActionRegistry::getInstance().getActionByName(SelectionClearAllMoleculesAction::NAME)->call(Action::NonInteractive);
+};
+
+Dialog* SelectionClearAllMoleculesAction::fillDialog(Dialog *dialog) {
+  ASSERT(dialog,"No Dialog given when filling action dialog");
+
+  dialog->queryEmpty(NAME, ValueStorage::getInstance().getDescription(NAME));
+
+  return dialog;
+}
+
+Action::state_ptr SelectionClearAllMoleculesAction::performCall() {
+  std::vector<molecule *> selectedMolecules = World::getInstance().getSelectedMolecules();
+  DoLog(1) && (Log() << Verbose(1) << "Clearing molecule selection." << endl);
+  World::getInstance().clearMoleculeSelection();
+  return Action::state_ptr(new SelectionClearAllMoleculesState(selectedMolecules));
+}
+
+Action::state_ptr SelectionClearAllMoleculesAction::performUndo(Action::state_ptr _state) {
+  SelectionClearAllMoleculesState *state = assert_cast<SelectionClearAllMoleculesState*>(_state.get());
+
+  World::getInstance().clearMoleculeSelection();
+  for(std::vector<molecule *>::iterator iter = state->selectedMolecules.begin(); iter != state->selectedMolecules.end(); ++iter)
+    World::getInstance().selectMolecule(*iter);
+
+  return Action::state_ptr(new SelectionClearAllMoleculesState(state->selectedMolecules));
+}
+
+Action::state_ptr SelectionClearAllMoleculesAction::performRedo(Action::state_ptr _state){
+  SelectionClearAllMoleculesState *state = assert_cast<SelectionClearAllMoleculesState*>(_state.get());
+
+  World::getInstance().clearMoleculeSelection();
+
+  return Action::state_ptr(new SelectionClearAllMoleculesState(state->selectedMolecules));
+}
+
+bool SelectionClearAllMoleculesAction::canUndo() {
+  return true;
+}
+
+bool SelectionClearAllMoleculesAction::shouldUndo() {
+  return true;
+}
+
+const string SelectionClearAllMoleculesAction::getName() {
+  return NAME;
+}
Index: src/Actions/SelectionAction/ClearAllMoleculesAction.hpp
===================================================================
--- src/Actions/SelectionAction/ClearAllMoleculesAction.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
+++ src/Actions/SelectionAction/ClearAllMoleculesAction.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -0,0 +1,36 @@
+/*
+ * ClearAllMoleculesAction.hpp
+ *
+ *  Created on: Aug 09, 2010
+ *      Author: heber
+ */
+
+#ifndef CLEARALLMOLECULESSACTION_HPP_
+#define CLEARALLMOLECULESSACTION_HPP_
+
+#include "Actions/Action.hpp"
+
+void SelectionClearAllMolecules();
+
+class SelectionClearAllMoleculesAction : public Action {
+  friend void SelectionClearAllMolecules();
+
+public:
+  SelectionClearAllMoleculesAction();
+  virtual ~SelectionClearAllMoleculesAction();
+
+  bool canUndo();
+  bool shouldUndo();
+
+  virtual const std::string getName();
+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);
+
+  static const char NAME[];
+};
+
+#endif /* CLEARALLMOLECULESSACTION_HPP_ */
Index: src/Actions/SelectionAction/MoleculeByFormulaAction.cpp
===================================================================
--- src/Actions/SelectionAction/MoleculeByFormulaAction.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
+++ src/Actions/SelectionAction/MoleculeByFormulaAction.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -0,0 +1,110 @@
+/*
+ * MoleculeByFormulaAction.cpp
+ *
+ *  Created on: May 12, 2010
+ *      Author: heber
+ */
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "Helpers/MemDebug.hpp"
+
+#include "Actions/SelectionAction/MoleculeByFormulaAction.hpp"
+#include "Actions/ActionRegistry.hpp"
+#include "Descriptors/MoleculeFormulaDescriptor.hpp"
+#include "molecule.hpp"
+#include "Helpers/Log.hpp"
+#include "Helpers/Verbose.hpp"
+#include "World.hpp"
+
+#include <iostream>
+#include <string>
+
+using namespace std;
+
+#include "UIElements/UIFactory.hpp"
+#include "UIElements/Dialog.hpp"
+#include "Actions/ValueStorage.hpp"
+
+
+// memento to remember the state when undoing
+
+class SelectionMoleculeByFormulaState : public ActionState {
+public:
+  SelectionMoleculeByFormulaState(std::vector<molecule*> selectedMolecules, const std::string &_formula) :
+    selectedMolecules(selectedMolecules),
+    formula(_formula)
+  {}
+  std::vector<molecule*> selectedMolecules;
+  std::string formula;
+};
+
+const char SelectionMoleculeByFormulaAction::NAME[] = "select-molecule-by-formula";
+
+SelectionMoleculeByFormulaAction::SelectionMoleculeByFormulaAction() :
+  Action(NAME)
+{}
+
+SelectionMoleculeByFormulaAction::~SelectionMoleculeByFormulaAction()
+{}
+
+void SelectionMoleculeByFormula(const std::string &_formula) {
+  ValueStorage::getInstance().setCurrentValue(SelectionMoleculeByFormulaAction::NAME, _formula);
+  ActionRegistry::getInstance().getActionByName(SelectionMoleculeByFormulaAction::NAME)->call(Action::NonInteractive);
+};
+
+Dialog* SelectionMoleculeByFormulaAction::fillDialog(Dialog *dialog) {
+  ASSERT(dialog,"No Dialog given when filling action dialog");
+
+  dialog->queryString(NAME, ValueStorage::getInstance().getDescription(NAME));
+
+  return dialog;
+}
+
+Action::state_ptr SelectionMoleculeByFormulaAction::performCall() {
+  std::string formula;
+  std::vector<molecule *> selectedMolecules = World::getInstance().getSelectedMolecules();
+
+  ValueStorage::getInstance().queryCurrentValue(NAME, formula);
+
+  DoLog(1) && (Log() << Verbose(1) << "Selecting molecules with chemical formula " << formula << ":" << endl);
+  std::vector<molecule *> matchingMolecules = World::getInstance().getAllMolecules(MoleculeByFormula(formula));
+  for (std::vector<molecule *>::const_iterator iter = matchingMolecules.begin(); iter != matchingMolecules.end(); ++iter) {
+    DoLog(1) && (Log() << Verbose(1) << "\t" << (*iter)->getId() << ", " << (*iter)->getName() << "." << endl);
+  }
+  World::getInstance().selectAllMolecules(MoleculeByFormula(formula));
+  return Action::state_ptr(new SelectionMoleculeByFormulaState(selectedMolecules,formula));
+}
+
+Action::state_ptr SelectionMoleculeByFormulaAction::performUndo(Action::state_ptr _state) {
+  SelectionMoleculeByFormulaState *state = assert_cast<SelectionMoleculeByFormulaState*>(_state.get());
+
+  World::getInstance().clearMoleculeSelection();
+  for(std::vector<molecule *>::iterator iter = state->selectedMolecules.begin(); iter != state->selectedMolecules.end(); ++iter)
+    World::getInstance().selectMolecule(*iter);
+
+  return Action::state_ptr(_state);
+}
+
+Action::state_ptr SelectionMoleculeByFormulaAction::performRedo(Action::state_ptr _state){
+  SelectionMoleculeByFormulaState *state = assert_cast<SelectionMoleculeByFormulaState*>(_state.get());
+
+  World::getInstance().selectAllMolecules(MoleculeByFormula(state->formula));
+
+  return Action::state_ptr(_state);
+}
+
+bool SelectionMoleculeByFormulaAction::canUndo() {
+  return true;
+}
+
+bool SelectionMoleculeByFormulaAction::shouldUndo() {
+  return true;
+}
+
+const string SelectionMoleculeByFormulaAction::getName() {
+  return NAME;
+}
Index: src/Actions/SelectionAction/MoleculeByFormulaAction.hpp
===================================================================
--- src/Actions/SelectionAction/MoleculeByFormulaAction.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
+++ src/Actions/SelectionAction/MoleculeByFormulaAction.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -0,0 +1,38 @@
+/*
+ * MoleculeByFormulaAction.hpp
+ *
+ *  Created on: May 12, 2010
+ *      Author: heber
+ */
+
+#ifndef MOLECULEBYFORMULAACTION_HPP_
+#define MOLECULEBYFORMULAACTION_HPP_
+
+#include "Actions/Action.hpp"
+
+class molecule;
+
+void SelectionMoleculeByFormula(molecule *_mol);
+
+class SelectionMoleculeByFormulaAction : public Action {
+  friend void SelectionMoleculeByFormula(const std::string &_formula);
+
+public:
+  SelectionMoleculeByFormulaAction();
+  virtual ~SelectionMoleculeByFormulaAction();
+
+  bool canUndo();
+  bool shouldUndo();
+
+  virtual const std::string getName();
+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);
+
+  static const char NAME[];
+};
+
+#endif /* MOLECULEBYFORMULAACTION_HPP_ */
Index: src/Actions/SelectionAction/MoleculeByIdAction.cpp
===================================================================
--- src/Actions/SelectionAction/MoleculeByIdAction.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
+++ src/Actions/SelectionAction/MoleculeByIdAction.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -0,0 +1,106 @@
+/*
+ * MoleculeByIdAction.cpp
+ *
+ *  Created on: May 12, 2010
+ *      Author: heber
+ */
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "Helpers/MemDebug.hpp"
+
+#include "Actions/SelectionAction/MoleculeByIdAction.hpp"
+#include "Actions/ActionRegistry.hpp"
+#include "molecule.hpp"
+#include "Helpers/Log.hpp"
+#include "Helpers/Verbose.hpp"
+#include "World.hpp"
+
+#include <iostream>
+#include <string>
+
+using namespace std;
+
+#include "UIElements/UIFactory.hpp"
+#include "UIElements/Dialog.hpp"
+#include "Actions/ValueStorage.hpp"
+
+
+// memento to remember the state when undoing
+
+class SelectionMoleculeByIdState : public ActionState {
+public:
+  SelectionMoleculeByIdState(molecule* _mol) :
+    mol(_mol)
+  {}
+  molecule* mol;
+};
+
+const char SelectionMoleculeByIdAction::NAME[] = "select-molecule-by-id";
+
+SelectionMoleculeByIdAction::SelectionMoleculeByIdAction() :
+  Action(NAME)
+{}
+
+SelectionMoleculeByIdAction::~SelectionMoleculeByIdAction()
+{}
+
+void SelectionMoleculeById(molecule *_mol) {
+  ValueStorage::getInstance().setCurrentValue(SelectionMoleculeByIdAction::NAME, _mol);
+  ActionRegistry::getInstance().getActionByName(SelectionMoleculeByIdAction::NAME)->call(Action::NonInteractive);
+};
+
+Dialog* SelectionMoleculeByIdAction::fillDialog(Dialog *dialog) {
+  ASSERT(dialog,"No Dialog given when filling action dialog");
+
+  dialog->queryMolecule(NAME, ValueStorage::getInstance().getDescription(NAME));
+
+  return dialog;
+}
+
+Action::state_ptr SelectionMoleculeByIdAction::performCall() {
+  molecule *mol = NULL;
+
+  ValueStorage::getInstance().queryCurrentValue(NAME, mol);
+
+  if (!World::getInstance().isSelected(mol)) {
+    DoLog(1) && (Log() << Verbose(1) << "Selecting molecule " << mol->name << endl);
+    World::getInstance().selectMolecule(mol);
+    return Action::state_ptr(new SelectionMoleculeByIdState(mol));
+  } else {
+    return Action::success;
+  }
+}
+
+Action::state_ptr SelectionMoleculeByIdAction::performUndo(Action::state_ptr _state) {
+  SelectionMoleculeByIdState *state = assert_cast<SelectionMoleculeByIdState*>(_state.get());
+
+  if (state->mol != NULL)
+    World::getInstance().unselectMolecule(state->mol);
+
+  return Action::state_ptr(new SelectionMoleculeByIdState(state->mol));
+}
+
+Action::state_ptr SelectionMoleculeByIdAction::performRedo(Action::state_ptr _state){
+  SelectionMoleculeByIdState *state = assert_cast<SelectionMoleculeByIdState*>(_state.get());
+
+  if (state->mol != NULL)
+    World::getInstance().selectMolecule(state->mol);
+
+  return Action::state_ptr(new SelectionMoleculeByIdState(state->mol));
+}
+
+bool SelectionMoleculeByIdAction::canUndo() {
+  return true;
+}
+
+bool SelectionMoleculeByIdAction::shouldUndo() {
+  return true;
+}
+
+const string SelectionMoleculeByIdAction::getName() {
+  return NAME;
+}
Index: src/Actions/SelectionAction/MoleculeByIdAction.hpp
===================================================================
--- src/Actions/SelectionAction/MoleculeByIdAction.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
+++ src/Actions/SelectionAction/MoleculeByIdAction.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -0,0 +1,38 @@
+/*
+ * MoleculeByIdAction.hpp
+ *
+ *  Created on: May 12, 2010
+ *      Author: heber
+ */
+
+#ifndef MOLECULEBYIDACTION_HPP_
+#define MOLECULEBYIDACTION_HPP_
+
+#include "Actions/Action.hpp"
+
+class molecule;
+
+void SelectionMoleculeById(molecule *_mol);
+
+class SelectionMoleculeByIdAction : public Action {
+  friend void SelectionMoleculeById(molecule *_mol);
+
+public:
+  SelectionMoleculeByIdAction();
+  virtual ~SelectionMoleculeByIdAction();
+
+  bool canUndo();
+  bool shouldUndo();
+
+  virtual const std::string getName();
+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);
+
+  static const char NAME[];
+};
+
+#endif /* MOLECULEBYIDACTION_HPP_ */
Index: src/Actions/SelectionAction/MoleculeOfAtomAction.cpp
===================================================================
--- src/Actions/SelectionAction/MoleculeOfAtomAction.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
+++ src/Actions/SelectionAction/MoleculeOfAtomAction.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -0,0 +1,105 @@
+/*
+ * MoleculeOfAtomAction.cpp
+ *
+ *  Created on: May 12, 2010
+ *      Author: heber
+ */
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "Helpers/MemDebug.hpp"
+
+#include "Actions/SelectionAction/MoleculeOfAtomAction.hpp"
+#include "Actions/ActionRegistry.hpp"
+#include "Descriptors/MoleculeDescriptor.hpp"
+#include "atom.hpp"
+#include "Helpers/Log.hpp"
+#include "Helpers/Verbose.hpp"
+#include "World.hpp"
+
+#include <iostream>
+#include <string>
+
+using namespace std;
+
+#include "UIElements/UIFactory.hpp"
+#include "UIElements/Dialog.hpp"
+#include "Actions/ValueStorage.hpp"
+
+
+// memento to remember the state when undoing
+
+class SelectionMoleculeOfAtomState : public ActionState {
+public:
+  SelectionMoleculeOfAtomState(std::vector<molecule*> selectedMolecules, atom *_Walker) :
+    selectedMolecules(selectedMolecules),
+    Walker(_Walker)
+  {}
+  std::vector<molecule*> selectedMolecules;
+  atom *Walker;
+};
+
+const char SelectionMoleculeOfAtomAction::NAME[] = "select-molecule-of-atom";
+
+SelectionMoleculeOfAtomAction::SelectionMoleculeOfAtomAction() :
+  Action(NAME)
+{}
+
+SelectionMoleculeOfAtomAction::~SelectionMoleculeOfAtomAction()
+{}
+
+void SelectionMoleculeOfAtom() {
+  ActionRegistry::getInstance().getActionByName(SelectionMoleculeOfAtomAction::NAME)->call(Action::NonInteractive);
+};
+
+Dialog* SelectionMoleculeOfAtomAction::fillDialog(Dialog *dialog) {
+  ASSERT(dialog,"No Dialog given when filling action dialog");
+
+  dialog->queryAtom(NAME, ValueStorage::getInstance().getDescription(NAME));
+
+  return dialog;
+}
+
+Action::state_ptr SelectionMoleculeOfAtomAction::performCall() {
+  atom *Walker = NULL;
+
+  ValueStorage::getInstance().queryCurrentValue(NAME, Walker);
+
+  std::vector<molecule *> selectedMolecules = World::getInstance().getSelectedMolecules();
+  DoLog(1) && (Log() << Verbose(1) << "Selecting molecule to which " << Walker->getName() << " belongs." << endl);
+  World::getInstance().selectMoleculeOfAtom(Walker);
+  return Action::state_ptr(new SelectionMoleculeOfAtomState(selectedMolecules, Walker));
+}
+
+Action::state_ptr SelectionMoleculeOfAtomAction::performUndo(Action::state_ptr _state) {
+  SelectionMoleculeOfAtomState *state = assert_cast<SelectionMoleculeOfAtomState*>(_state.get());
+
+  World::getInstance().clearMoleculeSelection();
+  for(std::vector<molecule *>::iterator iter = state->selectedMolecules.begin(); iter != state->selectedMolecules.end(); ++iter)
+    World::getInstance().selectMolecule(*iter);
+
+  return Action::state_ptr(new SelectionMoleculeOfAtomState(state->selectedMolecules, state->Walker));
+}
+
+Action::state_ptr SelectionMoleculeOfAtomAction::performRedo(Action::state_ptr _state){
+  SelectionMoleculeOfAtomState *state = assert_cast<SelectionMoleculeOfAtomState*>(_state.get());
+
+  World::getInstance().selectMoleculeOfAtom(state->Walker);
+
+  return Action::state_ptr(new SelectionMoleculeOfAtomState(state->selectedMolecules, state->Walker));
+}
+
+bool SelectionMoleculeOfAtomAction::canUndo() {
+  return true;
+}
+
+bool SelectionMoleculeOfAtomAction::shouldUndo() {
+  return true;
+}
+
+const string SelectionMoleculeOfAtomAction::getName() {
+  return NAME;
+}
Index: src/Actions/SelectionAction/MoleculeOfAtomAction.hpp
===================================================================
--- src/Actions/SelectionAction/MoleculeOfAtomAction.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
+++ src/Actions/SelectionAction/MoleculeOfAtomAction.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -0,0 +1,36 @@
+/*
+ * MoleculeOfAtomAction.hpp
+ *
+ *  Created on: May 12, 2010
+ *      Author: heber
+ */
+
+#ifndef MOLECULEOFATOMSACTION_HPP_
+#define MOLECULEOFATOMSACTION_HPP_
+
+#include "Actions/Action.hpp"
+
+void SelectionMoleculeOfAtom();
+
+class SelectionMoleculeOfAtomAction : public Action {
+  friend void SelectionMoleculeOfAtom();
+
+public:
+  SelectionMoleculeOfAtomAction();
+  virtual ~SelectionMoleculeOfAtomAction();
+
+  bool canUndo();
+  bool shouldUndo();
+
+  virtual const std::string getName();
+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);
+
+  static const char NAME[];
+};
+
+#endif /* MOLECULEOFATOMSACTION_HPP_ */
Index: src/Actions/SelectionAction/NotAllAtomsAction.cpp
===================================================================
--- src/Actions/SelectionAction/NotAllAtomsAction.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
+++ src/Actions/SelectionAction/NotAllAtomsAction.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -0,0 +1,99 @@
+/*
+ * NotAllAtomsAction.cpp
+ *
+ *  Created on: May 12, 2010
+ *      Author: heber
+ */
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "Helpers/MemDebug.hpp"
+
+#include "Actions/SelectionAction/NotAllAtomsAction.hpp"
+#include "Actions/ActionRegistry.hpp"
+#include "Descriptors/AtomDescriptor.hpp"
+#include "atom.hpp"
+#include "Helpers/Log.hpp"
+#include "Helpers/Verbose.hpp"
+#include "World.hpp"
+
+#include <iostream>
+#include <string>
+
+using namespace std;
+
+#include "UIElements/UIFactory.hpp"
+#include "UIElements/Dialog.hpp"
+#include "Actions/ValueStorage.hpp"
+
+
+// memento to remember the state when undoing
+
+class SelectionNotAllAtomsState : public ActionState {
+public:
+  SelectionNotAllAtomsState(std::vector<atom*> _selectedAtoms) :
+    selectedAtoms(_selectedAtoms)
+  {}
+  std::vector<atom*> selectedAtoms;
+};
+
+const char SelectionNotAllAtomsAction::NAME[] = "unselect-all-atoms";
+
+SelectionNotAllAtomsAction::SelectionNotAllAtomsAction() :
+  Action(NAME)
+{}
+
+SelectionNotAllAtomsAction::~SelectionNotAllAtomsAction()
+{}
+
+void SelectionNotAllAtoms() {
+  ActionRegistry::getInstance().getActionByName(SelectionNotAllAtomsAction::NAME)->call(Action::NonInteractive);
+};
+
+Dialog* SelectionNotAllAtomsAction::fillDialog(Dialog *dialog) {
+  ASSERT(dialog,"No Dialog given when filling action dialog");
+
+  dialog->queryEmpty(NAME, ValueStorage::getInstance().getDescription(NAME));
+
+  return dialog;
+}
+
+Action::state_ptr SelectionNotAllAtomsAction::performCall() {
+  std::vector<atom *> selectedAtoms = World::getInstance().getSelectedAtoms();
+  DoLog(1) && (Log() << Verbose(1) << "Unselecting all atoms." << endl);
+  World::getInstance().clearAtomSelection();
+  return Action::state_ptr(new SelectionNotAllAtomsState(selectedAtoms));
+}
+
+Action::state_ptr SelectionNotAllAtomsAction::performUndo(Action::state_ptr _state) {
+  SelectionNotAllAtomsState *state = assert_cast<SelectionNotAllAtomsState*>(_state.get());
+
+  World::getInstance().clearAtomSelection();
+  for(std::vector<atom *>::iterator iter = state->selectedAtoms.begin(); iter != state->selectedAtoms.end(); ++iter)
+    World::getInstance().selectAtom(*iter);
+
+  return Action::state_ptr(new SelectionNotAllAtomsState(state->selectedAtoms));
+}
+
+Action::state_ptr SelectionNotAllAtomsAction::performRedo(Action::state_ptr _state){
+  SelectionNotAllAtomsState *state = assert_cast<SelectionNotAllAtomsState*>(_state.get());
+
+  World::getInstance().clearAtomSelection();
+
+  return Action::state_ptr(new SelectionNotAllAtomsState(state->selectedAtoms));
+}
+
+bool SelectionNotAllAtomsAction::canUndo() {
+  return true;
+}
+
+bool SelectionNotAllAtomsAction::shouldUndo() {
+  return true;
+}
+
+const string SelectionNotAllAtomsAction::getName() {
+  return NAME;
+}
Index: src/Actions/SelectionAction/NotAllAtomsAction.hpp
===================================================================
--- src/Actions/SelectionAction/NotAllAtomsAction.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
+++ src/Actions/SelectionAction/NotAllAtomsAction.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -0,0 +1,36 @@
+/*
+ * NotAllAtomsAction.hpp
+ *
+ *  Created on: May 12, 2010
+ *      Author: heber
+ */
+
+#ifndef NOTALLATOMSACTION_HPP_
+#define NOTALLATOMSACTION_HPP_
+
+#include "Actions/Action.hpp"
+
+void SelectionNotAllAtoms();
+
+class SelectionNotAllAtomsAction : public Action {
+  friend void SelectionNotAllAtoms();
+
+public:
+  SelectionNotAllAtomsAction();
+  virtual ~SelectionNotAllAtomsAction();
+
+  bool canUndo();
+  bool shouldUndo();
+
+  virtual const std::string getName();
+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);
+
+  static const char NAME[];
+};
+
+#endif /* NOTALLATOMSACTION_HPP_ */
Index: src/Actions/SelectionAction/NotAllAtomsInsideCuboidAction.cpp
===================================================================
--- src/Actions/SelectionAction/NotAllAtomsInsideCuboidAction.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
+++ src/Actions/SelectionAction/NotAllAtomsInsideCuboidAction.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -0,0 +1,150 @@
+/*
+ * NotAllAtomsInsideCuboidAction.cpp
+ *
+ *  Created on: Aug 9, 2010
+ *      Author: heber
+ */
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "Helpers/MemDebug.hpp"
+
+#include "Actions/SelectionAction/NotAllAtomsInsideCuboidAction.hpp"
+#include "Actions/ActionRegistry.hpp"
+#include "Descriptors/AtomDescriptor.hpp"
+#include "Descriptors/AtomShapeDescriptor.hpp"
+#include "atom.hpp"
+#include "Helpers/Log.hpp"
+#include "Helpers/Verbose.hpp"
+#include "LinearAlgebra/Matrix.hpp"
+#include "LinearAlgebra/Vector.hpp"
+#include "Shapes/BaseShapes.hpp"
+#include "Shapes/Shape.hpp"
+#include "Shapes/ShapeOps.hpp"
+#include "World.hpp"
+
+#include <iostream>
+#include <string>
+
+using namespace std;
+
+#include "UIElements/UIFactory.hpp"
+#include "UIElements/Dialog.hpp"
+#include "Actions/ValueStorage.hpp"
+
+
+// memento to remember the state when undoing
+
+class SelectionNotAllAtomsInsideCuboidState : public ActionState {
+public:
+  SelectionNotAllAtomsInsideCuboidState(std::vector<atom*> _selectedAtoms, const Vector &_position, const Vector &_extension, const double _Xangle, const double _Yangle, const double _Zangle) :
+    selectedAtoms(_selectedAtoms),
+    position(_position),
+    extension(_extension),
+    Xangle(_Xangle),
+    Yangle(_Yangle),
+    Zangle(_Zangle)
+  {}
+  std::vector<atom*> selectedAtoms;
+  Vector position;
+  Vector extension;
+  double Xangle;
+  double Yangle;
+  double Zangle;
+};
+
+const char SelectionNotAllAtomsInsideCuboidAction::NAME[] = "unselect-atoms-inside-cuboid";
+
+SelectionNotAllAtomsInsideCuboidAction::SelectionNotAllAtomsInsideCuboidAction() :
+  Action(NAME)
+{}
+
+SelectionNotAllAtomsInsideCuboidAction::~SelectionNotAllAtomsInsideCuboidAction()
+{}
+
+void SelectionNotAllAtomsInsideCuboid(const Vector &position, const Vector &extension) {
+  ValueStorage::getInstance().setCurrentValue(SelectionNotAllAtomsInsideCuboidAction::NAME, extension);
+  ValueStorage::getInstance().setCurrentValue("position", position);
+  ActionRegistry::getInstance().getActionByName(SelectionNotAllAtomsInsideCuboidAction::NAME)->call(Action::NonInteractive);
+};
+
+void SelectionNotAllAtomsInsideCuboid(const Vector &position, const Vector &extension, const double Xangle, const double Yangle, const double Zangle) {
+  ValueStorage::getInstance().setCurrentValue(SelectionNotAllAtomsInsideCuboidAction::NAME, extension);
+  ValueStorage::getInstance().setCurrentValue("position", position);
+  ValueStorage::getInstance().setCurrentValue("angle-x", Xangle);
+  ValueStorage::getInstance().setCurrentValue("angle-y", Yangle);
+  ValueStorage::getInstance().setCurrentValue("angle-z", Zangle);
+  ActionRegistry::getInstance().getActionByName(SelectionNotAllAtomsInsideCuboidAction::NAME)->call(Action::NonInteractive);
+};
+
+Dialog* SelectionNotAllAtomsInsideCuboidAction::fillDialog(Dialog *dialog) {
+  ASSERT(dialog,"No Dialog given when filling action dialog");
+
+  dialog->queryVector(NAME, false, ValueStorage::getInstance().getDescription(NAME));
+  dialog->queryVector("position", false, ValueStorage::getInstance().getDescription("position"));
+
+  return dialog;
+}
+
+Action::state_ptr SelectionNotAllAtomsInsideCuboidAction::performCall() {
+  std::vector<atom *> selectedAtoms = World::getInstance().getSelectedAtoms();
+  Vector position;
+  Vector extension;
+  double Xangle = 0.;
+  double Yangle = 0.;
+  double Zangle = 0.;
+  Matrix RotationMatrix;
+
+  ValueStorage::getInstance().queryCurrentValue("position", position);
+  ValueStorage::getInstance().queryCurrentValue(NAME, extension);
+  // check whether a rotation is given.
+  if (ValueStorage::getInstance().queryCurrentValue("angle-x", Xangle, true))
+    Xangle = 0.;
+  if (ValueStorage::getInstance().queryCurrentValue("angle-y", Yangle, true))
+    Yangle = 0.;
+  if (ValueStorage::getInstance().queryCurrentValue("angle-z", Zangle, true))
+    Zangle = 0.;
+  RotationMatrix.rotation(Xangle, Yangle, Zangle);
+
+  DoLog(1) && (Log() << Verbose(1) << "Unselecting all atoms inside a rotated " << RotationMatrix << " cuboid at " << position << " and extension of " << extension << "." << endl);
+  Shape s = translate(transform(stretch(Cuboid(),extension),RotationMatrix),position);
+
+  World::getInstance().unselectAllAtoms(AtomByShape(s));
+  return Action::state_ptr(new SelectionNotAllAtomsInsideCuboidState(selectedAtoms, position, extension, Xangle, Yangle, Zangle));
+}
+
+Action::state_ptr SelectionNotAllAtomsInsideCuboidAction::performUndo(Action::state_ptr _state) {
+  SelectionNotAllAtomsInsideCuboidState *state = assert_cast<SelectionNotAllAtomsInsideCuboidState*>(_state.get());
+
+  World::getInstance().clearAtomSelection();
+  for(std::vector<atom *>::iterator iter = state->selectedAtoms.begin(); iter != state->selectedAtoms.end(); ++iter)
+    World::getInstance().selectAtom(*iter);
+
+  return Action::state_ptr(_state);
+}
+
+Action::state_ptr SelectionNotAllAtomsInsideCuboidAction::performRedo(Action::state_ptr _state){
+  SelectionNotAllAtomsInsideCuboidState *state = assert_cast<SelectionNotAllAtomsInsideCuboidState*>(_state.get());
+  Matrix RotationMatrix;
+
+  RotationMatrix.rotation(state->Xangle, state->Yangle, state->Zangle);
+  Shape s = translate(transform(stretch(Cuboid(),state->extension),RotationMatrix),state->position);
+  World::getInstance().unselectAllAtoms(AtomByShape(s));
+
+  return Action::state_ptr(_state);
+}
+
+bool SelectionNotAllAtomsInsideCuboidAction::canUndo() {
+  return true;
+}
+
+bool SelectionNotAllAtomsInsideCuboidAction::shouldUndo() {
+  return true;
+}
+
+const string SelectionNotAllAtomsInsideCuboidAction::getName() {
+  return NAME;
+}
Index: src/Actions/SelectionAction/NotAllAtomsInsideCuboidAction.hpp
===================================================================
--- src/Actions/SelectionAction/NotAllAtomsInsideCuboidAction.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
+++ src/Actions/SelectionAction/NotAllAtomsInsideCuboidAction.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -0,0 +1,39 @@
+/*
+ * NotAllAtomsInsideCuboidAction.hpp
+ *
+ *  Created on: Aug 9, 2010
+ *      Author: heber
+ */
+
+#ifndef NOTALLATOMSINSIDECUBOIDACTION_HPP_
+#define NOTALLATOMSINSIDECUBOIDACTION_HPP_
+
+#include "Actions/Action.hpp"
+
+class Vector;
+
+void SelectionNotAllAtomsInsideCuboid();
+
+class SelectionNotAllAtomsInsideCuboidAction : public Action {
+  friend void SelectionNotAllAtomsInsideCuboid(const Vector &position, const Vector &extension);
+  friend void SelectionNotAllAtomsInsideCuboid(const Vector &position, const Vector &extension, const double Xangle, const double Yangle, const double Zangle);
+
+public:
+  SelectionNotAllAtomsInsideCuboidAction();
+  virtual ~SelectionNotAllAtomsInsideCuboidAction();
+
+  bool canUndo();
+  bool shouldUndo();
+
+  virtual const std::string getName();
+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);
+
+  static const char NAME[];
+};
+
+#endif /* NOTALLATOMSINSIDECUBOIDACTION_HPP_ */
Index: src/Actions/SelectionAction/NotAllAtomsInsideSphereAction.cpp
===================================================================
--- src/Actions/SelectionAction/NotAllAtomsInsideSphereAction.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
+++ src/Actions/SelectionAction/NotAllAtomsInsideSphereAction.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -0,0 +1,119 @@
+/*
+ * NotAllAtomsInsideSphereAction.cpp
+ *
+ *  Created on: Aug 9, 2010
+ *      Author: heber
+ */
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "Helpers/MemDebug.hpp"
+
+#include "Actions/SelectionAction/NotAllAtomsInsideSphereAction.hpp"
+#include "Actions/ActionRegistry.hpp"
+#include "Descriptors/AtomDescriptor.hpp"
+#include "Descriptors/AtomShapeDescriptor.hpp"
+#include "atom.hpp"
+#include "Helpers/Log.hpp"
+#include "Helpers/Verbose.hpp"
+#include "LinearAlgebra/Vector.hpp"
+#include "Shapes/BaseShapes.hpp"
+#include "Shapes/Shape.hpp"
+#include "Shapes/ShapeOps.hpp"
+#include "World.hpp"
+
+#include <iostream>
+#include <string>
+
+using namespace std;
+
+#include "UIElements/UIFactory.hpp"
+#include "UIElements/Dialog.hpp"
+#include "Actions/ValueStorage.hpp"
+
+
+// memento to remember the state when undoing
+
+class SelectionNotAllAtomsInsideSphereState : public ActionState {
+public:
+  SelectionNotAllAtomsInsideSphereState(std::vector<atom*> _selectedAtoms, const Vector &_position, const double _radius) :
+    selectedAtoms(_selectedAtoms),
+    position(_position),
+    radius(_radius)
+  {}
+  std::vector<atom*> selectedAtoms;
+  Vector position;
+  double radius;
+};
+
+const char SelectionNotAllAtomsInsideSphereAction::NAME[] = "unselect-atoms-inside-sphere";
+
+SelectionNotAllAtomsInsideSphereAction::SelectionNotAllAtomsInsideSphereAction() :
+  Action(NAME)
+{}
+
+SelectionNotAllAtomsInsideSphereAction::~SelectionNotAllAtomsInsideSphereAction()
+{}
+
+void SelectionNotAllAtomsInsideSphere(const Vector &position, const double radius) {
+  ValueStorage::getInstance().setCurrentValue(SelectionNotAllAtomsInsideSphereAction::NAME, radius);
+  ValueStorage::getInstance().setCurrentValue("position", position);
+  ActionRegistry::getInstance().getActionByName(SelectionNotAllAtomsInsideSphereAction::NAME)->call(Action::NonInteractive);
+};
+
+Dialog* SelectionNotAllAtomsInsideSphereAction::fillDialog(Dialog *dialog) {
+  ASSERT(dialog,"No Dialog given when filling action dialog");
+
+  dialog->queryDouble(NAME, ValueStorage::getInstance().getDescription(NAME));
+  dialog->queryVector("position", false, ValueStorage::getInstance().getDescription("position"));
+
+  return dialog;
+}
+
+Action::state_ptr SelectionNotAllAtomsInsideSphereAction::performCall() {
+  std::vector<atom *> selectedAtoms = World::getInstance().getSelectedAtoms();
+  double radius = 0.;
+  Vector position;
+
+  ValueStorage::getInstance().queryCurrentValue(NAME, radius);
+  ValueStorage::getInstance().queryCurrentValue("position", position);
+
+  DoLog(1) && (Log() << Verbose(1) << "Unselecting all atoms inside a sphere at " << position << " with radius " << radius << "." << endl);
+  Shape s = translate(resize(Sphere(),radius),position);
+  World::getInstance().unselectAllAtoms(AtomByShape(s));
+  return Action::state_ptr(new SelectionNotAllAtomsInsideSphereState(selectedAtoms, position, radius));
+}
+
+Action::state_ptr SelectionNotAllAtomsInsideSphereAction::performUndo(Action::state_ptr _state) {
+  SelectionNotAllAtomsInsideSphereState *state = assert_cast<SelectionNotAllAtomsInsideSphereState*>(_state.get());
+
+  World::getInstance().clearAtomSelection();
+  for(std::vector<atom *>::iterator iter = state->selectedAtoms.begin(); iter != state->selectedAtoms.end(); ++iter)
+    World::getInstance().selectAtom(*iter);
+
+  return Action::state_ptr(new SelectionNotAllAtomsInsideSphereState(state->selectedAtoms, state->position, state->radius));
+}
+
+Action::state_ptr SelectionNotAllAtomsInsideSphereAction::performRedo(Action::state_ptr _state){
+  SelectionNotAllAtomsInsideSphereState *state = assert_cast<SelectionNotAllAtomsInsideSphereState*>(_state.get());
+
+  Shape s = translate(resize(Sphere(),state->radius),state->position);
+  World::getInstance().unselectAllAtoms(AtomByShape(s));
+
+  return Action::state_ptr(new SelectionNotAllAtomsInsideSphereState(state->selectedAtoms, state->position, state->radius));
+}
+
+bool SelectionNotAllAtomsInsideSphereAction::canUndo() {
+  return true;
+}
+
+bool SelectionNotAllAtomsInsideSphereAction::shouldUndo() {
+  return true;
+}
+
+const string SelectionNotAllAtomsInsideSphereAction::getName() {
+  return NAME;
+}
Index: src/Actions/SelectionAction/NotAllAtomsInsideSphereAction.hpp
===================================================================
--- src/Actions/SelectionAction/NotAllAtomsInsideSphereAction.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
+++ src/Actions/SelectionAction/NotAllAtomsInsideSphereAction.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -0,0 +1,38 @@
+/*
+ * NotAllAtomsInsideSphereAction.hpp
+ *
+ *  Created on: Aug 9, 2010
+ *      Author: heber
+ */
+
+#ifndef NOTALLATOMSINSIDESPHEREACTION_HPP_
+#define NOTALLATOMSINSIDESPHEREACTION_HPP_
+
+#include "Actions/Action.hpp"
+
+class Vector;
+
+void SelectionNotAllAtomsInsideSphere();
+
+class SelectionNotAllAtomsInsideSphereAction : public Action {
+  friend void SelectionNotAllAtomsInsideSphere(const Vector &position, const double radius);
+
+public:
+  SelectionNotAllAtomsInsideSphereAction();
+  virtual ~SelectionNotAllAtomsInsideSphereAction();
+
+  bool canUndo();
+  bool shouldUndo();
+
+  virtual const std::string getName();
+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);
+
+  static const char NAME[];
+};
+
+#endif /* NOTALLATOMSINSIDESPHEREACTION_HPP_ */
Index: src/Actions/SelectionAction/NotAllAtomsOfMoleculeAction.cpp
===================================================================
--- src/Actions/SelectionAction/NotAllAtomsOfMoleculeAction.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
+++ src/Actions/SelectionAction/NotAllAtomsOfMoleculeAction.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -0,0 +1,106 @@
+/*
+ * NotAllAtomsOfMoleculeAction.cpp
+ *
+ *  Created on: May 12, 2010
+ *      Author: heber
+ */
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "Helpers/MemDebug.hpp"
+
+#include "Actions/SelectionAction/NotAllAtomsOfMoleculeAction.hpp"
+#include "Actions/ActionRegistry.hpp"
+#include "Descriptors/AtomDescriptor.hpp"
+#include "atom.hpp"
+#include "molecule.hpp"
+#include "Helpers/Log.hpp"
+#include "Helpers/Verbose.hpp"
+#include "World.hpp"
+
+#include <iostream>
+#include <string>
+
+using namespace std;
+
+#include "UIElements/UIFactory.hpp"
+#include "UIElements/Dialog.hpp"
+#include "Actions/ValueStorage.hpp"
+
+
+// memento to remember the state when undoing
+
+class SelectionNotAllAtomsOfMoleculeState : public ActionState {
+public:
+  SelectionNotAllAtomsOfMoleculeState(std::vector<atom*> _selectedAtoms, molecule *_mol) :
+    selectedAtoms(_selectedAtoms),
+    mol(_mol)
+  {}
+  std::vector<atom*> selectedAtoms;
+  molecule *mol;
+};
+
+const char SelectionNotAllAtomsOfMoleculeAction::NAME[] = "unselect-molecules-atoms";
+
+SelectionNotAllAtomsOfMoleculeAction::SelectionNotAllAtomsOfMoleculeAction() :
+  Action(NAME)
+{}
+
+SelectionNotAllAtomsOfMoleculeAction::~SelectionNotAllAtomsOfMoleculeAction()
+{}
+
+void SelectionNotAllAtomsOfMolecule() {
+  ActionRegistry::getInstance().getActionByName(SelectionNotAllAtomsOfMoleculeAction::NAME)->call(Action::NonInteractive);
+};
+
+Dialog* SelectionNotAllAtomsOfMoleculeAction::fillDialog(Dialog *dialog) {
+  ASSERT(dialog,"No Dialog given when filling action dialog");
+
+  dialog->queryMolecule(NAME, ValueStorage::getInstance().getDescription(NAME));
+
+  return dialog;
+}
+
+Action::state_ptr SelectionNotAllAtomsOfMoleculeAction::performCall() {
+  molecule *mol = NULL;
+  std::vector<atom *> selectedAtoms = World::getInstance().getSelectedAtoms();
+
+  ValueStorage::getInstance().queryCurrentValue(NAME, mol);
+
+  DoLog(1) && (Log() << Verbose(1) << "Unselecting all atoms of molecule " << mol->getName() << "." << endl);
+  World::getInstance().unselectAtomsOfMolecule(mol);
+  return Action::state_ptr(new SelectionNotAllAtomsOfMoleculeState(selectedAtoms, mol));
+}
+
+Action::state_ptr SelectionNotAllAtomsOfMoleculeAction::performUndo(Action::state_ptr _state) {
+  SelectionNotAllAtomsOfMoleculeState *state = assert_cast<SelectionNotAllAtomsOfMoleculeState*>(_state.get());
+
+  World::getInstance().clearAtomSelection();
+  for(std::vector<atom *>::iterator iter = state->selectedAtoms.begin(); iter != state->selectedAtoms.end(); ++iter)
+    World::getInstance().selectAtom(*iter);
+
+  return Action::state_ptr(new SelectionNotAllAtomsOfMoleculeState(state->selectedAtoms, state->mol));
+}
+
+Action::state_ptr SelectionNotAllAtomsOfMoleculeAction::performRedo(Action::state_ptr _state){
+  SelectionNotAllAtomsOfMoleculeState *state = assert_cast<SelectionNotAllAtomsOfMoleculeState*>(_state.get());
+
+  World::getInstance().unselectAtomsOfMolecule(state->mol);
+
+  return Action::state_ptr(new SelectionNotAllAtomsOfMoleculeState(state->selectedAtoms, state->mol));
+}
+
+bool SelectionNotAllAtomsOfMoleculeAction::canUndo() {
+  return true;
+}
+
+bool SelectionNotAllAtomsOfMoleculeAction::shouldUndo() {
+  return true;
+}
+
+const string SelectionNotAllAtomsOfMoleculeAction::getName() {
+  return NAME;
+}
Index: src/Actions/SelectionAction/NotAllAtomsOfMoleculeAction.hpp
===================================================================
--- src/Actions/SelectionAction/NotAllAtomsOfMoleculeAction.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
+++ src/Actions/SelectionAction/NotAllAtomsOfMoleculeAction.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -0,0 +1,36 @@
+/*
+ * NotAllAtomsOfMoleculeAction.hpp
+ *
+ *  Created on: Aug 09, 2010
+ *      Author: heber
+ */
+
+#ifndef NOTALLATOMSOFMOLECULEACTION_HPP_
+#define NOTALLATOMSOFMOLECULEACTION_HPP_
+
+#include "Actions/Action.hpp"
+
+void SelectionNotAllAtomsOfMolecule();
+
+class SelectionNotAllAtomsOfMoleculeAction : public Action {
+  friend void SelectionNotAllAtomsOfMolecule();
+
+public:
+  SelectionNotAllAtomsOfMoleculeAction();
+  virtual ~SelectionNotAllAtomsOfMoleculeAction();
+
+  bool canUndo();
+  bool shouldUndo();
+
+  virtual const std::string getName();
+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);
+
+  static const char NAME[];
+};
+
+#endif /* NOTALLATOMSOFMOLECULEACTION_HPP_ */
Index: src/Actions/SelectionAction/NotAllMoleculesAction.cpp
===================================================================
--- src/Actions/SelectionAction/NotAllMoleculesAction.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
+++ src/Actions/SelectionAction/NotAllMoleculesAction.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -0,0 +1,99 @@
+/*
+ * NotAllMoleculesAction.cpp
+ *
+ *  Created on: May 12, 2010
+ *      Author: heber
+ */
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "Helpers/MemDebug.hpp"
+
+#include "Actions/SelectionAction/NotAllMoleculesAction.hpp"
+#include "Actions/ActionRegistry.hpp"
+#include "Descriptors/MoleculeDescriptor.hpp"
+#include "atom.hpp"
+#include "Helpers/Log.hpp"
+#include "Helpers/Verbose.hpp"
+#include "World.hpp"
+
+#include <iostream>
+#include <string>
+
+using namespace std;
+
+#include "UIElements/UIFactory.hpp"
+#include "UIElements/Dialog.hpp"
+#include "Actions/ValueStorage.hpp"
+
+
+// memento to remember the state when undoing
+
+class SelectionNotAllMoleculesState : public ActionState {
+public:
+  SelectionNotAllMoleculesState(std::vector<molecule*> selectedMolecules) :
+    selectedMolecules(selectedMolecules)
+  {}
+  std::vector<molecule*> selectedMolecules;
+};
+
+const char SelectionNotAllMoleculesAction::NAME[] = "unselect-all-molecules";
+
+SelectionNotAllMoleculesAction::SelectionNotAllMoleculesAction() :
+  Action(NAME)
+{}
+
+SelectionNotAllMoleculesAction::~SelectionNotAllMoleculesAction()
+{}
+
+void SelectionNotAllMolecules() {
+  ActionRegistry::getInstance().getActionByName(SelectionNotAllMoleculesAction::NAME)->call(Action::NonInteractive);
+};
+
+Dialog* SelectionNotAllMoleculesAction::fillDialog(Dialog *dialog) {
+  ASSERT(dialog,"No Dialog given when filling action dialog");
+
+  dialog->queryEmpty(NAME, ValueStorage::getInstance().getDescription(NAME));
+
+  return dialog;
+}
+
+Action::state_ptr SelectionNotAllMoleculesAction::performCall() {
+  std::vector<molecule *> selectedMolecules = World::getInstance().getSelectedMolecules();
+  DoLog(1) && (Log() << Verbose(1) << "Unselecting all molecules." << endl);
+  World::getInstance().clearMoleculeSelection();
+  return Action::state_ptr(new SelectionNotAllMoleculesState(selectedMolecules));
+}
+
+Action::state_ptr SelectionNotAllMoleculesAction::performUndo(Action::state_ptr _state) {
+  SelectionNotAllMoleculesState *state = assert_cast<SelectionNotAllMoleculesState*>(_state.get());
+
+  World::getInstance().clearMoleculeSelection();
+  for(std::vector<molecule *>::iterator iter = state->selectedMolecules.begin(); iter != state->selectedMolecules.end(); ++iter)
+    World::getInstance().selectMolecule(*iter);
+
+  return Action::state_ptr(new SelectionNotAllMoleculesState(state->selectedMolecules));
+}
+
+Action::state_ptr SelectionNotAllMoleculesAction::performRedo(Action::state_ptr _state){
+  SelectionNotAllMoleculesState *state = assert_cast<SelectionNotAllMoleculesState*>(_state.get());
+
+  World::getInstance().clearMoleculeSelection();
+
+  return Action::state_ptr(new SelectionNotAllMoleculesState(state->selectedMolecules));
+}
+
+bool SelectionNotAllMoleculesAction::canUndo() {
+  return true;
+}
+
+bool SelectionNotAllMoleculesAction::shouldUndo() {
+  return true;
+}
+
+const string SelectionNotAllMoleculesAction::getName() {
+  return NAME;
+}
Index: src/Actions/SelectionAction/NotAllMoleculesAction.hpp
===================================================================
--- src/Actions/SelectionAction/NotAllMoleculesAction.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
+++ src/Actions/SelectionAction/NotAllMoleculesAction.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -0,0 +1,36 @@
+/*
+ * NotAllMoleculesAction.hpp
+ *
+ *  Created on: May 12, 2010
+ *      Author: heber
+ */
+
+#ifndef NOTALLMOLECULESSACTION_HPP_
+#define NOTALLMOLECULESSACTION_HPP_
+
+#include "Actions/Action.hpp"
+
+void SelectionNotAllMolecules();
+
+class SelectionNotAllMoleculesAction : public Action {
+  friend void SelectionNotAllMolecules();
+
+public:
+  SelectionNotAllMoleculesAction();
+  virtual ~SelectionNotAllMoleculesAction();
+
+  bool canUndo();
+  bool shouldUndo();
+
+  virtual const std::string getName();
+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);
+
+  static const char NAME[];
+};
+
+#endif /* NOTALLMOLECULESSACTION_HPP_ */
Index: src/Actions/SelectionAction/NotAtomByElementAction.cpp
===================================================================
--- src/Actions/SelectionAction/NotAtomByElementAction.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
+++ src/Actions/SelectionAction/NotAtomByElementAction.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -0,0 +1,107 @@
+/*
+ * NotAtomByElementAction.cpp
+ *
+ *  Created on: May 12, 2010
+ *      Author: heber
+ */
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "Helpers/MemDebug.hpp"
+
+#include "Actions/SelectionAction/NotAtomByElementAction.hpp"
+#include "Actions/ActionRegistry.hpp"
+#include "Descriptors/AtomTypeDescriptor.hpp"
+#include "atom.hpp"
+#include "element.hpp"
+#include "Helpers/Log.hpp"
+#include "Helpers/Verbose.hpp"
+#include "World.hpp"
+
+#include <iostream>
+#include <string>
+
+using namespace std;
+
+#include "UIElements/UIFactory.hpp"
+#include "UIElements/Dialog.hpp"
+#include "Actions/ValueStorage.hpp"
+
+
+// memento to remember the state when undoing
+
+class SelectionNotAtomByElementState : public ActionState {
+public:
+  SelectionNotAtomByElementState(std::vector<atom*> _selectedAtoms, const element *_elemental) :
+    selectedAtoms(_selectedAtoms),
+    elemental(_elemental)
+  {}
+  std::vector<atom*> selectedAtoms;
+  const element *elemental;
+};
+
+const char SelectionNotAtomByElementAction::NAME[] = "unselect-atom-by-element";
+
+SelectionNotAtomByElementAction::SelectionNotAtomByElementAction() :
+  Action(NAME)
+{}
+
+SelectionNotAtomByElementAction::~SelectionNotAtomByElementAction()
+{}
+
+void SelectionNotAtomByElement(const element &_element) {
+  ValueStorage::getInstance().setCurrentValue(SelectionNotAtomByElementAction::NAME, _element);
+  ActionRegistry::getInstance().getActionByName(SelectionNotAtomByElementAction::NAME)->call(Action::NonInteractive);
+};
+
+Dialog* SelectionNotAtomByElementAction::fillDialog(Dialog *dialog) {
+  ASSERT(dialog,"No Dialog given when filling action dialog");
+
+  dialog->queryElement(NAME, ValueStorage::getInstance().getDescription(NAME));
+
+  return dialog;
+}
+
+Action::state_ptr SelectionNotAtomByElementAction::performCall() {
+  const element *elemental;
+  std::vector<atom *> selectedAtoms = World::getInstance().getSelectedAtoms();
+
+  ValueStorage::getInstance().queryCurrentValue(NAME, elemental);
+
+  DoLog(1) && (Log() << Verbose(1) << "Unselecting atoms of type " << *elemental << endl);
+  World::getInstance().unselectAllAtoms(AtomByType(elemental));
+  return Action::state_ptr(new SelectionNotAtomByElementState(selectedAtoms,elemental));
+}
+
+Action::state_ptr SelectionNotAtomByElementAction::performUndo(Action::state_ptr _state) {
+  SelectionNotAtomByElementState *state = assert_cast<SelectionNotAtomByElementState*>(_state.get());
+
+  World::getInstance().clearAtomSelection();
+  for(std::vector<atom *>::iterator iter = state->selectedAtoms.begin(); iter != state->selectedAtoms.end(); ++iter)
+    World::getInstance().selectAtom(*iter);
+
+  return Action::state_ptr(_state);
+}
+
+Action::state_ptr SelectionNotAtomByElementAction::performRedo(Action::state_ptr _state){
+  SelectionNotAtomByElementState *state = assert_cast<SelectionNotAtomByElementState*>(_state.get());
+
+  World::getInstance().unselectAllAtoms(AtomByType(state->elemental));
+
+  return Action::state_ptr(_state);
+}
+
+bool SelectionNotAtomByElementAction::canUndo() {
+  return true;
+}
+
+bool SelectionNotAtomByElementAction::shouldUndo() {
+  return true;
+}
+
+const string SelectionNotAtomByElementAction::getName() {
+  return NAME;
+}
Index: src/Actions/SelectionAction/NotAtomByElementAction.hpp
===================================================================
--- src/Actions/SelectionAction/NotAtomByElementAction.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
+++ src/Actions/SelectionAction/NotAtomByElementAction.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -0,0 +1,38 @@
+/*
+ * NotAtomByElementAction.hpp
+ *
+ *  Created on: May 12, 2010
+ *      Author: heber
+ */
+
+#ifndef NOTATOMBYELEMENTACTION_HPP_
+#define NOTATOMBYELEMENTACTION_HPP_
+
+#include "Actions/Action.hpp"
+
+class element;
+
+void SelectionNotAtomByElement(const element &_element);
+
+class SelectionNotAtomByElementAction : public Action {
+  friend void SelectionNotAtomByElement(const element &_element);
+
+public:
+  SelectionNotAtomByElementAction();
+  virtual ~SelectionNotAtomByElementAction();
+
+  bool canUndo();
+  bool shouldUndo();
+
+  virtual const std::string getName();
+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);
+
+  static const char NAME[];
+};
+
+#endif /* NOTATOMBYELEMENTACTION_HPP_ */
Index: src/Actions/SelectionAction/NotAtomByIdAction.cpp
===================================================================
--- src/Actions/SelectionAction/NotAtomByIdAction.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
+++ src/Actions/SelectionAction/NotAtomByIdAction.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -0,0 +1,106 @@
+/*
+ * NotAtomByIdAction.cpp
+ *
+ *  Created on: May 12, 2010
+ *      Author: heber
+ */
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "Helpers/MemDebug.hpp"
+
+#include "Actions/SelectionAction/NotAtomByIdAction.hpp"
+#include "Actions/ActionRegistry.hpp"
+#include "atom.hpp"
+#include "Helpers/Log.hpp"
+#include "Helpers/Verbose.hpp"
+#include "World.hpp"
+
+#include <iostream>
+#include <string>
+
+using namespace std;
+
+#include "UIElements/UIFactory.hpp"
+#include "UIElements/Dialog.hpp"
+#include "Actions/ValueStorage.hpp"
+
+
+// memento to remember the state when undoing
+
+class SelectionNotAtomByIdState : public ActionState {
+public:
+  SelectionNotAtomByIdState(atom* _walker) :
+    walker(_walker)
+  {}
+  atom* walker;
+};
+
+const char SelectionNotAtomByIdAction::NAME[] = "unselect-atom-by-id";
+
+SelectionNotAtomByIdAction::SelectionNotAtomByIdAction() :
+  Action(NAME)
+{}
+
+SelectionNotAtomByIdAction::~SelectionNotAtomByIdAction()
+{}
+
+void SelectionNotAtomById(atom *_atom) {
+  ValueStorage::getInstance().setCurrentValue(SelectionNotAtomByIdAction::NAME, _atom);
+  ActionRegistry::getInstance().getActionByName(SelectionNotAtomByIdAction::NAME)->call(Action::NonInteractive);
+};
+
+Dialog* SelectionNotAtomByIdAction::fillDialog(Dialog *dialog) {
+  ASSERT(dialog,"No Dialog given when filling action dialog");
+
+  dialog->queryAtom(NAME, ValueStorage::getInstance().getDescription(NAME));
+
+  return dialog;
+}
+
+Action::state_ptr SelectionNotAtomByIdAction::performCall() {
+  atom *Walker = NULL;
+
+  ValueStorage::getInstance().queryCurrentValue(NAME, Walker);
+
+  if (World::getInstance().isSelected(Walker)) {
+    DoLog(1) && (Log() << Verbose(1) << "Unselecting atom " << *Walker << endl);
+    World::getInstance().unselectAtom(Walker);
+    return Action::state_ptr(new SelectionNotAtomByIdState(Walker));
+  } else {
+    return Action::success;
+  }
+}
+
+Action::state_ptr SelectionNotAtomByIdAction::performUndo(Action::state_ptr _state) {
+  SelectionNotAtomByIdState *state = assert_cast<SelectionNotAtomByIdState*>(_state.get());
+
+  if (state->walker != NULL)
+    World::getInstance().selectAtom(state->walker);
+
+  return Action::state_ptr(new SelectionNotAtomByIdState(state->walker));
+}
+
+Action::state_ptr SelectionNotAtomByIdAction::performRedo(Action::state_ptr _state){
+  SelectionNotAtomByIdState *state = assert_cast<SelectionNotAtomByIdState*>(_state.get());
+
+  if (state->walker != NULL)
+    World::getInstance().unselectAtom(state->walker);
+
+  return Action::state_ptr(new SelectionNotAtomByIdState(state->walker));
+}
+
+bool SelectionNotAtomByIdAction::canUndo() {
+  return true;
+}
+
+bool SelectionNotAtomByIdAction::shouldUndo() {
+  return true;
+}
+
+const string SelectionNotAtomByIdAction::getName() {
+  return NAME;
+}
Index: src/Actions/SelectionAction/NotAtomByIdAction.hpp
===================================================================
--- src/Actions/SelectionAction/NotAtomByIdAction.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
+++ src/Actions/SelectionAction/NotAtomByIdAction.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -0,0 +1,38 @@
+/*
+ * NotAtomByIdAction.hpp
+ *
+ *  Created on: May 12, 2010
+ *      Author: heber
+ */
+
+#ifndef NOTATOMBYIDACTION_HPP_
+#define NOTATOMBYIDACTION_HPP_
+
+#include "Actions/Action.hpp"
+
+class atom;
+
+void SelectionNotAtomById(atom *_atom);
+
+class SelectionNotAtomByIdAction : public Action {
+  friend void SelectionNotAtomById(atom *_atom);
+
+public:
+  SelectionNotAtomByIdAction();
+  virtual ~SelectionNotAtomByIdAction();
+
+  bool canUndo();
+  bool shouldUndo();
+
+  virtual const std::string getName();
+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);
+
+  static const char NAME[];
+};
+
+#endif /* NOTATOMBYIDACTION_HPP_ */
Index: src/Actions/SelectionAction/NotMoleculeByFormulaAction.cpp
===================================================================
--- src/Actions/SelectionAction/NotMoleculeByFormulaAction.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
+++ src/Actions/SelectionAction/NotMoleculeByFormulaAction.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -0,0 +1,110 @@
+/*
+ * NotMoleculeByFormulaAction.cpp
+ *
+ *  Created on: May 12, 2010
+ *      Author: heber
+ */
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "Helpers/MemDebug.hpp"
+
+#include "Actions/SelectionAction/NotMoleculeByFormulaAction.hpp"
+#include "Actions/ActionRegistry.hpp"
+#include "Descriptors/MoleculeFormulaDescriptor.hpp"
+#include "molecule.hpp"
+#include "Helpers/Log.hpp"
+#include "Helpers/Verbose.hpp"
+#include "World.hpp"
+
+#include <iostream>
+#include <string>
+
+using namespace std;
+
+#include "UIElements/UIFactory.hpp"
+#include "UIElements/Dialog.hpp"
+#include "Actions/ValueStorage.hpp"
+
+
+// memento to remember the state when undoing
+
+class SelectionNotMoleculeByFormulaState : public ActionState {
+public:
+  SelectionNotMoleculeByFormulaState(std::vector<molecule*> selectedMolecules, const std::string &_formula) :
+    selectedMolecules(selectedMolecules),
+    formula(_formula)
+  {}
+  std::vector<molecule*> selectedMolecules;
+  std::string formula;
+};
+
+const char SelectionNotMoleculeByFormulaAction::NAME[] = "unselect-molecule-by-formula";
+
+SelectionNotMoleculeByFormulaAction::SelectionNotMoleculeByFormulaAction() :
+  Action(NAME)
+{}
+
+SelectionNotMoleculeByFormulaAction::~SelectionNotMoleculeByFormulaAction()
+{}
+
+void SelectionNotMoleculeByFormula(const std::string &_formula) {
+  ValueStorage::getInstance().setCurrentValue(SelectionNotMoleculeByFormulaAction::NAME, _formula);
+  ActionRegistry::getInstance().getActionByName(SelectionNotMoleculeByFormulaAction::NAME)->call(Action::NonInteractive);
+};
+
+Dialog* SelectionNotMoleculeByFormulaAction::fillDialog(Dialog *dialog) {
+  ASSERT(dialog,"No Dialog given when filling action dialog");
+
+  dialog->queryString(NAME, ValueStorage::getInstance().getDescription(NAME));
+
+  return dialog;
+}
+
+Action::state_ptr SelectionNotMoleculeByFormulaAction::performCall() {
+  std::string formula;
+  std::vector<molecule *> selectedMolecules = World::getInstance().getSelectedMolecules();
+
+  ValueStorage::getInstance().queryCurrentValue(NAME, formula);
+
+  DoLog(1) && (Log() << Verbose(1) << "Unselecting molecules with chemical formula " << formula << ":" << endl);
+  std::vector<molecule *> matchingMolecules = World::getInstance().getAllMolecules(MoleculeByFormula(formula));
+  for (std::vector<molecule *>::const_iterator iter = matchingMolecules.begin(); iter != matchingMolecules.end(); ++iter) {
+    DoLog(1) && (Log() << Verbose(1) << "\t" << (*iter)->getId() << ", " << (*iter)->getName() << "." << endl);
+  }
+  World::getInstance().unselectAllMolecules(MoleculeByFormula(formula));
+  return Action::state_ptr(new SelectionNotMoleculeByFormulaState(selectedMolecules,formula));
+}
+
+Action::state_ptr SelectionNotMoleculeByFormulaAction::performUndo(Action::state_ptr _state) {
+  SelectionNotMoleculeByFormulaState *state = assert_cast<SelectionNotMoleculeByFormulaState*>(_state.get());
+
+  World::getInstance().clearMoleculeSelection();
+  for(std::vector<molecule *>::iterator iter = state->selectedMolecules.begin(); iter != state->selectedMolecules.end(); ++iter)
+    World::getInstance().selectMolecule(*iter);
+
+  return Action::state_ptr(_state);
+}
+
+Action::state_ptr SelectionNotMoleculeByFormulaAction::performRedo(Action::state_ptr _state){
+  SelectionNotMoleculeByFormulaState *state = assert_cast<SelectionNotMoleculeByFormulaState*>(_state.get());
+
+  World::getInstance().unselectAllMolecules(MoleculeByFormula(state->formula));
+
+  return Action::state_ptr(_state);
+}
+
+bool SelectionNotMoleculeByFormulaAction::canUndo() {
+  return true;
+}
+
+bool SelectionNotMoleculeByFormulaAction::shouldUndo() {
+  return true;
+}
+
+const string SelectionNotMoleculeByFormulaAction::getName() {
+  return NAME;
+}
Index: src/Actions/SelectionAction/NotMoleculeByFormulaAction.hpp
===================================================================
--- src/Actions/SelectionAction/NotMoleculeByFormulaAction.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
+++ src/Actions/SelectionAction/NotMoleculeByFormulaAction.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -0,0 +1,38 @@
+/*
+ * NotMoleculeByFormulaAction.hpp
+ *
+ *  Created on: May 12, 2010
+ *      Author: heber
+ */
+
+#ifndef NOTMOLECULEBYFORMULAACTION_HPP_
+#define NOTMOLECULEBYFORMULAACTION_HPP_
+
+#include "Actions/Action.hpp"
+
+class molecule;
+
+void SelectionNotMoleculeByFormula(molecule *_mol);
+
+class SelectionNotMoleculeByFormulaAction : public Action {
+  friend void SelectionNotMoleculeByFormula(const std::string &_formula);
+
+public:
+  SelectionNotMoleculeByFormulaAction();
+  virtual ~SelectionNotMoleculeByFormulaAction();
+
+  bool canUndo();
+  bool shouldUndo();
+
+  virtual const std::string getName();
+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);
+
+  static const char NAME[];
+};
+
+#endif /* NOTMOLECULEBYFORMULAACTION_HPP_ */
Index: src/Actions/SelectionAction/NotMoleculeByIdAction.cpp
===================================================================
--- src/Actions/SelectionAction/NotMoleculeByIdAction.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
+++ src/Actions/SelectionAction/NotMoleculeByIdAction.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -0,0 +1,106 @@
+/*
+ * NotMoleculeByIdAction.cpp
+ *
+ *  Created on: May 12, 2010
+ *      Author: heber
+ */
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "Helpers/MemDebug.hpp"
+
+#include "Actions/SelectionAction/NotMoleculeByIdAction.hpp"
+#include "Actions/ActionRegistry.hpp"
+#include "molecule.hpp"
+#include "Helpers/Log.hpp"
+#include "Helpers/Verbose.hpp"
+#include "World.hpp"
+
+#include <iostream>
+#include <string>
+
+using namespace std;
+
+#include "UIElements/UIFactory.hpp"
+#include "UIElements/Dialog.hpp"
+#include "Actions/ValueStorage.hpp"
+
+
+// memento to remember the state when undoing
+
+class SelectionNotMoleculeByIdState : public ActionState {
+public:
+  SelectionNotMoleculeByIdState(molecule* _mol) :
+    mol(_mol)
+  {}
+  molecule* mol;
+};
+
+const char SelectionNotMoleculeByIdAction::NAME[] = "unselect-molecule-by-id";
+
+SelectionNotMoleculeByIdAction::SelectionNotMoleculeByIdAction() :
+  Action(NAME)
+{}
+
+SelectionNotMoleculeByIdAction::~SelectionNotMoleculeByIdAction()
+{}
+
+void SelectionNotMoleculeById(molecule *_mol) {
+  ValueStorage::getInstance().setCurrentValue(SelectionNotMoleculeByIdAction::NAME, _mol);
+  ActionRegistry::getInstance().getActionByName(SelectionNotMoleculeByIdAction::NAME)->call(Action::NonInteractive);
+};
+
+Dialog* SelectionNotMoleculeByIdAction::fillDialog(Dialog *dialog) {
+  ASSERT(dialog,"No Dialog given when filling action dialog");
+
+  dialog->queryMolecule(NAME, ValueStorage::getInstance().getDescription(NAME));
+
+  return dialog;
+}
+
+Action::state_ptr SelectionNotMoleculeByIdAction::performCall() {
+  molecule *mol = NULL;
+
+  ValueStorage::getInstance().queryCurrentValue(NAME, mol);
+
+  if (World::getInstance().isSelected(mol)) {
+    DoLog(1) && (Log() << Verbose(1) << "Unselecting molecule " << mol->name << endl);
+    World::getInstance().unselectMolecule(mol);
+    return Action::state_ptr(new SelectionNotMoleculeByIdState(mol));
+  } else {
+    return Action::success;
+  }
+}
+
+Action::state_ptr SelectionNotMoleculeByIdAction::performUndo(Action::state_ptr _state) {
+  SelectionNotMoleculeByIdState *state = assert_cast<SelectionNotMoleculeByIdState*>(_state.get());
+
+  if (state->mol != NULL)
+    World::getInstance().selectMolecule(state->mol);
+
+  return Action::state_ptr(new SelectionNotMoleculeByIdState(state->mol));
+}
+
+Action::state_ptr SelectionNotMoleculeByIdAction::performRedo(Action::state_ptr _state){
+  SelectionNotMoleculeByIdState *state = assert_cast<SelectionNotMoleculeByIdState*>(_state.get());
+
+  if (state->mol != NULL)
+    World::getInstance().unselectMolecule(state->mol);
+
+  return Action::state_ptr(new SelectionNotMoleculeByIdState(state->mol));
+}
+
+bool SelectionNotMoleculeByIdAction::canUndo() {
+  return true;
+}
+
+bool SelectionNotMoleculeByIdAction::shouldUndo() {
+  return true;
+}
+
+const string SelectionNotMoleculeByIdAction::getName() {
+  return NAME;
+}
Index: src/Actions/SelectionAction/NotMoleculeByIdAction.hpp
===================================================================
--- src/Actions/SelectionAction/NotMoleculeByIdAction.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
+++ src/Actions/SelectionAction/NotMoleculeByIdAction.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -0,0 +1,38 @@
+/*
+ * NotMoleculeByIdAction.hpp
+ *
+ *  Created on: May 12, 2010
+ *      Author: heber
+ */
+
+#ifndef NOTMOLECULEBYIDACTION_HPP_
+#define NOTMOLECULEBYIDACTION_HPP_
+
+#include "Actions/Action.hpp"
+
+class molecule;
+
+void SelectionNotMoleculeById(molecule *_mol);
+
+class SelectionNotMoleculeByIdAction : public Action {
+  friend void SelectionNotMoleculeById(molecule *_mol);
+
+public:
+  SelectionNotMoleculeByIdAction();
+  virtual ~SelectionNotMoleculeByIdAction();
+
+  bool canUndo();
+  bool shouldUndo();
+
+  virtual const std::string getName();
+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);
+
+  static const char NAME[];
+};
+
+#endif /* NOTMOLECULEBYIDACTION_HPP_ */
Index: src/Actions/SelectionAction/NotMoleculeOfAtomAction.cpp
===================================================================
--- src/Actions/SelectionAction/NotMoleculeOfAtomAction.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
+++ src/Actions/SelectionAction/NotMoleculeOfAtomAction.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -0,0 +1,105 @@
+/*
+ * NotMoleculeOfAtomAction.cpp
+ *
+ *  Created on: May 12, 2010
+ *      Author: heber
+ */
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "Helpers/MemDebug.hpp"
+
+#include "Actions/SelectionAction/NotMoleculeOfAtomAction.hpp"
+#include "Actions/ActionRegistry.hpp"
+#include "Descriptors/MoleculeDescriptor.hpp"
+#include "atom.hpp"
+#include "Helpers/Log.hpp"
+#include "Helpers/Verbose.hpp"
+#include "World.hpp"
+
+#include <iostream>
+#include <string>
+
+using namespace std;
+
+#include "UIElements/UIFactory.hpp"
+#include "UIElements/Dialog.hpp"
+#include "Actions/ValueStorage.hpp"
+
+
+// memento to remember the state when undoing
+
+class SelectionNotMoleculeOfAtomState : public ActionState {
+public:
+  SelectionNotMoleculeOfAtomState(std::vector<molecule*> selectedMolecules, atom *_Walker) :
+    selectedMolecules(selectedMolecules),
+    Walker(_Walker)
+  {}
+  std::vector<molecule*> selectedMolecules;
+  atom *Walker;
+};
+
+const char SelectionNotMoleculeOfAtomAction::NAME[] = "unselect-molecule-of-atom";
+
+SelectionNotMoleculeOfAtomAction::SelectionNotMoleculeOfAtomAction() :
+  Action(NAME)
+{}
+
+SelectionNotMoleculeOfAtomAction::~SelectionNotMoleculeOfAtomAction()
+{}
+
+void SelectionNotMoleculeOfAtom() {
+  ActionRegistry::getInstance().getActionByName(SelectionNotMoleculeOfAtomAction::NAME)->call(Action::NonInteractive);
+};
+
+Dialog* SelectionNotMoleculeOfAtomAction::fillDialog(Dialog *dialog) {
+  ASSERT(dialog,"No Dialog given when filling action dialog");
+
+  dialog->queryAtom(NAME, ValueStorage::getInstance().getDescription(NAME));
+
+  return dialog;
+}
+
+Action::state_ptr SelectionNotMoleculeOfAtomAction::performCall() {
+  atom *Walker = NULL;
+
+  ValueStorage::getInstance().queryCurrentValue(NAME, Walker);
+
+  std::vector<molecule *> selectedMolecules = World::getInstance().getSelectedMolecules();
+  DoLog(1) && (Log() << Verbose(1) << "Unselecting molecule to which " << Walker->getName() << " belongs." << endl);
+  World::getInstance().unselectMoleculeOfAtom(Walker);
+  return Action::state_ptr(new SelectionNotMoleculeOfAtomState(selectedMolecules, Walker));
+}
+
+Action::state_ptr SelectionNotMoleculeOfAtomAction::performUndo(Action::state_ptr _state) {
+  SelectionNotMoleculeOfAtomState *state = assert_cast<SelectionNotMoleculeOfAtomState*>(_state.get());
+
+  World::getInstance().clearMoleculeSelection();
+  for(std::vector<molecule *>::iterator iter = state->selectedMolecules.begin(); iter != state->selectedMolecules.end(); ++iter)
+    World::getInstance().selectMolecule(*iter);
+
+  return Action::state_ptr(new SelectionNotMoleculeOfAtomState(state->selectedMolecules, state->Walker));
+}
+
+Action::state_ptr SelectionNotMoleculeOfAtomAction::performRedo(Action::state_ptr _state){
+  SelectionNotMoleculeOfAtomState *state = assert_cast<SelectionNotMoleculeOfAtomState*>(_state.get());
+
+  World::getInstance().unselectMoleculeOfAtom(state->Walker);
+
+  return Action::state_ptr(new SelectionNotMoleculeOfAtomState(state->selectedMolecules, state->Walker));
+}
+
+bool SelectionNotMoleculeOfAtomAction::canUndo() {
+  return true;
+}
+
+bool SelectionNotMoleculeOfAtomAction::shouldUndo() {
+  return true;
+}
+
+const string SelectionNotMoleculeOfAtomAction::getName() {
+  return NAME;
+}
Index: src/Actions/SelectionAction/NotMoleculeOfAtomAction.hpp
===================================================================
--- src/Actions/SelectionAction/NotMoleculeOfAtomAction.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
+++ src/Actions/SelectionAction/NotMoleculeOfAtomAction.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -0,0 +1,36 @@
+/*
+ * NotMoleculeOfAtomAction.hpp
+ *
+ *  Created on: May 12, 2010
+ *      Author: heber
+ */
+
+#ifndef NOTMOLECULEOFATOMSACTION_HPP_
+#define NOTMOLECULEOFATOMSACTION_HPP_
+
+#include "Actions/Action.hpp"
+
+void SelectionNotMoleculeOfAtom();
+
+class SelectionNotMoleculeOfAtomAction : public Action {
+  friend void SelectionNotMoleculeOfAtom();
+
+public:
+  SelectionNotMoleculeOfAtomAction();
+  virtual ~SelectionNotMoleculeOfAtomAction();
+
+  bool canUndo();
+  bool shouldUndo();
+
+  virtual const std::string getName();
+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);
+
+  static const char NAME[];
+};
+
+#endif /* NOTMOLECULEOFATOMSACTION_HPP_ */
Index: src/Actions/TesselationAction/ConvexEnvelopeAction.cpp
===================================================================
--- src/Actions/TesselationAction/ConvexEnvelopeAction.cpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/Actions/TesselationAction/ConvexEnvelopeAction.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -6,7 +6,21 @@
  */
 
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
 #include "Helpers/MemDebug.hpp"
 
 #include "Actions/TesselationAction/ConvexEnvelopeAction.hpp"
+#include "Actions/ActionRegistry.hpp"
+#include "boundary.hpp"
+#include "config.hpp"
+#include "linkedcell.hpp"
+#include "Helpers/Log.hpp"
+#include "molecule.hpp"
+#include "tesselation.hpp"
+#include "Helpers/Verbose.hpp"
+#include "World.hpp"
 
 #include <iostream>
@@ -17,14 +31,5 @@
 #include "UIElements/UIFactory.hpp"
 #include "UIElements/Dialog.hpp"
-#include "Actions/MapOfActions.hpp"
-
-#include "atom.hpp"
-#include "boundary.hpp"
-#include "config.hpp"
-#include "linkedcell.hpp"
-#include "log.hpp"
-#include "molecule.hpp"
-#include "verbose.hpp"
-#include "World.hpp"
+#include "Actions/ValueStorage.hpp"
 
 /****** TesselationConvexEnvelopeAction *****/
@@ -51,17 +56,32 @@
 {}
 
+void TesselationConvexEnvelope(std::string &filenameConvex, std::string &filenameNonConvex) {
+  ValueStorage::getInstance().setCurrentValue("convex-file", filenameConvex);
+  ValueStorage::getInstance().setCurrentValue("nonconvex-file", filenameConvex);
+  ActionRegistry::getInstance().getActionByName(TesselationConvexEnvelopeAction::NAME)->call(Action::NonInteractive);
+};
+
+Dialog* TesselationConvexEnvelopeAction::fillDialog(Dialog *dialog) {
+  ASSERT(dialog,"No Dialog given when filling action dialog");
+
+  dialog->queryEmpty(NAME, ValueStorage::getInstance().getDescription(NAME));
+  dialog->queryString("convex-file", ValueStorage::getInstance().getDescription("convex-file"));
+  dialog->queryString("nonconvex-file", ValueStorage::getInstance().getDescription("nonconvex-file"));
+
+  return dialog;
+}
+
 Action::state_ptr TesselationConvexEnvelopeAction::performCall() {
   string filenameConvex;
   string filenameNonConvex;
-  Dialog *dialog = UIFactory::getInstance().makeDialog();
   molecule * mol = NULL;
-  bool Success = false;
+  bool Success = true;
   config *configuration = World::getInstance().getConfig();
 
-  dialog->queryMolecule(NAME, &mol, MapOfActions::getInstance().getDescription(NAME));
-  dialog->queryString("convex-file", &filenameConvex, MapOfActions::getInstance().getDescription("convex-file"));
-  dialog->queryString("nonconvex-file", &filenameNonConvex, MapOfActions::getInstance().getDescription("nonconvex-file"));
+  ValueStorage::getInstance().queryCurrentValue("convex-file", filenameConvex);
+  ValueStorage::getInstance().queryCurrentValue("nonconvex-file", filenameNonConvex);
 
-  if(dialog->display()) {
+  for (World::MoleculeSelectionIterator iter = World::getInstance().beginMoleculeSelection(); iter != World::getInstance().endMoleculeSelection(); ++iter) {
+    mol = iter->second;
     class Tesselation *TesselStruct = NULL;
     const LinkedCell *LCList = NULL;
@@ -70,5 +90,5 @@
     DoLog(1) && (Log() << Verbose(1) << "Storing tecplot non-convex data in " << filenameNonConvex << "." << endl);
     LCList = new LinkedCell(mol, 100.);
-    Boundaries *BoundaryPoints = NULL;
+    //Boundaries *BoundaryPoints = NULL;
     //FindConvexBorder(mol, BoundaryPoints, TesselStruct, LCList, argv[argptr]);
     // TODO: Beide Funktionen sollten streams anstelle des Filenamen benutzen, besser fuer unit tests
@@ -81,12 +101,9 @@
     delete(TesselStruct);
     delete(LCList);
-    delete dialog;
-    if (Success)
-      return Action::success;
-    else
-      return Action::failure;
   }
-  delete dialog;
-  return Action::failure;
+  if (Success)
+    return Action::success;
+  else
+    return Action::failure;
 }
 
Index: src/Actions/TesselationAction/ConvexEnvelopeAction.hpp
===================================================================
--- src/Actions/TesselationAction/ConvexEnvelopeAction.hpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/Actions/TesselationAction/ConvexEnvelopeAction.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -10,9 +10,13 @@
 
 #include "Actions/Action.hpp"
-#include "Actions/Process.hpp"
+
 
 class TesselationListClass;
 
+void TesselationConvexEnvelope(std::string &filenameConvex, std::string &filenameNonConvex);
+
 class TesselationConvexEnvelopeAction : public Action {
+  friend void TesselationConvexEnvelope(std::string &filenameConvex, std::string &filenameNonConvex);
+
 public:
   TesselationConvexEnvelopeAction();
@@ -23,4 +27,6 @@
 
   virtual const std::string getName();
+protected:
+  virtual Dialog * fillDialog(Dialog *dialog);
 private:
   virtual Action::state_ptr performCall();
Index: src/Actions/TesselationAction/NonConvexEnvelopeAction.cpp
===================================================================
--- src/Actions/TesselationAction/NonConvexEnvelopeAction.cpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/Actions/TesselationAction/NonConvexEnvelopeAction.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -6,7 +6,20 @@
  */
 
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
 #include "Helpers/MemDebug.hpp"
 
 #include "Actions/TesselationAction/NonConvexEnvelopeAction.hpp"
+#include "Actions/ActionRegistry.hpp"
+#include "boundary.hpp"
+#include "linkedcell.hpp"
+#include "Helpers/Log.hpp"
+#include "molecule.hpp"
+#include "tesselation.hpp"
+#include "Helpers/Verbose.hpp"
+#include "World.hpp"
 
 #include <iostream>
@@ -17,13 +30,5 @@
 #include "UIElements/UIFactory.hpp"
 #include "UIElements/Dialog.hpp"
-#include "Actions/MapOfActions.hpp"
-
-#include "atom.hpp"
-#include "boundary.hpp"
-#include "linkedcell.hpp"
-#include "log.hpp"
-#include "molecule.hpp"
-#include "verbose.hpp"
-#include "World.hpp"
+#include "Actions/ValueStorage.hpp"
 
 /****** TesselationNonConvexEnvelopeAction *****/
@@ -50,7 +55,21 @@
 {}
 
+void TesselationNonConvexEnvelope(double radius, std::string &filename) {
+  ValueStorage::getInstance().setCurrentValue(TesselationNonConvexEnvelopeAction::NAME, radius);
+  ValueStorage::getInstance().setCurrentValue("nonconvex-file", filename);
+  ActionRegistry::getInstance().getActionByName(TesselationNonConvexEnvelopeAction::NAME)->call(Action::NonInteractive);
+};
+
+Dialog* TesselationNonConvexEnvelopeAction::fillDialog(Dialog *dialog) {
+  ASSERT(dialog,"No Dialog given when filling action dialog");
+
+  dialog->queryDouble(NAME, ValueStorage::getInstance().getDescription(NAME));
+  dialog->queryString("nonconvex-file", ValueStorage::getInstance().getDescription("nonconvex-file"));
+
+  return dialog;
+}
+
 Action::state_ptr TesselationNonConvexEnvelopeAction::performCall() {
   string filename;
-  Dialog *dialog = UIFactory::getInstance().makeDialog();
   molecule * Boundary = NULL;
   double SphereRadius = 0;
@@ -58,9 +77,9 @@
   clock_t start,end;
 
-  dialog->queryMolecule(NAME, &Boundary, MapOfActions::getInstance().getDescription(NAME));
-  dialog->queryString("nonconvex-file", &filename, MapOfActions::getInstance().getDescription("nonconvex-file"));
-  dialog->queryDouble("sphere-radius", &SphereRadius, MapOfActions::getInstance().getDescription("sphere-radius"));
+  ValueStorage::getInstance().queryCurrentValue(NAME, SphereRadius);
+  ValueStorage::getInstance().queryCurrentValue("nonconvex-file", filename);
 
-  if(dialog->display()) {
+  for (World::MoleculeSelectionIterator iter = World::getInstance().beginMoleculeSelection(); iter != World::getInstance().endMoleculeSelection(); ++iter) {
+    Boundary = iter->second;
     class Tesselation *T = NULL;
     const LinkedCell *LCList = NULL;
@@ -76,12 +95,9 @@
     delete(LCList);
     delete(T);
-    delete dialog;
-    if (Success)
-      return Action::success;
-    else
-      return Action::failure;
   }
-  delete dialog;
-  return Action::failure;
+  if (Success)
+    return Action::success;
+  else
+    return Action::failure;
 }
 
Index: src/Actions/TesselationAction/NonConvexEnvelopeAction.hpp
===================================================================
--- src/Actions/TesselationAction/NonConvexEnvelopeAction.hpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/Actions/TesselationAction/NonConvexEnvelopeAction.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -10,9 +10,13 @@
 
 #include "Actions/Action.hpp"
-#include "Actions/Process.hpp"
+
 
 class TesselationListClass;
 
+void TesselationNonConvexEnvelope(double radius, std::string &filename);
+
 class TesselationNonConvexEnvelopeAction : public Action {
+  friend void TesselationNonConvexEnvelope(double radius, std::string &filename);
+
 public:
   TesselationNonConvexEnvelopeAction();
@@ -23,4 +27,6 @@
 
   virtual const std::string getName();
+protected:
+  virtual Dialog * fillDialog(Dialog *dialog);
 private:
   virtual Action::state_ptr performCall();
Index: src/Actions/ValueStorage.cpp
===================================================================
--- src/Actions/ValueStorage.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
+++ src/Actions/ValueStorage.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -0,0 +1,28 @@
+/*
+ * ValueStorage.cpp
+ *
+ *  Created on: Jul 22, 2010
+ *      Author: heber
+ */
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "Helpers/MemDebug.hpp"
+
+#include "ValueStorage.hpp"
+#include "Patterns/Singleton_impl.hpp"
+
+ValueStorage::ValueStorage() :
+  MapOfActions_instance(MapOfActions::getInstance())
+{};
+
+ValueStorage::~ValueStorage() {};
+
+std::string ValueStorage::getDescription(std::string actionname) {
+  return MapOfActions::getInstance().getDescription(actionname);
+}
+
+CONSTRUCT_SINGLETON(ValueStorage)
Index: src/Actions/ValueStorage.hpp
===================================================================
--- src/Actions/ValueStorage.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
+++ src/Actions/ValueStorage.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -0,0 +1,59 @@
+/*
+ * ValueStorage.hpp
+ *
+ *  Created on: Jul 22, 2010
+ *      Author: heber
+ */
+
+#ifndef VALUESTORAGE_HPP_
+#define VALUESTORAGE_HPP_
+
+#include "Actions/MapOfActions.hpp"
+#include "Patterns/Singleton.hpp"
+
+/** ValueStorage serves as a mediator to MapOfActions.
+ * This is needed to relax inter-dependencies between the Queries and the Actions.
+ * I.e. this is the interface implemented in MapOfActions which both can safely rely on
+ * to store&retrieve/exchange values.
+ */
+class ValueStorage : public Singleton<ValueStorage> {
+  friend class Singleton<ValueStorage>;
+
+public:
+  /** Gets a value from the storage
+   * If the value is not present, an ASSERT is thrown unless optional is set to true.
+   * \param _T key of value
+   * \param optional whether this value is optional, i.e. may actually not be in the storage (i.e. may return false in this case).
+   * \return true - value present, false - value not present (only given when optional set to true)
+   */
+  template <typename T> bool queryCurrentValue(const char *name, T &_T, const bool optional = false) {
+    if (optional) {
+      if (!MapOfActions_instance.isCurrentValuePresent(name))
+        return false;
+    }
+    MapOfActions_instance.queryCurrentValue(name, _T);
+    return true;
+  }
+
+  /** Sets a value in the storage.
+   * \param name key of value
+   * \param _T value
+   */
+  template <typename T> void setCurrentValue(const char *name, T &_T) {
+    MapOfActions_instance.setCurrentValue(name, _T);
+  }
+
+  /** Obtain a descriptive text for a given key.
+   * \param actionname key
+   * \return text describing the key's contents
+   */
+  std::string getDescription(std::string actionname);
+
+protected:
+  ValueStorage();
+  ~ValueStorage();
+
+  MapOfActions &MapOfActions_instance;
+};
+
+#endif /* VALUESTORAGE_HPP_ */
Index: src/Actions/Values.hpp
===================================================================
--- src/Actions/Values.hpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/Actions/Values.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -19,8 +19,8 @@
 {
   double xx;
-  double xy;
-  double xz;
+  double yx;
   double yy;
-  double yz;
+  double zx;
+  double zy;
   double zz;
 };
Index: src/Actions/WorldAction/AddEmptyBoundaryAction.cpp
===================================================================
--- src/Actions/WorldAction/AddEmptyBoundaryAction.cpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/Actions/WorldAction/AddEmptyBoundaryAction.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -6,10 +6,16 @@
  */
 
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
 #include "Helpers/MemDebug.hpp"
 
 #include "Actions/WorldAction/AddEmptyBoundaryAction.hpp"
+#include "Actions/ActionRegistry.hpp"
 #include "atom.hpp"
-#include "log.hpp"
-#include "vector.hpp"
+#include "Helpers/Log.hpp"
+#include "LinearAlgebra/Vector.hpp"
 #include "World.hpp"
 
@@ -22,5 +28,5 @@
 #include "UIElements/UIFactory.hpp"
 #include "UIElements/Dialog.hpp"
-#include "Actions/MapOfActions.hpp"
+#include "Actions/ValueStorage.hpp"
 #include "Helpers/Assert.hpp"
 
@@ -34,6 +40,18 @@
 {}
 
+void WorldAddEmptyBoundary(Vector &boundary) {
+  ValueStorage::getInstance().setCurrentValue(WorldAddEmptyBoundaryAction::NAME, boundary);
+  ActionRegistry::getInstance().getActionByName(WorldAddEmptyBoundaryAction::NAME)->call(Action::NonInteractive);
+};
+
+Dialog* WorldAddEmptyBoundaryAction::fillDialog(Dialog *dialog) {
+  ASSERT(dialog,"No Dialog given when filling action dialog");
+
+  dialog->queryVector(NAME, false, ValueStorage::getInstance().getDescription(NAME));
+
+  return dialog;
+}
+
 Action::state_ptr WorldAddEmptyBoundaryAction::performCall() {
-  Dialog *dialog = UIFactory::getInstance().makeDialog();
   Vector boundary;
   Vector Min;
@@ -41,40 +59,36 @@
   int j=0;
 
-  dialog->queryVector(NAME, &boundary, World::getInstance().getDomain(), false, MapOfActions::getInstance().getDescription(NAME));
+  ValueStorage::getInstance().queryCurrentValue(NAME, boundary);
 
-  if(dialog->display()) {
-    // get maximum and minimum
-    vector<atom *> AllAtoms = World::getInstance().getAllAtoms();
-    ASSERT(AllAtoms.size() > 0, "There must be atoms present for AddingEmptyBoundary.");
-    vector<atom *>::iterator AtomRunner = AllAtoms.begin();
-    Min = (*AtomRunner)->x;
-    Max = (*AtomRunner)->x;
-    for (; AtomRunner != AllAtoms.end(); ++AtomRunner) {
-      for (int i=0;i<NDIM;i++) {
-        if ((*AtomRunner)->x[i] > Max[i])
-          Max[i] = (*AtomRunner)->x[i];
-        if ((*AtomRunner)->x[i] < Min[i])
-          Min[i] = (*AtomRunner)->x[i];
-      }
+  // get maximum and minimum
+  vector<atom *> AllAtoms = World::getInstance().getAllAtoms();
+  ASSERT(AllAtoms.size() > 0, "There must be atoms present for AddingEmptyBoundary.");
+  vector<atom *>::iterator AtomRunner = AllAtoms.begin();
+  Min = (*AtomRunner)->getPosition();
+  Max = (*AtomRunner)->getPosition();
+  for (; AtomRunner != AllAtoms.end(); ++AtomRunner) {
+    for (int i=0;i<NDIM;i++) {
+      if ((*AtomRunner)->at(i) > Max[i])
+        Max[i] = (*AtomRunner)->at(i);
+      if ((*AtomRunner)->at(i) < Min[i])
+        Min[i] = (*AtomRunner)->at(i);
     }
-    // set new box size
-    double * const cell_size = World::getInstance().getDomain();
-    for (j=0;j<6;j++)
-      cell_size[j] = 0.;
-    j=-1;
-    for (int i=0;i<NDIM;i++) {
-      j += i+1;
-      cell_size[j] = (Max[i]-Min[i]+2.*boundary[i]);
-    }
-    // translate all atoms, such that Min is aty (0,0,0)
-    AtomRunner = AllAtoms.begin();
-    for (; AtomRunner != AllAtoms.end(); ++AtomRunner)
-      (*AtomRunner)->x -= Min - boundary;
-    delete dialog;
-    return Action::success;
-  } else {
-    delete dialog;
-    return Action::failure;
   }
+  // set new box size
+  double * const cell_size = new double[6];
+  for (j=0;j<6;j++)
+    cell_size[j] = 0.;
+  j=-1;
+  for (int i=0;i<NDIM;i++) {
+    j += i+1;
+    cell_size[j] = (Max[i]-Min[i]+2.*boundary[i]);
+  }
+  World::getInstance().setDomain(cell_size);
+  delete[] cell_size;
+  // translate all atoms, such that Min is aty (0,0,0)
+  AtomRunner = AllAtoms.begin();
+  for (; AtomRunner != AllAtoms.end(); ++AtomRunner)
+    *(*AtomRunner) -= Min - boundary;
+  return Action::success;
 }
 
Index: src/Actions/WorldAction/AddEmptyBoundaryAction.hpp
===================================================================
--- src/Actions/WorldAction/AddEmptyBoundaryAction.hpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/Actions/WorldAction/AddEmptyBoundaryAction.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -10,6 +10,11 @@
 
 #include "Actions/Action.hpp"
+#include "LinearAlgebra/Vector.hpp"
+
+void WorldAddEmptyBoundary(Vector &boundary);
 
 class WorldAddEmptyBoundaryAction : public Action {
+  friend void WorldAddEmptyBoundary(Vector &boundary);
+
 public:
   WorldAddEmptyBoundaryAction();
@@ -20,4 +25,6 @@
 
   virtual const std::string getName();
+protected:
+  virtual Dialog * fillDialog(Dialog *dialog);
 private:
   virtual Action::state_ptr performCall();
Index: src/Actions/WorldAction/BoundInBoxAction.cpp
===================================================================
--- src/Actions/WorldAction/BoundInBoxAction.cpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/Actions/WorldAction/BoundInBoxAction.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -6,8 +6,14 @@
  */
 
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
 #include "Helpers/MemDebug.hpp"
 
 #include "Actions/WorldAction/BoundInBoxAction.hpp"
-#include "log.hpp"
+#include "Actions/ActionRegistry.hpp"
+#include "Helpers/Log.hpp"
 #include "molecule.hpp"
 #include "World.hpp"
@@ -21,5 +27,5 @@
 #include "UIElements/UIFactory.hpp"
 #include "UIElements/Dialog.hpp"
-#include "Actions/MapOfActions.hpp"
+#include "Actions/ValueStorage.hpp"
 
 const char WorldBoundInBoxAction::NAME[] = "bound-in-box";
@@ -32,21 +38,24 @@
 {}
 
+void WorldBoundInBox() {
+  ActionRegistry::getInstance().getActionByName(WorldBoundInBoxAction::NAME)->call(Action::NonInteractive);
+};
+
+Dialog* WorldBoundInBoxAction::fillDialog(Dialog *dialog) {
+  ASSERT(dialog,"No Dialog given when filling action dialog");
+
+  dialog->queryEmpty(NAME, ValueStorage::getInstance().getDescription(NAME));
+
+  return dialog;
+}
+
 Action::state_ptr WorldBoundInBoxAction::performCall() {
-  Dialog *dialog = UIFactory::getInstance().makeDialog();
 
-  dialog->queryEmpty(NAME, MapOfActions::getInstance().getDescription(NAME));
-
-  if(dialog->display()) {
-    // center
-    vector<molecule*> AllMolecules = World::getInstance().getAllMolecules();
-    for (vector<molecule*>::iterator MolRunner = AllMolecules.begin(); MolRunner != AllMolecules.end(); ++MolRunner) {
-      (*MolRunner)->BoundInBox();
-    }
-    delete dialog;
-    return Action::success;
-  } else {
-    delete dialog;
-    return Action::failure;
+  // center
+  vector<molecule*> AllMolecules = World::getInstance().getAllMolecules();
+  for (vector<molecule*>::iterator MolRunner = AllMolecules.begin(); MolRunner != AllMolecules.end(); ++MolRunner) {
+    (*MolRunner)->BoundInBox();
   }
+  return Action::success;
 }
 
Index: src/Actions/WorldAction/BoundInBoxAction.hpp
===================================================================
--- src/Actions/WorldAction/BoundInBoxAction.hpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/Actions/WorldAction/BoundInBoxAction.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -11,5 +11,9 @@
 #include "Actions/Action.hpp"
 
+void WorldBoundInBox();
+
 class WorldBoundInBoxAction : public Action {
+  friend void WorldBoundInBox();
+
 public:
   WorldBoundInBoxAction();
@@ -20,4 +24,6 @@
 
   virtual const std::string getName();
+protected:
+  virtual Dialog * fillDialog(Dialog *dialog);
 private:
   virtual Action::state_ptr performCall();
Index: src/Actions/WorldAction/CenterInBoxAction.cpp
===================================================================
--- src/Actions/WorldAction/CenterInBoxAction.cpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/Actions/WorldAction/CenterInBoxAction.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -6,8 +6,15 @@
  */
 
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
 #include "Helpers/MemDebug.hpp"
 
 #include "Actions/WorldAction/CenterInBoxAction.hpp"
-#include "log.hpp"
+#include "Actions/ActionRegistry.hpp"
+#include "Box.hpp"
+#include "Helpers/Log.hpp"
 #include "molecule.hpp"
 #include "World.hpp"
@@ -20,5 +27,5 @@
 #include "UIElements/UIFactory.hpp"
 #include "UIElements/Dialog.hpp"
-#include "Actions/MapOfActions.hpp"
+#include "Actions/ValueStorage.hpp"
 
 const char WorldCenterInBoxAction::NAME[] = "center-in-box";
@@ -31,23 +38,29 @@
 {}
 
+void WorldCenterInBox(Box &_box) {
+  ValueStorage::getInstance().setCurrentValue(WorldCenterInBoxAction::NAME, _box);
+  ActionRegistry::getInstance().getActionByName(WorldCenterInBoxAction::NAME)->call(Action::NonInteractive);
+};
+
+Dialog* WorldCenterInBoxAction::fillDialog(Dialog *dialog) {
+  ASSERT(dialog,"No Dialog given when filling action dialog");
+
+  dialog->queryBox(NAME, ValueStorage::getInstance().getDescription(NAME));
+
+  return dialog;
+}
+
 Action::state_ptr WorldCenterInBoxAction::performCall() {
-  Dialog *dialog = UIFactory::getInstance().makeDialog();
 
-  double * cell_size = World::getInstance().getDomain();
-  dialog->queryBox(NAME, &cell_size, MapOfActions::getInstance().getDescription(NAME));
+  Box& cell_size = World::getInstance().getDomain();
+  ValueStorage::getInstance().queryCurrentValue(NAME, cell_size);
+  World::getInstance().setDomain(cell_size.getM());
 
-  if(dialog->display()) {
-    World::getInstance().setDomain(cell_size);
-    // center
-    vector<molecule *> AllMolecules = World::getInstance().getAllMolecules();
-    for (vector<molecule*>::iterator MolRunner = AllMolecules.begin(); MolRunner != AllMolecules.end(); ++MolRunner) {
-      (*MolRunner)->CenterInBox();
-    }
-    delete dialog;
-    return Action::success;
-  } else {
-    delete dialog;
-    return Action::failure;
+  // center
+  vector<molecule *> AllMolecules = World::getInstance().getAllMolecules();
+  for (vector<molecule*>::iterator MolRunner = AllMolecules.begin(); MolRunner != AllMolecules.end(); ++MolRunner) {
+    (*MolRunner)->CenterInBox();
   }
+  return Action::success;
 }
 
Index: src/Actions/WorldAction/CenterInBoxAction.hpp
===================================================================
--- src/Actions/WorldAction/CenterInBoxAction.hpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/Actions/WorldAction/CenterInBoxAction.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -10,6 +10,11 @@
 
 #include "Actions/Action.hpp"
+#include "Box.hpp"
+
+void WorldCenterInBox(Box &_box);
 
 class WorldCenterInBoxAction : public Action {
+  friend void WorldCenterInBox(Box &_box);
+
 public:
   WorldCenterInBoxAction();
@@ -20,4 +25,6 @@
 
   virtual const std::string getName();
+protected:
+  virtual Dialog * fillDialog(Dialog *dialog);
 private:
   virtual Action::state_ptr performCall();
Index: src/Actions/WorldAction/CenterOnEdgeAction.cpp
===================================================================
--- src/Actions/WorldAction/CenterOnEdgeAction.cpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/Actions/WorldAction/CenterOnEdgeAction.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -6,11 +6,18 @@
  */
 
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
 #include "Helpers/MemDebug.hpp"
 
 #include "Actions/WorldAction/CenterOnEdgeAction.hpp"
+#include "Actions/ActionRegistry.hpp"
 #include "atom.hpp"
-#include "log.hpp"
-#include "vector.hpp"
+#include "Helpers/Log.hpp"
+#include "LinearAlgebra/Vector.hpp"
 #include "World.hpp"
+#include "LinearAlgebra/Matrix.hpp"
 
 #include <iostream>
@@ -21,5 +28,5 @@
 #include "UIElements/UIFactory.hpp"
 #include "UIElements/Dialog.hpp"
-#include "Actions/MapOfActions.hpp"
+#include "Actions/ValueStorage.hpp"
 #include "Helpers/Assert.hpp"
 
@@ -33,46 +40,47 @@
 {}
 
+void WorldCenterOnEdge() {
+  ActionRegistry::getInstance().getActionByName(WorldCenterOnEdgeAction::NAME)->call(Action::NonInteractive);
+};
+
+Dialog* WorldCenterOnEdgeAction::fillDialog(Dialog *dialog) {
+  ASSERT(dialog,"No Dialog given when filling action dialog");
+
+  dialog->queryEmpty(NAME, ValueStorage::getInstance().getDescription(NAME));
+
+  return dialog;
+}
+
 Action::state_ptr WorldCenterOnEdgeAction::performCall() {
-  Dialog *dialog = UIFactory::getInstance().makeDialog();
   Vector Min;
   Vector Max;
-  int j=0;
 
-  dialog->queryEmpty(NAME, MapOfActions::getInstance().getDescription(NAME));
+  // get maximum and minimum
+  vector<atom *> AllAtoms = World::getInstance().getAllAtoms();
+  ASSERT(AllAtoms.size() > 0, "For CenteronEdge atoms must be present.");
+  vector<atom *>::iterator AtomRunner = AllAtoms.begin();
+  Min = (*AtomRunner)->getPosition();
+  Max = (*AtomRunner)->getPosition();
+  for (; AtomRunner != AllAtoms.end(); ++AtomRunner) {
+    for (int i=0;i<NDIM;i++) {
+      if ((*AtomRunner)->at(i) > Max[i])
+        Max[i] = (*AtomRunner)->at(i);
+      if ((*AtomRunner)->at(i) < Min[i])
+        Min[i] = (*AtomRunner)->at(i);
+    }
+  }
+  // set new box size
+  Matrix domain;
+  for (int i=0;i<NDIM;i++) {
+    double tmp = Max[i]-Min[i];
+    tmp = fabs(tmp)>=1. ? tmp : 1.0;
+    domain.at(i,i) = tmp;
+  }
+  World::getInstance().setDomain(domain);
+  // translate all atoms, such that Min is aty (0,0,0)
+  for (vector<atom*>::iterator AtomRunner = AllAtoms.begin(); AtomRunner != AllAtoms.end(); ++AtomRunner)
+    *(*AtomRunner) -= Min;
 
-  if(dialog->display()) {
-    // get maximum and minimum
-    vector<atom *> AllAtoms = World::getInstance().getAllAtoms();
-    ASSERT(AllAtoms.size() > 0, "For CenteronEdge atoms must be present.");
-    vector<atom *>::iterator AtomRunner = AllAtoms.begin();
-    Min = (*AtomRunner)->x;
-    Max = (*AtomRunner)->x;
-    for (; AtomRunner != AllAtoms.end(); ++AtomRunner) {
-      for (int i=0;i<NDIM;i++) {
-        if ((*AtomRunner)->x[i] > Max[i])
-          Max[i] = (*AtomRunner)->x[i];
-        if ((*AtomRunner)->x[i] < Min[i])
-          Min[i] = (*AtomRunner)->x[i];
-      }
-    }
-    // set new box size
-    double * const cell_size = World::getInstance().getDomain();
-    for (j=0;j<6;j++)
-      cell_size[j] = 0.;
-    j=-1;
-    for (int i=0;i<NDIM;i++) {
-      j += i+1;
-      cell_size[j] = (Max[i]-Min[i]);
-    }
-    World::getInstance().setDomain(cell_size);
-    // translate all atoms, such that Min is aty (0,0,0)
-    for (vector<atom*>::iterator AtomRunner = AllAtoms.begin(); AtomRunner != AllAtoms.end(); ++AtomRunner)
-      (*AtomRunner)->x -= Min;
-    delete dialog;
-    return Action::success;
-  } else {
-    delete dialog;
-    return Action::failure;
-  }
+  return Action::success;
 }
 
Index: src/Actions/WorldAction/CenterOnEdgeAction.hpp
===================================================================
--- src/Actions/WorldAction/CenterOnEdgeAction.hpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/Actions/WorldAction/CenterOnEdgeAction.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -11,5 +11,9 @@
 #include "Actions/Action.hpp"
 
+void WorldCenterOnEdge();
+
 class WorldCenterOnEdgeAction : public Action {
+  friend void WorldCenterOnEdge();
+
 public:
   WorldCenterOnEdgeAction();
@@ -20,4 +24,6 @@
 
   virtual const std::string getName();
+protected:
+  virtual Dialog * fillDialog(Dialog *dialog);
 private:
   virtual Action::state_ptr performCall();
Index: src/Actions/WorldAction/ChangeBoxAction.cpp
===================================================================
--- src/Actions/WorldAction/ChangeBoxAction.cpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/Actions/WorldAction/ChangeBoxAction.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -6,10 +6,18 @@
  */
 
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
 #include "Helpers/MemDebug.hpp"
 
 #include "Actions/WorldAction/ChangeBoxAction.hpp"
-#include "log.hpp"
-#include "verbose.hpp"
+#include "Actions/ActionRegistry.hpp"
+#include "Helpers/Log.hpp"
+#include "Helpers/Verbose.hpp"
 #include "World.hpp"
+#include "Box.hpp"
+#include "LinearAlgebra/Matrix.hpp"
 
 #include <iostream>
@@ -20,5 +28,5 @@
 #include "UIElements/UIFactory.hpp"
 #include "UIElements/Dialog.hpp"
-#include "Actions/MapOfActions.hpp"
+#include "Actions/ValueStorage.hpp"
 
 const char WorldChangeBoxAction::NAME[] = "change-box";
@@ -31,19 +39,25 @@
 {}
 
+void WorldChangeBox(Box &_box) {
+  ValueStorage::getInstance().setCurrentValue(WorldChangeBoxAction::NAME, _box);
+  ActionRegistry::getInstance().getActionByName(WorldChangeBoxAction::NAME)->call(Action::NonInteractive);
+};
+
+Dialog* WorldChangeBoxAction::fillDialog(Dialog *dialog) {
+  ASSERT(dialog,"No Dialog given when filling action dialog");
+
+  dialog->queryBox(NAME, ValueStorage::getInstance().getDescription(NAME));
+
+  return dialog;
+}
+
 Action::state_ptr WorldChangeBoxAction::performCall() {
-  Dialog *dialog = UIFactory::getInstance().makeDialog();
 
-  double * cell_size = World::getInstance().getDomain();
-  dialog->queryBox(NAME, &cell_size, MapOfActions::getInstance().getDescription(NAME));
+  Box cell_size;
+  ValueStorage::getInstance().queryCurrentValue(NAME, cell_size);
+  World::getInstance().setDomain(cell_size.getM()); // this is needed as only this function is OBSERVEd.
 
-  if(dialog->display()) {
-    DoLog(0) && (Log() << Verbose(0) << "Setting box domain to " << cell_size[0] << "," << cell_size[1] << "," << cell_size[2] << "," << cell_size[3] << "," << cell_size[4] << "," << cell_size[5] << "," << endl);
-    World::getInstance().setDomain(cell_size);
-    delete dialog;
-    return Action::success;
-  } else {
-    delete dialog;
-    return Action::failure;
-  }
+  DoLog(0) && (Log() << Verbose(0) << "Setting box domain to " << World::getInstance().getDomain().getM() << endl);
+  return Action::success;
 }
 
Index: src/Actions/WorldAction/ChangeBoxAction.hpp
===================================================================
--- src/Actions/WorldAction/ChangeBoxAction.hpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/Actions/WorldAction/ChangeBoxAction.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -10,6 +10,11 @@
 
 #include "Actions/Action.hpp"
+#include "Box.hpp"
+
+void WorldChangeBox(Box &_box);
 
 class WorldChangeBoxAction : public Action {
+  friend void WorldChangeBox(Box &_box);
+
 public:
   WorldChangeBoxAction();
@@ -20,4 +25,6 @@
 
   virtual const std::string getName();
+protected:
+  virtual Dialog * fillDialog(Dialog *dialog);
 private:
   virtual Action::state_ptr performCall();
Index: src/Actions/WorldAction/InputAction.cpp
===================================================================
--- src/Actions/WorldAction/InputAction.cpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/Actions/WorldAction/InputAction.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -6,12 +6,18 @@
  */
 
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
 #include "Helpers/MemDebug.hpp"
 
 #include "Actions/WorldAction/InputAction.hpp"
-#include "log.hpp"
+#include "Actions/ActionRegistry.hpp"
+#include "Helpers/Log.hpp"
 #include "molecule.hpp"
 #include "Parser/FormatParserStorage.hpp"
 #include "Parser/PcpParser.hpp"
-#include "verbose.hpp"
+#include "Helpers/Verbose.hpp"
 #include "World.hpp"
 
@@ -23,5 +29,5 @@
 #include "UIElements/UIFactory.hpp"
 #include "UIElements/Dialog.hpp"
-#include "Actions/MapOfActions.hpp"
+#include "Actions/ValueStorage.hpp"
 
 const char WorldInputAction::NAME[] = "input";
@@ -34,6 +40,18 @@
 {}
 
+void WorldInput(std::string &filename) {
+  ValueStorage::getInstance().setCurrentValue(WorldInputAction::NAME, filename);
+  ActionRegistry::getInstance().getActionByName(WorldInputAction::NAME)->call(Action::NonInteractive);
+};
+
+Dialog* WorldInputAction::fillDialog(Dialog *dialog) {
+  ASSERT(dialog,"No Dialog given when filling action dialog");
+
+  dialog->queryString(NAME, ValueStorage::getInstance().getDescription(NAME));
+
+  return dialog;
+}
+
 Action::state_ptr WorldInputAction::performCall() {
-  Dialog *dialog = UIFactory::getInstance().makeDialog();
   MoleculeListClass *molecules = World::getInstance().getMolecules();
   molecule *mol = NULL;
@@ -41,44 +59,38 @@
   std::ifstream test;
 
-  dialog->queryString(NAME, &filename, MapOfActions::getInstance().getDescription(NAME));
+  ValueStorage::getInstance().queryCurrentValue(NAME, filename);
 
-  if(dialog->display()) {
-    DoLog(0) && (Log() << Verbose(0) << "Config file given." << endl);
-    if (filename.find('.') != string::npos) {
-      std::string FilenamePrefix = filename.substr(0,filename.find_last_of('.'));
-      std::string FilenameSuffix = filename.substr(filename.find_last_of('.')+1, filename.length());
-      DoLog(1) && (Log() << Verbose(1) << "Setting config file name prefix to " << FilenamePrefix << "." << endl);
-      test.open(filename.c_str());
-      if (test == NULL) {
-        DoLog(1) && (Log() << Verbose(1) << "Specified config file " << filename << " not found." << endl);
-      } else {
-        DoLog(1) && (Log() << Verbose(1) << "Specified config file found, parsing ... ");
-        FormatParserStorage::getInstance().get((std::istream &)test, FilenameSuffix);
-        test.close();
-      }
-      FormatParserStorage::getInstance().SetOutputPrefixForAll(FilenamePrefix);
-      // set mol to first active molecule
-      if (molecules->ListOfMolecules.size() != 0) {
-        for (MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++)
-          if ((*ListRunner)->ActiveFlag) {
-            mol = *ListRunner;
-            break;
-          }
-      }
-      if (mol == NULL) {
-        mol = World::getInstance().createMolecule();
-        mol->ActiveFlag = true;
-        molecules->insert(mol);
-      }
-      mol->SetNameFromFilename(filename.substr(0,filename.find('.')).c_str());
+  DoLog(0) && (Log() << Verbose(0) << "Config file given." << endl);
+  if (filename.find('.') != string::npos) {
+    std::string FilenamePrefix = filename.substr(0,filename.find_last_of('.'));
+    std::string FilenameSuffix = filename.substr(filename.find_last_of('.')+1, filename.length());
+    DoLog(1) && (Log() << Verbose(1) << "Setting config file name prefix to " << FilenamePrefix << "." << endl);
+    test.open(filename.c_str());
+    if (test == NULL) {
+      DoLog(1) && (Log() << Verbose(1) << "Specified config file " << filename << " not found." << endl);
     } else {
-      DoeLog(1) && (eLog() << Verbose(1) << "Input file does not have a suffix, cannot recognize format." << endl);
+      DoLog(1) && (Log() << Verbose(1) << "Specified config file found, parsing ... ");
+      FormatParserStorage::getInstance().get((std::istream &)test, FilenameSuffix);
+      test.close();
     }
-    delete dialog;
-    return Action::success;
+    FormatParserStorage::getInstance().SetOutputPrefixForAll(FilenamePrefix);
+    // set mol to first active molecule
+    if (molecules->ListOfMolecules.size() != 0) {
+      for (MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++)
+        if ((*ListRunner)->ActiveFlag) {
+          mol = *ListRunner;
+          break;
+        }
+    }
+    if (mol == NULL) {
+      mol = World::getInstance().createMolecule();
+      mol->ActiveFlag = true;
+      molecules->insert(mol);
+    }
+    mol->SetNameFromFilename(filename.substr(0,filename.find('.')).c_str());
   } else {
-    delete dialog;
-    return Action::failure;
+    DoeLog(1) && (eLog() << Verbose(1) << "Input file does not have a suffix, cannot recognize format." << endl);
   }
+  return Action::success;
 }
 
Index: src/Actions/WorldAction/InputAction.hpp
===================================================================
--- src/Actions/WorldAction/InputAction.hpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/Actions/WorldAction/InputAction.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -11,5 +11,9 @@
 #include "Actions/Action.hpp"
 
+void WorldInput(std::string &filename);
+
 class WorldInputAction : public Action {
+  friend void WorldInput(std::string &filename);
+
 public:
   WorldInputAction();
@@ -20,4 +24,6 @@
 
   virtual const std::string getName();
+protected:
+  virtual Dialog * fillDialog(Dialog *dialog);
 private:
   virtual Action::state_ptr performCall();
Index: src/Actions/WorldAction/OutputAction.cpp
===================================================================
--- src/Actions/WorldAction/OutputAction.cpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/Actions/WorldAction/OutputAction.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -6,10 +6,16 @@
  */
 
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
 #include "Helpers/MemDebug.hpp"
 
 #include "Actions/WorldAction/OutputAction.hpp"
+#include "Actions/ActionRegistry.hpp"
 #include "Parser/ChangeTracker.hpp"
-#include "log.hpp"
-#include "verbose.hpp"
+#include "Helpers/Log.hpp"
+#include "Helpers/Verbose.hpp"
 #include "World.hpp"
 
@@ -21,5 +27,5 @@
 #include "UIElements/UIFactory.hpp"
 #include "UIElements/Dialog.hpp"
-#include "Actions/MapOfActions.hpp"
+#include "Actions/ValueStorage.hpp"
 
 const char WorldOutputAction::NAME[] = "output";
@@ -32,18 +38,21 @@
 {}
 
+void WorldOutput() {
+  ActionRegistry::getInstance().getActionByName(WorldOutputAction::NAME)->call(Action::NonInteractive);
+};
+
+Dialog* WorldOutputAction::fillDialog(Dialog *dialog) {
+  ASSERT(dialog,"No Dialog given when filling action dialog");
+
+  dialog->queryEmpty(NAME, ValueStorage::getInstance().getDescription(NAME));
+
+  return dialog;
+}
+
 Action::state_ptr WorldOutputAction::performCall() {
-  Dialog *dialog = UIFactory::getInstance().makeDialog();
 
-  dialog->queryEmpty(NAME, MapOfActions::getInstance().getDescription(NAME));
-
-  if(dialog->display()) {
-    DoLog(0) && (Log() << Verbose(0) << "Saving world to files." << endl);
-    ChangeTracker::getInstance().saveStatus();
-    delete dialog;
-    return Action::success;
-  } else {
-    delete dialog;
-    return Action::failure;
-  }
+  DoLog(0) && (Log() << Verbose(0) << "Saving world to files." << endl);
+  ChangeTracker::getInstance().saveStatus();
+  return Action::success;
 }
 
Index: src/Actions/WorldAction/OutputAction.hpp
===================================================================
--- src/Actions/WorldAction/OutputAction.hpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/Actions/WorldAction/OutputAction.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -11,5 +11,9 @@
 #include "Actions/Action.hpp"
 
+void WorldOutput();
+
 class WorldOutputAction : public Action {
+  friend void WorldOutput();
+
 public:
   WorldOutputAction();
@@ -20,4 +24,6 @@
 
   virtual const std::string getName();
+protected:
+  virtual Dialog * fillDialog(Dialog *dialog);
 private:
   virtual Action::state_ptr performCall();
Index: c/Actions/WorldAction/RemoveSphereOfAtomsAction.cpp
===================================================================
--- src/Actions/WorldAction/RemoveSphereOfAtomsAction.cpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ 	(revision )
@@ -1,90 +1,0 @@
-/*
- * RemoveSphereOfAtomsAction.cpp
- *
- *  Created on: May 12, 2010
- *      Author: heber
- */
-
-#include "Helpers/MemDebug.hpp"
-
-#include "Actions/WorldAction/RemoveSphereOfAtomsAction.hpp"
-#include "atom.hpp"
-#include "Descriptors/AtomDescriptor.hpp"
-#include "log.hpp"
-#include "molecule.hpp"
-#include "vector.hpp"
-#include "verbose.hpp"
-#include "World.hpp"
-
-#include <iostream>
-#include <string>
-
-using namespace std;
-
-#include "UIElements/UIFactory.hpp"
-#include "UIElements/Dialog.hpp"
-#include "Actions/MapOfActions.hpp"
-
-const char WorldRemoveSphereOfAtomsAction::NAME[] = "remove-sphere";
-
-WorldRemoveSphereOfAtomsAction::WorldRemoveSphereOfAtomsAction() :
-  Action(NAME)
-{}
-
-WorldRemoveSphereOfAtomsAction::~WorldRemoveSphereOfAtomsAction()
-{}
-
-Action::state_ptr WorldRemoveSphereOfAtomsAction::performCall() {
-  Dialog *dialog = UIFactory::getInstance().makeDialog();
-  double radius = 0.;
-  Vector point;
-
-  dialog->queryDouble(NAME, &radius, MapOfActions::getInstance().getDescription(NAME));
-  dialog->queryVector("position", &point, World::getInstance().getDomain(), false, MapOfActions::getInstance().getDescription("position"));
-
-  if(dialog->display()) {
-    delete dialog;
-    DoLog(1) && (Log() << Verbose(1) << "Removing atoms around " << point << " with radius " << radius << "." << endl);
-    vector<atom*> AllAtoms = World::getInstance().getAllAtoms();
-    vector<molecule *> molecules = World::getInstance().getAllMolecules();
-    for (vector<atom*>::iterator AtomRunner = AllAtoms.begin(); AtomRunner != AllAtoms.end(); ++AtomRunner) {
-      if (point.DistanceSquared((*AtomRunner)->x) > radius*radius) { // distance to first above radius ...
-        // TODO: This is not necessary anymore when atoms are completely handled by World (create/destroy and load/save)
-        for (vector<molecule *>::iterator iter = molecules.begin();iter != molecules.end();++iter)
-          (*iter)->erase(*AtomRunner);
-        World::getInstance().destroyAtom(*AtomRunner);
-      }
-    }
-    return Action::success;
-  } else {
-    delete dialog;
-    return Action::failure;
-  }
-
-}
-
-Action::state_ptr WorldRemoveSphereOfAtomsAction::performUndo(Action::state_ptr _state) {
-//  ParserLoadXyzState *state = assert_cast<ParserLoadXyzState*>(_state.get());
-
-  return Action::failure;
-//  string newName = state->mol->getName();
-//  state->mol->setName(state->lastName);
-//
-//  return Action::state_ptr(new ParserLoadXyzState(state->mol,newName));
-}
-
-Action::state_ptr WorldRemoveSphereOfAtomsAction::performRedo(Action::state_ptr _state){
-  return Action::failure;
-}
-
-bool WorldRemoveSphereOfAtomsAction::canUndo() {
-  return false;
-}
-
-bool WorldRemoveSphereOfAtomsAction::shouldUndo() {
-  return false;
-}
-
-const string WorldRemoveSphereOfAtomsAction::getName() {
-  return NAME;
-}
Index: c/Actions/WorldAction/RemoveSphereOfAtomsAction.hpp
===================================================================
--- src/Actions/WorldAction/RemoveSphereOfAtomsAction.hpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ 	(revision )
@@ -1,30 +1,0 @@
-/*
- * RemoveSphereOfAtomsAction.hpp
- *
- *  Created on: May 9, 2010
- *      Author: heber
- */
-
-#ifndef REMOVESPHEREOFATOMS_HPP_
-#define REMOVESPHEREOFATOMS_HPP_
-
-#include "Actions/Action.hpp"
-
-class WorldRemoveSphereOfAtomsAction : public Action {
-public:
-  WorldRemoveSphereOfAtomsAction();
-  virtual ~WorldRemoveSphereOfAtomsAction();
-
-  bool canUndo();
-  bool shouldUndo();
-
-  virtual const std::string getName();
-private:
-  virtual Action::state_ptr performCall();
-  virtual Action::state_ptr performUndo(Action::state_ptr);
-  virtual Action::state_ptr performRedo(Action::state_ptr);
-
-  static const char NAME[];
-};
-
-#endif /* REMOVESPHEREOFATOMS_HPP_ */
Index: src/Actions/WorldAction/RepeatBoxAction.cpp
===================================================================
--- src/Actions/WorldAction/RepeatBoxAction.cpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/Actions/WorldAction/RepeatBoxAction.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -6,16 +6,25 @@
  */
 
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
 #include "Helpers/MemDebug.hpp"
 
 #include "Actions/WorldAction/RepeatBoxAction.hpp"
+#include "Actions/ActionRegistry.hpp"
 #include "atom.hpp"
-#include "log.hpp"
+#include "Helpers/Log.hpp"
 #include "molecule.hpp"
-#include "vector.hpp"
-#include "verbose.hpp"
+#include "LinearAlgebra/Vector.hpp"
+#include "LinearAlgebra/Matrix.hpp"
+#include "Helpers/Verbose.hpp"
 #include "World.hpp"
+#include "Box.hpp"
 
 #include <iostream>
 #include <string>
+#include <vector>
 
 using namespace std;
@@ -23,5 +32,5 @@
 #include "UIElements/UIFactory.hpp"
 #include "UIElements/Dialog.hpp"
-#include "Actions/MapOfActions.hpp"
+#include "Actions/ValueStorage.hpp"
 #include "Descriptors/MoleculeDescriptor.hpp"
 #include "Descriptors/MoleculePtrDescriptor.hpp"
@@ -36,6 +45,18 @@
 {}
 
+void WorldRepeatBox(Vector &Repeater) {
+  ValueStorage::getInstance().setCurrentValue(WorldRepeatBoxAction::NAME, Repeater);
+  ActionRegistry::getInstance().getActionByName(WorldRepeatBoxAction::NAME)->call(Action::NonInteractive);
+};
+
+Dialog * WorldRepeatBoxAction::fillDialog(Dialog *dialog) {
+  ASSERT(dialog,"No Dialog given when filling action dialog");
+
+  dialog->queryVector(NAME, false, ValueStorage::getInstance().getDescription(NAME));
+
+  return dialog;
+}
+
 Action::state_ptr WorldRepeatBoxAction::performCall() {
-  Dialog *dialog = UIFactory::getInstance().makeDialog();
   Vector Repeater;
   int count;
@@ -46,6 +67,6 @@
   MoleculeListClass *molecules = World::getInstance().getMolecules();
 
-  dialog->queryVector(NAME, &Repeater, World::getInstance().getDomain(), false, MapOfActions::getInstance().getDescription(NAME));
-  //dialog->queryMolecule("molecule-by-id", &mol,MapOfActions::getInstance().getDescription("molecule-by-id"));
+  ValueStorage::getInstance().queryCurrentValue(NAME, Repeater);
+
   vector<molecule *> AllMolecules;
   if (mol != NULL) {
@@ -57,73 +78,67 @@
   }
 
-  if(dialog->display()) {
-    (cout << "Repeating box " << Repeater << " times for (x,y,z) axis." << endl);
-    double * const cell_size = World::getInstance().getDomain();
-    double *M = ReturnFullMatrixforSymmetric(cell_size);
-    Vector x,y;
-    int n[NDIM];
-    for (int axis = 0; axis < NDIM; axis++) {
-      Repeater[axis] = floor(Repeater[axis]);
-      if (Repeater[axis] < 1) {
-        DoeLog(1) && (eLog()<< Verbose(1) << "Repetition factor must be greater than 1!" << endl);
-        Repeater[axis] = 1;
-      }
-      cell_size[ ((axis == 1) ? 2 : (axis == 2) ? 5 : 0) ] *= Repeater[axis];
+  (cout << "Repeating box " << Repeater << " times for (x,y,z) axis." << endl);
+  Matrix M = World::getInstance().getDomain().getM();
+  Matrix newM = M;
+  Vector x,y;
+  int n[NDIM];
+  Matrix repMat;
+  for (int axis = 0; axis < NDIM; axis++) {
+    Repeater[axis] = floor(Repeater[axis]);
+    if (Repeater[axis] < 1) {
+      DoeLog(1) && (eLog()<< Verbose(1) << "Repetition factor must be greater than 1!" << endl);
+      Repeater[axis] = 1;
     }
+    repMat.at(axis,axis) = Repeater[axis];
+  }
+  newM *= repMat;
+  World::getInstance().setDomain(newM);
 
-    World::getInstance().setDomain(cell_size);
-    molecule *newmol = NULL;
-    Vector ** vectors = NULL;
-    for (n[0] = 0; n[0] < Repeater[0]; n[0]++) {
-      y[0] = n[0];
-      for (n[1] = 0; n[1] < Repeater[1]; n[1]++) {
-        y[1] = n[1];
-        for (n[2] = 0; n[2] < Repeater[2]; n[2]++) {
-          y[2] = n[2];
-          if ((n[0] == 0) && (n[1] == 0) && (n[2] == 0))
-            continue;
-          for (vector<molecule *>::iterator MolRunner = AllMolecules.begin(); MolRunner != AllMolecules.end(); ++MolRunner) {
-            mol = *MolRunner;
-            DoLog(1) && (Log() << Verbose(1) << "Current mol is " << mol->name << "." << endl);
-            count = mol->getAtomCount();   // is changed becausing of adding, thus has to be stored away beforehand
-            if (count != 0) {  // if there is more than none
-              Elements = new const element *[count];
-              vectors = new Vector *[count];
-              j = 0;
-              for(molecule::iterator AtomRunner = mol->begin(); AtomRunner != mol->end(); ++AtomRunner) {
-                Elements[j] = (*AtomRunner)->type;
-                vectors[j] = &(*AtomRunner)->x;
-                j++;
-              }
-              if (count != j)
-                DoeLog(1) && (eLog()<< Verbose(1) << "AtomCount " << count << " is not equal to number of atoms in molecule " << j << "!" << endl);
-              x = y;
-              x.MatrixMultiplication(M);
-              newmol = World::getInstance().createMolecule();
-              molecules->insert(newmol);
-              for (int k=count;k--;) { // go through every atom of the original cell
-                Walker = World::getInstance().createAtom(); // create a new body
-                Walker->x = (*vectors[k]) + x;
-                Walker->type = Elements[k];  // insert original element
-                cout << "new atom is " << *Walker << endl;
-                newmol->AddAtom(Walker);        // and add to the molecule (which increments ElementsInMolecule, AtomCount, ...)
-              }
-              // free memory
-              delete[](Elements);
-              delete[](vectors);
-            } else {
-              DoLog(1) && (Log() << Verbose(1) << "\t ... is empty." << endl);
+  molecule *newmol = NULL;
+  std::vector<Vector> vectors;
+  for (n[0] = 0; n[0] < Repeater[0]; n[0]++) {
+    y[0] = n[0];
+    for (n[1] = 0; n[1] < Repeater[1]; n[1]++) {
+      y[1] = n[1];
+      for (n[2] = 0; n[2] < Repeater[2]; n[2]++) {
+        y[2] = n[2];
+        if ((n[0] == 0) && (n[1] == 0) && (n[2] == 0))
+          continue;
+        for (vector<molecule *>::iterator MolRunner = AllMolecules.begin(); MolRunner != AllMolecules.end(); ++MolRunner) {
+          mol = *MolRunner;
+          DoLog(1) && (Log() << Verbose(1) << "Current mol is " << mol->name << "." << endl);
+          count = mol->getAtomCount();   // is changed becausing of adding, thus has to be stored away beforehand
+          if (count != 0) {  // if there is more than none
+            Elements = new const element *[count];
+            vectors.resize(count);
+            j = 0;
+            for(molecule::iterator AtomRunner = mol->begin(); AtomRunner != mol->end(); ++AtomRunner) {
+              Elements[j] = (*AtomRunner)->getType();
+              vectors[j] = (*AtomRunner)->getPosition();
+              j++;
             }
+            if (count != j)
+              DoeLog(1) && (eLog()<< Verbose(1) << "AtomCount " << count << " is not equal to number of atoms in molecule " << j << "!" << endl);
+            x = y;
+            x *= M;
+            newmol = World::getInstance().createMolecule();
+            molecules->insert(newmol);
+            for (int k=count;k--;) { // go through every atom of the original cell
+              Walker = World::getInstance().createAtom(); // create a new body
+              Walker->setPosition((vectors[k]) + x);
+              Walker->setType(Elements[k]);  // insert original element
+              cout << "new atom is " << *Walker << endl;
+              newmol->AddAtom(Walker);        // and add to the molecule (which increments ElementsInMolecule, AtomCount, ...)
+            }
+            // free memory
+            delete[](Elements);
+          } else {
+            DoLog(1) && (Log() << Verbose(1) << "\t ... is empty." << endl);
           }
         }
       }
     }
-    delete(M);
-    delete dialog;
-    return Action::success;
-  } else {
-    delete dialog;
-    return Action::failure;
   }
+  return Action::success;
 }
 
Index: src/Actions/WorldAction/RepeatBoxAction.hpp
===================================================================
--- src/Actions/WorldAction/RepeatBoxAction.hpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/Actions/WorldAction/RepeatBoxAction.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -10,6 +10,11 @@
 
 #include "Actions/Action.hpp"
+#include "LinearAlgebra/Vector.hpp"
+
+void WorldRepeatBox(Vector &Repeater);
 
 class WorldRepeatBoxAction : public Action {
+  friend void WorldRepeatBox(Vector &Repeater);
+
 public:
   WorldRepeatBoxAction();
@@ -20,4 +25,6 @@
 
   virtual const std::string getName();
+protected:
+  virtual Dialog * fillDialog(Dialog *dialog);
 private:
   virtual Action::state_ptr performCall();
Index: src/Actions/WorldAction/ScaleBoxAction.cpp
===================================================================
--- src/Actions/WorldAction/ScaleBoxAction.cpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/Actions/WorldAction/ScaleBoxAction.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -6,12 +6,20 @@
  */
 
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
 #include "Helpers/MemDebug.hpp"
 
 #include "Actions/WorldAction/ScaleBoxAction.hpp"
+#include "Actions/ActionRegistry.hpp"
 #include "atom.hpp"
-#include "log.hpp"
-#include "vector.hpp"
-#include "verbose.hpp"
+#include "Helpers/Log.hpp"
+#include "LinearAlgebra/Vector.hpp"
+#include "Helpers/Verbose.hpp"
 #include "World.hpp"
+#include "Box.hpp"
+#include "LinearAlgebra/Matrix.hpp"
 
 #include <iostream>
@@ -22,5 +30,5 @@
 #include "UIElements/UIFactory.hpp"
 #include "UIElements/Dialog.hpp"
-#include "Actions/MapOfActions.hpp"
+#include "Actions/ValueStorage.hpp"
 
 const char WorldScaleBoxAction::NAME[] = "scale-box";
@@ -33,34 +41,41 @@
 {}
 
+void WorldScaleBox(Vector &Scaler) {
+  ValueStorage::getInstance().setCurrentValue(WorldScaleBoxAction::NAME, Scaler);
+  ActionRegistry::getInstance().getActionByName(WorldScaleBoxAction::NAME)->call(Action::NonInteractive);
+};
+
+Dialog* WorldScaleBoxAction::fillDialog(Dialog *dialog) {
+  ASSERT(dialog,"No Dialog given when filling action dialog");
+
+  dialog->queryVector(NAME, false, ValueStorage::getInstance().getDescription(NAME));
+
+  return dialog;
+}
+
 Action::state_ptr WorldScaleBoxAction::performCall() {
-  Dialog *dialog = UIFactory::getInstance().makeDialog();
   Vector Scaler;
   double x[NDIM];
-  int j=0;
 
-  dialog->queryVector(NAME, &Scaler, World::getInstance().getDomain(), false, MapOfActions::getInstance().getDescription(NAME));
+  ValueStorage::getInstance().queryCurrentValue(NAME, Scaler);
 
-  if(dialog->display()) {
-    DoLog(1) && (Log() << Verbose(1) << "Scaling all atomic positions by factor." << endl);
-    for (int i=0;i<NDIM;i++)
-      x[i] = Scaler[i];
-    vector<atom*> AllAtoms = World::getInstance().getAllAtoms();
-    for(vector<atom*>::iterator AtomRunner = AllAtoms.begin(); AtomRunner != AllAtoms.end(); ++AtomRunner) {
-      (*AtomRunner)->x.ScaleAll(x);
-    }
-    j = -1;
-    double * const cell_size = World::getInstance().getDomain();
-    for (int i=0;i<NDIM;i++) {
-      j += i+1;
-      cell_size[j]*=x[i];
-    }
-    World::getInstance().setDomain(cell_size);
+  DoLog(1) && (Log() << Verbose(1) << "Scaling all atomic positions by factor." << endl);
+  for (int i=0;i<NDIM;i++)
+    x[i] = Scaler[i];
+  vector<atom*> AllAtoms = World::getInstance().getAllAtoms();
+  for(vector<atom*>::iterator AtomRunner = AllAtoms.begin(); AtomRunner != AllAtoms.end(); ++AtomRunner) {
+    (*AtomRunner)->ScaleAll(x);
+  }
 
-    delete dialog;
-    return Action::success;
-  } else {
-    delete dialog;
-    return Action::failure;
+  Matrix M = World::getInstance().getDomain().getM();
+  Matrix scale;
+
+  for (int i=0;i<NDIM;i++) {
+    scale.at(i,i) = x[i];
   }
+  M *= scale;
+  World::getInstance().setDomain(M);
+
+  return Action::success;
 }
 
Index: src/Actions/WorldAction/ScaleBoxAction.hpp
===================================================================
--- src/Actions/WorldAction/ScaleBoxAction.hpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/Actions/WorldAction/ScaleBoxAction.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -10,6 +10,11 @@
 
 #include "Actions/Action.hpp"
+#include "LinearAlgebra/Vector.hpp"
+
+void WorldScaleBox(Vector &Scaler);
 
 class WorldScaleBoxAction : public Action {
+  friend void WorldScaleBox(Vector &Scaler);
+
 public:
   WorldScaleBoxAction();
@@ -20,4 +25,6 @@
 
   virtual const std::string getName();
+protected:
+  virtual Dialog * fillDialog(Dialog *dialog);
 private:
   virtual Action::state_ptr performCall();
Index: src/Actions/WorldAction/SetDefaultNameAction.cpp
===================================================================
--- src/Actions/WorldAction/SetDefaultNameAction.cpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/Actions/WorldAction/SetDefaultNameAction.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -6,9 +6,15 @@
  */
 
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
 #include "Helpers/MemDebug.hpp"
 
 #include "Actions/WorldAction/SetDefaultNameAction.hpp"
-#include "log.hpp"
-#include "verbose.hpp"
+#include "Actions/ActionRegistry.hpp"
+#include "Helpers/Log.hpp"
+#include "Helpers/Verbose.hpp"
 #include "World.hpp"
 
@@ -20,5 +26,16 @@
 #include "UIElements/UIFactory.hpp"
 #include "UIElements/Dialog.hpp"
-#include "Actions/MapOfActions.hpp"
+#include "Actions/ValueStorage.hpp"
+
+
+// memento to remember the state when undoing
+
+class WorldSetDefaultNameState : public ActionState {
+public:
+  WorldSetDefaultNameState(std::string _lastName) :
+    lastName(_lastName)
+  {}
+  std::string lastName;
+};
 
 const char WorldSetDefaultNameAction::NAME[] = "default-molname";
@@ -31,42 +48,51 @@
 {}
 
+void WorldSetDefaultName(std::string &defaultname) {
+  ValueStorage::getInstance().setCurrentValue(WorldSetDefaultNameAction::NAME, defaultname);
+  ActionRegistry::getInstance().getActionByName(WorldSetDefaultNameAction::NAME)->call(Action::NonInteractive);
+};
+
+Dialog* WorldSetDefaultNameAction::fillDialog(Dialog *dialog) {
+  ASSERT(dialog,"No Dialog given when filling action dialog");
+
+  string defaultname = World::getInstance().getDefaultName();
+  ValueStorage::getInstance().setCurrentValue(NAME, defaultname);
+  dialog->queryString(NAME, ValueStorage::getInstance().getDescription(NAME));
+
+  return dialog;
+}
+
 Action::state_ptr WorldSetDefaultNameAction::performCall() {
-  Dialog *dialog = UIFactory::getInstance().makeDialog();
   string defaultname;
 
   defaultname = World::getInstance().getDefaultName();
-  dialog->queryString(NAME, &defaultname, MapOfActions::getInstance().getDescription(NAME));
+  WorldSetDefaultNameState *UndoState = new WorldSetDefaultNameState(defaultname);
+  ValueStorage::getInstance().queryCurrentValue(NAME, defaultname);
 
-  if(dialog->display()) {
-    World::getInstance().setDefaultName(defaultname);
-    DoLog(0) && (Log() << Verbose(0) << "Default name of new molecules set to " << World::getInstance().getDefaultName() << "." << endl);
-    delete dialog;
-    return Action::success;
-  } else {
-    delete dialog;
-    return Action::failure;
-  }
+  World::getInstance().setDefaultName(defaultname);
+  DoLog(0) && (Log() << Verbose(0) << "Default name of new molecules set to " << World::getInstance().getDefaultName() << "." << endl);
+  return Action::state_ptr(UndoState);
 }
 
 Action::state_ptr WorldSetDefaultNameAction::performUndo(Action::state_ptr _state) {
-//  ParserLoadXyzState *state = assert_cast<ParserLoadXyzState*>(_state.get());
+  WorldSetDefaultNameState *state = assert_cast<WorldSetDefaultNameState*>(_state.get());
 
-  return Action::failure;
-//  string newName = state->mol->getName();
-//  state->mol->setName(state->lastName);
-//
-//  return Action::state_ptr(new ParserLoadXyzState(state->mol,newName));
+  string newName = World::getInstance().getDefaultName();
+  World::getInstance().setDefaultName(state->lastName);
+  DoLog(0) && (Log() << Verbose(0) << "Default name of new molecules set to " << World::getInstance().getDefaultName() << "." << endl);
+
+  return Action::state_ptr(new WorldSetDefaultNameState(newName));
 }
 
 Action::state_ptr WorldSetDefaultNameAction::performRedo(Action::state_ptr _state){
-  return Action::failure;
+  return performUndo(_state);
 }
 
 bool WorldSetDefaultNameAction::canUndo() {
-  return false;
+  return true;
 }
 
 bool WorldSetDefaultNameAction::shouldUndo() {
-  return false;
+  return true;
 }
 
Index: src/Actions/WorldAction/SetDefaultNameAction.hpp
===================================================================
--- src/Actions/WorldAction/SetDefaultNameAction.hpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/Actions/WorldAction/SetDefaultNameAction.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -11,5 +11,9 @@
 #include "Actions/Action.hpp"
 
+void WorldSetDefaultName(std::string &defaultname);
+
 class WorldSetDefaultNameAction : public Action {
+  friend void WorldSetDefaultName(std::string &defaultname);
+
 public:
   WorldSetDefaultNameAction();
@@ -20,4 +24,6 @@
 
   virtual const std::string getName();
+protected:
+  virtual Dialog * fillDialog(Dialog *dialog);
 private:
   virtual Action::state_ptr performCall();
Index: src/Actions/WorldAction/SetGaussianBasisAction.cpp
===================================================================
--- src/Actions/WorldAction/SetGaussianBasisAction.cpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/Actions/WorldAction/SetGaussianBasisAction.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -6,10 +6,16 @@
  */
 
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
 #include "Helpers/MemDebug.hpp"
 
 #include "Actions/WorldAction/SetGaussianBasisAction.hpp"
+#include "Actions/ActionRegistry.hpp"
 #include "config.hpp"
-#include "log.hpp"
-#include "verbose.hpp"
+#include "Helpers/Log.hpp"
+#include "Helpers/Verbose.hpp"
 #include "World.hpp"
 
@@ -21,5 +27,17 @@
 #include "UIElements/UIFactory.hpp"
 #include "UIElements/Dialog.hpp"
-#include "Actions/MapOfActions.hpp"
+#include "Actions/ValueStorage.hpp"
+
+
+// memento to remember the state when undoing
+
+class WorldSetGaussianBasisState : public ActionState {
+public:
+  WorldSetGaussianBasisState(std::string _lastName) :
+    lastName(_lastName)
+  {}
+  std::string lastName;
+};
+
 
 const char WorldSetGaussianBasisAction::NAME[] = "set-basis";
@@ -32,39 +50,47 @@
 {}
 
+void WorldSetGaussianBasis(std::string &basisname) {
+  ValueStorage::getInstance().setCurrentValue(WorldSetGaussianBasisAction::NAME, basisname);
+  ActionRegistry::getInstance().getActionByName(WorldSetGaussianBasisAction::NAME)->call(Action::NonInteractive);
+};
+
+Dialog* WorldSetGaussianBasisAction::fillDialog(Dialog *dialog) {
+  ASSERT(dialog,"No Dialog given when filling action dialog");
+
+  dialog->queryString(NAME, ValueStorage::getInstance().getDescription(NAME));
+
+  return dialog;
+}
+
 Action::state_ptr WorldSetGaussianBasisAction::performCall() {
-  Dialog *dialog = UIFactory::getInstance().makeDialog();
   config *configuration = World::getInstance().getConfig();
-  dialog->queryString(NAME, &(configuration->basis), MapOfActions::getInstance().getDescription(NAME));
 
-  if(dialog->display()) {
-    DoLog(1) && (Log() << Verbose(1) << "Setting MPQC basis to " << configuration->basis << "." << endl);
-    delete dialog;
-    return Action::success;
-  } else {
-    delete dialog;
-    return Action::failure;
-  }
+  string lastname = configuration->basis;
+  ValueStorage::getInstance().queryCurrentValue(NAME, configuration->basis);
+
+  DoLog(1) && (Log() << Verbose(1) << "Setting MPQC basis to " << configuration->basis << "." << endl);
+  return Action::success;
 }
 
 Action::state_ptr WorldSetGaussianBasisAction::performUndo(Action::state_ptr _state) {
-//  ParserLoadXyzState *state = assert_cast<ParserLoadXyzState*>(_state.get());
+  WorldSetGaussianBasisState *state = assert_cast<WorldSetGaussianBasisState*>(_state.get());
 
-  return Action::failure;
-//  string newName = state->mol->getName();
-//  state->mol->setName(state->lastName);
-//
-//  return Action::state_ptr(new ParserLoadXyzState(state->mol,newName));
+  config *configuration = World::getInstance().getConfig();
+  string newName = configuration->basis;
+  configuration->basis = state->lastName;
+
+  return Action::state_ptr(new WorldSetGaussianBasisState(newName));
 }
 
 Action::state_ptr WorldSetGaussianBasisAction::performRedo(Action::state_ptr _state){
-  return Action::failure;
+  return performUndo(_state);
 }
 
 bool WorldSetGaussianBasisAction::canUndo() {
-  return false;
+  return true;
 }
 
 bool WorldSetGaussianBasisAction::shouldUndo() {
-  return false;
+  return true;
 }
 
Index: src/Actions/WorldAction/SetGaussianBasisAction.hpp
===================================================================
--- src/Actions/WorldAction/SetGaussianBasisAction.hpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/Actions/WorldAction/SetGaussianBasisAction.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -11,5 +11,9 @@
 #include "Actions/Action.hpp"
 
+void WorldSetGaussianBasis(std::string &basisname);
+
 class WorldSetGaussianBasisAction : public Action {
+  friend void WorldSetGaussianBasis(std::string &basisname);
+
 public:
   WorldSetGaussianBasisAction();
@@ -20,4 +24,6 @@
 
   virtual const std::string getName();
+protected:
+  virtual Dialog * fillDialog(Dialog *dialog);
 private:
   virtual Action::state_ptr performCall();
Index: src/Actions/WorldAction/SetOutputFormatsAction.cpp
===================================================================
--- src/Actions/WorldAction/SetOutputFormatsAction.cpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/Actions/WorldAction/SetOutputFormatsAction.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -6,11 +6,17 @@
  */
 
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
 #include "Helpers/MemDebug.hpp"
 
 #include "Actions/WorldAction/SetOutputFormatsAction.hpp"
+#include "Actions/ActionRegistry.hpp"
 #include "Parser/ChangeTracker.hpp"
 #include "Parser/FormatParserStorage.hpp"
-#include "log.hpp"
-#include "verbose.hpp"
+#include "Helpers/Log.hpp"
+#include "Helpers/Verbose.hpp"
 #include "World.hpp"
 
@@ -22,5 +28,5 @@
 #include "UIElements/UIFactory.hpp"
 #include "UIElements/Dialog.hpp"
-#include "Actions/MapOfActions.hpp"
+#include "Actions/ValueStorage.hpp"
 
 const char WorldSetOutputFormatsAction::NAME[] = "set-output";
@@ -33,35 +39,41 @@
 {}
 
+void WorldSetOutputFormats(vector<std::string> &FormatList) {
+  ValueStorage::getInstance().setCurrentValue(WorldSetOutputFormatsAction::NAME, FormatList);
+  ActionRegistry::getInstance().getActionByName(WorldSetOutputFormatsAction::NAME)->call(Action::NonInteractive);
+};
+
+Dialog* WorldSetOutputFormatsAction::fillDialog(Dialog *dialog) {
+  ASSERT(dialog,"No Dialog given when filling action dialog");
+
+  dialog->queryStrings(NAME, ValueStorage::getInstance().getDescription(NAME));
+
+  return dialog;
+}
+
 Action::state_ptr WorldSetOutputFormatsAction::performCall() {
-  Dialog *dialog = UIFactory::getInstance().makeDialog();
   vector<std::string> FormatList;
 
-  dialog->queryStrings(NAME, &FormatList, MapOfActions::getInstance().getDescription(NAME));
+  ValueStorage::getInstance().queryCurrentValue(NAME, FormatList);
 
-  if(dialog->display()) {
-    for (vector<std::string>::iterator iter = FormatList.begin(); iter != FormatList.end(); ++iter) {
-      if (*iter == "mpqc") {
-        FormatParserStorage::getInstance().addMpqc();
-        DoLog(0) && (Log() << Verbose(0) << "Adding mpqc type to output." << endl);
-      } else if (*iter == "pcp") {
-        FormatParserStorage::getInstance().addPcp();
-        DoLog(0) && (Log() << Verbose(0) << "Adding pcp type to output." << endl);
-      } else if (*iter == "tremolo") {
-        FormatParserStorage::getInstance().addTremolo();
-        DoLog(0) && (Log() << Verbose(0) << "Adding tremolo type to output." << endl);
-      } else if (*iter == "xyz") {
-        FormatParserStorage::getInstance().addXyz();
-        DoLog(0) && (Log() << Verbose(0) << "Adding xyz type to output." << endl);
-      } else {
-        DoeLog(1) && (eLog() << Verbose(1) << "Unknown format." << endl);
-      }
+  for (vector<std::string>::iterator iter = FormatList.begin(); iter != FormatList.end(); ++iter) {
+    if (*iter == "mpqc") {
+      FormatParserStorage::getInstance().addMpqc();
+      DoLog(0) && (Log() << Verbose(0) << "Adding mpqc type to output." << endl);
+    } else if (*iter == "pcp") {
+      FormatParserStorage::getInstance().addPcp();
+      DoLog(0) && (Log() << Verbose(0) << "Adding pcp type to output." << endl);
+    } else if (*iter == "tremolo") {
+      FormatParserStorage::getInstance().addTremolo();
+      DoLog(0) && (Log() << Verbose(0) << "Adding tremolo type to output." << endl);
+    } else if (*iter == "xyz") {
+      FormatParserStorage::getInstance().addXyz();
+      DoLog(0) && (Log() << Verbose(0) << "Adding xyz type to output." << endl);
+    } else {
+      DoeLog(1) && (eLog() << Verbose(1) << "Unknown format:" << *iter << endl);
     }
-    ChangeTracker::getInstance().saveStatus();
-    delete dialog;
-    return Action::success;
-  } else {
-    delete dialog;
-    return Action::failure;
   }
+  ChangeTracker::getInstance().saveStatus();
+  return Action::success;
 }
 
Index: src/Actions/WorldAction/SetOutputFormatsAction.hpp
===================================================================
--- src/Actions/WorldAction/SetOutputFormatsAction.hpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/Actions/WorldAction/SetOutputFormatsAction.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -11,5 +11,11 @@
 #include "Actions/Action.hpp"
 
+#include <vector>
+
+void WorldSetOutputFormats(std::vector<std::string> &FormatList);
+
 class WorldSetOutputFormatsAction : public Action {
+  friend void WorldSetOutputFormats(std::vector<std::string> &FormatList);
+
 public:
   WorldSetOutputFormatsAction();
@@ -20,4 +26,6 @@
 
   virtual const std::string getName();
+protected:
+  virtual Dialog * fillDialog(Dialog *dialog);
 private:
   virtual Action::state_ptr performCall();
Index: src/AtomSet.hpp
===================================================================
--- src/AtomSet.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
+++ src/AtomSet.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -0,0 +1,91 @@
+/*
+ * AtomSet.hpp
+ *
+ *  Created on: Jul 30, 2010
+ *      Author: crueger
+ */
+
+#ifndef ATOMSET_HPP_
+#define ATOMSET_HPP_
+
+
+#include <functional>
+#include <algorithm>
+#include <boost/foreach.hpp>
+#include <limits>
+
+/**
+ * A simple mixin to give any STL conforming structure fast Vector abilities
+ *
+ * TODO: make this work for maps
+ */
+
+#include "atom.hpp"
+#include <list>
+
+// this tests, whether we actually have a Vector
+template <class V>
+struct is_atom{};
+
+template <>
+struct is_atom<atom*>{
+  typedef void wrong_type;
+};
+
+template <class Set>
+class AtomSetMixin : public Set
+{
+  // when our set carries something besides a atom* this will produce an error
+  typedef typename is_atom<typename Set::value_type>::wrong_type check_for_atom;
+public:
+  // typedefs for STL conforming structure
+  typedef typename Set::iterator iterator;
+  typedef typename Set::const_iterator const_iterator;
+
+  AtomSetMixin() :
+    Set()
+  {}
+
+  AtomSetMixin(const Set& src) :
+    Set(src)
+  {}
+  virtual ~AtomSetMixin(){}
+
+  /**
+   * translate all Atoms within this set by a specified amount
+   */
+  void translate(const Vector &translater);
+
+  template<class Function>
+  void transformNodes(Function f);
+
+private:
+  template<class Function>
+  struct workOnNodePointer {
+    workOnNodePointer(Function &_f) : f(_f){}
+    void operator()(atom *atom){
+      atom->setPosition(f(atom->getPosition()));
+    }
+    Function &f;
+  };
+};
+
+template<class Set>
+inline void AtomSetMixin<Set>::translate(const Vector &translater){
+  BOOST_FOREACH(atom *atom,*this){
+    *(atom) += translater;
+  }
+}
+
+template<class Set>
+template<class Function>
+inline void AtomSetMixin<Set>::transformNodes(Function f){
+  std::for_each(this->begin(),
+                this->end(),
+                AtomSetMixin::workOnNodePointer<Function>(f));
+}
+
+// allows simpler definition of AtomSets
+#define ATOMSET(container_type) AtomSetMixin<container_type<atom*> >
+
+#endif /* ATOMSET_HPP_ */
Index: src/AtomicInfo.cpp
===================================================================
--- src/AtomicInfo.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
+++ src/AtomicInfo.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -0,0 +1,62 @@
+/*
+ * AtomicInfo.cpp
+ *
+ *  Created on: Aug 10, 2010
+ *      Author: heber
+ */
+
+#include "atom.hpp"
+#include "AtomicInfo.hpp"
+#include "element.hpp"
+#include "LinearAlgebra/Vector.hpp"
+
+/********************************** Functions for class AtomicInfo **********************************/
+
+AtomicInfo::AtomicInfo() :
+    Type(NULL),
+    Father(NULL),
+    Id(-1)
+{}
+AtomicInfo::AtomicInfo(const atom &_atom) :
+    Position(_atom.getPosition()),
+    Type(_atom.getType()),
+    Velocity(_atom.AtomicVelocity),
+    Father(_atom.father),
+    Mol(_atom.getMolecule()),
+    Id(_atom.getId())
+{}
+
+AtomicInfo::~AtomicInfo()
+{}
+
+
+bool AtomicInfo::setAtom(atom &_atom) const
+{
+  _atom.setPosition(Position);
+  _atom.setType(Type);
+  _atom.father = const_cast<atom *>(Father); // TODO: Actually, atom::father should be const atom *!
+  _atom.setMolecule(const_cast<molecule *>(Mol)); // this is ok, mol is const within AtomicInfo, but not outside (atoms need to register)
+  _atom.AtomicVelocity = Velocity;
+  if (_atom.getId() == Id)
+    return true;
+  else
+    return (_atom.changeId(Id));
+}
+
+atomId_t AtomicInfo::getId() const {
+  return Id;
+}
+
+AtomicInfo& AtomicInfo::operator=(const AtomicInfo& AI)
+{
+  if (&AI == this)  // check self-assignment
+    return *this;
+  Position = AI.Position;
+  Type = AI.Type;
+  Father = AI.Father;
+  Mol = AI.Mol;
+  Velocity = AI.Velocity;
+  Id = AI.Id;
+  return *this;
+}
+
Index: src/AtomicInfo.hpp
===================================================================
--- src/AtomicInfo.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
+++ src/AtomicInfo.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -0,0 +1,40 @@
+/*
+ * AtomicInfo.hpp
+ *
+ *  Created on: Aug 10, 2010
+ *      Author: heber
+ */
+
+#ifndef ATOMICINFO_HPP_
+#define ATOMICINFO_HPP_
+
+class atom;
+class element;
+class molecule;
+class Vector;
+
+/** This is for storing and transfering the information contained within an atom.
+ * This is needed for Undo/Redo operations of AtomActions.
+ */
+class AtomicInfo {
+public:
+  AtomicInfo();
+  AtomicInfo(const atom &_atom);
+  ~AtomicInfo();
+
+  bool setAtom(atom &_atom) const;
+  atomId_t getId() const;
+
+  AtomicInfo& operator=(const AtomicInfo&);
+
+private:
+  Vector Position;
+  const element * Type;
+  Vector Velocity;
+  const atom * Father;
+  const molecule * Mol;
+  atomId_t Id;
+};
+
+
+#endif /* ATOMICINFO_HPP_ */
Index: src/BoundaryLineSet.cpp
===================================================================
--- src/BoundaryLineSet.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
+++ src/BoundaryLineSet.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -0,0 +1,292 @@
+/*
+ * BoundaryLineSet.cpp
+ *
+ *  Created on: Jul 29, 2010
+ *      Author: heber
+ */
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "Helpers/MemDebug.hpp"
+
+#include "BoundaryLineSet.hpp"
+
+#include <iostream>
+
+#include "BoundaryPointSet.hpp"
+#include "BoundaryTriangleSet.hpp"
+#include "TesselPoint.hpp"
+
+#include "Helpers/Assert.hpp"
+#include "Helpers/Info.hpp"
+#include "Helpers/Log.hpp"
+#include "Helpers/Verbose.hpp"
+#include "tesselationhelpers.hpp"
+#include "LinearAlgebra/Vector.hpp"
+
+using namespace std;
+
+/** Constructor of BoundaryLineSet.
+ */
+BoundaryLineSet::BoundaryLineSet() :
+  Nr(-1)
+{
+  Info FunctionInfo(__func__);
+  for (int i = 0; i < 2; i++)
+    endpoints[i] = NULL;
+}
+;
+
+/** Constructor of BoundaryLineSet with two endpoints.
+ * Adds line automatically to each endpoints' LineMap
+ * \param *Point[2] array of two boundary points
+ * \param number number of the list
+ */
+BoundaryLineSet::BoundaryLineSet(BoundaryPointSet * const Point[2], const int number)
+{
+  Info FunctionInfo(__func__);
+  // set number
+  Nr = number;
+  // set endpoints in ascending order
+  SetEndpointsOrdered(endpoints, Point[0], Point[1]);
+  // add this line to the hash maps of both endpoints
+  Point[0]->AddLine(this); //Taken out, to check whether we can avoid unwanted double adding.
+  Point[1]->AddLine(this); //
+  // set skipped to false
+  skipped = false;
+  // clear triangles list
+  DoLog(0) && (Log() << Verbose(0) << "New Line with endpoints " << *this << "." << endl);
+}
+;
+
+/** Constructor of BoundaryLineSet with two endpoints.
+ * Adds line automatically to each endpoints' LineMap
+ * \param *Point1 first boundary point
+ * \param *Point2 second boundary point
+ * \param number number of the list
+ */
+BoundaryLineSet::BoundaryLineSet(BoundaryPointSet * const Point1, BoundaryPointSet * const Point2, const int number) :
+  Nr(number),
+  skipped(false)
+{
+  Info FunctionInfo(__func__);
+  // set endpoints in ascending order
+  SetEndpointsOrdered(endpoints, Point1, Point2);
+  // add this line to the hash maps of both endpoints
+  Point1->AddLine(this); //Taken out, to check whether we can avoid unwanted double adding.
+  Point2->AddLine(this); //
+  // clear triangles list
+  DoLog(0) && (Log() << Verbose(0) << "New Line with endpoints " << *this << "." << endl);
+}
+;
+
+/** Destructor for BoundaryLineSet.
+ * Removes itself from each endpoints' LineMap, calling RemoveTrianglePoint() when point not connected anymore.
+ * \note When removing lines from a class Tesselation, use RemoveTesselationLine()
+ */
+BoundaryLineSet::~BoundaryLineSet()
+{
+  Info FunctionInfo(__func__);
+  int Numbers[2];
+
+  // get other endpoint number of finding copies of same line
+  if (endpoints[1] != NULL)
+    Numbers[0] = endpoints[1]->Nr;
+  else
+    Numbers[0] = -1;
+  if (endpoints[0] != NULL)
+    Numbers[1] = endpoints[0]->Nr;
+  else
+    Numbers[1] = -1;
+
+  for (int i = 0; i < 2; i++) {
+    if (endpoints[i] != NULL) {
+      if (Numbers[i] != -1) { // as there may be multiple lines with same endpoints, we have to go through each and find in the endpoint's line list this line set
+        pair<LineMap::iterator, LineMap::iterator> erasor = endpoints[i]->lines.equal_range(Numbers[i]);
+        for (LineMap::iterator Runner = erasor.first; Runner != erasor.second; Runner++)
+          if ((*Runner).second == this) {
+            //Log() << Verbose(0) << "Removing Line Nr. " << Nr << " in boundary point " << *endpoints[i] << "." << endl;
+            endpoints[i]->lines.erase(Runner);
+            break;
+          }
+      } else { // there's just a single line left
+        if (endpoints[i]->lines.erase(Nr)) {
+          //Log() << Verbose(0) << "Removing Line Nr. " << Nr << " in boundary point " << *endpoints[i] << "." << endl;
+        }
+      }
+      if (endpoints[i]->lines.empty()) {
+        //Log() << Verbose(0) << *endpoints[i] << " has no more lines it's attached to, erasing." << endl;
+        if (endpoints[i] != NULL) {
+          delete (endpoints[i]);
+          endpoints[i] = NULL;
+        }
+      }
+    }
+  }
+  if (!triangles.empty())
+    DoeLog(2) && (eLog() << Verbose(2) << "Memory Leak! I " << *this << " am still connected to some triangles." << endl);
+}
+;
+
+/** Add triangle to TriangleMap of this boundary line.
+ * \param *triangle to add
+ */
+void BoundaryLineSet::AddTriangle(BoundaryTriangleSet * const triangle)
+{
+  Info FunctionInfo(__func__);
+  DoLog(0) && (Log() << Verbose(0) << "Add " << triangle->Nr << " to line " << *this << "." << endl);
+  triangles.insert(TrianglePair(triangle->Nr, triangle));
+}
+;
+
+/** Checks whether we have a common endpoint with given \a *line.
+ * \param *line other line to test
+ * \return true - common endpoint present, false - not connected
+ */
+bool BoundaryLineSet::IsConnectedTo(const BoundaryLineSet * const line) const
+{
+  Info FunctionInfo(__func__);
+  if ((endpoints[0] == line->endpoints[0]) || (endpoints[1] == line->endpoints[0]) || (endpoints[0] == line->endpoints[1]) || (endpoints[1] == line->endpoints[1]))
+    return true;
+  else
+    return false;
+}
+;
+
+/** Checks whether the adjacent triangles of a baseline are convex or not.
+ * We sum the two angles of each height vector with respect to the center of the baseline.
+ * If greater/equal M_PI than we are convex.
+ * \param *out output stream for debugging
+ * \return true - triangles are convex, false - concave or less than two triangles connected
+ */
+bool BoundaryLineSet::CheckConvexityCriterion() const
+{
+  Info FunctionInfo(__func__);
+  double angle = CalculateConvexity();
+  if (angle > -MYEPSILON) {
+    DoLog(0) && (Log() << Verbose(0) << "ACCEPT: Angle is greater than pi: convex." << endl);
+    return true;
+  } else {
+    DoLog(0) && (Log() << Verbose(0) << "REJECT: Angle is less than pi: concave." << endl);
+    return false;
+  }
+}
+
+
+/** Calculates the angle between two triangles with respect to their normal vector.
+ * We sum the two angles of each height vector with respect to the center of the baseline.
+ * \return angle > 0 then convex, if < 0 then concave
+ */
+double BoundaryLineSet::CalculateConvexity() const
+{
+  Info FunctionInfo(__func__);
+  Vector BaseLineCenter, BaseLineNormal, BaseLine, helper[2], NormalCheck;
+  // get the two triangles
+  if (triangles.size() != 2) {
+    DoeLog(0) && (eLog() << Verbose(0) << "Baseline " << *this << " is connected to less than two triangles, Tesselation incomplete!" << endl);
+    return true;
+  }
+  // check normal vectors
+  // have a normal vector on the base line pointing outwards
+  //Log() << Verbose(0) << "INFO: " << *this << " has vectors at " << *(endpoints[0]->node->node) << " and at " << *(endpoints[1]->node->node) << "." << endl;
+  BaseLineCenter = (1./2.)*((endpoints[0]->node->getPosition()) + (endpoints[1]->node->getPosition()));
+  BaseLine = (endpoints[0]->node->getPosition()) - (endpoints[1]->node->getPosition());
+
+  //Log() << Verbose(0) << "INFO: Baseline is " << BaseLine << " and its center is at " << BaseLineCenter << "." << endl;
+
+  BaseLineNormal.Zero();
+  NormalCheck.Zero();
+  double sign = -1.;
+  int i = 0;
+  class BoundaryPointSet *node = NULL;
+  for (TriangleMap::const_iterator runner = triangles.begin(); runner != triangles.end(); runner++) {
+    //Log() << Verbose(0) << "INFO: NormalVector of " << *(runner->second) << " is " << runner->second->NormalVector << "." << endl;
+    NormalCheck += runner->second->NormalVector;
+    NormalCheck *= sign;
+    sign = -sign;
+    if (runner->second->NormalVector.NormSquared() > MYEPSILON)
+      BaseLineNormal = runner->second->NormalVector;   // yes, copy second on top of first
+    else {
+      DoeLog(0) && (eLog() << Verbose(0) << "Triangle " << *runner->second << " has zero normal vector!" << endl);
+    }
+    node = runner->second->GetThirdEndpoint(this);
+    if (node != NULL) {
+      //Log() << Verbose(0) << "INFO: Third node for triangle " << *(runner->second) << " is " << *node << " at " << *(node->node->node) << "." << endl;
+      helper[i] = (node->node->getPosition()) - BaseLineCenter;
+      helper[i].MakeNormalTo(BaseLine);  // we want to compare the triangle's heights' angles!
+      //Log() << Verbose(0) << "INFO: Height vector with respect to baseline is " << helper[i] << "." << endl;
+      i++;
+    } else {
+      DoeLog(1) && (eLog() << Verbose(1) << "I cannot find third node in triangle, something's wrong." << endl);
+      return true;
+    }
+  }
+  //Log() << Verbose(0) << "INFO: BaselineNormal is " << BaseLineNormal << "." << endl;
+  if (NormalCheck.NormSquared() < MYEPSILON) {
+    DoLog(0) && (Log() << Verbose(0) << "ACCEPT: Normalvectors of both triangles are the same: convex." << endl);
+    return true;
+  }
+  BaseLineNormal.Scale(-1.);
+  double angle = GetAngle(helper[0], helper[1], BaseLineNormal);
+  return (angle - M_PI);
+}
+
+/** Checks whether point is any of the two endpoints this line contains.
+ * \param *point point to test
+ * \return true - point is of the line, false - is not
+ */
+bool BoundaryLineSet::ContainsBoundaryPoint(const BoundaryPointSet * const point) const
+{
+  Info FunctionInfo(__func__);
+  for (int i = 0; i < 2; i++)
+    if (point == endpoints[i])
+      return true;
+  return false;
+}
+;
+
+/** Returns other endpoint of the line.
+ * \param *point other endpoint
+ * \return NULL - if endpoint not contained in BoundaryLineSet::lines, or pointer to BoundaryPointSet otherwise
+ */
+class BoundaryPointSet *BoundaryLineSet::GetOtherEndpoint(const BoundaryPointSet * const point) const
+{
+  Info FunctionInfo(__func__);
+  if (endpoints[0] == point)
+    return endpoints[1];
+  else if (endpoints[1] == point)
+    return endpoints[0];
+  else
+    return NULL;
+}
+;
+
+/** Returns other triangle of the line.
+ * \param *point other endpoint
+ * \return NULL - if triangle not contained in BoundaryLineSet::triangles, or pointer to BoundaryTriangleSet otherwise
+ */
+class BoundaryTriangleSet *BoundaryLineSet::GetOtherTriangle(const BoundaryTriangleSet * const triangle) const
+{
+  Info FunctionInfo(__func__);
+  if (triangles.size() == 2) {
+    for (TriangleMap::const_iterator TriangleRunner = triangles.begin(); TriangleRunner != triangles.end(); ++TriangleRunner)
+      if (TriangleRunner->second != triangle)
+        return TriangleRunner->second;
+  }
+  return NULL;
+}
+;
+
+/** output operator for BoundaryLineSet.
+ * \param &ost output stream
+ * \param &a boundary line
+ */
+ostream & operator <<(ostream &ost, const BoundaryLineSet &a)
+{
+  ost << "[" << a.Nr << "|" << a.endpoints[0]->node->getName() << " at " << a.endpoints[0]->node->getPosition() << "," << a.endpoints[1]->node->getName() << " at " << a.endpoints[1]->node->getPosition() << "]";
+  return ost;
+}
+;
Index: src/BoundaryLineSet.hpp
===================================================================
--- src/BoundaryLineSet.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
+++ src/BoundaryLineSet.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -0,0 +1,54 @@
+/*
+ * BoundaryLineSet.hpp
+ *
+ *  Created on: Jul 29, 2010
+ *      Author: heber
+ */
+
+#ifndef BOUNDARYLINESET_HPP_
+#define BOUNDARYLINESET_HPP_
+
+#include "BoundaryMaps.hpp"
+
+#include <iostream>
+#include <map>
+
+class BoundaryLineSet;
+class BoundaryPointSet;
+class BoundaryTriangleSet;
+
+class BoundaryLineSet {
+  public:
+    BoundaryLineSet();
+    BoundaryLineSet(BoundaryPointSet * const Point[2], const int number);
+    BoundaryLineSet(BoundaryPointSet * const Point1, BoundaryPointSet * const Point2, const int number);
+    ~BoundaryLineSet();
+
+    void AddTriangle(BoundaryTriangleSet * const triangle);
+    bool IsConnectedTo(const BoundaryLineSet * const line) const;
+    bool ContainsBoundaryPoint(const BoundaryPointSet * const point) const;
+    bool CheckConvexityCriterion() const;
+    double CalculateConvexity() const;
+    class BoundaryPointSet *GetOtherEndpoint(const BoundaryPointSet * const point) const;
+    class BoundaryTriangleSet *GetOtherTriangle(const BoundaryTriangleSet * const triangle) const;
+
+    class BoundaryPointSet *endpoints[2];
+    TriangleMap triangles;
+    int Nr;
+    bool skipped;
+};
+
+std::ostream & operator << (std::ostream &ost, const BoundaryLineSet &a);
+
+template <typename T> void SetEndpointsOrdered(T endpoints[2], T endpoint1, T endpoint2)
+{
+  if (endpoint1->Nr < endpoint2->Nr) {
+    endpoints[0] = endpoint1;
+    endpoints[1] = endpoint2;
+  } else {
+    endpoints[0] = endpoint2;
+    endpoints[1] = endpoint1;
+  }
+};
+
+#endif /* BOUNDARYLINESET_HPP_ */
Index: src/BoundaryMaps.hpp
===================================================================
--- src/BoundaryMaps.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
+++ src/BoundaryMaps.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -0,0 +1,80 @@
+/*
+ * BoundaryMaps.hpp
+ *
+ *  Created on: Jul 29, 2010
+ *      Author: heber
+ */
+
+#ifndef BOUNDARYMAPS_HPP_
+#define BOUNDARYMAPS_HPP_
+
+class BoundaryPointSet;
+class BoundaryLineSet;
+class BoundaryTriangleSet;
+class BoundaryPolygonSet;
+class CandidateForTesselation;
+class TesselPoint;
+
+#include <list>
+#include <map>
+#include <set>
+
+typedef std::map <int, int> IndexToIndex;
+
+// ============= TesselPoint maps ======================== //
+typedef std::pair < double, class TesselPoint * > TesselPointDistancePair;
+typedef std::multimap < double, class TesselPoint * > TesselPointDistanceMap;
+typedef std::pair < TesselPointDistanceMap::iterator, bool > TesselPointDistanceTestPair;
+
+typedef std::list <TesselPoint *> TesselPointList;
+typedef std::set <TesselPoint *> TesselPointSet;
+
+typedef std::list<std::list <TesselPoint *> *> ListOfTesselPointList;
+
+// ============= BoundaryPointSet maps ======================== //
+typedef std::map < int, class BoundaryPointSet * > PointMap;
+typedef std::set < class BoundaryPointSet * > PointSet;
+typedef std::list < class BoundaryPointSet * > PointList;
+typedef std::pair < int, class BoundaryPointSet * > PointPair;
+typedef std::pair < PointMap::iterator, bool > PointTestPair;
+
+typedef std::multimap <double, class BoundaryPointSet * > DistanceToPointMap;
+typedef std::pair <double, class BoundaryPointSet * > DistanceToPointPair;
+
+// ============= BoundaryLineSet maps ======================== //
+typedef std::multimap < int, class BoundaryLineSet * > LineMap;
+typedef std::set < class BoundaryLineSet * > LineSet;
+typedef std::list < class BoundaryLineSet * > LineList;
+typedef std::pair < int, class BoundaryLineSet * > LinePair;
+typedef std::pair < LineMap::iterator, bool > LineTestPair;
+
+// ============= BoundaryTriangleSet maps ======================== //
+typedef std::map < int, class BoundaryTriangleSet * > TriangleMap;
+typedef std::set < class BoundaryTriangleSet * > TriangleSet;
+typedef std::list < class BoundaryTriangleSet * > TriangleList;
+typedef std::pair < int, class BoundaryTriangleSet * > TrianglePair;
+typedef std::pair < TriangleMap::iterator, bool > TriangleTestPair;
+
+// ============= BoundaryPolygonSet maps ======================== //
+typedef std::map < int, class BoundaryPolygonSet * > PolygonMap;
+typedef std::set < class BoundaryPolygonSet * > PolygonSet;
+typedef std::list < class BoundaryPolygonSet * > PolygonList;
+
+// ============= CandidateForTesselation maps ======================== //
+typedef std::list <class CandidateForTesselation *> CandidateList;
+typedef std::map <class BoundaryLineSet *, class CandidateForTesselation *> CandidateMap;
+
+// ============= Various maps ======================== //
+typedef std::map <double, TesselPointDistancePair > Boundaries;
+typedef std::pair<double, TesselPointDistancePair > BoundariesPair;
+typedef std::pair< Boundaries::iterator, bool> BoundariesTestPair;
+
+typedef std::multimap <double, std::pair < PointMap::iterator, PointMap::iterator> > DistanceMultiMap;
+typedef std::pair <double, std::pair < PointMap::iterator, PointMap::iterator> > DistanceMultiMapPair;
+
+enum centers {Opt, OtherOpt};
+
+
+
+
+#endif /* BOUNDARYMAPS_HPP_ */
Index: src/BoundaryPointSet.cpp
===================================================================
--- src/BoundaryPointSet.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
+++ src/BoundaryPointSet.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -0,0 +1,98 @@
+/*
+ * BoundaryPointSet.cpp
+ *
+ *  Created on: Jul 29, 2010
+ *      Author: heber
+ */
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "Helpers/MemDebug.hpp"
+
+#include "BoundaryPointSet.hpp"
+
+#include <iostream>
+
+#include "BoundaryLineSet.hpp"
+#include "BoundaryTriangleSet.hpp"
+#include "TesselPoint.hpp"
+
+#include "Helpers/Assert.hpp"
+#include "Helpers/Info.hpp"
+#include "Helpers/Log.hpp"
+#include "LinearAlgebra/Vector.hpp"
+#include "Helpers/Verbose.hpp"
+
+using namespace std;
+
+// ======================================== Points on Boundary =================================
+
+/** Constructor of BoundaryPointSet.
+ */
+BoundaryPointSet::BoundaryPointSet() :
+  LinesCount(0),
+  value(0.),
+  Nr(-1)
+{
+  Info FunctionInfo(__func__);
+  DoLog(1) && (Log() << Verbose(1) << "Adding noname." << endl);
+}
+;
+
+/** Constructor of BoundaryPointSet with Tesselpoint.
+ * \param *Walker TesselPoint this boundary point represents
+ */
+BoundaryPointSet::BoundaryPointSet(TesselPoint * const Walker) :
+  LinesCount(0),
+  node(Walker),
+  value(0.),
+  Nr(Walker->nr)
+{
+  Info FunctionInfo(__func__);
+  DoLog(1) && (Log() << Verbose(1) << "Adding Node " << *Walker << endl);
+}
+;
+
+/** Destructor of BoundaryPointSet.
+ * Sets node to NULL to avoid removing the original, represented TesselPoint.
+ * \note When removing point from a class Tesselation, use RemoveTesselationPoint()
+ */
+BoundaryPointSet::~BoundaryPointSet()
+{
+  Info FunctionInfo(__func__);
+  //Log() << Verbose(0) << "Erasing point nr. " << Nr << "." << endl;
+  if (!lines.empty())
+    DoeLog(2) && (eLog() << Verbose(2) << "Memory Leak! I " << *this << " am still connected to some lines." << endl);
+  node = NULL;
+}
+;
+
+/** Add a line to the LineMap of this point.
+ * \param *line line to add
+ */
+void BoundaryPointSet::AddLine(BoundaryLineSet * const line)
+{
+  Info FunctionInfo(__func__);
+  DoLog(1) && (Log() << Verbose(1) << "Adding " << *this << " to line " << *line << "." << endl);
+  if (line->endpoints[0] == this) {
+    lines.insert(LinePair(line->endpoints[1]->Nr, line));
+  } else {
+    lines.insert(LinePair(line->endpoints[0]->Nr, line));
+  }
+  LinesCount++;
+}
+;
+
+/** output operator for BoundaryPointSet.
+ * \param &ost output stream
+ * \param &a boundary point
+ */
+ostream & operator <<(ostream &ost, const BoundaryPointSet &a)
+{
+  ost << "[" << a.Nr << "|" << a.node->getName() << " at " << a.node->getPosition() << "]";
+  return ost;
+}
+;
Index: src/BoundaryPointSet.hpp
===================================================================
--- src/BoundaryPointSet.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
+++ src/BoundaryPointSet.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -0,0 +1,36 @@
+/*
+ * BoundaryPointSet.hpp
+ *
+ *  Created on: Jul 29, 2010
+ *      Author: heber
+ */
+
+#ifndef BOUNDARYPOINTSET_HPP_
+#define BOUNDARYPOINTSET_HPP_
+
+#include "BoundaryMaps.hpp"
+
+#include <iostream>
+#include <map>
+
+class BoundaryLineSet;
+class TesselPoint;
+
+class BoundaryPointSet {
+  public:
+    BoundaryPointSet();
+    BoundaryPointSet(TesselPoint * const Walker);
+    ~BoundaryPointSet();
+
+    void AddLine(BoundaryLineSet * const line);
+
+    LineMap lines;
+    int LinesCount;
+    TesselPoint *node;
+    double value;
+    int Nr;
+};
+
+std::ostream & operator << (std::ostream &ost, const BoundaryPointSet &a);
+
+#endif /* BOUNDARYPOINTSET_HPP_ */
Index: src/BoundaryPolygonSet.cpp
===================================================================
--- src/BoundaryPolygonSet.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
+++ src/BoundaryPolygonSet.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -0,0 +1,294 @@
+/*
+ * BoundaryPolygonSet.cpp
+ *
+ *  Created on: Jul 29, 2010
+ *      Author: heber
+ */
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "Helpers/MemDebug.hpp"
+
+#include "BoundaryPolygonSet.hpp"
+
+#include <iostream>
+
+#include "BoundaryLineSet.hpp"
+#include "BoundaryPointSet.hpp"
+#include "BoundaryTriangleSet.hpp"
+#include "TesselPoint.hpp"
+
+#include "Helpers/Assert.hpp"
+#include "Helpers/helpers.hpp"
+#include "Helpers/Info.hpp"
+#include "Helpers/Log.hpp"
+#include "LinearAlgebra/Plane.hpp"
+#include "LinearAlgebra/Vector.hpp"
+#include "Helpers/Verbose.hpp"
+
+using namespace std;
+
+/** Constructor for BoundaryPolygonSet.
+ */
+BoundaryPolygonSet::BoundaryPolygonSet() :
+  Nr(-1)
+{
+  Info FunctionInfo(__func__);
+}
+;
+
+/** Destructor of BoundaryPolygonSet.
+ * Just clears endpoints.
+ * \note When removing triangles from a class Tesselation, use RemoveTesselationTriangle()
+ */
+BoundaryPolygonSet::~BoundaryPolygonSet()
+{
+  Info FunctionInfo(__func__);
+  endpoints.clear();
+  DoLog(1) && (Log() << Verbose(1) << "Erasing polygon Nr." << Nr << " itself." << endl);
+}
+;
+
+/** Calculates the normal vector for this triangle.
+ * Is made unique by comparison with \a OtherVector to point in the other direction.
+ * \param &OtherVector direction vector to make normal vector unique.
+ * \return allocated vector in normal direction
+ */
+Vector * BoundaryPolygonSet::GetNormalVector(const Vector &OtherVector) const
+{
+  Info FunctionInfo(__func__);
+  // get normal vector
+  Vector TemporaryNormal;
+  Vector *TotalNormal = new Vector;
+  PointSet::const_iterator Runner[3];
+  for (int i = 0; i < 3; i++) {
+    Runner[i] = endpoints.begin();
+    for (int j = 0; j < i; j++) { // go as much further
+      Runner[i]++;
+      if (Runner[i] == endpoints.end()) {
+        DoeLog(0) && (eLog() << Verbose(0) << "There are less than three endpoints in the polygon!" << endl);
+        performCriticalExit();
+      }
+    }
+  }
+  TotalNormal->Zero();
+  int counter = 0;
+  for (; Runner[2] != endpoints.end();) {
+    TemporaryNormal = Plane(((*Runner[0])->node->getPosition()),
+                            ((*Runner[1])->node->getPosition()),
+                            ((*Runner[2])->node->getPosition())).getNormal();
+    for (int i = 0; i < 3; i++) // increase each of them
+      Runner[i]++;
+    (*TotalNormal) += TemporaryNormal;
+  }
+  TotalNormal->Scale(1. / (double) counter);
+
+  // make it always point inward (any offset vector onto plane projected onto normal vector suffices)
+  if (TotalNormal->ScalarProduct(OtherVector) > 0.)
+    TotalNormal->Scale(-1.);
+  DoLog(1) && (Log() << Verbose(1) << "Normal Vector is " << *TotalNormal << "." << endl);
+
+  return TotalNormal;
+}
+;
+
+/** Calculates the center point of the triangle.
+ * Is third of the sum of all endpoints.
+ * \param *center central point on return.
+ */
+void BoundaryPolygonSet::GetCenter(Vector * const center) const
+{
+  Info FunctionInfo(__func__);
+  center->Zero();
+  int counter = 0;
+  for(PointSet::const_iterator Runner = endpoints.begin(); Runner != endpoints.end(); Runner++) {
+    (*center) += ((*Runner)->node->getPosition());
+    counter++;
+  }
+  center->Scale(1. / (double) counter);
+  DoLog(1) && (Log() << Verbose(1) << "Center is at " << *center << "." << endl);
+}
+
+/** Checks whether the polygons contains all three endpoints of the triangle.
+ * \param *triangle triangle to test
+ * \return true - triangle is contained polygon, false - is not
+ */
+bool BoundaryPolygonSet::ContainsBoundaryTriangle(const BoundaryTriangleSet * const triangle) const
+{
+  Info FunctionInfo(__func__);
+  return ContainsPresentTupel(triangle->endpoints, 3);
+}
+;
+
+/** Checks whether the polygons contains both endpoints of the line.
+ * \param *line line to test
+ * \return true - line is of the triangle, false - is not
+ */
+bool BoundaryPolygonSet::ContainsBoundaryLine(const BoundaryLineSet * const line) const
+{
+  Info FunctionInfo(__func__);
+  return ContainsPresentTupel(line->endpoints, 2);
+}
+;
+
+/** Checks whether point is any of the three endpoints this triangle contains.
+ * \param *point point to test
+ * \return true - point is of the triangle, false - is not
+ */
+bool BoundaryPolygonSet::ContainsBoundaryPoint(const BoundaryPointSet * const point) const
+{
+  Info FunctionInfo(__func__);
+  for (PointSet::const_iterator Runner = endpoints.begin(); Runner != endpoints.end(); Runner++) {
+    DoLog(0) && (Log() << Verbose(0) << "Checking against " << **Runner << endl);
+    if (point == (*Runner)) {
+      DoLog(0) && (Log() << Verbose(0) << " Contained." << endl);
+      return true;
+    }
+  }
+  DoLog(0) && (Log() << Verbose(0) << " Not contained." << endl);
+  return false;
+}
+;
+
+/** Checks whether point is any of the three endpoints this triangle contains.
+ * \param *point TesselPoint to test
+ * \return true - point is of the triangle, false - is not
+ */
+bool BoundaryPolygonSet::ContainsBoundaryPoint(const TesselPoint * const point) const
+{
+  Info FunctionInfo(__func__);
+  for (PointSet::const_iterator Runner = endpoints.begin(); Runner != endpoints.end(); Runner++)
+    if (point == (*Runner)->node) {
+      DoLog(0) && (Log() << Verbose(0) << " Contained." << endl);
+      return true;
+    }
+  DoLog(0) && (Log() << Verbose(0) << " Not contained." << endl);
+  return false;
+}
+;
+
+/** Checks whether given array of \a *Points coincide with polygons's endpoints.
+ * \param **Points pointer to an array of BoundaryPointSet
+ * \param dim dimension of array
+ * \return true - set of points is contained in polygon, false - is not
+ */
+bool BoundaryPolygonSet::ContainsPresentTupel(const BoundaryPointSet * const * Points, const int dim) const
+{
+  Info FunctionInfo(__func__);
+  int counter = 0;
+  DoLog(1) && (Log() << Verbose(1) << "Polygon is " << *this << endl);
+  for (int i = 0; i < dim; i++) {
+    DoLog(1) && (Log() << Verbose(1) << " Testing endpoint " << *Points[i] << endl);
+    if (ContainsBoundaryPoint(Points[i])) {
+      counter++;
+    }
+  }
+
+  if (counter == dim)
+    return true;
+  else
+    return false;
+}
+;
+
+/** Checks whether given PointList coincide with polygons's endpoints.
+ * \param &endpoints PointList
+ * \return true - set of points is contained in polygon, false - is not
+ */
+bool BoundaryPolygonSet::ContainsPresentTupel(const PointSet &endpoints) const
+{
+  Info FunctionInfo(__func__);
+  size_t counter = 0;
+  DoLog(1) && (Log() << Verbose(1) << "Polygon is " << *this << endl);
+  for (PointSet::const_iterator Runner = endpoints.begin(); Runner != endpoints.end(); Runner++) {
+    DoLog(1) && (Log() << Verbose(1) << " Testing endpoint " << **Runner << endl);
+    if (ContainsBoundaryPoint(*Runner))
+      counter++;
+  }
+
+  if (counter == endpoints.size())
+    return true;
+  else
+    return false;
+}
+;
+
+/** Checks whether given set of \a *Points coincide with polygons's endpoints.
+ * \param *P pointer to BoundaryPolygonSet
+ * \return true - is the very triangle, false - is not
+ */
+bool BoundaryPolygonSet::ContainsPresentTupel(const BoundaryPolygonSet * const P) const
+{
+  return ContainsPresentTupel((const PointSet) P->endpoints);
+}
+;
+
+/** Gathers all the endpoints' triangles in a unique set.
+ * \return set of all triangles
+ */
+TriangleSet * BoundaryPolygonSet::GetAllContainedTrianglesFromEndpoints() const
+{
+  Info FunctionInfo(__func__);
+  pair<TriangleSet::iterator, bool> Tester;
+  TriangleSet *triangles = new TriangleSet;
+
+  for (PointSet::const_iterator Runner = endpoints.begin(); Runner != endpoints.end(); Runner++)
+    for (LineMap::const_iterator Walker = (*Runner)->lines.begin(); Walker != (*Runner)->lines.end(); Walker++)
+      for (TriangleMap::const_iterator Sprinter = (Walker->second)->triangles.begin(); Sprinter != (Walker->second)->triangles.end(); Sprinter++) {
+        //Log() << Verbose(0) << " Testing triangle " << *(Sprinter->second) << endl;
+        if (ContainsBoundaryTriangle(Sprinter->second)) {
+          Tester = triangles->insert(Sprinter->second);
+          if (Tester.second)
+            DoLog(0) && (Log() << Verbose(0) << "Adding triangle " << *(Sprinter->second) << endl);
+        }
+      }
+
+  DoLog(1) && (Log() << Verbose(1) << "The Polygon of " << endpoints.size() << " endpoints has " << triangles->size() << " unique triangles in total." << endl);
+  return triangles;
+}
+;
+
+/** Fills the endpoints of this polygon from the triangles attached to \a *line.
+ * \param *line lines with triangles attached
+ * \return true - polygon contains endpoints, false - line was NULL
+ */
+bool BoundaryPolygonSet::FillPolygonFromTrianglesOfLine(const BoundaryLineSet * const line)
+{
+  Info FunctionInfo(__func__);
+  pair<PointSet::iterator, bool> Tester;
+  if (line == NULL)
+    return false;
+  DoLog(1) && (Log() << Verbose(1) << "Filling polygon from line " << *line << endl);
+  for (TriangleMap::const_iterator Runner = line->triangles.begin(); Runner != line->triangles.end(); Runner++) {
+    for (int i = 0; i < 3; i++) {
+      Tester = endpoints.insert((Runner->second)->endpoints[i]);
+      if (Tester.second)
+        DoLog(1) && (Log() << Verbose(1) << "  Inserting endpoint " << *((Runner->second)->endpoints[i]) << endl);
+    }
+  }
+
+  return true;
+}
+;
+
+/** output operator for BoundaryPolygonSet.
+ * \param &ost output stream
+ * \param &a boundary polygon
+ */
+ostream &operator <<(ostream &ost, const BoundaryPolygonSet &a)
+{
+  ost << "[" << a.Nr << "|";
+  for (PointSet::const_iterator Runner = a.endpoints.begin(); Runner != a.endpoints.end();) {
+    ost << (*Runner)->node->getName();
+    Runner++;
+    if (Runner != a.endpoints.end())
+      ost << ",";
+  }
+  ost << "]";
+  return ost;
+}
+;
+
Index: src/BoundaryPolygonSet.hpp
===================================================================
--- src/BoundaryPolygonSet.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
+++ src/BoundaryPolygonSet.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -0,0 +1,51 @@
+/*
+ * BoundaryPolygonSet.hpp
+ *
+ *  Created on: Jul 29, 2010
+ *      Author: heber
+ */
+
+#ifndef BOUNDARYPOLYGONSET_HPP_
+#define BOUNDARYPOLYGONSET_HPP_
+
+#include "BoundaryMaps.hpp"
+
+#include <iostream>
+#include <set>
+
+class BoundaryPointSet;
+class BoundaryLineSet;
+class BoundaryTriangleSet;
+class TesselPoint;
+class Vector;
+
+/** Set of BoundaryPointSet.
+ * This is just meant as a container for a group of endpoints, extending the node, line, triangle concept. However, this has
+ * only marginally something to do with the tesselation. Hence, there is no incorporation into the bookkeeping of the Tesselation
+ * class (i.e. no allocation, no deletion).
+ * \note we assume that the set of endpoints reside (more or less) on a plane.
+ */
+class BoundaryPolygonSet {
+  public:
+    BoundaryPolygonSet();
+    ~BoundaryPolygonSet();
+
+    Vector * GetNormalVector(const Vector &NormalVector) const;
+    void GetCenter(Vector *center) const;
+    bool ContainsBoundaryLine(const BoundaryLineSet * const line) const;
+    bool ContainsBoundaryPoint(const BoundaryPointSet * const point) const;
+    bool ContainsBoundaryPoint(const TesselPoint * const point) const;
+    bool ContainsBoundaryTriangle(const BoundaryTriangleSet * const point) const;
+    bool ContainsPresentTupel(const BoundaryPointSet * const * Points, const int dim) const;
+    bool ContainsPresentTupel(const BoundaryPolygonSet * const P) const;
+    bool ContainsPresentTupel(const PointSet &endpoints) const;
+    TriangleSet * GetAllContainedTrianglesFromEndpoints() const;
+    bool FillPolygonFromTrianglesOfLine(const BoundaryLineSet * const line);
+
+    PointSet endpoints;
+    int Nr;
+};
+
+std::ostream & operator << (std::ostream &ost, const BoundaryPolygonSet &a);
+
+#endif /* BOUNDARYPOLYGONSET_HPP_ */
Index: src/BoundaryTriangleSet.cpp
===================================================================
--- src/BoundaryTriangleSet.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
+++ src/BoundaryTriangleSet.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -0,0 +1,430 @@
+/*
+ * BoundaryTriangleSet.cpp
+ *
+ *  Created on: Jul 29, 2010
+ *      Author: heber
+ */
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "Helpers/MemDebug.hpp"
+
+#include "BoundaryTriangleSet.hpp"
+
+#include <iostream>
+
+#include "BoundaryLineSet.hpp"
+#include "BoundaryPointSet.hpp"
+#include "TesselPoint.hpp"
+
+#include "Helpers/Assert.hpp"
+#include "Helpers/Info.hpp"
+#include "LinearAlgebra/Line.hpp"
+#include "Helpers/Log.hpp"
+#include "LinearAlgebra/Plane.hpp"
+#include "LinearAlgebra/Vector.hpp"
+#include "Helpers/Verbose.hpp"
+
+using namespace std;
+
+/** Constructor for BoundaryTriangleSet.
+ */
+BoundaryTriangleSet::BoundaryTriangleSet() :
+  Nr(-1)
+{
+  Info FunctionInfo(__func__);
+  for (int i = 0; i < 3; i++) {
+    endpoints[i] = NULL;
+    lines[i] = NULL;
+  }
+}
+;
+
+/** Constructor for BoundaryTriangleSet with three lines.
+ * \param *line[3] lines that make up the triangle
+ * \param number number of triangle
+ */
+BoundaryTriangleSet::BoundaryTriangleSet(class BoundaryLineSet * const line[3], const int number) :
+  Nr(number)
+{
+  Info FunctionInfo(__func__);
+  // set number
+  // set lines
+  for (int i = 0; i < 3; i++) {
+    lines[i] = line[i];
+    lines[i]->AddTriangle(this);
+  }
+  // get ascending order of endpoints
+  PointMap OrderMap;
+  for (int i = 0; i < 3; i++) {
+    // for all three lines
+    for (int j = 0; j < 2; j++) { // for both endpoints
+      OrderMap.insert(pair<int, class BoundaryPointSet *> (line[i]->endpoints[j]->Nr, line[i]->endpoints[j]));
+      // and we don't care whether insertion fails
+    }
+  }
+  // set endpoints
+  int Counter = 0;
+  DoLog(0) && (Log() << Verbose(0) << "New triangle " << Nr << " with end points: " << endl);
+  for (PointMap::iterator runner = OrderMap.begin(); runner != OrderMap.end(); runner++) {
+    endpoints[Counter] = runner->second;
+    DoLog(0) && (Log() << Verbose(0) << " " << *endpoints[Counter] << endl);
+    Counter++;
+  }
+  ASSERT(Counter >= 3,"We have a triangle with only two distinct endpoints!");
+};
+
+
+/** Destructor of BoundaryTriangleSet.
+ * Removes itself from each of its lines' LineMap and removes them if necessary.
+ * \note When removing triangles from a class Tesselation, use RemoveTesselationTriangle()
+ */
+BoundaryTriangleSet::~BoundaryTriangleSet()
+{
+  Info FunctionInfo(__func__);
+  for (int i = 0; i < 3; i++) {
+    if (lines[i] != NULL) {
+      if (lines[i]->triangles.erase(Nr)) {
+        //Log() << Verbose(0) << "Triangle Nr." << Nr << " erased in line " << *lines[i] << "." << endl;
+      }
+      if (lines[i]->triangles.empty()) {
+        //Log() << Verbose(0) << *lines[i] << " is no more attached to any triangle, erasing." << endl;
+        delete (lines[i]);
+        lines[i] = NULL;
+      }
+    }
+  }
+  //Log() << Verbose(0) << "Erasing triangle Nr." << Nr << " itself." << endl;
+}
+;
+
+/** Calculates the normal vector for this triangle.
+ * Is made unique by comparison with \a OtherVector to point in the other direction.
+ * \param &OtherVector direction vector to make normal vector unique.
+ */
+void BoundaryTriangleSet::GetNormalVector(const Vector &OtherVector)
+{
+  Info FunctionInfo(__func__);
+  // get normal vector
+  NormalVector = Plane((endpoints[0]->node->getPosition()),
+                       (endpoints[1]->node->getPosition()),
+                       (endpoints[2]->node->getPosition())).getNormal();
+
+  // make it always point inward (any offset vector onto plane projected onto normal vector suffices)
+  if (NormalVector.ScalarProduct(OtherVector) > 0.)
+    NormalVector.Scale(-1.);
+  DoLog(1) && (Log() << Verbose(1) << "Normal Vector is " << NormalVector << "." << endl);
+}
+;
+
+/** Finds the point on the triangle \a *BTS through which the line defined by \a *MolCenter and \a *x crosses.
+ * We call Vector::GetIntersectionWithPlane() to receive the intersection point with the plane
+ * Thus we test if it's really on the plane and whether it's inside the triangle on the plane or not.
+ * The latter is done as follows: We calculate the cross point of one of the triangle's baseline with the line
+ * given by the intersection and the third basepoint. Then, we check whether it's on the baseline (i.e. between
+ * the first two basepoints) or not.
+ * \param *out output stream for debugging
+ * \param &MolCenter offset vector of line
+ * \param &x second endpoint of line, minus \a *MolCenter is directional vector of line
+ * \param &Intersection intersection on plane on return
+ * \return true - \a *Intersection contains intersection on plane defined by triangle, false - zero vector if outside of triangle.
+ */
+
+bool BoundaryTriangleSet::GetIntersectionInsideTriangle(const Vector & MolCenter, const Vector & x, Vector &Intersection) const
+{
+  Info FunctionInfo(__func__);
+  Vector CrossPoint;
+  Vector helper;
+
+  try {
+    Line centerLine = makeLineThrough(MolCenter, x);
+    Intersection = Plane(NormalVector, (endpoints[0]->node->getPosition())).GetIntersection(centerLine);
+
+    DoLog(1) && (Log() << Verbose(1) << "INFO: Triangle is " << *this << "." << endl);
+    DoLog(1) && (Log() << Verbose(1) << "INFO: Line is from " << MolCenter << " to " << x << "." << endl);
+    DoLog(1) && (Log() << Verbose(1) << "INFO: Intersection is " << Intersection << "." << endl);
+
+    if (Intersection.DistanceSquared(endpoints[0]->node->getPosition()) < MYEPSILON) {
+      DoLog(1) && (Log() << Verbose(1) << "Intersection coindices with first endpoint." << endl);
+      return true;
+    }   else if (Intersection.DistanceSquared(endpoints[1]->node->getPosition()) < MYEPSILON) {
+      DoLog(1) && (Log() << Verbose(1) << "Intersection coindices with second endpoint." << endl);
+      return true;
+    }   else if (Intersection.DistanceSquared(endpoints[2]->node->getPosition()) < MYEPSILON) {
+      DoLog(1) && (Log() << Verbose(1) << "Intersection coindices with third endpoint." << endl);
+      return true;
+    }
+    // Calculate cross point between one baseline and the line from the third endpoint to intersection
+    int i = 0;
+    do {
+      Line line1 = makeLineThrough((endpoints[i%3]->node->getPosition()),(endpoints[(i+1)%3]->node->getPosition()));
+      Line line2 = makeLineThrough((endpoints[(i+2)%3]->node->getPosition()),Intersection);
+      CrossPoint = line1.getIntersection(line2);
+      helper = (endpoints[(i+1)%3]->node->getPosition()) - (endpoints[i%3]->node->getPosition());
+      CrossPoint -= (endpoints[i%3]->node->getPosition());  // cross point was returned as absolute vector
+      const double s = CrossPoint.ScalarProduct(helper)/helper.NormSquared();
+      DoLog(1) && (Log() << Verbose(1) << "INFO: Factor s is " << s << "." << endl);
+      if ((s < -MYEPSILON) || ((s-1.) > MYEPSILON)) {
+        DoLog(1) && (Log() << Verbose(1) << "INFO: Crosspoint " << CrossPoint << "outside of triangle." << endl);
+        return false;
+      }
+      i++;
+    } while (i < 3);
+    DoLog(1) && (Log() << Verbose(1) << "INFO: Crosspoint " << CrossPoint << " inside of triangle." << endl);
+    return true;
+  }
+  catch (MathException &excp) {
+    Log() << Verbose(1) << excp;
+    DoeLog(1) && (eLog() << Verbose(1) << "Alas! Intersection with plane failed - at least numerically - the intersection is not on the plane!" << endl);
+    return false;
+  }
+}
+;
+
+/** Finds the point on the triangle to the point \a *x.
+ * We call Vector::GetIntersectionWithPlane() with \a * and the center of the triangle to receive an intersection point.
+ * Then we check the in-plane part (the part projected down onto plane). We check whether it crosses one of the
+ * boundary lines. If it does, we return this intersection as closest point, otherwise the projected point down.
+ * Thus we test if it's really on the plane and whether it's inside the triangle on the plane or not.
+ * The latter is done as follows: We calculate the cross point of one of the triangle's baseline with the line
+ * given by the intersection and the third basepoint. Then, we check whether it's on the baseline (i.e. between
+ * the first two basepoints) or not.
+ * \param *x point
+ * \param *ClosestPoint desired closest point inside triangle to \a *x, is absolute vector
+ * \return Distance squared between \a *x and closest point inside triangle
+ */
+double BoundaryTriangleSet::GetClosestPointInsideTriangle(const Vector &x, Vector &ClosestPoint) const
+{
+  Info FunctionInfo(__func__);
+  Vector Direction;
+
+  // 1. get intersection with plane
+  DoLog(1) && (Log() << Verbose(1) << "INFO: Looking for closest point of triangle " << *this << " to " << x << "." << endl);
+  GetCenter(Direction);
+  try {
+    Line l = makeLineThrough(x, Direction);
+    ClosestPoint = Plane(NormalVector, (endpoints[0]->node->getPosition())).GetIntersection(l);
+  }
+  catch (MathException &excp) {
+    (ClosestPoint) = (x);
+  }
+
+  // 2. Calculate in plane part of line (x, intersection)
+  Vector InPlane = (x) - (ClosestPoint); // points from plane intersection to straight-down point
+  InPlane.ProjectOntoPlane(NormalVector);
+  InPlane += ClosestPoint;
+
+  DoLog(2) && (Log() << Verbose(2) << "INFO: Triangle is " << *this << "." << endl);
+  DoLog(2) && (Log() << Verbose(2) << "INFO: Line is from " << Direction << " to " << x << "." << endl);
+  DoLog(2) && (Log() << Verbose(2) << "INFO: In-plane part is " << InPlane << "." << endl);
+
+  // Calculate cross point between one baseline and the desired point such that distance is shortest
+  double ShortestDistance = -1.;
+  bool InsideFlag = false;
+  Vector CrossDirection[3];
+  Vector CrossPoint[3];
+  Vector helper;
+  for (int i = 0; i < 3; i++) {
+    // treat direction of line as normal of a (cut)plane and the desired point x as the plane offset, the intersect line with point
+    Direction = (endpoints[(i+1)%3]->node->getPosition()) - (endpoints[i%3]->node->getPosition());
+    // calculate intersection, line can never be parallel to Direction (is the same vector as PlaneNormal);
+    Line l = makeLineThrough((endpoints[i%3]->node->getPosition()), (endpoints[(i+1)%3]->node->getPosition()));
+    CrossPoint[i] = Plane(Direction, InPlane).GetIntersection(l);
+    CrossDirection[i] = CrossPoint[i] - InPlane;
+    CrossPoint[i] -= (endpoints[i%3]->node->getPosition());  // cross point was returned as absolute vector
+    const double s = CrossPoint[i].ScalarProduct(Direction)/Direction.NormSquared();
+    DoLog(2) && (Log() << Verbose(2) << "INFO: Factor s is " << s << "." << endl);
+    if ((s >= -MYEPSILON) && ((s-1.) <= MYEPSILON)) {
+          CrossPoint[i] += (endpoints[i%3]->node->getPosition());  // make cross point absolute again
+      DoLog(2) && (Log() << Verbose(2) << "INFO: Crosspoint is " << CrossPoint[i] << ", intersecting BoundaryLine between " << endpoints[i % 3]->node->getPosition() << " and " << endpoints[(i + 1) % 3]->node->getPosition() << "." << endl);
+      const double distance = CrossPoint[i].DistanceSquared(x);
+      if ((ShortestDistance < 0.) || (ShortestDistance > distance)) {
+        ShortestDistance = distance;
+        (ClosestPoint) = CrossPoint[i];
+      }
+    } else
+      CrossPoint[i].Zero();
+  }
+  InsideFlag = true;
+  for (int i = 0; i < 3; i++) {
+    const double sign = CrossDirection[i].ScalarProduct(CrossDirection[(i + 1) % 3]);
+    const double othersign = CrossDirection[i].ScalarProduct(CrossDirection[(i + 2) % 3]);
+
+    if ((sign > -MYEPSILON) && (othersign > -MYEPSILON)) // have different sign
+      InsideFlag = false;
+  }
+  if (InsideFlag) {
+    (ClosestPoint) = InPlane;
+    ShortestDistance = InPlane.DistanceSquared(x);
+  } else { // also check endnodes
+    for (int i = 0; i < 3; i++) {
+      const double distance = x.DistanceSquared(endpoints[i]->node->getPosition());
+      if ((ShortestDistance < 0.) || (ShortestDistance > distance)) {
+        ShortestDistance = distance;
+        (ClosestPoint) = (endpoints[i]->node->getPosition());
+      }
+    }
+  }
+  DoLog(1) && (Log() << Verbose(1) << "INFO: Closest Point is " << ClosestPoint << " with shortest squared distance is " << ShortestDistance << "." << endl);
+  return ShortestDistance;
+}
+;
+
+/** Checks whether lines is any of the three boundary lines this triangle contains.
+ * \param *line line to test
+ * \return true - line is of the triangle, false - is not
+ */
+bool BoundaryTriangleSet::ContainsBoundaryLine(const BoundaryLineSet * const line) const
+{
+  Info FunctionInfo(__func__);
+  for (int i = 0; i < 3; i++)
+    if (line == lines[i])
+      return true;
+  return false;
+}
+;
+
+/** Checks whether point is any of the three endpoints this triangle contains.
+ * \param *point point to test
+ * \return true - point is of the triangle, false - is not
+ */
+bool BoundaryTriangleSet::ContainsBoundaryPoint(const BoundaryPointSet * const point) const
+{
+  Info FunctionInfo(__func__);
+  for (int i = 0; i < 3; i++)
+    if (point == endpoints[i])
+      return true;
+  return false;
+}
+;
+
+/** Checks whether point is any of the three endpoints this triangle contains.
+ * \param *point TesselPoint to test
+ * \return true - point is of the triangle, false - is not
+ */
+bool BoundaryTriangleSet::ContainsBoundaryPoint(const TesselPoint * const point) const
+{
+  Info FunctionInfo(__func__);
+  for (int i = 0; i < 3; i++)
+    if (point == endpoints[i]->node)
+      return true;
+  return false;
+}
+;
+
+/** Checks whether three given \a *Points coincide with triangle's endpoints.
+ * \param *Points[3] pointer to BoundaryPointSet
+ * \return true - is the very triangle, false - is not
+ */
+bool BoundaryTriangleSet::IsPresentTupel(const BoundaryPointSet * const Points[3]) const
+{
+  Info FunctionInfo(__func__);
+  DoLog(1) && (Log() << Verbose(1) << "INFO: Checking " << Points[0] << "," << Points[1] << "," << Points[2] << " against " << endpoints[0] << "," << endpoints[1] << "," << endpoints[2] << "." << endl);
+  return (((endpoints[0] == Points[0]) || (endpoints[0] == Points[1]) || (endpoints[0] == Points[2])) && ((endpoints[1] == Points[0]) || (endpoints[1] == Points[1]) || (endpoints[1] == Points[2])) && ((endpoints[2] == Points[0]) || (endpoints[2] == Points[1]) || (endpoints[2] == Points[2])
+
+  ));
+}
+;
+
+/** Checks whether three given \a *Points coincide with triangle's endpoints.
+ * \param *Points[3] pointer to BoundaryPointSet
+ * \return true - is the very triangle, false - is not
+ */
+bool BoundaryTriangleSet::IsPresentTupel(const BoundaryTriangleSet * const T) const
+{
+  Info FunctionInfo(__func__);
+  return (((endpoints[0] == T->endpoints[0]) || (endpoints[0] == T->endpoints[1]) || (endpoints[0] == T->endpoints[2])) && ((endpoints[1] == T->endpoints[0]) || (endpoints[1] == T->endpoints[1]) || (endpoints[1] == T->endpoints[2])) && ((endpoints[2] == T->endpoints[0]) || (endpoints[2] == T->endpoints[1]) || (endpoints[2] == T->endpoints[2])
+
+  ));
+}
+;
+
+/** Returns the endpoint which is not contained in the given \a *line.
+ * \param *line baseline defining two endpoints
+ * \return pointer third endpoint or NULL if line does not belong to triangle.
+ */
+class BoundaryPointSet *BoundaryTriangleSet::GetThirdEndpoint(const BoundaryLineSet * const line) const
+{
+  Info FunctionInfo(__func__);
+  // sanity check
+  if (!ContainsBoundaryLine(line))
+    return NULL;
+  for (int i = 0; i < 3; i++)
+    if (!line->ContainsBoundaryPoint(endpoints[i]))
+      return endpoints[i];
+  // actually, that' impossible :)
+  return NULL;
+}
+;
+
+/** Returns the baseline which does not contain the given boundary point \a *point.
+ * \param *point endpoint which is neither endpoint of the desired line
+ * \return pointer to desired third baseline
+ */
+class BoundaryLineSet *BoundaryTriangleSet::GetThirdLine(const BoundaryPointSet * const point) const
+{
+  Info FunctionInfo(__func__);
+  // sanity check
+  if (!ContainsBoundaryPoint(point))
+    return NULL;
+  for (int i = 0; i < 3; i++)
+    if (!lines[i]->ContainsBoundaryPoint(point))
+      return lines[i];
+  // actually, that' impossible :)
+  return NULL;
+}
+;
+
+/** Calculates the center point of the triangle.
+ * Is third of the sum of all endpoints.
+ * \param *center central point on return.
+ */
+void BoundaryTriangleSet::GetCenter(Vector & center) const
+{
+  Info FunctionInfo(__func__);
+  center.Zero();
+  for (int i = 0; i < 3; i++)
+    (center) += (endpoints[i]->node->getPosition());
+  center.Scale(1. / 3.);
+  DoLog(1) && (Log() << Verbose(1) << "INFO: Center is at " << center << "." << endl);
+}
+
+/**
+ * gets the Plane defined by the three triangle Basepoints
+ */
+Plane BoundaryTriangleSet::getPlane() const{
+  ASSERT(endpoints[0] && endpoints[1] && endpoints[2], "Triangle not fully defined");
+
+  return Plane(endpoints[0]->node->getPosition(),
+               endpoints[1]->node->getPosition(),
+               endpoints[2]->node->getPosition());
+}
+
+Vector BoundaryTriangleSet::getEndpoint(int i) const{
+  ASSERT(i>=0 && i<3,"Index of Endpoint out of Range");
+
+  return endpoints[i]->node->getPosition();
+}
+
+string BoundaryTriangleSet::getEndpointName(int i) const{
+  ASSERT(i>=0 && i<3,"Index of Endpoint out of Range");
+
+  return endpoints[i]->node->getName();
+}
+
+/** output operator for BoundaryTriangleSet.
+ * \param &ost output stream
+ * \param &a boundary triangle
+ */
+ostream &operator <<(ostream &ost, const BoundaryTriangleSet &a)
+{
+  ost << "[" << a.Nr << "|" << a.getEndpointName(0) << "," << a.getEndpointName(1) << "," << a.getEndpointName(2) << "]";
+  //  ost << "[" << a.Nr << "|" << a.endpoints[0]->node->Name << " at " << *a.endpoints[0]->node->node << ","
+  //      << a.endpoints[1]->node->Name << " at " << *a.endpoints[1]->node->node << "," << a.endpoints[2]->node->Name << " at " << *a.endpoints[2]->node->node << "]";
+  return ost;
+}
+;
+
Index: src/BoundaryTriangleSet.hpp
===================================================================
--- src/BoundaryTriangleSet.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
+++ src/BoundaryTriangleSet.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -0,0 +1,55 @@
+/*
+ * BoundaryTriangleSet.hpp
+ *
+ *  Created on: Jul 29, 2010
+ *      Author: heber
+ */
+
+#ifndef BOUNDARYTRIANGLESET_HPP_
+#define BOUNDARYTRIANGLESET_HPP_
+
+#include "BoundaryMaps.hpp"
+#include "LinearAlgebra/Vector.hpp"
+
+class BoundaryLineSet;
+class BoundaryPointSet;
+class BoundaryTriangleSet;
+class Plane;
+class TesselPoint;
+
+class BoundaryTriangleSet {
+  public:
+    BoundaryTriangleSet();
+    BoundaryTriangleSet(class BoundaryLineSet * const line[3], const int number);
+    ~BoundaryTriangleSet();
+
+    void GetNormalVector(const Vector &NormalVector);
+    void GetCenter(Vector &center) const;
+    bool GetIntersectionInsideTriangle(const Vector & MolCenter, const Vector &x, Vector &Intersection) const;
+    double GetClosestPointInsideTriangle(const Vector &x, Vector &ClosestPoint) const;
+    bool ContainsBoundaryLine(const BoundaryLineSet * const line) const;
+    bool ContainsBoundaryPoint(const BoundaryPointSet * const point) const;
+    bool ContainsBoundaryPoint(const TesselPoint * const point) const;
+    class BoundaryPointSet *GetThirdEndpoint(const BoundaryLineSet * const line) const;
+    class BoundaryLineSet *GetThirdLine(const BoundaryPointSet * const point) const;
+    bool IsPresentTupel(const BoundaryPointSet * const Points[3]) const;
+    bool IsPresentTupel(const BoundaryTriangleSet * const T) const;
+
+    Plane getPlane() const;
+    Vector getEndpoint(int) const;
+    std::string getEndpointName(int) const;
+
+    class BoundaryPointSet *endpoints[3];
+    class BoundaryLineSet *lines[3];
+    Vector NormalVector;
+    Vector SphereCenter;
+    int Nr;
+
+  private:
+
+};
+
+std::ostream & operator << (std::ostream &ost, const BoundaryTriangleSet &a);
+
+
+#endif /* BOUNDARYTRIANGLESET_HPP_ */
Index: src/Box.cpp
===================================================================
--- src/Box.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
+++ src/Box.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -0,0 +1,263 @@
+/*
+ * Box.cpp
+ *
+ *  Created on: Jun 30, 2010
+ *      Author: crueger
+ */
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "Helpers/MemDebug.hpp"
+
+#include "Box.hpp"
+
+#include <cmath>
+#include <iostream>
+#include <cstdlib>
+
+#include "LinearAlgebra/Matrix.hpp"
+#include "LinearAlgebra/Vector.hpp"
+#include "LinearAlgebra/Plane.hpp"
+
+#include "Helpers/Assert.hpp"
+
+using namespace std;
+
+Box::Box()
+{
+  M= new Matrix();
+  M->one();
+  Minv = new Matrix();
+  Minv->one();
+  conditions.resize(3);
+  conditions[0] = conditions[1] = conditions[2] = Wrap;
+}
+
+Box::Box(const Box& src){
+  M=new Matrix(*src.M);
+  Minv = new Matrix(*src.Minv);
+  conditions = src.conditions;
+}
+
+Box::~Box()
+{
+  delete M;
+  delete Minv;
+}
+
+const Matrix &Box::getM() const{
+  return *M;
+}
+const Matrix &Box::getMinv() const{
+  return *Minv;
+}
+
+void Box::setM(Matrix _M){
+  ASSERT(_M.determinant()!=0,"Matrix in Box construction was not invertible");
+  *M    =_M;
+  *Minv = M->invert();
+}
+
+Vector Box::translateIn(const Vector &point) const{
+  return (*M) * point;
+}
+
+Vector Box::translateOut(const Vector &point) const{
+  return (*Minv) * point;
+}
+
+Vector Box::WrapPeriodically(const Vector &point) const{
+  Vector helper = translateOut(point);
+  for(int i=NDIM;i--;){
+
+    switch(conditions[i]){
+    case Wrap:
+      helper.at(i)=fmod(helper.at(i),1);
+      helper.at(i)+=(helper.at(i)>=0)?0:1;
+      break;
+    case Bounce:
+      {
+        // there probably is a better way to handle this...
+        // all the fabs and fmod modf probably makes it very slow
+        double intpart,fracpart;
+        fracpart = modf(fabs(helper.at(i)),&intpart);
+        helper.at(i) = fabs(fracpart-fmod(intpart,2));
+      }
+      break;
+    case Ignore:
+      break;
+    default:
+      ASSERT(0,"No default case for this");
+    }
+
+  }
+  return translateIn(helper);
+}
+
+bool Box::isInside(const Vector &point) const
+{
+  bool result = true;
+  Vector tester = translateOut(point);
+
+  for(int i=0;i<NDIM;i++)
+    result = result &&
+              ((conditions[i] == Ignore) ||
+               ((tester[i] >= -MYEPSILON) &&
+               ((tester[i] - 1.) < MYEPSILON)));
+
+  return result;
+}
+
+
+VECTORSET(std::list) Box::explode(const Vector &point,int n) const{
+  ASSERT(isInside(point),"Exploded point not inside Box");
+  VECTORSET(std::list) res;
+
+  Vector translater = translateOut(point);
+  Vector mask; // contains the ignored coordinates
+
+  // count the number of coordinates we need to do
+  int dims = 0; // number of dimensions that are not ignored
+  vector<int> coords;
+  vector<int> index;
+  for(int i=0;i<NDIM;++i){
+    if(conditions[i]==Ignore){
+      mask[i]=translater[i];
+      continue;
+    }
+    coords.push_back(i);
+    index.push_back(-n);
+    dims++;
+  } // there are max vectors in total we need to create
+
+  if(!dims){
+    // all boundaries are ignored
+    res.push_back(point);
+    return res;
+  }
+
+  bool done = false;
+  while(!done){
+    // create this vector
+    Vector helper;
+    for(int i=0;i<dims;++i){
+      switch(conditions[coords[i]]){
+        case Wrap:
+          helper[coords[i]] = index[i]+translater[coords[i]];
+          break;
+        case Bounce:
+          {
+            // Bouncing the coordinate x produces the series:
+            // 0 -> x
+            // 1 -> 2-x
+            // 2 -> 2+x
+            // 3 -> 4-x
+            // 4 -> 4+x
+            // the first number is the next bigger even number (n+n%2)
+            // the next number is the value with alternating sign (x-2*(n%2)*x)
+            // the negative numbers produce the same sequence reversed and shifted
+            int n = abs(index[i]) + ((index[i]<0)?-1:0);
+            int sign = (index[i]<0)?-1:+1;
+            int even = n%2;
+            helper[coords[i]]=n+even+translater[coords[i]]-2*even*translater[coords[i]];
+            helper[coords[i]]*=sign;
+          }
+          break;
+        case Ignore:
+          ASSERT(0,"Ignored coordinate handled in generation loop");
+        default:
+          ASSERT(0,"No default case for this switch-case");
+      }
+
+    }
+    // add back all ignored coordinates (not handled in above loop)
+    helper+=mask;
+    res.push_back(translateIn(helper));
+    // set the new indexes
+    int pos=0;
+    ++index[pos];
+    while(index[pos]>n){
+      index[pos++]=-n;
+      if(pos>=dims) { // it's trying to increase one beyond array... all vectors generated
+        done = true;
+        break;
+      }
+      ++index[pos];
+    }
+  }
+  return res;
+}
+
+VECTORSET(std::list) Box::explode(const Vector &point) const{
+  ASSERT(isInside(point),"Exploded point not inside Box");
+  return explode(point,1);
+}
+
+double Box::periodicDistanceSquared(const Vector &point1,const Vector &point2) const{
+  Vector helper1 = WrapPeriodically(point1);
+  Vector helper2 = WrapPeriodically(point2);
+  VECTORSET(std::list) expansion = explode(helper1);
+  double res = expansion.minDistSquared(helper2);
+  return res;
+}
+
+double Box::periodicDistance(const Vector &point1,const Vector &point2) const{
+  double res;
+  res = sqrt(periodicDistanceSquared(point1,point2));
+  return res;
+}
+
+const Box::Conditions_t Box::getConditions(){
+  return conditions;
+}
+
+void Box::setCondition(int i,Box::BoundaryCondition_t condition){
+  conditions[i]=condition;
+}
+
+const vector<pair<Plane,Plane> >  Box::getBoundingPlanes(){
+  vector<pair<Plane,Plane> > res;
+  for(int i=0;i<NDIM;++i){
+    Vector base1,base2,base3;
+    base2[(i+1)%NDIM] = 1.;
+    base3[(i+2)%NDIM] = 1.;
+    Plane p1(translateIn(base1),
+             translateIn(base2),
+             translateIn(base3));
+    Vector offset;
+    offset[i]=1;
+    Plane p2(translateIn(base1+offset),
+             translateIn(base2+offset),
+             translateIn(base3+offset));
+    res.push_back(make_pair(p1,p2));
+  }
+  return res;
+}
+
+void Box::setCuboid(const Vector &endpoint){
+  ASSERT(endpoint[0]>0 && endpoint[1]>0 && endpoint[2]>0,"Vector does not define a full cuboid");
+  M->one();
+  M->diagonal()=endpoint;
+  Vector &dinv = Minv->diagonal();
+  for(int i=NDIM;i--;)
+    dinv[i]=1/endpoint[i];
+}
+
+Box &Box::operator=(const Box &src){
+  if(&src!=this){
+    delete M;
+    delete Minv;
+    M    = new Matrix(*src.M);
+    Minv = new Matrix(*src.Minv);
+    conditions = src.conditions;
+  }
+  return *this;
+}
+
+Box &Box::operator=(const Matrix &mat){
+  setM(mat);
+  return *this;
+}
Index: src/Box.hpp
===================================================================
--- src/Box.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
+++ src/Box.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -0,0 +1,114 @@
+/*
+ * Box.hpp
+ *
+ *  Created on: Jun 30, 2010
+ *      Author: crueger
+ */
+
+#ifndef BOX_HPP_
+#define BOX_HPP_
+
+class Matrix;
+class Vector;
+class Plane;
+
+#include <list>
+#include <vector>
+#include "LinearAlgebra/VectorSet.hpp"
+
+/**
+ * A simple class that can be used to store periodic Boxes
+ * in the form of a parallelepiped.
+ *
+ * Stores a matrix that can be used to translate from periodic
+ * [0,1) space as well as the inverse that is needed to
+ * translate back to that space.
+ */
+class Box
+{
+public:
+  typedef enum{
+    Wrap,
+    Bounce,
+    Ignore
+  } BoundaryCondition_t;
+
+  typedef vector<BoundaryCondition_t> Conditions_t;
+
+  Box();
+  Box(const Box&);
+  virtual ~Box();
+
+  /**
+   * Get the matrix describing the form of the parallelepiped
+   */
+  const Matrix &getM() const;
+
+  /**
+   * Get the inverse of the matrix M (see above).
+   */
+  const Matrix &getMinv() const;
+
+  /**
+   * Set the form of the parallelepiped.
+   */
+  void setM(Matrix);
+
+  Box &operator=(const Box&);
+  Box &operator=(const Matrix&);
+
+  /**
+   * Translate a point from [0,1) to the boxed space.
+   */
+  Vector translateIn(const Vector &point) const;
+
+  /**
+   * Translate a point from the boxed space to the [0,1) space.
+   */
+  Vector translateOut(const Vector &point) const;
+
+  /**
+   * Wrap a point so that it will lie within the space defined by the box.
+   */
+  Vector WrapPeriodically(const Vector &point) const;
+
+  /**
+   * Checks whether a given vector is inside the box.
+   */
+  bool isInside(const Vector &point) const;
+
+  /**
+   * Produce corresponding points in several adjacent boxes.
+   *
+   * n specifies the number of times the point is expanded.
+   * Carefull, needs O(n^3) time and produces as many vectors.
+   */
+  VECTORSET(std::list) explode(const Vector &point,int n) const;
+  VECTORSET(std::list) explode(const Vector &point) const;
+
+  /**
+   * Calculate the distance of two points in the periodic space
+   * defined by this box
+   */
+  double periodicDistanceSquared(const Vector &point1,const Vector &point2) const;
+
+  /**
+   * Calculate the distance of two points in the periodic space
+   * defined by this box
+   */
+  double periodicDistance(const Vector &point1,const Vector &point2) const;
+
+  const Conditions_t getConditions();
+  void setCondition(int,BoundaryCondition_t);
+
+  const vector<pair<Plane,Plane> > getBoundingPlanes();
+
+  void setCuboid(const Vector&);
+
+private:
+  Conditions_t conditions;
+  Matrix *M;    //!< Defines the layout of the box
+  Matrix *Minv; //!< Inverse of M to avoid recomputation
+};
+
+#endif /* BOX_HPP_ */
Index: src/CandidateForTesselation.cpp
===================================================================
--- src/CandidateForTesselation.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
+++ src/CandidateForTesselation.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -0,0 +1,182 @@
+/*
+ * CandidateForTesselation.cpp
+ *
+ *  Created on: Jul 29, 2010
+ *      Author: heber
+ */
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "Helpers/MemDebug.hpp"
+
+#include "CandidateForTesselation.hpp"
+
+#include <iostream>
+#include <iomanip>
+
+#include "BoundaryLineSet.hpp"
+#include "BoundaryPointSet.hpp"
+#include "TesselPoint.hpp"
+
+#include "Helpers/Assert.hpp"
+#include "Helpers/Info.hpp"
+//#include "Line.hpp"
+#include "linkedcell.hpp"
+#include "Helpers/Log.hpp"
+//#include "Plane.hpp"
+#include "LinearAlgebra/Vector.hpp"
+#include "Helpers/Verbose.hpp"
+
+using namespace std;
+
+
+const double CandidateForTesselation::HULLEPSILON = 1e-9;
+
+
+/** Constructor of class CandidateForTesselation.
+ */
+CandidateForTesselation::CandidateForTesselation(BoundaryLineSet* line) :
+  BaseLine(line),
+  ThirdPoint(NULL),
+  T(NULL),
+  ShortestAngle(2. * M_PI),
+  OtherShortestAngle(2. * M_PI)
+{
+  Info FunctionInfo(__func__);
+}
+;
+
+/** Constructor of class CandidateForTesselation.
+ */
+CandidateForTesselation::CandidateForTesselation(TesselPoint *candidate, BoundaryLineSet* line, BoundaryPointSet* point, const Vector &OptCandidateCenter, const Vector &OtherOptCandidateCenter) :
+  BaseLine(line),
+  ThirdPoint(point),
+  T(NULL),
+  OptCenter(OptCandidateCenter),
+  OtherOptCenter(OtherOptCandidateCenter),
+  ShortestAngle(2. * M_PI),
+  OtherShortestAngle(2. * M_PI)
+{
+  Info FunctionInfo(__func__);
+};
+
+
+/** Destructor for class CandidateForTesselation.
+ */
+CandidateForTesselation::~CandidateForTesselation()
+{
+}
+;
+
+/** Checks validity of a given sphere of a candidate line.
+ * Sphere must touch all candidates and the baseline endpoints and there must be no other atoms inside.
+ * \param RADIUS radius of sphere
+ * \param *LC LinkedCell structure with other atoms
+ * \return true - sphere is valid, false - sphere contains other points
+ */
+bool CandidateForTesselation::CheckValidity(const double RADIUS, const LinkedCell *LC) const
+{
+  Info FunctionInfo(__func__);
+
+  const double radiusSquared = RADIUS * RADIUS;
+  list<const Vector *> VectorList;
+  VectorList.push_back(&OptCenter);
+  //VectorList.push_back(&OtherOptCenter);  // don't check the other (wrong) center
+
+  if (!pointlist.empty())
+    DoLog(1) && (Log() << Verbose(1) << "INFO: Checking whether sphere contains candidate list and baseline " << *BaseLine->endpoints[0] << "<->" << *BaseLine->endpoints[1] << " only ..." << endl);
+  else
+    DoLog(1) && (Log() << Verbose(1) << "INFO: Checking whether sphere with no candidates contains baseline " << *BaseLine->endpoints[0] << "<->" << *BaseLine->endpoints[1] << " only ..." << endl);
+  // check baseline for OptCenter and OtherOptCenter being on sphere's surface
+  for (list<const Vector *>::const_iterator VRunner = VectorList.begin(); VRunner != VectorList.end(); ++VRunner) {
+    for (int i = 0; i < 2; i++) {
+      const double distance = fabs((*VRunner)->DistanceSquared(BaseLine->endpoints[i]->node->getPosition()) - radiusSquared);
+      if (distance > HULLEPSILON) {
+        DoeLog(1) && (eLog() << Verbose(1) << "Endpoint " << *BaseLine->endpoints[i] << " is out of sphere at " << *(*VRunner) << " by " << distance << "." << endl);
+        return false;
+      }
+    }
+  }
+
+  // check Candidates for OptCenter and OtherOptCenter being on sphere's surface
+  for (TesselPointList::const_iterator Runner = pointlist.begin(); Runner != pointlist.end(); ++Runner) {
+    const TesselPoint *Walker = *Runner;
+    for (list<const Vector *>::const_iterator VRunner = VectorList.begin(); VRunner != VectorList.end(); ++VRunner) {
+      const double distance = fabs((*VRunner)->DistanceSquared(Walker->getPosition()) - radiusSquared);
+      if (distance > HULLEPSILON) {
+        DoeLog(1) && (eLog() << Verbose(1) << "Candidate " << *Walker << " is out of sphere at " << *(*VRunner) << " by " << distance << "." << endl);
+        return false;
+      } else {
+        DoLog(1) && (Log() << Verbose(1) << "Candidate " << *Walker << " is inside by " << distance << "." << endl);
+      }
+    }
+  }
+
+  DoLog(1) && (Log() << Verbose(1) << "INFO: Checking whether sphere contains no others points ..." << endl);
+  bool flag = true;
+  for (list<const Vector *>::const_iterator VRunner = VectorList.begin(); VRunner != VectorList.end(); ++VRunner) {
+    // get all points inside the sphere
+    TesselPointList *ListofPoints = LC->GetPointsInsideSphere(RADIUS, (*VRunner));
+
+    DoLog(1) && (Log() << Verbose(1) << "The following atoms are inside sphere at " << (*VRunner) << ":" << endl);
+    for (TesselPointList::const_iterator Runner = ListofPoints->begin(); Runner != ListofPoints->end(); ++Runner)
+      DoLog(1) && (Log() << Verbose(1) << "  " << *(*Runner) << " with distance " << (*Runner)->distance(*(*VRunner)) << "." << endl);
+
+    // remove baseline's endpoints and candidates
+    for (int i = 0; i < 2; i++) {
+      DoLog(1) && (Log() << Verbose(1) << "INFO: removing baseline tesselpoint " << *BaseLine->endpoints[i]->node << "." << endl);
+      ListofPoints->remove(BaseLine->endpoints[i]->node);
+    }
+    for (TesselPointList::const_iterator Runner = pointlist.begin(); Runner != pointlist.end(); ++Runner) {
+      DoLog(1) && (Log() << Verbose(1) << "INFO: removing candidate tesselpoint " << *(*Runner) << "." << endl);
+      ListofPoints->remove(*Runner);
+    }
+    if (!ListofPoints->empty()) {
+      DoeLog(1) && (eLog() << Verbose(1) << "CheckValidity: There are still " << ListofPoints->size() << " points inside the sphere." << endl);
+      flag = false;
+      DoeLog(1) && (eLog() << Verbose(1) << "External atoms inside of sphere at " << *(*VRunner) << ":" << endl);
+      for (TesselPointList::const_iterator Runner = ListofPoints->begin(); Runner != ListofPoints->end(); ++Runner)
+        DoeLog(1) && (eLog() << Verbose(1) << "  " << *(*Runner) << " at distance " << setprecision(13) << (*Runner)->distance(*(*VRunner)) << setprecision(6) << "." << endl);
+
+      // check with animate_sphere.tcl VMD script
+      if (ThirdPoint != NULL) {
+        DoeLog(1) && (eLog() << Verbose(1) << "Check by: animate_sphere 0 " << BaseLine->endpoints[0]->Nr + 1 << " " << BaseLine->endpoints[1]->Nr + 1 << " " << ThirdPoint->Nr + 1 << " " << RADIUS << " " << OldCenter[0] << " " << OldCenter[1] << " " << OldCenter[2] << " " << (*VRunner)->at(0) << " " << (*VRunner)->at(1) << " " << (*VRunner)->at(2) << endl);
+      } else {
+        DoeLog(1) && (eLog() << Verbose(1) << "Check by: ... missing third point ..." << endl);
+        DoeLog(1) && (eLog() << Verbose(1) << "Check by: animate_sphere 0 " << BaseLine->endpoints[0]->Nr + 1 << " " << BaseLine->endpoints[1]->Nr + 1 << " ??? " << RADIUS << " " << OldCenter[0] << " " << OldCenter[1] << " " << OldCenter[2] << " " << (*VRunner)->at(0) << " " << (*VRunner)->at(1) << " " << (*VRunner)->at(2) << endl);
+      }
+    }
+    delete (ListofPoints);
+
+  }
+  return flag;
+}
+;
+
+/** output operator for CandidateForTesselation.
+ * \param &ost output stream
+ * \param &a boundary line
+ */
+ostream & operator <<(ostream &ost, const CandidateForTesselation &a)
+{
+  ost << "[" << a.BaseLine->Nr << "|" << a.BaseLine->endpoints[0]->node->getName() << "," << a.BaseLine->endpoints[1]->node->getName() << "] with ";
+  if (a.pointlist.empty())
+    ost << "no candidate.";
+  else {
+    ost << "candidate";
+    if (a.pointlist.size() != 1)
+      ost << "s ";
+    else
+      ost << " ";
+    for (TesselPointList::const_iterator Runner = a.pointlist.begin(); Runner != a.pointlist.end(); Runner++)
+      ost << *(*Runner) << " ";
+    ost << " at angle " << (a.ShortestAngle) << ".";
+  }
+
+  return ost;
+}
+;
+
Index: src/CandidateForTesselation.hpp
===================================================================
--- src/CandidateForTesselation.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
+++ src/CandidateForTesselation.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -0,0 +1,48 @@
+/*
+ * CandidateForTesselation.hpp
+ *
+ *  Created on: Jul 29, 2010
+ *      Author: heber
+ */
+
+#ifndef CANDIDATEFORTESSELATION_HPP_
+#define CANDIDATEFORTESSELATION_HPP_
+
+#include "BoundaryMaps.hpp"
+#include "LinearAlgebra/Vector.hpp"
+
+#include <list>
+#include <set>
+
+class BoundaryLineSet;
+class BoundaryPointSet;
+class BoundaryTriangleSet;
+class LinkedCell;
+class TesselPoint;
+
+class CandidateForTesselation {
+  public :
+  CandidateForTesselation(BoundaryLineSet* currentBaseLine);
+  CandidateForTesselation(TesselPoint* candidate, BoundaryLineSet* currentBaseLine, BoundaryPointSet *point, const Vector &OptCandidateCenter, const Vector &OtherOptCandidateCenter);
+  ~CandidateForTesselation();
+
+  bool CheckValidity(const double RADIUS, const class LinkedCell *LC) const;
+
+  TesselPointList pointlist;
+  const BoundaryLineSet * BaseLine;
+  const BoundaryPointSet * ThirdPoint;
+  const BoundaryTriangleSet *T;
+  Vector OldCenter;
+  Vector OptCenter;
+  Vector OtherOptCenter;
+  double ShortestAngle;
+  double OtherShortestAngle;
+
+  private:
+  static const double HULLEPSILON; //!< TODO: Get rid of HULLEPSILON, points to numerical instabilities
+};
+
+std::ostream & operator <<(std::ostream &ost, const  CandidateForTesselation &a);
+
+
+#endif /* CANDIDATEFORTESSELATION_HPP_ */
Index: src/CommandLineParser.cpp
===================================================================
--- src/CommandLineParser.cpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/CommandLineParser.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -5,4 +5,9 @@
  *      Author: heber
  */
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
 
 #include "Helpers/MemDebug.hpp"
@@ -15,6 +20,6 @@
 #include "Patterns/Singleton_impl.hpp"
 #include "CommandLineParser.hpp"
-#include "log.hpp"
-#include "verbose.hpp"
+#include "Helpers/Log.hpp"
+#include "Helpers/Verbose.hpp"
 
 using namespace std;
@@ -41,5 +46,5 @@
 void CommandLineParser::Parse()
 {
-  po::store(po::command_line_parser(argc,argv).options(cmdline_options).options(visible).run(), vm);
+  po::store(po::command_line_parser(argc,argv).options(cmdline_options).run(), vm);
   ifstream input;
   input.open("example.cfg");
Index: src/ConfigFileBuffer.cpp
===================================================================
--- src/ConfigFileBuffer.cpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/ConfigFileBuffer.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -6,8 +6,16 @@
  */
 
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "Helpers/MemDebug.hpp"
+
 #include "ConfigFileBuffer.hpp"
-#include "helpers.hpp"
+#include "Helpers/helpers.hpp"
 #include "lists.hpp"
-#include "log.hpp"
+#include "Helpers/Verbose.hpp"
+#include "Helpers/Log.hpp"
 #include "World.hpp"
 
@@ -50,5 +58,9 @@
 /** Constructor for ConfigFileBuffer class.
  */
-ConfigFileBuffer::ConfigFileBuffer() : buffer(NULL), LineMapping(NULL), CurrentLine(0), NoLines(0)
+ConfigFileBuffer::ConfigFileBuffer() :
+    buffer(NULL),
+    LineMapping(NULL),
+    CurrentLine(0),
+    NoLines(0)
 {
 };
@@ -57,5 +69,9 @@
  * \param *filename file name
  */
-ConfigFileBuffer::ConfigFileBuffer(const char * const filename) : buffer(NULL), LineMapping(NULL), CurrentLine(0), NoLines(0)
+ConfigFileBuffer::ConfigFileBuffer(const char * const filename) :
+    buffer(NULL),
+    LineMapping(NULL),
+    CurrentLine(0),
+    NoLines(0)
 {
   InitFileBuffer(filename);
Index: src/ConfigFileBuffer.hpp
===================================================================
--- src/ConfigFileBuffer.hpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/ConfigFileBuffer.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -17,5 +17,5 @@
 #endif
 
-#include <iostream>
+#include <iosfwd>
 
 /****************************************** forward declarations *****************************/
Index: src/Descriptors/AtomDescriptor.cpp
===================================================================
--- src/Descriptors/AtomDescriptor.cpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/Descriptors/AtomDescriptor.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -5,4 +5,9 @@
  *      Author: crueger
  */
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
 
 #include "Helpers/MemDebug.hpp"
@@ -13,4 +18,5 @@
 #include "World.hpp"
 #include "atom.hpp"
+#include "Patterns/ObservedContainer_impl.hpp"
 
 #include <boost/bind.hpp>
@@ -20,5 +26,5 @@
 using namespace std;
 
-typedef World::AtomSet::iterator atoms_iter_t;
+typedef World::AtomSet::internal_iterator atoms_iter_t;
 
 /************************ Forwarding object **************************************/
@@ -73,7 +79,7 @@
 
 atom* AtomDescriptor_impl::find() {
-  World::AtomSet atoms = getAtoms();
-  atoms_iter_t res = find_if(atoms.begin(),atoms.end(),boost::bind(&AtomDescriptor_impl::predicate,this,_1));
-  return (res!=atoms.end())?((*res).second):0;
+  World::AtomSet &atoms = getAtoms();
+  atoms_iter_t res = find_if(atoms.begin_internal(),atoms.end_internal(),boost::bind(&AtomDescriptor_impl::predicate,this,_1));
+  return (res!=atoms.end_internal())?((*res).second):0;
 }
 
@@ -81,11 +87,15 @@
   vector<atom*> res;
   World::AtomSet atoms = getAtoms();
-  atoms_iter_t iter;
-  for(iter=atoms.begin();iter!=atoms.end();++iter) {
-    if(predicate(*iter)){
-      res.push_back((*iter).second);
-    }
+  for_each(atoms.begin_internal(),
+           atoms.end_internal(),
+           boost::bind(&AtomDescriptor_impl::checkAndAdd,
+                       this,&res,_1));
+  return res;
+}
+
+void AtomDescriptor_impl::checkAndAdd(std::vector<atom*> *v,std::pair<atomId_t,atom*> p){
+  if(predicate(p)){
+    v->push_back(p.second);
   }
-  return res;
 }
 
Index: src/Descriptors/AtomDescriptor.hpp
===================================================================
--- src/Descriptors/AtomDescriptor.hpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/Descriptors/AtomDescriptor.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -35,5 +35,5 @@
   // close coupling to the world to allow access
   friend atom* World::getAtom(AtomDescriptor descriptor);
-  friend std::vector<atom*> World::getAllAtoms(AtomDescriptor descriptor);
+  friend World::AtomComposite World::getAllAtoms(AtomDescriptor descriptor);
   template <class,class,class> friend class SelectiveIterator;
 
Index: src/Descriptors/AtomDescriptor_impl.hpp
===================================================================
--- src/Descriptors/AtomDescriptor_impl.hpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/Descriptors/AtomDescriptor_impl.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -50,4 +50,6 @@
    */
   World::AtomSet& getAtoms();
+
+  void checkAndAdd(std::vector<atom*>*,std::pair<atomId_t,atom*>);
 };
 
Index: src/Descriptors/AtomIdDescriptor.cpp
===================================================================
--- src/Descriptors/AtomIdDescriptor.cpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/Descriptors/AtomIdDescriptor.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -6,4 +6,9 @@
  */
 
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
 #include "Helpers/MemDebug.hpp"
 
@@ -12,4 +17,5 @@
 
 #include "atom.hpp"
+#include "Patterns/ObservedContainer_impl.hpp"
 
 using namespace std;
@@ -32,5 +38,5 @@
 
 atom *AtomIdDescriptor_impl::find(){
-  World::AtomSet atoms = getAtoms();
+  World::AtomSet &atoms = getAtoms();
   World::AtomSet::iterator res = atoms.find(id);
   return (res!=atoms.end())?((*res).second):0;
Index: src/Descriptors/AtomSelectionDescriptor.cpp
===================================================================
--- src/Descriptors/AtomSelectionDescriptor.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
+++ src/Descriptors/AtomSelectionDescriptor.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -0,0 +1,50 @@
+/*
+ * AtomSelectionDescriptor.cpp
+ *
+ *  Created on: Jul 16, 2010
+ *      Author: crueger
+ */
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "Helpers/MemDebug.hpp"
+
+#include "Descriptors/AtomSelectionDescriptor.hpp"
+#include "Descriptors/AtomSelectionDescriptor_impl.hpp"
+
+#include "Helpers/helpers.hpp"
+
+AtomSelectionDescriptor_impl::AtomSelectionDescriptor_impl(){}
+
+AtomSelectionDescriptor_impl::~AtomSelectionDescriptor_impl(){}
+
+bool AtomSelectionDescriptor_impl::predicate(std::pair<atomId_t,atom*> atom){
+  return getSelectedAtoms().count(atom.first);
+}
+
+atom* AtomSelectionDescriptor_impl::find(){
+  World::AtomSet &set = getSelectedAtoms();
+  World::AtomSet::internal_iterator begin = set.begin_internal();
+  return (begin!=set.end_internal())?(begin->second):0;
+}
+
+std::vector<atom*> AtomSelectionDescriptor_impl::findAll(){
+  std::vector<atom*> res;
+  World::AtomSet &set = getSelectedAtoms();
+  transform(set.begin_internal(),
+           set.end_internal(),
+           back_inserter(res),
+           _take<atom*,World::AtomSet::value_type>::get);
+  return res;
+}
+
+World::AtomSet& AtomSelectionDescriptor_impl::getSelectedAtoms(){
+  return World::getInstance().selectedAtoms;
+}
+
+AtomDescriptor AtomsBySelection(){
+  return AtomDescriptor(AtomDescriptor::impl_ptr(new AtomSelectionDescriptor_impl()));
+}
Index: src/Descriptors/AtomSelectionDescriptor.hpp
===================================================================
--- src/Descriptors/AtomSelectionDescriptor.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
+++ src/Descriptors/AtomSelectionDescriptor.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -0,0 +1,15 @@
+/*
+ * AtomSelectionDescriptor.hpp
+ *
+ *  Created on: Jul 16, 2010
+ *      Author: crueger
+ */
+
+#ifndef ATOMSELECTIONDESCRIPTOR_HPP_
+#define ATOMSELECTIONDESCRIPTOR_HPP_
+
+#include "Descriptors/AtomDescriptor.hpp"
+
+AtomDescriptor AtomsBySelection();
+
+#endif /* ATOMSELECTIONDESCRIPTOR_HPP_ */
Index: src/Descriptors/AtomSelectionDescriptor_impl.hpp
===================================================================
--- src/Descriptors/AtomSelectionDescriptor_impl.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
+++ src/Descriptors/AtomSelectionDescriptor_impl.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -0,0 +1,26 @@
+/*
+ * AtomSelectionDescriptor_impl.hpp
+ *
+ *  Created on: Jul 16, 2010
+ *      Author: crueger
+ */
+
+#ifndef ATOMSELECTIONDESCRIPTOR_IMPL_HPP_
+#define ATOMSELECTIONDESCRIPTOR_IMPL_HPP_
+
+#include "Descriptors/AtomDescriptor_impl.hpp"
+
+class AtomSelectionDescriptor_impl : public AtomDescriptor_impl{
+public:
+  AtomSelectionDescriptor_impl();
+  virtual ~AtomSelectionDescriptor_impl();
+  bool predicate(std::pair<atomId_t,atom*> atom);
+protected:
+  // need to overide more than the standard methods to make this fast
+  virtual atom* find();
+  virtual std::vector<atom*> findAll();
+
+  World::AtomSet& getSelectedAtoms();
+};
+
+#endif /* ATOMSELECTIONDESCRIPTOR_IMPL_HPP_ */
Index: src/Descriptors/AtomShapeDescriptor.cpp
===================================================================
--- src/Descriptors/AtomShapeDescriptor.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
+++ src/Descriptors/AtomShapeDescriptor.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -0,0 +1,38 @@
+/*
+ * AtomShapeDescriptor.cpp
+ *
+ *  Created on: Aug 9, 2010
+ *      Author: heber
+ */
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "Helpers/MemDebug.hpp"
+
+#include "AtomShapeDescriptor.hpp"
+#include "AtomShapeDescriptor_impl.hpp"
+
+#include "atom.hpp"
+#include "Patterns/ObservedContainer_impl.hpp"
+#include "Shapes/Shape.hpp"
+
+using namespace std;
+
+
+AtomShapeDescriptor_impl::AtomShapeDescriptor_impl(Shape _shape) :
+  shape(_shape)
+{}
+
+AtomShapeDescriptor_impl::~AtomShapeDescriptor_impl()
+{}
+
+bool AtomShapeDescriptor_impl::predicate(std::pair<atomId_t,atom*> atom) {
+  return shape.isInside(atom.second->getPosition());
+}
+
+AtomDescriptor AtomByShape(Shape &_shape){
+  return AtomDescriptor(AtomDescriptor::impl_ptr(new AtomShapeDescriptor_impl(_shape)));
+}
Index: src/Descriptors/AtomShapeDescriptor.hpp
===================================================================
--- src/Descriptors/AtomShapeDescriptor.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
+++ src/Descriptors/AtomShapeDescriptor.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -0,0 +1,18 @@
+/*
+ * AtomShapeDescriptor.hpp
+ *
+ *  Created on: Aug 9, 2010
+ *      Author: heber
+ */
+
+#ifndef ATOMSHAPEDESCRIPTOR_HPP_
+#define ATOMSHAPEDESCRIPTOR_HPP_
+
+#include "defs.hpp"
+#include "Descriptors/AtomDescriptor.hpp"
+
+class Shape;
+
+AtomDescriptor AtomByShape(Shape &_shape);
+
+#endif /* ATOMSHAPEDESCRIPTOR_HPP_ */
Index: src/Descriptors/AtomShapeDescriptor_impl.hpp
===================================================================
--- src/Descriptors/AtomShapeDescriptor_impl.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
+++ src/Descriptors/AtomShapeDescriptor_impl.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -0,0 +1,26 @@
+/*
+ * AtomShapeDescriptor_impl.hpp
+ *
+ *  Created on: Aug 9, 2010
+ *      Author: heber
+ */
+
+#ifndef ATOMSHAPEDESCRIPTOR_IMPL_HPP
+#define ATOMSHAPEDESCRIPTOR_IMPL_HPP
+
+#include "Descriptors/AtomDescriptor_impl.hpp"
+#include "Shapes/Shape.hpp"
+
+class AtomShapeDescriptor_impl : public AtomDescriptor_impl
+{
+public:
+  AtomShapeDescriptor_impl(Shape _shape);
+  virtual ~AtomShapeDescriptor_impl();
+
+  bool predicate(std::pair<atomId_t,atom*> atom);
+
+private:
+  Shape shape;
+};
+
+#endif //ATOMSHAPEDESCRIPTOR_IMPL_HPP
Index: src/Descriptors/AtomTypeDescriptor.cpp
===================================================================
--- src/Descriptors/AtomTypeDescriptor.cpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/Descriptors/AtomTypeDescriptor.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -5,4 +5,9 @@
  *      Author: crueger
  */
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
 
 #include "Helpers/MemDebug.hpp"
Index: src/Descriptors/MoleculeDescriptor.cpp
===================================================================
--- src/Descriptors/MoleculeDescriptor.cpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/Descriptors/MoleculeDescriptor.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -6,4 +6,9 @@
  */
 
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
 #include "Helpers/MemDebug.hpp"
 
@@ -12,4 +17,5 @@
 
 #include "World.hpp"
+#include "Patterns/ObservedContainer_impl.hpp"
 
 #include "molecule.hpp"
@@ -20,5 +26,5 @@
 using namespace std;
 
-typedef World::MoleculeSet::iterator molecules_iter_t;
+typedef World::MoleculeSet::internal_iterator molecules_iter_t;
 
 /************************ Forwarding object **************************************/
@@ -73,19 +79,23 @@
 
 molecule* MoleculeDescriptor_impl::find() {
-  World::MoleculeSet molecules = getMolecules();
-  molecules_iter_t res = find_if(molecules.begin(),molecules.end(),boost::bind(&MoleculeDescriptor_impl::predicate,this,_1));
-  return (res!=molecules.end())?((*res).second):0;
+  World::MoleculeSet &molecules = getMolecules();
+  molecules_iter_t res = find_if(molecules.begin_internal(),molecules.end_internal(),boost::bind(&MoleculeDescriptor_impl::predicate,this,_1));
+  return (res!=molecules.end_internal())?((*res).second):0;
 }
 
 vector<molecule*> MoleculeDescriptor_impl::findAll() {
   vector<molecule*> res;
-  World::MoleculeSet molecules = getMolecules();
-  molecules_iter_t iter;
-  for(iter=molecules.begin();iter!=molecules.end();++iter) {
-    if(predicate(*iter)){
-      res.push_back((*iter).second);
-    }
+  World::MoleculeSet &molecules = getMolecules();
+  for_each(molecules.begin_internal(),
+           molecules.end_internal(),
+           boost::bind(&MoleculeDescriptor_impl::checkAndAdd,
+                       this,&res,_1));
+  return res;
+}
+
+void MoleculeDescriptor_impl::checkAndAdd(std::vector<molecule*> *v,std::pair<moleculeId_t,molecule*> p){
+  if(predicate(p)){
+    v->push_back(p.second);
   }
-  return res;
 }
 
Index: src/Descriptors/MoleculeDescriptor_impl.hpp
===================================================================
--- src/Descriptors/MoleculeDescriptor_impl.hpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/Descriptors/MoleculeDescriptor_impl.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -50,4 +50,6 @@
    */
   World::MoleculeSet& getMolecules();
+
+  void checkAndAdd(std::vector<molecule*>*,std::pair<moleculeId_t,molecule*>);
 };
 
Index: src/Descriptors/MoleculeFormulaDescriptor.cpp
===================================================================
--- src/Descriptors/MoleculeFormulaDescriptor.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
+++ src/Descriptors/MoleculeFormulaDescriptor.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -0,0 +1,40 @@
+/*
+ * MoleculeFormulaDescriptor.cpp
+ *
+ *  Created on: Jul 22, 2010
+ *      Author: crueger
+ */
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "Helpers/MemDebug.hpp"
+
+#include "MoleculeFormulaDescriptor.hpp"
+#include "MoleculeFormulaDescriptor_impl.hpp"
+
+#include "molecule.hpp"
+
+
+MoleculeFormulaDescriptor_impl::MoleculeFormulaDescriptor_impl(const Formula &_formula) :
+  formula(_formula)
+{}
+
+MoleculeFormulaDescriptor_impl::~MoleculeFormulaDescriptor_impl(){}
+
+bool MoleculeFormulaDescriptor_impl::predicate(std::pair<moleculeId_t,molecule*> molecule){
+  return molecule.second->getFormula() == formula;
+}
+
+
+MoleculeDescriptor MoleculeByFormula(const Formula &formula)
+{
+  return MoleculeDescriptor(MoleculeDescriptor::impl_ptr(new MoleculeFormulaDescriptor_impl(formula)));
+}
+
+MoleculeDescriptor MoleculeByFormula(const std::string &_formula) throw(ParseError){
+  Formula formula(_formula);
+  return MoleculeByFormula(formula);
+}
Index: src/Descriptors/MoleculeFormulaDescriptor.hpp
===================================================================
--- src/Descriptors/MoleculeFormulaDescriptor.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
+++ src/Descriptors/MoleculeFormulaDescriptor.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -0,0 +1,19 @@
+/*
+ * MoleculeFormulaDescriptor.hpp
+ *
+ *  Created on: Jul 22, 2010
+ *      Author: crueger
+ */
+
+#ifndef MOLECULEFORMULADESCRIPTOR_HPP_
+#define MOLECULEFORMULADESCRIPTOR_HPP_
+
+#include "Descriptors/MoleculeDescriptor.hpp"
+#include "Exceptions/ParseError.hpp"
+
+class Formula;
+
+MoleculeDescriptor MoleculeByFormula(const Formula&);
+MoleculeDescriptor MoleculeByFormula(const std::string&) throw(ParseError);
+
+#endif /* MOLECULEFORMULADESCRIPTOR_HPP_ */
Index: src/Descriptors/MoleculeFormulaDescriptor_impl.hpp
===================================================================
--- src/Descriptors/MoleculeFormulaDescriptor_impl.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
+++ src/Descriptors/MoleculeFormulaDescriptor_impl.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -0,0 +1,24 @@
+/*
+ * MoleculeFormulaDescriptor_impl.hpp
+ *
+ *  Created on: Jul 22, 2010
+ *      Author: crueger
+ */
+
+#ifndef MOLECULEFORMULADESCRIPTOR_IMPL_HPP_
+#define MOLECULEFORMULADESCRIPTOR_IMPL_HPP_
+
+#include "Descriptors/MoleculeDescriptor_impl.hpp"
+#include "Formula.hpp"
+
+class MoleculeFormulaDescriptor_impl : public MoleculeDescriptor_impl
+{
+public:
+  MoleculeFormulaDescriptor_impl(const Formula &);
+  virtual ~MoleculeFormulaDescriptor_impl();
+  bool predicate(std::pair<moleculeId_t,molecule*> molecule);
+private:
+  Formula formula;
+};
+
+#endif /* MOLECULEFORMULADESCRIPTOR_IMPL_HPP_ */
Index: src/Descriptors/MoleculeIdDescriptor.cpp
===================================================================
--- src/Descriptors/MoleculeIdDescriptor.cpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/Descriptors/MoleculeIdDescriptor.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -6,8 +6,15 @@
  */
 
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
 #include "Helpers/MemDebug.hpp"
 
 #include "MoleculeIdDescriptor.hpp"
 #include "MoleculeIdDescriptor_impl.hpp"
+
+#include "Patterns/ObservedContainer_impl.hpp"
 
 #include "molecule.hpp"
@@ -32,5 +39,5 @@
 
 molecule *MoleculeIdDescriptor_impl::find(){
-  World::MoleculeSet molecules = getMolecules();
+  World::MoleculeSet &molecules = getMolecules();
   World::MoleculeSet::iterator res = molecules.find(id);
   return (res!=molecules.end())?((*res).second):0;
Index: src/Descriptors/MoleculeNameDescriptor.cpp
===================================================================
--- src/Descriptors/MoleculeNameDescriptor.cpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/Descriptors/MoleculeNameDescriptor.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -5,4 +5,11 @@
  *      Author: heber
  */
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "Helpers/MemDebug.hpp"
 
 #include "MoleculeNameDescriptor.hpp"
@@ -30,5 +37,5 @@
 
 molecule *MoleculeNameDescriptor_impl::find(){
-  World::MoleculeSet molecules = getMolecules();
+  World::MoleculeSet &molecules = getMolecules();
   World::MoleculeSet::iterator res = molecules.begin();
   for (; res != molecules.end(); res++)
Index: src/Descriptors/MoleculePtrDescriptor.cpp
===================================================================
--- src/Descriptors/MoleculePtrDescriptor.cpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/Descriptors/MoleculePtrDescriptor.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -6,8 +6,15 @@
  */
 
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
 #include "Helpers/MemDebug.hpp"
 
 #include "MoleculePtrDescriptor.hpp"
 #include "MoleculePtrDescriptor_impl.hpp"
+
+#include "Patterns/ObservedContainer_impl.hpp"
 
 #include "molecule.hpp"
@@ -32,5 +39,5 @@
 
 molecule *MoleculePtrDescriptor_impl::find(){
-  World::MoleculeSet molecules = getMolecules();
+  World::MoleculeSet &molecules = getMolecules();
   World::MoleculeSet::iterator res = molecules.find(ptr->getId());
   return (res!=molecules.end())?((*res).second):0;
Index: src/Descriptors/MoleculeSelectionDescriptor.cpp
===================================================================
--- src/Descriptors/MoleculeSelectionDescriptor.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
+++ src/Descriptors/MoleculeSelectionDescriptor.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -0,0 +1,50 @@
+/*
+ * MoleculeSelectionDescriptor.cpp
+ *
+ *  Created on: Jul 16, 2010
+ *      Author: crueger
+ */
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "Helpers/MemDebug.hpp"
+
+#include "Descriptors/MoleculeSelectionDescriptor.hpp"
+#include "Descriptors/MoleculeSelectionDescriptor_impl.hpp"
+
+#include "Helpers/helpers.hpp"
+
+MoleculeSelectionDescriptor_impl::MoleculeSelectionDescriptor_impl(){}
+
+MoleculeSelectionDescriptor_impl::~MoleculeSelectionDescriptor_impl(){}
+
+bool MoleculeSelectionDescriptor_impl::predicate(std::pair<moleculeId_t,molecule*> molecule){
+  return getSelectedMolecules().count(molecule.first);
+}
+
+molecule* MoleculeSelectionDescriptor_impl::find(){
+  World::MoleculeSet &set = getSelectedMolecules();
+  World::MoleculeSet::internal_iterator begin = set.begin_internal();
+  return (begin!=set.end_internal())?(begin->second):0;
+}
+
+std::vector<molecule*> MoleculeSelectionDescriptor_impl::findAll(){
+  std::vector<molecule*> res;
+  World::MoleculeSet &set = getSelectedMolecules();
+  transform(set.begin_internal(),
+           set.end_internal(),
+           back_inserter(res),
+           _take<molecule*,World::MoleculeSet::value_type>::get);
+  return res;
+}
+
+World::MoleculeSet& MoleculeSelectionDescriptor_impl::getSelectedMolecules(){
+  return World::getInstance().selectedMolecules;
+}
+
+MoleculeDescriptor MoleculesBySelection(){
+  return MoleculeDescriptor(MoleculeDescriptor::impl_ptr(new MoleculeSelectionDescriptor_impl()));
+}
Index: src/Descriptors/MoleculeSelectionDescriptor.hpp
===================================================================
--- src/Descriptors/MoleculeSelectionDescriptor.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
+++ src/Descriptors/MoleculeSelectionDescriptor.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -0,0 +1,15 @@
+/*
+ * MoleculeSelectionDescriptor.hpp
+ *
+ *  Created on: Jul 16, 2010
+ *      Author: crueger
+ */
+
+#ifndef MOLECULESELECTIONDESCRIPTOR_HPP_
+#define MOLECULESELECTIONDESCRIPTOR_HPP_
+
+#include "Descriptors/MoleculeDescriptor.hpp"
+
+MoleculeDescriptor MoleculesBySelection();
+
+#endif /* MOLECULESELECTIONDESCRIPTOR_HPP_ */
Index: src/Descriptors/MoleculeSelectionDescriptor_impl.hpp
===================================================================
--- src/Descriptors/MoleculeSelectionDescriptor_impl.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
+++ src/Descriptors/MoleculeSelectionDescriptor_impl.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -0,0 +1,26 @@
+/*
+ * MoleculeSelectionDescriptor_impl.hpp
+ *
+ *  Created on: Jul 16, 2010
+ *      Author: crueger
+ */
+
+#ifndef MOLECULESELECTIONDESCRIPTOR_IMPL_HPP_
+#define MOLECULESELECTIONDESCRIPTOR_IMPL_HPP_
+
+#include "Descriptors/MoleculeDescriptor_impl.hpp"
+
+class MoleculeSelectionDescriptor_impl : public MoleculeDescriptor_impl{
+public:
+  MoleculeSelectionDescriptor_impl();
+  virtual ~MoleculeSelectionDescriptor_impl();
+  bool predicate(std::pair<moleculeId_t,molecule*> molecule);
+protected:
+  // need to overide more than the standard methods to make this fast
+  virtual molecule* find();
+  virtual std::vector<molecule*> findAll();
+
+  World::MoleculeSet& getSelectedMolecules();
+};
+
+#endif /* MOLECULESELECTIONDESCRIPTOR_IMPL_HPP_ */
Index: src/Descriptors/SelectiveIterator_impl.hpp
===================================================================
--- src/Descriptors/SelectiveIterator_impl.hpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/Descriptors/SelectiveIterator_impl.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -9,5 +9,5 @@
 #define SELECTIVEITERATOR_IMPL_HPP_
 
-#include "helpers.hpp"
+#include "Helpers/helpers.hpp"
 
 template<class _Target,
Index: src/Exceptions/CustomException.cpp
===================================================================
--- src/Exceptions/CustomException.cpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/Exceptions/CustomException.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -6,7 +6,13 @@
  */
 
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
 #include "Helpers/MemDebug.hpp"
 
 #include "CustomException.hpp"
+#include <iostream>
 
 using namespace std;
Index: src/Exceptions/CustomException.hpp
===================================================================
--- src/Exceptions/CustomException.hpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/Exceptions/CustomException.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -10,5 +10,6 @@
 
 #include <exception>
-#include <iostream>
+#include <iosfwd>
+#include <string>
 
 /**
Index: src/Exceptions/IllegalTypeException.cpp
===================================================================
--- src/Exceptions/IllegalTypeException.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
+++ src/Exceptions/IllegalTypeException.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -0,0 +1,28 @@
+/*
+ * IllegalTypeException.cpp
+ *
+ *  Created on: Jun 25, 2010
+ *      Author: crueger
+ */
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "Helpers/MemDebug.hpp"
+
+#include "IllegalTypeException.hpp"
+
+using namespace std;
+
+IllegalTypeException::IllegalTypeException(string _file, int _line) :
+  CustomException(_file,_line)
+{}
+
+IllegalTypeException::~IllegalTypeException() throw ()
+{}
+
+const char* IllegalTypeException::what() const throw(){
+  return "Illegal type in cast";
+}
Index: src/Exceptions/IllegalTypeException.hpp
===================================================================
--- src/Exceptions/IllegalTypeException.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
+++ src/Exceptions/IllegalTypeException.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -0,0 +1,22 @@
+/*
+ * IllegalTypeException.hpp
+ *
+ *  Created on: Jun 25, 2010
+ *      Author: crueger
+ */
+
+#ifndef ILLEGALTYPEEXCEPTION_HPP_
+#define ILLEGALTYPEEXCEPTION_HPP_
+
+#include "Exceptions/CustomException.hpp"
+
+class IllegalTypeException : public CustomException
+{
+public:
+  IllegalTypeException(std::string _file, int _line);
+  virtual ~IllegalTypeException() throw ();
+
+  virtual const char* what() const throw();
+};
+
+#endif /* ILLEGALTYPEEXCEPTION_HPP_ */
Index: src/Exceptions/LinearDependenceException.cpp
===================================================================
--- src/Exceptions/LinearDependenceException.cpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/Exceptions/LinearDependenceException.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -5,4 +5,9 @@
  *      Author: crueger
  */
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
 
 #include "Helpers/MemDebug.hpp"
Index: src/Exceptions/Makefile.am
===================================================================
--- src/Exceptions/Makefile.am	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
+++ src/Exceptions/Makefile.am	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -0,0 +1,80 @@
+# PLEASE adhere to the alphabetical ordering in this Makefile!
+# Also indentation by a single tab
+
+INCLUDES = -I$(top_srcdir)/src
+
+AM_LDFLAGS = $(CPPUNIT_LIBS) -ldl
+# Position-Independent Code necessary for shared library
+AM_CXXFLAGS = $(CPPUNIT_CFLAGS)
+
+EXCEPTIONSOURCE = \
+  CustomException.cpp \
+  IllegalTypeException.cpp \
+  LinearDependenceException.cpp \
+  MathException.cpp \
+  MissingValueException.cpp \
+  NotInvertibleException.cpp \
+  ParseError.cpp \
+  SkewException.cpp \
+  ZeroVectorException.cpp
+				  
+EXCEPTIONHEADER = \
+  CustomException.hpp \
+  IllegalTypeException.hpp \
+  LinearDependenceException.hpp \
+  MathException.hpp \
+  MissingValueException.hpp \
+  NotInvertibleException.hpp \
+  ParseError.hpp \
+  SkewException.hpp \
+  ZeroVectorException.hpp
+
+
+
+lib_LTLIBRARIES = libMolecuilderExceptions-@MOLECUILDER_API_VERSION@.la
+libMolecuilderExceptions_includedir = $(includedir)/molecuilder-$(MOLECUILDER_API_VERSION)/Actions/
+nobase_libMolecuilderExceptions_include_HEADERS = ${EXCEPTIONHEADER}
+
+## Define the source file list for the "libexample-@MOLECUILDER_API_VERSION@.la"
+## target.  Note that @MOLECUILDER_API_VERSION@ is not interpreted by Automake and
+## will therefore be treated as if it were literally part of the target name,
+## and the variable name derived from that.
+## The file extension .cc is recognized by Automake, and makes it produce
+## rules which invoke the C++ compiler to produce a libtool object file (.lo)
+## from each source file.  Note that it is not necessary to list header files
+## which are already listed elsewhere in a _HEADERS variable assignment.
+libMolecuilderExceptions_@MOLECUILDER_API_VERSION@_la_SOURCES = ${EXCEPTIONSOURCE}
+
+## Instruct libtool to include ABI version information in the generated shared
+## library file (.so).  The library ABI version is defined in configure.ac, so
+## that all version information is kept in one place.
+libMolecuilderExceptions_@MOLECUILDER_API_VERSION@_la_LDFLAGS = -version-info $(MOLECUILDER_SO_VERSION)
+
+## The generated configuration header is installed in its own subdirectory of
+## $(libdir).  The reason for this is that the configuration information put
+## into this header file describes the target platform the installed library
+## has been built for.  Thus the file must not be installed into a location
+## intended for architecture-independent files, as defined by the Filesystem
+## Hierarchy Standard (FHS).
+## The nodist_ prefix instructs Automake to not generate rules for including
+## the listed files in the distribution on 'make dist'.  Files that are listed
+## in _HEADERS variables are normally included in the distribution, but the
+## configuration header file is generated at configure time and should not be
+## shipped with the source tarball.
+libMolecuilderExceptions_libincludedir = $(libdir)/molecuilder-$(MOLECUILDER_API_VERSION)/include
+nodist_libMolecuilderExceptions_libinclude_HEADERS = $(top_builddir)/libmolecuilder_config.h
+
+## Install the generated pkg-config file (.pc) into the expected location for
+## architecture-dependent package configuration information.  Occasionally,
+## pkg-config files are also used for architecture-independent data packages,
+## in which case the correct install location would be $(datadir)/pkgconfig.
+pkgconfigdir = $(libdir)/pkgconfig
+pkgconfig_DATA = $(top_builddir)/molecuilder-$(MOLECUILDER_API_VERSION).pc
+
+unity.cpp:
+	echo "" >  unity.cpp; \
+	list='$(EXCEPTIONSOURCE)'; for file in $$list; do \
+	  echo "#include \"$(srcdir)/$$file\"" >> unity.cpp; \
+	done;
+	
+MOSTLYCLEANFILES = unity.cpp
Index: src/Exceptions/MathException.cpp
===================================================================
--- src/Exceptions/MathException.cpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/Exceptions/MathException.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -5,4 +5,9 @@
  *      Author: crueger
  */
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
 
 #include "Helpers/MemDebug.hpp"
Index: src/Exceptions/MissingValueException.cpp
===================================================================
--- src/Exceptions/MissingValueException.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
+++ src/Exceptions/MissingValueException.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -0,0 +1,28 @@
+/*
+ * MissingValueException.cpp
+ *
+ *  Created on: Jul 23, 2010
+ *      Author: heber
+ */
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "Helpers/MemDebug.hpp"
+
+#include "MissingValueException.hpp"
+
+using namespace std;
+
+MissingValueException::MissingValueException(string _file, int _line) :
+  CustomException(_file,_line)
+{}
+
+MissingValueException::~MissingValueException() throw ()
+{}
+
+const char* MissingValueException::what() const throw(){
+  return "Value necessary for Action not present in ValueStorage";
+}
Index: src/Exceptions/MissingValueException.hpp
===================================================================
--- src/Exceptions/MissingValueException.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
+++ src/Exceptions/MissingValueException.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -0,0 +1,22 @@
+/*
+ * MissingValueException.hpp
+ *
+ *  Created on: Jul 23, 2010
+ *      Author: heber
+ */
+
+#ifndef MISSINGVALUEEXCEPTION_HPP_
+#define MISSINGVALUEEXCEPTION_HPP_
+
+#include "Exceptions/CustomException.hpp"
+
+class MissingValueException : public CustomException
+{
+public:
+  MissingValueException(std::string _file, int _line);
+  virtual ~MissingValueException() throw ();
+
+  virtual const char* what() const throw();
+};
+
+#endif /* MISSINGVALUEEXCEPTION_HPP_ */
Index: src/Exceptions/NotInvertibleException.cpp
===================================================================
--- src/Exceptions/NotInvertibleException.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
+++ src/Exceptions/NotInvertibleException.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -0,0 +1,28 @@
+/*
+ * NotInvertibleException.cpp
+ *
+ *  Created on: Jun 25, 2010
+ *      Author: crueger
+ */
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "Helpers/MemDebug.hpp"
+
+#include "NotInvertibleException.hpp"
+
+using namespace std;
+
+NotInvertibleException::NotInvertibleException(string _file, int _line) :
+  MathException(_file,_line)
+{}
+
+NotInvertibleException::~NotInvertibleException() throw ()
+{}
+
+const char* NotInvertibleException::what() const throw(){
+  return "Given Matrix is not invertible";
+}
Index: src/Exceptions/NotInvertibleException.hpp
===================================================================
--- src/Exceptions/NotInvertibleException.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
+++ src/Exceptions/NotInvertibleException.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -0,0 +1,22 @@
+/*
+ * NotInvertibleException.hpp
+ *
+ *  Created on: Jun 25, 2010
+ *      Author: crueger
+ */
+
+#ifndef NOTINVERTIBLEEXCEPTION_HPP_
+#define NOTINVERTIBLEEXCEPTION_HPP_
+
+#include "Exceptions/MathException.hpp"
+
+class NotInvertibleException : public MathException
+{
+public:
+  NotInvertibleException(std::string _file, int _line);
+  virtual ~NotInvertibleException() throw ();
+
+  virtual const char* what() const throw();
+};
+
+#endif /* NOTINVERTIBLEEXCEPTION_HPP_ */
Index: src/Exceptions/ParseError.cpp
===================================================================
--- src/Exceptions/ParseError.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
+++ src/Exceptions/ParseError.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -0,0 +1,25 @@
+/*
+ * ParseError.cpp
+ *
+ *  Created on: Jul 21, 2010
+ *      Author: crueger
+ */
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "Helpers/MemDebug.hpp"
+
+#include "ParseError.hpp"
+
+ParseError::ParseError(std::string file, int line) :
+  CustomException(file,line)
+{}
+
+ParseError::~ParseError() throw(){}
+
+const char* ParseError::what() const throw(){
+  return "Could not parse string";
+}
Index: src/Exceptions/ParseError.hpp
===================================================================
--- src/Exceptions/ParseError.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
+++ src/Exceptions/ParseError.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -0,0 +1,22 @@
+/*
+ * ParseError.hpp
+ *
+ *  Created on: Jul 21, 2010
+ *      Author: crueger
+ */
+
+#ifndef PARSEERROR_HPP_
+#define PARSEERROR_HPP_
+
+#include "Exceptions/CustomException.hpp"
+
+class ParseError : public CustomException
+{
+public:
+  ParseError(std::string file, int line);
+  virtual ~ParseError() throw();
+
+  virtual const char* what() const throw();
+};
+
+#endif /* PARSEERROR_HPP_ */
Index: src/Exceptions/SkewException.cpp
===================================================================
--- src/Exceptions/SkewException.cpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/Exceptions/SkewException.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -5,4 +5,9 @@
  *      Author: crueger
  */
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
 
 #include "Helpers/MemDebug.hpp"
Index: src/Exceptions/ZeroVectorException.cpp
===================================================================
--- src/Exceptions/ZeroVectorException.cpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/Exceptions/ZeroVectorException.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -5,4 +5,9 @@
  *      Author: crueger
  */
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
 
 #include "Helpers/MemDebug.hpp"
Index: src/Formula.cpp
===================================================================
--- src/Formula.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
+++ src/Formula.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -0,0 +1,443 @@
+/*
+ * Formula.cpp
+ *
+ *  Created on: Jul 21, 2010
+ *      Author: crueger
+ */
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "Helpers/MemDebug.hpp"
+
+#include "Formula.hpp"
+
+#include <sstream>
+
+#include "World.hpp"
+#include "periodentafel.hpp"
+#include "element.hpp"
+#include "Helpers/Assert.hpp"
+#include "Helpers/Range.hpp"
+
+using namespace std;
+
+Formula::Formula() :
+  numElements(0)
+{}
+
+Formula::Formula(const Formula &src) :
+  elementCounts(src.elementCounts),
+  numElements(src.numElements)
+{}
+
+Formula::Formula(const string &formula) :
+  numElements(0)
+{
+  fromString(formula);
+}
+
+Formula::~Formula()
+{}
+
+Formula &Formula::operator=(const Formula &rhs){
+  // No self-assignment check needed
+  elementCounts=rhs.elementCounts;
+  numElements=rhs.numElements;
+  return *this;
+}
+
+std::string Formula::toString() const{
+  stringstream sstr;
+  for(const_iterator iter=end();iter!=begin();){
+    --iter;
+    sstr << (*iter).first->getSymbol();
+    if((*iter).second>1)
+      sstr << (*iter).second;
+  }
+  return sstr.str();
+}
+
+void Formula::fromString(const std::string &formula) throw(ParseError){
+  // make this transactional, in case an error is thrown
+  Formula res;
+  string::const_iterator begin = formula.begin();
+  string::const_iterator end = formula.end();
+  res.parseFromString(begin,end,static_cast<char>(0));
+  (*this)=res;
+}
+
+int Formula::parseMaybeNumber(string::const_iterator &it,string::const_iterator &end) throw(ParseError){
+  static const range<char> Numbers = makeRange('0',static_cast<char>('9'+1));
+  int count = 0;
+  while(it!=end && Numbers.isInRange(*it))
+    count = (count*10) + ((*it++)-Numbers.first);
+  // one is implicit
+  count = (count!=0)?count:1;
+  return count;
+}
+
+void Formula::parseFromString(string::const_iterator &it,string::const_iterator &end,char delimiter) throw(ParseError){
+  // some constants needed for parsing... Assumes ASCII, change if other encodings are used
+  static const range<char> CapitalLetters = makeRange('A',static_cast<char>('Z'+1));
+  static const range<char> SmallLetters = makeRange('a',static_cast<char>('z'+1));
+  map<char,char> delimiters;
+  delimiters['('] = ')';
+  delimiters['['] = ']';
+  // clean the formula
+  clear();
+  for(/*send from above*/;it!=end && *it!=delimiter;/*updated in loop*/){
+    // we might have a sub formula
+    if(delimiters.count(*it)){
+      Formula sub;
+      char nextdelim=delimiters[*it];
+      sub.parseFromString(++it,end,nextdelim);
+      if(!sub.getElementCount()){
+        throw(ParseError(__FILE__,__LINE__));
+      }
+      int count = parseMaybeNumber(++it,end);
+      addFormula(sub,count);
+      continue;
+    }
+    string shorthand;
+    // Atom names start with a capital letter
+    if(!CapitalLetters.isInRange(*it))
+      throw(ParseError(__FILE__,__LINE__));
+    shorthand+=(*it++);
+    // the rest of the name follows
+    while(it!=end && SmallLetters.isInRange(*it))
+      shorthand+=(*it++);
+    int count = parseMaybeNumber(it,end);
+    // test if the shorthand exists
+    if(!World::getInstance().getPeriode()->FindElement(shorthand))
+      throw(ParseError(__FILE__,__LINE__));
+    // done, we can get the next one
+    addElements(shorthand,count);
+  }
+  if(it==end && delimiter!=0){
+    throw(ParseError(__FILE__,__LINE__));
+  }
+}
+
+bool Formula::checkOut(ostream *output) const{
+  bool result = true;
+  int No = 1;
+
+  if (output != NULL) {
+    *output << "# Ion type data (PP = PseudoPotential, Z = atomic number)" << endl;
+    *output << "#Ion_TypeNr.\tAmount\tZ\tRGauss\tL_Max(PP)L_Loc(PP)IonMass\t# chemical name, symbol" << endl;
+    for(const_iterator iter=begin(); iter!=end();++iter){
+      result = result && (*iter).first->Checkout(output, No++, (*iter).second);
+    }
+    return result;
+  } else
+    return false;
+}
+
+unsigned int Formula::getElementCount() const{
+  return numElements;
+}
+
+bool Formula::hasElement(const element *element) const{
+  ASSERT(element,"Invalid pointer in Formula::hasElement(element*)");
+  return hasElement(element->getNumber());
+}
+
+bool Formula::hasElement(atomicNumber_t Z) const{
+  ASSERT(Z>0,"Invalid atomic Number");
+  ASSERT(World::getInstance().getPeriode()->FindElement(Z),"No Element with this number in Periodentafel");
+  return elementCounts.size()>=Z && elementCounts[Z-1];
+}
+
+bool Formula::hasElement(const string &shorthand) const{
+  const element * element = World::getInstance().getPeriode()->FindElement(shorthand);
+  return hasElement(element);
+}
+
+void Formula::operator+=(const element *element){
+  ASSERT(element,"Invalid pointer in increment of Formula");
+  operator+=(element->getNumber());
+}
+
+void Formula::operator+=(atomicNumber_t Z){
+  ASSERT(Z>0,"Invalid atomic Number");
+  ASSERT(World::getInstance().getPeriode()->FindElement(Z),"No Element with this number in Periodentafel");
+  elementCounts.resize(max<atomicNumber_t>(Z,elementCounts.size()),0); // No-op when we already have the right size
+  // might need to update number of elements
+  if(!elementCounts[Z-1]){
+    numElements++;
+  }
+  elementCounts[Z-1]++;    // atomic numbers start at 1
+}
+
+void Formula::operator+=(const string &shorthand){
+  const element * element = World::getInstance().getPeriode()->FindElement(shorthand);
+  operator+=(element);
+}
+
+void Formula::operator-=(const element *element){
+  ASSERT(element,"Invalid pointer in decrement of Formula");
+  operator-=(element->getNumber());
+}
+
+void Formula::operator-=(atomicNumber_t Z){
+  ASSERT(Z>0,"Invalid atomic Number");
+  ASSERT(World::getInstance().getPeriode()->FindElement(Z),"No Element with this number in Periodentafel");
+  ASSERT(elementCounts.size()>=Z && elementCounts[Z-1], "Element not in Formula upon decrement");
+  elementCounts[Z-1]--;    // atomic numbers start at 1
+  // might need to update number of elements
+  if(!elementCounts[Z-1]){
+    numElements--;
+    // resize the Array if this was at the last position
+    if(Z==elementCounts.size()){
+      // find the first element from the back that is not equal to zero
+      set_t::reverse_iterator riter = find_if(elementCounts.rbegin(),
+                                              elementCounts.rend(),
+                                              bind1st(not_equal_to<mapped_type>(),0));
+      // see how many elements are in this range
+      set_t::reverse_iterator::difference_type diff = riter - elementCounts.rbegin();
+      elementCounts.resize(elementCounts.size()-diff);
+    }
+  }
+}
+
+void Formula::operator-=(const string &shorthand){
+  const element * element = World::getInstance().getPeriode()->FindElement(shorthand);
+  operator-=(element);
+}
+
+void Formula::addElements(const element *element,unsigned int count){
+  ASSERT(element,"Invalid pointer in Formula::addElements(element*)");
+  addElements(element->getNumber(),count);
+}
+
+void Formula::addElements(atomicNumber_t Z,unsigned int count){
+  if(count==0) return;
+  ASSERT(Z>0,"Invalid atomic Number");
+  ASSERT(World::getInstance().getPeriode()->FindElement(Z),"No Element with this number in Periodentafel");
+  elementCounts.resize(max<atomicNumber_t>(Z,elementCounts.size()),0); // No-op when we already have the right size
+  // might need to update number of elements
+  if(!elementCounts[Z-1]){
+    numElements++;
+  }
+  elementCounts[Z-1]+=count;
+}
+
+void Formula::addElements(const string &shorthand,unsigned int count){
+  const element * element = World::getInstance().getPeriode()->FindElement(shorthand);
+  addElements(element,count);
+}
+
+void Formula::addFormula(const Formula &formula,unsigned int n){
+  for(Formula::const_iterator iter=formula.begin();iter!=formula.end();++iter){
+    this->addElements(iter->first,iter->second*n);
+  }
+}
+
+enumeration<Formula::key_type> Formula::enumerateElements() const{
+  enumeration<key_type> res(1);
+  for(Formula::const_iterator iter=begin();iter!=end();++iter){
+    res.add(iter->first);
+  }
+  return res;
+}
+
+const unsigned int Formula::operator[](const element *element) const{
+  ASSERT(element,"Invalid pointer in access of Formula");
+  return operator[](element->getNumber());
+}
+
+const unsigned int Formula::operator[](atomicNumber_t Z) const{
+  ASSERT(Z>0,"Invalid atomic Number");
+  ASSERT(World::getInstance().getPeriode()->FindElement(Z),"No Element with this number in Periodentafel");
+  if(elementCounts.size()<Z)
+    return 0;
+  return elementCounts[Z-1]; // atomic numbers start at 1
+}
+
+const unsigned int Formula::operator[](string shorthand) const{
+  const element * element = World::getInstance().getPeriode()->FindElement(shorthand);
+  return operator[](element);
+}
+
+bool Formula::operator==(const Formula &rhs) const{
+  // quick check... number of elements used
+  if(numElements != rhs.numElements){
+    return false;
+  }
+  // second quick check, size of vectors (== last element in formula)
+  if(elementCounts.size()!=rhs.elementCounts.size()){
+    return false;
+  }
+  // slow check: all elements
+  // direct access to internal structure means all element-counts have to be compared
+  // this avoids access to periodentafel to find elements though and is probably faster
+  // in total
+  return equal(elementCounts.begin(),
+               elementCounts.end(),
+               rhs.elementCounts.begin());
+}
+
+bool Formula::operator!=(const Formula &rhs) const{
+  return !operator==(rhs);
+}
+
+Formula::iterator Formula::begin(){
+  return iterator(elementCounts,0);
+}
+Formula::const_iterator Formula::begin() const{
+  // this is the only place where this is needed, so this is better than making it mutable
+  return const_iterator(const_cast<set_t&>(elementCounts),0);
+}
+Formula::iterator Formula::end(){
+  return iterator(elementCounts);
+}
+Formula::const_iterator Formula::end() const{
+  // this is the only place where this is needed, so this is better than making it mutable
+  return const_iterator(const_cast<set_t&>(elementCounts));
+}
+
+void Formula::clear(){
+  elementCounts.clear();
+  numElements = 0;
+}
+
+/**************** Iterator structure ********************/
+
+template <class result_type>
+Formula::_iterator<result_type>::_iterator(set_t &_set) :
+    set(&_set)
+{
+  pos=set->size();
+}
+
+template <class result_type>
+Formula::_iterator<result_type>::_iterator(set_t &_set,size_t _pos) :
+  set(&_set),pos(_pos)
+{
+  ASSERT(pos<=set->size(),"invalid position in iterator construction");
+  while(pos<set->size() && (*set)[pos]==0) ++pos;
+}
+
+template <class result_type>
+Formula::_iterator<result_type>::_iterator(const _iterator &rhs) :
+  set(rhs.set),pos(rhs.pos)
+{}
+
+template <class result_type>
+Formula::_iterator<result_type>::~_iterator(){}
+
+template <class result_type>
+Formula::_iterator<result_type>&
+Formula::_iterator<result_type>::operator=(const _iterator<result_type> &rhs){
+  set=rhs.set;
+  pos=rhs.pos;
+  return *this;
+}
+
+template <class result_type>
+bool
+Formula::_iterator<result_type>::operator==(const _iterator<result_type> &rhs){
+  return set==rhs.set && pos==rhs.pos;
+}
+
+template <class result_type>
+bool
+Formula::_iterator<result_type>::operator!=(const _iterator<result_type> &rhs){
+  return !operator==(rhs);
+}
+
+template <class result_type>
+Formula::_iterator<result_type>
+Formula::_iterator<result_type>::operator++(){
+  ASSERT(pos!=set->size(),"Incrementing Formula::iterator beyond end");
+  pos++;
+  while(pos<set->size() && (*set)[pos]==0) ++pos;
+  return *this;
+}
+
+template <class result_type>
+Formula::_iterator<result_type>
+Formula::_iterator<result_type>::operator++(int){
+  Formula::_iterator<result_type> retval = *this;
+  ++(*this);
+  return retval;
+}
+
+template <class result_type>
+Formula::_iterator<result_type>
+Formula::_iterator<result_type>::operator--(){
+  ASSERT(pos!=0,"Decrementing Formula::iterator beyond begin");
+  pos--;
+  while(pos>0 && (*set)[pos]==0) --pos;
+  return *this;
+}
+
+template <class result_type>
+Formula::_iterator<result_type>
+Formula::_iterator<result_type>::operator--(int){
+  Formula::_iterator<result_type> retval = *this;
+  --(*this);
+  return retval;
+}
+
+template <class result_type>
+result_type
+Formula::_iterator<result_type>::operator*(){
+  const element *element = World::getInstance().getPeriode()->FindElement(pos+1);
+  ASSERT(element,"Element with position of iterator not found");
+  return make_pair(element,(*set)[pos]);
+}
+
+template <class result_type>
+result_type*
+Formula::_iterator<result_type>::operator->(){
+  // no one can keep this value around, so a static is ok to avoid temporaries
+  static value_type value=make_pair(reinterpret_cast<element*>(0),0); // no default constructor for std::pair
+  const element *element = World::getInstance().getPeriode()->FindElement(pos+1);
+  ASSERT(element,"Element with position of iterator not found");
+  value = make_pair(element,(*set)[pos]);
+  return &value;
+}
+
+// explicit instantiation of all iterator template methods
+// this is quite ugly, but there is no better way unless we expose iterator implementation
+
+// instantiate Formula::iterator
+template Formula::iterator::_iterator(set_t&);
+template Formula::iterator::_iterator(set_t&,size_t);
+template Formula::iterator::_iterator(const Formula::iterator&);
+template Formula::iterator::~_iterator();
+template Formula::iterator &Formula::iterator::operator=(const Formula::iterator&);
+template bool Formula::iterator::operator==(const Formula::iterator&);
+template bool Formula::iterator::operator!=(const Formula::iterator&);
+template Formula::iterator Formula::iterator::operator++();
+template Formula::iterator Formula::iterator::operator++(int);
+template Formula::iterator Formula::iterator::operator--();
+template Formula::iterator Formula::iterator::operator--(int);
+template Formula::value_type Formula::iterator::operator*();
+template Formula::value_type *Formula::iterator::operator->();
+
+// instantiate Formula::const_iterator
+template Formula::const_iterator::_iterator(set_t&);
+template Formula::const_iterator::_iterator(set_t&,size_t);
+template Formula::const_iterator::_iterator(const Formula::const_iterator&);
+template Formula::const_iterator::~_iterator();
+template Formula::const_iterator &Formula::const_iterator::operator=(const Formula::const_iterator&);
+template bool Formula::const_iterator::operator==(const Formula::const_iterator&);
+template bool Formula::const_iterator::operator!=(const Formula::const_iterator&);
+template Formula::const_iterator Formula::const_iterator::operator++();
+template Formula::Formula::const_iterator Formula::const_iterator::operator++(int);
+template Formula::Formula::const_iterator Formula::const_iterator::operator--();
+template Formula::Formula::const_iterator Formula::const_iterator::operator--(int);
+template const Formula::value_type Formula::const_iterator::operator*();
+template const Formula::value_type *Formula::const_iterator::operator->();
+
+/********************** I/O of Formulas ************************************************/
+
+std::ostream &operator<<(std::ostream &ost,const Formula &formula){
+  ost << formula.toString();
+  return ost;
+}
Index: src/Formula.hpp
===================================================================
--- src/Formula.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
+++ src/Formula.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -0,0 +1,117 @@
+/*
+ * Formula.hpp
+ *
+ *  Created on: Jul 21, 2010
+ *      Author: crueger
+ */
+
+#ifndef FORMULA_HPP_
+#define FORMULA_HPP_
+
+#include <vector>
+#include <iosfwd>
+#include <iterator>
+
+#include "Exceptions/ParseError.hpp"
+
+#include "types.hpp"
+#include "Helpers/helpers.hpp"
+
+class element;
+
+class Formula
+{
+public:
+  typedef const element*                                key_type;
+  typedef unsigned int                                  mapped_type;
+  typedef std::pair<key_type, mapped_type>              value_type;
+  typedef std::vector<unsigned int>                     set_t;
+
+  template <class result_type>
+  class _iterator : public std::iterator <std::bidirectional_iterator_tag,
+                                         result_type>
+  {
+  public:
+    _iterator(set_t&);
+    _iterator(set_t&,size_t);
+    _iterator(const _iterator &rhs);
+    ~_iterator();
+    _iterator   &operator=(const _iterator &);
+    bool         operator==(const _iterator&);
+    bool         operator!=(const _iterator&);
+    _iterator    operator++();
+    _iterator    operator++(int);
+    _iterator    operator--();
+    _iterator    operator--(int);
+    result_type  operator*();
+    result_type *operator->();
+  private:
+    set_t *set;
+    size_t pos; // cannot use an iterator, because we need a position to access the element
+  };
+
+  typedef _iterator<value_type>                 iterator;
+  typedef _iterator<const value_type>           const_iterator;
+
+  Formula();
+  Formula(const std::string&);
+  Formula(const Formula&);
+  virtual ~Formula();
+
+  Formula &operator=(const Formula&);
+
+  std::string toString() const;
+  void fromString(const std::string&) throw(ParseError);
+  bool checkOut(std::ostream*) const;
+
+  unsigned int getElementCount() const;
+  bool hasElement(key_type)             const;
+  bool hasElement(atomicNumber_t)       const;
+  bool hasElement(const std::string&)   const;
+
+  void operator+=(key_type);
+  void operator+=(atomicNumber_t);
+  void operator+=(const std::string&);
+
+  void operator-=(key_type);
+  void operator-=(atomicNumber_t);
+  void operator-=(const std::string&);
+
+  void addElements(key_type,unsigned int);
+  void addElements(atomicNumber_t,unsigned int);
+  void addElements(const std::string&,unsigned int);
+
+  void addFormula(const Formula&,unsigned int);
+
+  enumeration<key_type> enumerateElements() const;
+
+  // only const versions, because someone might try to increment a previously
+  // not set element
+  const unsigned int operator[](key_type) const;
+  const unsigned int operator[](atomicNumber_t) const;
+  const unsigned int operator[](std::string)    const;
+
+  bool operator==(const Formula&) const;
+  bool operator!=(const Formula&) const;
+
+  iterator       begin();
+  const_iterator begin() const;
+  iterator       end();
+  const_iterator end()   const;
+
+  void clear();
+
+private:
+  void parseFromString(std::string::const_iterator&,std::string::const_iterator&,char) throw(ParseError);
+  int parseMaybeNumber(std::string::const_iterator &it,std::string::const_iterator &end) throw(ParseError);
+  // this contains all counts of elements in the formula
+  // the size of the actual structure might be used in comparisons
+  // so be sure not to keep any zero elements at the end
+  // e.g. {5;4;0;0;0;2;1} or {0;1;0;0;2} are ok, but {1;2;3;0;0;0} is bad
+  set_t elementCounts;
+  unsigned int numElements;
+};
+
+std::ostream &operator<<(std::ostream&,const Formula&);
+
+#endif /* FORMULA_HPP_ */
Index: src/Helpers/Assert.cpp
===================================================================
--- src/Helpers/Assert.cpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/Helpers/Assert.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -5,4 +5,9 @@
  *      Author: crueger
  */
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
 
 #include "Helpers/MemDebug.hpp"
@@ -46,55 +51,125 @@
 }
 
-using namespace Assert;
-
 #ifndef NDEBUG
 
-Action _my_assert::defaultAction = Ask;
-std::vector<Assert::hook_t> _my_assert::hooks;
-
-std::map<std::string,bool> _wrapper::ignores;
-const char* _wrapper::message_ptr = "source pointer did not point to object of desired type";
-const char* _wrapper::message_ref = "source reference did not contain object of desired type";
-
-
-bool _my_assert::check(const bool res,
-                       const char* condition,
-                       const char* message,
-                       const char* filename,
-                       const int line,
-                       bool& ignore)
+#ifdef __GNUC__
+#include <cstdlib>
+#include <execinfo.h>
+#include <cxxabi.h>
+#endif
+
+Assert::Action Assert::_my_assert::defaultAction = Ask;
+std::vector<Assert::hook_t> Assert::_my_assert::hooks;
+
+std::map<std::string,bool> Assert::_wrapper::ignores;
+const char* Assert::_wrapper::message_ptr = "source pointer did not point to object of desired type";
+const char* Assert::_wrapper::message_ref = "source reference did not contain object of desired type";
+
+bool Assert::_my_assert::check(const char* condition,
+                               const char* message,
+                               const char* filename,
+                               const int line,
+                               bool& ignore)
 {
-  if(!res){
-    cout << "Assertion \"" << condition << "\" failed in file " << filename << " at line " << line << endl;
-    cout << "Assertion Message: " << message << std::endl;
-    while(true){
-      char choice;
-      if(defaultAction==Ask) {
-        cout << "Please choose: (a)bort, (t)hrow execption, (i)gnore, al(w)ays ignore" << endl;
-        cin >> choice;
+  cout << "Assertion \"" << condition << "\" failed in file " << filename << " at line " << line << endl;
+  cout << "Assertion Message: " << message << std::endl;
+  while(true){
+    char choice;
+    if(defaultAction==Assert::Ask) {
+#ifdef __GNUC__
+      cout << "Please choose: (a)bort, (t)hrow execption, show (b)actrace, (i)gnore, al(w)ays ignore" << endl;
+#else
+      cout << "Please choose: (a)bort, (t)hrow execption, (i)gnore, al(w)ays ignore" << endl;
+#endif /* __GNUC__ */
+      cin >> choice;
+    }
+    else{
+      choice = ActionKeys[defaultAction];
+    }
+    switch(choice){
+      case 'a':
+        return true;
+        break;
+      case 't':
+        throw AssertionFailure(condition,filename,line,message);
+        break;
+#ifdef __GNUC__
+      case 'b':
+        Assert::_my_assert::backtrace(filename,line);
+       break;
+#endif /* __GNUC__ */
+      case 'w':
+        ignore = true;
+        // fallthrough
+      case 'i':
+        return false;
+        break;
+    }
+  }
+  return false;
+}
+
+#ifdef __GNUC__
+void Assert::_my_assert::backtrace(const char *file, int line){
+  const size_t max_depth = 100;
+  void* stack_addrs[max_depth];
+  size_t stack_depth;
+  char **stack_strings=0;
+  const char *func_name=0;
+  size_t sz = 64;
+
+  // get the backtrace
+  stack_depth   = ::backtrace(stack_addrs,max_depth);
+  stack_strings = backtrace_symbols(stack_addrs, stack_depth);
+  // used later for demangling
+  // reserved here, so we can free it unconditionally
+  char *dm_function = static_cast<char*>(malloc(sz));
+  if(!dm_function){
+    // malloc failed... we are out of luck
+    cout << "cannot provide stack trace due to exhausted memory" << endl;
+    return;
+  }
+
+  cout << "Backtrace from  " << file << "@" << line << ":" << endl;
+
+  // i=2 because we don't want this function, nor the assertion handler
+  for(unsigned int i=2;i<stack_depth-2;++i){
+    // find the mangled function name
+    char *begin = stack_strings[i];
+    // function name starts with a (
+    while(*begin && *begin!='(') ++begin;
+    char *end=begin;
+    while(*end && *end!='+') ++end;
+
+    // see if we found our function name
+    if(*begin && *end){
+      *begin++ = 0;
+      *end = 0;
+      // use the C++ demangler
+
+      int status;
+      char *func_ret = abi::__cxa_demangle(begin, dm_function, &sz, &status);
+      if(func_ret){
+        // abi might have realloced...
+        dm_function = func_ret;
+        func_name = dm_function;
       }
       else{
-        choice = ActionKeys[defaultAction];
+        // demangling failed... get the function name without demangling
+        func_name = begin;
       }
-      switch(choice){
-        case 'a':
-          return true;
-          break;
-        case 't':
-          throw AssertionFailure(condition,filename,line,message);
-          break;
-        case 'w':
-          ignore = true;
-          // fallthrough
-        case 'i':
-          return false;
-          break;
-      }
-    }
-  }
-  return false;
-}
-
-void _my_assert::doHooks(){
+    }
+    else{
+      // function name not found... get the whole line
+      func_name = stack_strings[i];
+    }
+    cout << func_name << endl;
+  }
+  free(dm_function);
+  free(stack_strings); // malloc()ed by backtrace_symbols
+}
+#endif /* __GNUC__ */
+
+void Assert::_my_assert::doHooks(){
   for(vector<hook_t>::reverse_iterator iter = hooks.rbegin(); iter!=hooks.rend(); ++iter ){
     (*iter)();
@@ -102,9 +177,9 @@
 }
 
-void _my_assert::addHook(hook_t hook){
+void Assert::_my_assert::addHook(hook_t hook){
   hooks.push_back(hook);
 }
 
-void _my_assert::removeHook(Assert::hook_t hook){
+void Assert::_my_assert::removeHook(Assert::hook_t hook){
   for(vector<hook_t>::iterator iter = hooks.begin(); iter!=hooks.end();){
     if((*iter)==hook){
@@ -117,11 +192,11 @@
 }
 
-void _my_assert::setDefault(Assert::Action action){
+void Assert::_my_assert::setDefault(Assert::Action action){
   defaultAction = action;
 }
-Assert::Action _my_assert::getDefault(){
+Assert::Action Assert::_my_assert::getDefault(){
   return defaultAction;
 }
-std::string _my_assert::printDefault(){
+std::string Assert::_my_assert::printDefault(){
   return ActionNames[defaultAction];
 }
Index: src/Helpers/Assert.hpp
===================================================================
--- src/Helpers/Assert.hpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/Helpers/Assert.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -11,5 +11,5 @@
 #include<sstream>
 #include<string>
-#include<iostream>
+#include<iosfwd>
 #include<vector>
 #include<map>
@@ -234,6 +234,6 @@
       static bool ignore = false;\
       if(!ignore){\
-        if(Assert::_my_assert::check((condition),STRINGIFY(condition),(message),\
-                                     __FILE__,__LINE__,ignore)){\
+        if(!(condition) && Assert::_my_assert::check(STRINGIFY(condition),(message),\
+                                                     __FILE__,__LINE__,ignore)){\
           Assert::_my_assert::doHooks();\
           DEBUG_BREAK;\
@@ -247,7 +247,7 @@
 		  static bool ignore = false; \
 		  if(!ignore){\
-			  if(Assert::_my_assert::check(false,"Exception caught",(message),__FILE__,__LINE__,ignore)){\
+			  if(Assert::_my_assert::check("Exception caught",(message),__FILE__,__LINE__,ignore)){\
 			    Assert::_my_assert::doHooks();\
-          DEBUG_BREAK;\
+                            DEBUG_BREAK;\
 			  }\
 		  }\
@@ -299,10 +299,12 @@
     class _my_assert{
     public:
-      static bool check(const bool res,
-                        const char* condition,
+      static bool check(const char* condition,
                         const char* message,
                         const char* filename,
                         const int line,
                         bool& ignore);
+#ifdef __GNUC__
+      static void backtrace(const char *file, int line);
+#endif /* __GNUC__ */
       static void addHook(Assert::hook_t hook);
       static void removeHook(Assert::hook_t hook);
@@ -332,6 +334,6 @@
 
       if(!ignore){
-        if(_my_assert::check(dynamic_cast<target>(src)==static_cast<target>(src),"type-safe typecast",
-                                       message_ptr,file,line,ignore)){
+        bool res = dynamic_cast<target>(src)==static_cast<target>(src);
+        if(!res && _my_assert::check("type-safe typecast",message_ptr,file,line,ignore)){
           _my_assert::doHooks();
           DEBUG_BREAK;
@@ -354,5 +356,5 @@
       catch(...){
         if(!ignore){
-          if(_my_assert::check(0,"type-safe typecast",message_ref,file,line,ignore)){
+          if(_my_assert::check("type-safe typecast",message_ref,file,line,ignore)){
             _my_assert::doHooks();
             DEBUG_BREAK;
Index: src/Helpers/Info.cpp
===================================================================
--- src/Helpers/Info.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
+++ src/Helpers/Info.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -0,0 +1,48 @@
+/*
+ * Info.cpp
+ *
+ *  Created on: Nov 25, 2009
+ *      Author: heber
+ */
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "Helpers/MemDebug.hpp"
+
+#include "Helpers/Info.hpp"
+#include "Helpers/Log.hpp"
+#include "Helpers/Verbose.hpp"
+
+int Info::verbosity = 0;
+
+/**
+ * Constructor. Do not use this function. Use getInstance() instead.
+ *
+ * \return Info instance
+ */
+Info::Info(const char *msg) :
+  FunctionName(msg)
+{
+  verbosity++;
+  DoLog(0) && (Log() << Verbose(0) << "Begin of " << FunctionName << endl);
+};
+
+/**
+ * Destructor. Better use purgeInstance().
+ */
+Info::~Info() {
+  DoLog(0) && (Log() << Verbose(0) << "End of " << FunctionName << endl);
+  verbosity--;
+}
+
+/**
+ * Sets the verbosity.
+ *
+ * \param verbosityLevel verbosity
+ */
+void Info::setVerbosity(int verbosityLevel) {
+  verbosity = verbosityLevel;
+}
Index: src/Helpers/Info.hpp
===================================================================
--- src/Helpers/Info.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
+++ src/Helpers/Info.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -0,0 +1,30 @@
+/*
+ * Info.hpp
+ *
+ *  Created on: Nov 25, 2009
+ *      Author: heber
+ */
+
+#ifndef INFO_HPP_
+#define INFO_HPP_
+
+using namespace std;
+
+/*********************************************** includes ***********************************/
+
+/****************************************** forward declarations *****************************/
+
+/********************************************** definitions *********************************/
+
+class Info {
+public :
+  static int verbosity;
+  const char *FunctionName;
+
+  Info(const char *msg);
+  ~Info();
+  static void setVerbosity(int verbosityLevel);
+
+};
+
+#endif /* INFO_HPP_ */
Index: src/Helpers/Log.cpp
===================================================================
--- src/Helpers/Log.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
+++ src/Helpers/Log.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -0,0 +1,74 @@
+/*
+ * log.cpp
+ *
+ *  Created on: Oct 19, 2009
+ *      Author: metzler
+ */
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "Helpers/MemDebug.hpp"
+
+#include "Helpers/logger.hpp"
+#include "Helpers/errorlogger.hpp"
+
+/**
+ * Sets verbosity for the error logger and the standard logger.
+ *
+ * \param int verbosity level
+ */
+void setVerbosity(int verbosityLevel) {
+  logger::getInstance().setVerbosity(verbosityLevel);
+}
+
+/**
+ * Gets verbosity for the error logger and the standard logger.
+ *
+ * \param int verbosity level
+ */
+int getVerbosity() {
+  return logger::getInstance().getVerbosity();
+}
+
+/**
+ * Prints a log entry.
+ *
+ * \param indentation level of the message to log
+ */
+class logger& Log() {
+  return logger::getInstance();
+}
+
+/** Checks verbosity for logger.
+ * Is supposed to be used in construct as this:
+ * DoLog(2) && (Log() << Verbose(2) << "message." << endl);
+ * If DoLog does not return true, the right-hand side is not evaluated and we save some time.
+ * \param verbose verbosity level of this message
+ * \return true - print, false - don't
+ */
+bool DoLog(int verbose) {
+  return (verbose <= logger::getInstance().verbosity);
+}
+
+/** Checks verbosity for errorlogger.
+ * Is supposed to be used in construct as this:
+ * DoLog(2) && (Log() << Verbose(2) << "message." << endl);
+ * If DoLog does not return true, the right-hand side is not evaluated and we save some time.
+ * \param verbose verbosity level of this message
+ * \return true - print, false - don't
+ */
+bool DoeLog(int verbose) {
+  return (verbose <= errorLogger::getInstance().verbosity);
+}
+
+/**
+ * Prints an error log entry.
+ *
+ * \param indentation level of the message to log
+ */
+class errorLogger & eLog() {
+  return errorLogger::getInstance();
+}
Index: src/Helpers/Log.hpp
===================================================================
--- src/Helpers/Log.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
+++ src/Helpers/Log.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -0,0 +1,21 @@
+/*
+ * log.hpp
+ *
+ *  Created on: Oct 19, 2009
+ *      Author: metzler
+ */
+
+#ifndef LOG_HPP_
+#define LOG_HPP_
+
+#include "Helpers/errorlogger.hpp"
+#include "Helpers/logger.hpp"
+
+class logger & Log();
+class errorLogger & eLog();
+void setVerbosity(int verbosityLevel);
+int getVerbosity();
+bool DoLog(int verbose);
+bool DoeLog(int verbose);
+
+#endif /* LOG_HPP_ */
Index: src/Helpers/Makefile.am
===================================================================
--- src/Helpers/Makefile.am	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
+++ src/Helpers/Makefile.am	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -0,0 +1,79 @@
+# PLEASE adhere to the alphabetical ordering in this Makefile!
+# Also indentation by a single tab
+
+INCLUDES = -I$(top_srcdir)/src
+
+AM_LDFLAGS = $(CPPUNIT_LIBS) -ldl
+# Position-Independent Code necessary for shared library
+AM_CXXFLAGS = $(CPPUNIT_CFLAGS)
+
+# this includes source files that need to be present at multiple points
+HELPERSSOURCE =  \
+  Assert.cpp \
+  errorlogger.cpp \
+  helpers.cpp \
+  Info.cpp \
+  Log.cpp \
+  logger.cpp \
+  MemDebug.cpp \
+  Verbose.cpp
+
+HELPERSHEADER =  \
+  Assert.hpp \
+  errorlogger.hpp \
+  helpers.hpp \
+  Info.hpp \
+  Log.hpp \
+  logger.hpp \
+  MemDebug.hpp \
+  Verbose.hpp
+
+lib_LTLIBRARIES = libMolecuilderHelpers-@MOLECUILDER_API_VERSION@.la
+libMolecuilderHelpers_includedir = $(includedir)/molecuilder-$(MOLECUILDER_API_VERSION)/Actions/
+nobase_libMolecuilderHelpers_include_HEADERS = ${HELPERSHEADER}
+
+## Define the source file list for the "libexample-@MOLECUILDER_API_VERSION@.la"
+## target.  Note that @MOLECUILDER_API_VERSION@ is not interpreted by Automake and
+## will therefore be treated as if it were literally part of the target name,
+## and the variable name derived from that.
+## The file extension .cc is recognized by Automake, and makes it produce
+## rules which invoke the C++ compiler to produce a libtool object file (.lo)
+## from each source file.  Note that it is not necessary to list header files
+## which are already listed elsewhere in a _HEADERS variable assignment.
+libMolecuilderHelpers_@MOLECUILDER_API_VERSION@_la_SOURCES = ${HELPERSSOURCE}
+
+## Instruct libtool to include ABI version information in the generated shared
+## library file (.so).  The library ABI version is defined in configure.ac, so
+## that all version information is kept in one place.
+libMolecuilderHelpers_@MOLECUILDER_API_VERSION@_la_LDFLAGS = -version-info $(MOLECUILDER_SO_VERSION)
+
+## The generated configuration header is installed in its own subdirectory of
+## $(libdir).  The reason for this is that the configuration information put
+## into this header file describes the target platform the installed library
+## has been built for.  Thus the file must not be installed into a location
+## intended for architecture-independent files, as defined by the Filesystem
+## Hierarchy Standard (FHS).
+## The nodist_ prefix instructs Automake to not generate rules for including
+## the listed files in the distribution on 'make dist'.  Files that are listed
+## in _HEADERS variables are normally included in the distribution, but the
+## configuration header file is generated at configure time and should not be
+## shipped with the source tarball.
+libMolecuilderHelpers_libincludedir = $(libdir)/molecuilder-$(MOLECUILDER_API_VERSION)/include
+nodist_libMolecuilderHelpers_libinclude_HEADERS = $(top_builddir)/libmolecuilder_config.h
+
+## Install the generated pkg-config file (.pc) into the expected location for
+## architecture-dependent package configuration information.  Occasionally,
+## pkg-config files are also used for architecture-independent data packages,
+## in which case the correct install location would be $(datadir)/pkgconfig.
+pkgconfigdir = $(libdir)/pkgconfig
+pkgconfig_DATA = $(top_builddir)/molecuilder-$(MOLECUILDER_API_VERSION).pc
+
+unity.cpp:
+	echo "" >  unity.cpp; \
+	list='$(HELPERSSOURCE)'; for file in $$list; do \
+	  if [ "$$file" != "MemDebug.cpp" ]; then \
+		  echo "#include \"$(srcdir)/$$file\"" >> unity.cpp; \
+	 	fi; \
+	done;
+	
+MOSTLYCLEANFILES = unity.cpp
Index: src/Helpers/MemDebug.cpp
===================================================================
--- src/Helpers/MemDebug.cpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/Helpers/MemDebug.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -6,6 +6,28 @@
  */
 
-#ifndef NDEBUG
-#ifndef NO_MEMDEBUG
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+// NDEBUG implies NO_MEMDEBUG
+#ifdef NDEBUG
+# ifndef NO_MEMDEBUG
+#   define NO_MEMDEBUG
+# endif
+#endif
+
+// NO_MEMDEBUG and MEMDEBUG are mutually exclusive, but at least one must be set
+#ifdef NO_MEMDEBUG
+# ifdef MEMDEBUG
+#   undef MEMDEBUG
+# endif
+#else
+# ifndef MEMDEBUG
+#   define MEMDEBUG
+# endif
+#endif
+
+#ifdef MEMDEBUG
 
 #include <iostream>
@@ -55,4 +77,5 @@
   // all allocated memory blocks
   struct entry_t {
+    typedef unsigned int checksum_t;
     // we seperate the tracking info from the rest
     // A checksum will be calculated for this part of
@@ -73,5 +96,5 @@
     } info;
     bool isIgnored;
-    char checksum;
+    checksum_t checksum;
     entry_t *prev;
     entry_t *next;
@@ -100,7 +123,7 @@
   // calculates a simple checksum for the info block
   // the checksum is used to find memory corruptions
-  inline char calcChecksum(entry_t::info_t *info){
+  inline entry_t::checksum_t calcChecksum(entry_t::info_t *info){
     char *buffer = (char*)info;
-    char checksum =0;
+    entry_t::checksum_t checksum =0;
     for(size_t i=0;i<sizeof(entry_t::info_t);i++){
       checksum+=buffer[i];
@@ -137,4 +160,32 @@
       cout << "Chunk reserved at: " << pos->info.file << ":" << pos->info.line << endl;
 #endif
+    }
+  }
+
+  void dumpMemory(std::ostream &ost){
+    ost << "Maximum allocated Memory: " << max << " bytes" << endl;
+    ost << "Maximum allocated Memory: " << max << " bytes" << endl;
+    ost << "Currently allocated Memory: " << state <<" bytes" << endl;
+    ost << allocs << " allocated chunks total" << endl;
+    bool corrupted=false;
+    for(entry_t *pos=begin;pos;pos=pos->next){
+      ost << "\nChunk of " << pos->info.nbytes << " bytes" << " still available" << endl;
+#     ifdef __GNUC__
+        ost << "Chunk reserved at: " << pos->info.function
+             << " (" << pos->info.file << ":" << pos->info.line  << ")" << endl;
+#     else
+        ost << "Chunk reserved at: " << pos->info.file << ":" << pos->info.line << endl;
+#     endif
+        ost << "Chunk address: " << pos->info.location << endl;
+        entry_t::checksum_t checksum = calcChecksum(&pos->info);
+        ost << "Checksum of chunk: " << checksum << endl;
+        ost << "Checksum at allocation time: " << pos->checksum << endl;
+        if(checksum!=pos->checksum){
+          ost << "!!!Chunk was corrupted!!!" << endl;
+          corrupted=true;
+        }
+    }
+    if(corrupted){
+      ost << "\n!!!Memory corruption detected!!!" << endl;
     }
   }
@@ -489,3 +540,2 @@
 }
 #endif
-#endif
Index: src/Helpers/MemDebug.hpp
===================================================================
--- src/Helpers/MemDebug.hpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/Helpers/MemDebug.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -21,10 +21,26 @@
  * your sourcefiles.
  */
-#ifndef NDEBUG
-#ifndef NO_MEMDEBUG
 
-#ifndef MEMDEBUG
-#define MEMDEBUG
+// Set all flags in a way that makes sense
+
+// NDEBUG implies NO_MEMDEBUG
+#ifdef NDEBUG
+# ifndef NO_MEMDEBUG
+#   define NO_MEMDEBUG
+# endif
 #endif
+
+// NO_MEMDEBUG and MEMDEBUG are mutually exclusive, but at least one must be set
+#ifdef NO_MEMDEBUG
+# ifdef MEMDEBUG
+#   undef MEMDEBUG
+# endif
+#else
+# ifndef MEMDEBUG
+#   define MEMDEBUG
+# endif
+#endif
+
+#ifdef MEMDEBUG
 
 #include <new>
@@ -45,4 +61,5 @@
    */
   void getState();
+  void dumpMemory(std::ostream&);
 
   void _ignore(void*);
@@ -83,17 +100,14 @@
 #endif
 
-#endif
-#endif
+#else
 
+#include <iosfwd>
 
-#ifdef NDEBUG
-#undef MEMDEBUG
-#endif
-
-#ifndef MEMDEBUG
 // memory debugging was disabled
 
 namespace Memory {
-  inline void getState(){}
+  inline void getState(){};
+
+  inline void dumpMemory(std::ostream&){};
 
   template <typename T>
@@ -104,3 +118,5 @@
 
 #endif
+
+
 #endif /* MEMDEBUG_HPP_ */
Index: src/Helpers/Range.hpp
===================================================================
--- src/Helpers/Range.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
+++ src/Helpers/Range.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -0,0 +1,65 @@
+/*
+ * Range.hpp
+ *
+ *  Created on: Jul 22, 2010
+ *      Author: crueger
+ */
+
+#ifndef RANGE_HPP_
+#define RANGE_HPP_
+template <class T>
+struct range {
+  range(const T&,const T&);
+  bool isInRange(const T&) const;
+  bool isBefore(const T&) const;
+  bool isBeyond(const T&) const;
+
+  T first;
+  T last;
+};
+
+template <class T>
+inline range<T>::range(const T &_first,const T &_last) :
+first(_first),last(_last)
+{}
+
+template <class T>
+inline bool range<T>::isInRange(const T &value) const{
+  return first <= value && value < last;
+}
+
+template <class T>
+inline bool range<T>::isBefore(const T &value) const{
+  return value < first;
+}
+
+template <class T>
+inline bool range<T>::isBeyond(const T &value) const{
+ return last <= value;
+}
+
+template <class T>
+inline range<T> makeRange(const T&first, const T&last){
+  return range<T>(first,last);
+}
+
+template <class T>
+inline bool operator<(const range <T> &x, const range<T> &y){
+  return (x.first!=y.first)?x.first<y.first:x.last<y.last;
+}
+
+template <class T>
+inline bool operator==(const range<T> &x,const range<T> &y){
+  return x.first==y.first && x.last==y.last;
+}
+
+template <class T>
+inline bool operator!= (const range<T>& x, const range<T>& y) { return !(x==y); }
+template <class T>
+inline bool operator>  (const range<T>& x, const range<T>& y) { return y<x; }
+template <class T>
+inline bool operator<=(const range<T>& x, const range<T>& y) { return !(y<x); }
+template <class T>
+inline bool operator>= (const range<T>& x, const range<T>& y) { return !(x<y); }
+
+#endif /* RANGE_HPP_ */
Index: src/Helpers/Verbose.cpp
===================================================================
--- src/Helpers/Verbose.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
+++ src/Helpers/Verbose.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -0,0 +1,95 @@
+/** \file Verbose.cpp
+ *
+ * Function implementations for the class Verbose.
+ *
+ */
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "Helpers/MemDebug.hpp"
+
+#include "Helpers/Info.hpp"
+#include "Helpers/Verbose.hpp"
+#include <iostream>
+
+using namespace std;
+
+/** Prints the tabs according to verbosity stored in the temporary constructed class.
+ * \param &ost stream to extend with tabs
+ * \return &ost stream with tabs
+ */
+ostream& Verbose::print (ostream &ost) const
+{
+  for (int i=Verbosity+Info::verbosity;i--;)
+    ost.put('\t');
+  //Log() << Verbose(0) << "Verbose(.) called." << endl;
+  return ost;
+};
+
+/** States whether current output message should be print or not.
+ * Compares Verbose::Verbosity plus Info::verbosity against \a verbosityLevel.
+ * \param verbosityLevel given global level of verbosity
+ * \return true - do output, false - don't
+ */
+bool Verbose::DoOutput(int verbosityLevel) const
+{
+  return (verbosityLevel >= Verbosity+Info::verbosity);
+};
+
+/** States whether current error output message should be print or not.
+ * Compares Verbose::Verbosity against \a verbosityLevel.
+ * \param verbosityLevel given global level of verbosity
+ * \return true - do output, false - don't
+ */
+bool Verbose::DoErrorOutput(int verbosityLevel) const
+{
+  return (verbosityLevel >= Verbosity);
+};
+
+/** Operator for the Verbose(arg) call.
+ * Constructs temporary a Verbose class object, wherein the verbosity is stored.
+ * Then << is called, which calls Verbose's print which adds the tabs and returns the stream.
+ * \param &ost stream to extend
+ * \param &m pointer to created Verbose object
+ * \return &ost
+ */ 
+ostream& operator<<(ostream& ost,const Verbose& m)
+{
+  return m.print(ost);
+};
+
+/** Prints the tabs according to verbosity stored in the temporary constructed class.
+ * Note that highest bit is set artificially to give number of bits to print
+ * \param &ost stream to extend with tabs
+ * \return &ost stream with tabs
+ */
+ostream& Binary::print (ostream &ost) const
+{
+  int bits = 1, counter = 1;
+  while ((bits = 1 << counter) < BinaryNumber)
+    counter++;
+  for (int i=0;i<counter-1;i++) {
+    if ((BinaryNumber & (1 << i)) == 0)
+      ost.put('0');
+     else
+      ost.put('1');
+  }
+  ost.put('b');
+  //Log() << Verbose(0) << "Binary(.) called." << endl;
+  return ost;
+};
+
+/** Operator for the Binary(arg) call.
+ * Constructs temporary a Verbose class object, wherein the Binary is stored.
+ * Then << is called, which calls Binary's print which adds the tabs and returns the stream.
+ * \param &ost stream to extend
+ * \param &m pointer to created Binary object
+ * \return &ost
+ */ 
+ostream& operator<<(ostream& ost,const Binary& m)
+{
+  return m.print(ost);
+};
Index: src/Helpers/Verbose.hpp
===================================================================
--- src/Helpers/Verbose.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
+++ src/Helpers/Verbose.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -0,0 +1,62 @@
+/*
+ * verbose.hpp
+ *
+ *  Created on: Aug 3, 2009
+ *      Author: heber
+ */
+
+#ifndef VERBOSE_HPP_
+#define VERBOSE_HPP_
+
+using namespace std;
+
+/*********************************************** includes ***********************************/
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <iosfwd>
+
+/************************************* Class Verbose & Binary *******************************/
+
+/** Verbose is an IO manipulator, that writes tabs according to \a Verbosity level.
+ */
+class Verbose
+{
+  public:
+    Verbose(int value) : Verbosity(value) { }
+
+    // allow access to private variable Verbose::Verbosity
+    friend ostream& operator<<(class errorLogger& l, const Verbose& v);
+    friend ostream& operator<<(class errorLogger* l, const Verbose& v);
+    friend ostream& operator<<(class logger& l, const Verbose& v);
+    friend ostream& operator<<(class logger* l, const Verbose& v);
+
+    ostream& print (ostream &ost) const;
+    bool DoOutput(int verbosityLevel) const;
+    bool DoErrorOutput(int verbosityLevel) const;
+  private:
+    int Verbosity;
+};
+
+ostream& operator<<(ostream& ost,const Verbose& m);
+
+/** Binary is an IO manipulator, that writes 0 and 1 according to number \a Binary.
+ */
+class Binary
+{
+  public:
+    Binary(int value) : BinaryNumber(value) { }
+
+    ostream& print (ostream &ost) const;
+  private:
+    int BinaryNumber;
+};
+
+ostream& operator<<(ostream& ost,const Binary& m);
+
+
+
+#endif /* VERBOSE_HPP_ */
Index: src/Helpers/errorlogger.cpp
===================================================================
--- src/Helpers/errorlogger.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
+++ src/Helpers/errorlogger.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -0,0 +1,115 @@
+/*
+ * errorLogger.cpp
+ *
+ *  Created on: Oct 19, 2009
+ *      Author: metzler
+ */
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "Helpers/MemDebug.hpp"
+
+#include <fstream>
+#include <iostream>
+#include "Helpers/errorlogger.hpp"
+#include "Helpers/Verbose.hpp"
+#include "Patterns/Singleton_impl.hpp"
+
+ofstream null("/dev/null");
+int errorLogger::verbosity = 2;
+ostream* errorLogger::nix = &null;
+
+/**
+ * Constructor. Do not use this function. Use getInstance() instead.
+ *
+ * \return errorLogger instance
+ */
+errorLogger::errorLogger()
+{};
+
+/**
+ * Destructor. Better use purgeInstance().
+ */
+errorLogger::~errorLogger()
+{}
+
+CONSTRUCT_SINGLETON(errorLogger)
+
+/**
+ * Sets the verbosity.
+ *
+ * \param verbosityLevel verbosity
+ */
+void errorLogger::setVerbosity(int verbosityLevel) {
+  verbosity = verbosityLevel;
+}
+
+/**
+ * Gets the verbosity.
+ *
+ * \return verbosity level
+ */
+int errorLogger::getVerbosity()
+{
+  return verbosity;
+}
+
+/**
+ * Operator for the Binary(arg) call.
+ * Constructs temporary a Verbose class object, wherein the Binary is stored.
+ * Then << is called, which calls Binary's print which adds the tabs and logs
+ * the stream.
+ * \param &ost stream to extend
+ * \param &m pointer to created Binary object
+ * \return &ost
+ */
+ostream& operator<<(class errorLogger& l, const Verbose& v)
+{
+  int verbosityLevel = l.verbosity;
+  l.nix->clear();
+  if (v.DoErrorOutput(verbosityLevel)) {
+    switch(v.Verbosity) {
+      case 0:
+        cerr << "CRITICAL: ";
+        break;
+      case 1:
+        cerr << "ERROR: ";
+        break;
+      case 2:
+        cerr << "WARNING: ";
+        break;
+      default:
+        break;
+    }
+    v.print(cerr);
+    return cerr;
+  } else
+    return *l.nix;
+};
+ostream& operator<<(class errorLogger* l, const Verbose& v)
+{
+  int verbosityLevel = l->verbosity;
+  l->nix->clear();
+  if (v.DoErrorOutput(verbosityLevel)) {
+    switch(v.Verbosity) {
+      case 0:
+        cerr << "CRITICAL: ";
+        break;
+      case 1:
+        cerr << "ERROR: ";
+        break;
+      case 2:
+      default:
+        cerr << "WARNING: ";
+        break;
+    }
+    v.print(cerr);
+    return cerr;
+  } else
+    return *l->nix;
+};
+
+
Index: src/Helpers/errorlogger.hpp
===================================================================
--- src/Helpers/errorlogger.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
+++ src/Helpers/errorlogger.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -0,0 +1,40 @@
+/*
+ * errorLogger.hpp
+ *
+ *  Created on: Oct 19, 2009
+ *      Author: metzler
+ */
+
+#ifndef ERRORLOGGER_HPP_
+#define ERRORLOGGER_HPP_
+
+#include <iosfwd>
+
+#include "Patterns/Singleton.hpp"
+
+using namespace std;
+
+class Verbose;
+
+class errorLogger : public Singleton<errorLogger>{
+  friend class Singleton<errorLogger>;
+public :
+  static ostream *nix;
+  static int verbosity;
+
+  static bool DoOutput();
+  static void setVerbosity(int verbosityLevel);
+  static int getVerbosity();
+
+protected:
+  /** Do not call this constructor directly, use getInstance() instead. */
+  errorLogger();
+  /** Do not call this destructor directly, use purgeInstance() instead. */
+  ~errorLogger();
+
+};
+
+ostream& operator<<(class errorLogger&l, const Verbose& ost);
+ostream& operator<<(class errorLogger*l, const Verbose& ost);
+
+#endif /* ERRORLOGGER_HPP_ */
Index: src/Helpers/helpers.cpp
===================================================================
--- src/Helpers/helpers.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
+++ src/Helpers/helpers.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -0,0 +1,147 @@
+/** \file helpers.cpp
+ *
+ * Implementation of some auxiliary functions for memory dis-/allocation and so on
+ */
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "Helpers/MemDebug.hpp"
+
+#include "Helpers/helpers.hpp"
+#include "Helpers/fast_functions.hpp"
+#include "Helpers/Verbose.hpp"
+#include "Helpers/Log.hpp"
+
+#include <iostream>
+
+/********************************************** helpful functions *********************************/
+
+
+/** Asks for a double value and checks input
+ * \param *text question
+ */
+double ask_value(const char *text)
+{
+  double test = 0.1439851348959832147598734598273456723948652983045928346598365;
+  do {
+    DoLog(0) && (Log() << Verbose(0) << text);
+    cin >> test;
+  } while (test == 0.1439851348959832147598734598273456723948652983045928346598365);
+  return test;
+};
+
+/** Output of a debug message to stderr.
+ * \param *P Problem at hand, points to ParallelSimulationData#me
+ * \param output output string
+ */
+#ifdef HAVE_DEBUG
+void debug_in(const char *output, const char *file, const int line) {
+  if (output) fprintf(stderr,"DEBUG: in %s at line %i: %s\n", file, line, output);
+}
+#else
+void debug_in(const char *output, const char *file, const int line) {}  // print nothing
+#endif
+
+/** modulo operator for doubles.
+ * \param *b pointer to double
+ * \param lower_bound lower bound
+ * \param upper_bound upper bound
+ */
+void bound(double *b, double lower_bound, double upper_bound)
+{
+  double step = (upper_bound - lower_bound);
+  while (*b >= upper_bound)
+    *b -= step;
+  while (*b < lower_bound)
+    *b += step;
+};
+
+/** Counts lines in file.
+ * Note we are scanning lines from current position, not from beginning.
+ * \param InputFile file to be scanned.
+ */
+int CountLinesinFile(ifstream &InputFile)
+{
+  char *buffer = new char[MAXSTRINGSIZE];
+  int lines=0;
+
+  int PositionMarker = InputFile.tellg();  // not needed as Inputfile is copied, given by value, not by ref
+  // count the number of lines, i.e. the number of fragments
+  InputFile.getline(buffer, MAXSTRINGSIZE); // skip comment lines
+  InputFile.getline(buffer, MAXSTRINGSIZE);
+  while(!InputFile.eof()) {
+    InputFile.getline(buffer, MAXSTRINGSIZE);
+    lines++;
+  }
+  InputFile.seekg(PositionMarker, ios::beg);
+  delete[](buffer);
+  return lines;
+};
+
+/** Returns a string with \a i prefixed with 0s to match order of total number of molecules in digits.
+ * \param FragmentNumber total number of fragments to determine necessary number of digits
+ * \param digits number to create with 0 prefixed
+ * \return allocated(!) char array with number in digits, ten base.
+ */
+char *FixedDigitNumber(const int FragmentNumber, const int digits)
+{
+  char *returnstring;
+  int number = FragmentNumber;
+  int order = 0;
+  while (number != 0) { // determine number of digits needed
+    number = (int)floor(((double)number / 10.));
+    order++;
+    //Log() << Verbose(0) << "Number is " << number << ", order is " << order << "." << endl;
+  }
+  // allocate string
+  returnstring = new char[order + 2];
+  // terminate  and fill string array from end backward
+  returnstring[order] = '\0';
+  number = digits;
+  for (int i=order;i--;) {
+    returnstring[i] = '0' + (char)(number % 10);
+    number = (int)floor(((double)number / 10.));
+  }
+  //Log() << Verbose(0) << returnstring << endl;
+  return returnstring;
+};
+
+/** Tests whether a given string contains a valid number or not.
+ * \param *string
+ * \return true - is a number, false - is not a valid number
+ */
+bool IsValidNumber( const char *string)
+{
+  int ptr = 0;
+  if ((string[ptr] == '.') || (string[ptr] == '-')) // number may be negative or start with dot
+    ptr++;
+  if ((string[ptr] >= '0') && (string[ptr] <= '9'))
+    return true;
+  return false;
+};
+
+/** Comparison function for GSL heapsort on distances in two molecules.
+ * \param *a
+ * \param *b
+ * \return <0, \a *a less than \a *b, ==0 if equal, >0 \a *a greater than \a *b
+ */
+int CompareDoubles (const void * a, const void * b)
+{
+  if (*(double *)a > *(double *)b)
+    return -1;
+  else if (*(double *)a < *(double *)b)
+    return 1;
+  else
+    return 0;
+};
+
+
+/**
+ * Calls exit(255).
+ */
+void performCriticalExit() {
+  exit(255);
+}
Index: src/Helpers/helpers.hpp
===================================================================
--- src/Helpers/helpers.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
+++ src/Helpers/helpers.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -0,0 +1,247 @@
+/** \file helpers.hpp
+ *
+ * Declaration of some auxiliary functions for memory dis-/allocation and so on
+ */
+
+#ifndef HELPERS_HPP_
+#define HELPERS_HPP_
+
+using namespace std;
+
+/*********************************************** includes ***********************************/
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <fstream>
+
+#include "defs.hpp"
+#include "Helpers/Log.hpp"
+
+/********************************************** definitions *********************************/
+
+/********************************************** helpful functions *********************************/
+
+// taken out of TREMOLO
+/*@-namechecks@*/
+#ifndef __GNUC__
+# undef __attribute__
+# define __attribute__(x)
+#endif
+/*@=namechecks@*/
+
+/* Behandelt aufgetretene Fehler. error ist der Fehlertyp(enum Errors)
+   void *SpecialData ist ein untypisierter Zeiger auf Spezielle Daten zur Fehlerbehandlung.
+   Man koennte auch noch einen Zeiger auf eine Funktion uebergeben */
+extern void /*@exits@*/ debug(const char *output);
+  //__attribute__ ((__return__));
+#define debug(data) debug_in((data), __FILE__, __LINE__)
+
+extern void /*@exits@*/ debug_in(const char *output,
+    const char *file, const int line);
+  //__attribute__ ((__return__));
+
+double ask_value(const char *text);
+bool check_bounds(double *x, double *cell_size);
+void bound(double *b, double lower_bound, double upper_bound);
+int CountLinesinFile(ifstream &InputFile);
+char *FixedDigitNumber(const int FragmentNumber, const int digits);
+bool IsValidNumber( const char *string);
+int CompareDoubles (const void * a, const void * b);
+void performCriticalExit();
+
+/********************************************** helpful template functions *********************************/
+
+
+/** returns greater of the two values.
+ * \param x first value
+ * \param y second value
+ * \return greater of the two (by operator>())
+ */
+template <typename T> T Max(T x, T y)
+{
+  if (x > y)
+    return x;
+  else return y;
+};
+
+/** returns smaller of the two values.
+ * \param x first value
+ * \param y second value
+ * \return smaller of the two (by operator<())
+ */
+template <typename T> T Min(T x, T y)
+{
+  if (x < y)
+    return x;
+  else return y;
+};
+
+/** Creates a lookup table for true father's Atom::Nr -> atom ptr.
+ * \param *start begin of chain list
+ * \paran *end end of chain list
+ * \param **Lookuptable pointer to return allocated lookup table (should be NULL on start)
+ * \param count optional predetermined size for table (otherwise we set the count to highest true father id)
+ * \return true - success, false - failure
+ */
+template <typename T> bool CreateFatherLookupTable(T *start, T *end, T **&LookupTable, int count = 0)
+{
+  bool status = true;
+  T *Walker = NULL;
+  int AtomNo;
+
+  if (LookupTable != NULL) {
+    DoeLog(0) && (eLog() << Verbose(0) << "Pointer for Lookup table is not NULL! Aborting ..." <<endl);
+    return false;
+  }
+
+  // count them
+  if (count == 0) {
+    Walker = start;
+    while (Walker->next != end) { // create a lookup table (Atom::nr -> atom) used as a marker table lateron
+      Walker = Walker->next;
+      count = (count < Walker->GetTrueFather()->nr) ? Walker->GetTrueFather()->nr : count;
+    }
+  }
+  if (count <= 0) {
+    DoeLog(1) && (eLog() << Verbose(1) << "Count of lookup list is 0 or less." << endl);
+    return false;
+  }
+
+  // allocate and fill
+  LookupTable = new T*[count];
+  if (LookupTable == NULL) {
+    DoeLog(0) && (eLog()<< Verbose(0) << "LookupTable memory allocation failed!" << endl);
+    performCriticalExit();
+    status = false;
+  } else {
+    Walker = start;
+    while (Walker->next != end) { // create a lookup table (Atom::nr -> atom) used as a marker table lateron
+      Walker = Walker->next;
+      AtomNo = Walker->GetTrueFather()->nr;
+      if ((AtomNo >= 0) && (AtomNo < count)) {
+        //*out << "Setting LookupTable[" << AtomNo << "] to " << *Walker << endl;
+        LookupTable[AtomNo] = Walker;
+      } else {
+        DoeLog(2) && (eLog() << Verbose(2) << "Walker " << *Walker << " exceeded range of nuclear ids [0, " << count << ")." << endl);
+        status = false;
+        break;
+      }
+    }
+  }
+
+  return status;
+};
+
+
+/** Frees a two-dimensional array.
+ * \param *ptr pointer to array
+ * \param dim first dim of array
+ */
+template <typename X> void Free2DArray(X **ptr, int dim)
+{
+  int i;
+  if (ptr != NULL) {
+    for(i=dim;i--;)
+      if (ptr[i] != NULL)
+        free(ptr[i]);
+    free(ptr);
+  }
+};
+
+template <typename T> void Increment(T *value, T *inc)
+{
+  *value += *inc;
+};
+
+template <typename T> void AbsoluteValue(T *value, T *abs)
+{
+  *value = *abs;
+};
+
+template <typename T> void IncrementalAbsoluteValue(T *value, T *abs)
+{
+  *value = *abs;
+  (*abs) += 1;
+};
+
+#define PLURAL_S(v) (((v)==1)?"":"s")
+
+// this is to allow different modes of access for
+// maps and sets
+template<typename Res,typename T>
+struct _take{
+  Res get(T value) const;
+};
+
+// if we have a set,vector etc we can directly access the result
+template<typename Res>
+struct _take<Res,Res>{
+  static inline Res get(Res value){
+    return value;
+  }
+};
+
+// if we have a map we have to access the second part of
+// the pair
+template<typename Res,typename T1>
+struct _take<Res,std::pair<T1,Res> >{
+  static inline Res get(std::pair<T1,Res> value){
+    return value.second;
+  }
+};
+
+/************ struct to contain simple enumerations ***************/
+template <class C>
+struct enumeration{
+  enumeration() : max(0) {}
+  enumeration(unsigned int i) : max(i) {}
+  enumeration(const enumeration &src) :
+    there(src.there),
+    back(src.back),
+    max(src.max)
+  {}
+  enumeration &operator=(const enumeration &src){
+    /* no self-assignment check needed */
+    there = src.there;
+    back = src.back;
+    max = src.max;
+    return *this;
+  }
+  void add(const C &value){
+    if(!there.count(value)){
+      there[value]=max;
+      back[max++]=value;
+    }
+  }
+  unsigned int getMax() const{
+    return max;
+  }
+
+  map<C,unsigned int> there;
+  map<unsigned int,C> back;
+private:
+  unsigned int max;
+};
+
+/***** A counter to generate sequential numbers *******************/
+struct counter{
+  inline counter() : count(0){};
+  inline counter(int i) : count(i){};
+  inline unsigned int operator()(){
+    return count++;
+  }
+private:
+  unsigned int count;
+};
+
+template <class C,class ForwardIterator>
+enumeration<C> enumerate(ForwardIterator first,ForwardIterator last){
+  enumeration<C> res;
+  for_each(first,last,bind1st(mem_fun(&enumeration<C>::add),&res));
+  return res;
+}
+
+#endif /*HELPERS_HPP_*/
Index: src/Helpers/logger.cpp
===================================================================
--- src/Helpers/logger.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
+++ src/Helpers/logger.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -0,0 +1,89 @@
+/*
+ * logger.cpp
+ *
+ *  Created on: Oct 19, 2009
+ *      Author: metzler
+ */
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "Helpers/MemDebug.hpp"
+
+#include <fstream>
+#include <iostream>
+#include "Helpers/logger.hpp"
+#include "Helpers/Verbose.hpp"
+#include "Patterns/Singleton_impl.hpp"
+
+ofstream nullStream("/dev/null");
+
+int logger::verbosity = 2;
+ostream* logger::nix = &nullStream;
+
+/**
+ * Constructor. Do not use this function. Use getInstance() instead.
+ *
+ * \return logger instance
+ */
+logger::logger()
+{};
+
+/**
+ * Destructor. Better use purgeInstance().
+ */
+logger::~logger() {}
+
+CONSTRUCT_SINGLETON(logger)
+
+/**
+ * Sets the verbosity.
+ *
+ * \param verbosityLevel verbosity
+ */
+void logger::setVerbosity(int verbosityLevel) {
+  verbosity = verbosityLevel;
+}
+
+/**
+ * Gets the verbosity.
+ *
+ * \return verbosity level
+ */
+int logger::getVerbosity()
+{
+  return verbosity;
+}
+
+/**
+ * Operator for the Binary(arg) call.
+ * Constructs temporary a Verbose class object, wherein the Binary is stored.
+ * Then << is called, which calls Binary's print which adds the tabs and logs
+ * the stream.
+ * \param &ost stream to extend
+ * \param &m pointer to created Binary object
+ * \return &ost
+ */
+ostream& operator<<(class logger& l, const Verbose& v)
+{
+  int verbosityLevel = l.verbosity;
+  l.nix->clear();
+  if (v.DoOutput(verbosityLevel)) {
+    v.print(cout);
+    return cout;
+  } else
+    return *l.nix;
+};
+ostream& operator<<(class logger* l, const Verbose& v)
+{
+  int verbosityLevel = l->verbosity;
+  l->nix->clear();
+  if (v.DoOutput(verbosityLevel)) {
+    v.print(cout);
+    return cout;
+  } else
+    return *l->nix;
+};
+
Index: src/Helpers/logger.hpp
===================================================================
--- src/Helpers/logger.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
+++ src/Helpers/logger.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -0,0 +1,39 @@
+/*
+ * logger.hpp
+ *
+ *  Created on: Oct 19, 2009
+ *      Author: metzler
+ */
+
+#ifndef LOGGER_HPP_
+#define LOGGER_HPP_
+
+#include <iosfwd>
+
+#include "Patterns/Singleton.hpp"
+
+using namespace std;
+
+class Verbose;
+
+class logger : public Singleton<logger> {
+  friend class Singleton<logger>;
+public :
+  static ostream *nix;
+  static int verbosity;
+
+  static bool DoOutput();
+  static void setVerbosity(int verbosityLevel);
+  static int getVerbosity();
+
+protected:
+  /** Do not call this constructor directly, use getInstance() instead. */
+  logger();
+  /** Do not call this destructor directly, use purgeInstance() instead. */
+  ~logger();
+};
+
+ostream& operator<<(class logger&l, const Verbose& ost);
+ostream& operator<<(class logger*l, const Verbose& ost);
+
+#endif /* LOGGER_HPP_ */
Index: c/Legacy/oldmenu.cpp
===================================================================
--- src/Legacy/oldmenu.cpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ 	(revision )
@@ -1,1119 +1,0 @@
-/** \file menu.cpp
- * The class in this file is responsible for displaying the menu and enabling choices.
- *
- * This class is currently being refactored. Functions were copied from builder.cpp and are
- * to be imported into the menu class.
- *
- */
-
-#include "Helpers/MemDebug.hpp"
-
-#include "Legacy/oldmenu.hpp"
-#include "analysis_bonds.hpp"
-#include "analysis_correlation.hpp"
-#include "World.hpp"
-#include "atom.hpp"
-#include "bond.hpp"
-#include "bondgraph.hpp"
-#include "boundary.hpp"
-#include "config.hpp"
-#include "element.hpp"
-#include "ellipsoid.hpp"
-#include "helpers.hpp"
-#include "leastsquaremin.hpp"
-#include "linkedcell.hpp"
-#include "log.hpp"
-#include "memoryusageobserverunittest.hpp"
-#include "molecule.hpp"
-#include "periodentafel.hpp"
-#include "vector_ops.hpp"
-#include "Plane.hpp"
-#include "Line.hpp"
-
-#include "UIElements/UIFactory.hpp"
-#include "UIElements/Dialog.hpp"
-#include "Menu/Menu.hpp"
-#include "Menu/TextMenu.hpp"
-#include "Menu/ActionMenuItem.hpp"
-#include "Menu/SeperatorItem.hpp"
-#include "Menu/DisplayMenuItem.hpp"
-#include "Menu/SubMenuItem.hpp"
-#include "Actions/MapOfActions.hpp"
-#include "Actions/MethodAction.hpp"
-#include "Actions/ErrorAction.hpp"
-#include "Views/StreamStringView.hpp"
-#include "Views/MethodStringView.hpp"
-
-
-#include <boost/bind.hpp>
-
-/* copied methods for refactoring */
-/*TODO: Move these methods inside menu class
- * and restructure menu class*/
-
-/********************************************* Subsubmenu routine ************************************/
-
-/** Submenu for adding atoms to the molecule.
- * \param *periode periodentafel
- * \param *molecule molecules with atoms
- */
-void oldmenu::AddAtoms(periodentafel *periode, molecule *mol)
-{
-  atom *first, *second, *third, *fourth;
-  Vector **atoms;
-  Vector x,y,z,n;  // coordinates for absolute point in cell volume
-  double a,b,c;
-  char choice;  // menu choice char
-  bool valid;
-  bool aborted;
-
-  Log() << Verbose(0) << "===========ADD ATOM============================" << endl;
-  Log() << Verbose(0) << " a - state absolute coordinates of atom" << endl;
-  Log() << Verbose(0) << " b - state relative coordinates of atom wrt to reference point" << endl;
-  Log() << Verbose(0) << " c - state relative coordinates of atom wrt to already placed atom" << endl;
-  Log() << Verbose(0) << " d - state two atoms, two angles and a distance" << endl;
-  Log() << Verbose(0) << " e - least square distance position to a set of atoms" << endl;
-  Log() << Verbose(0) << "all else - go back" << endl;
-  Log() << Verbose(0) << "===============================================" << endl;
-  Log() << Verbose(0) << "Note: Specifiy angles in degrees not multiples of Pi!" << endl;
-  Log() << Verbose(0) << "INPUT: ";
-  cin >> choice;
-
-  switch (choice) {
-    default:
-      eLog() << Verbose(2) << "Not a valid choice." << endl;
-      break;
-      case 'a': // absolute coordinates of atom
-      {
-        Dialog *dialog = UIFactory::getInstance().makeDialog();
-        first = World::getInstance().createAtom();
-        std::vector<element *> elements;
-        dialog->queryVector("Please enter coordinates: ",&first->x,World::getInstance().getDomain(), false);
-        dialog->queryElement("Please choose element: ",&elements);
-        if(dialog->display()){
-          if (elements.size() == 1) {
-            first->type = elements.at(0);
-            mol->AddAtom(first);  // add to molecule
-          } else {
-            DoeLog(1) && (eLog() << Verbose(1) << "Unequal to one element given for element of new atom." << endl);
-          }
-        }
-        else{
-          World::getInstance().destroyAtom(first);
-        }
-      }
-      break;
-
-      case 'b': // relative coordinates of atom wrt to reference point
-        first = World::getInstance().createAtom();
-        valid = true;
-        aborted = false;
-        do {
-          if (!valid) eLog() << Verbose(2) << "Resulting position out of cell." << endl;
-          auto_ptr<Dialog> dialog(UIFactory::getInstance().makeDialog());
-          dialog->queryVector("Enter reference coordinates.",&x,World::getInstance().getDomain(), true);
-          dialog->queryVector("Enter relative coordinates.",&first->x,World::getInstance().getDomain(), false);
-          if((aborted = !dialog->display())){
-            continue;
-          }
-          first->x += x;
-        } while (!aborted && !(valid = mol->CheckBounds((const Vector *)&first->x)));
-        if(!aborted){
-          first->type = periode->AskElement();  // give type
-          mol->AddAtom(first);  // add to molecule
-        }
-        else{
-          World::getInstance().destroyAtom(first);
-        }
-        break;
-
-      case 'c': // relative coordinates of atom wrt to already placed atom
-      {
-        first = World::getInstance().createAtom();
-        valid = true;
-        do {
-          if (!valid) eLog() << Verbose(2) << "Resulting position out of cell." << endl;
-          auto_ptr<Dialog> dialog(UIFactory::getInstance().makeDialog());
-          second = mol->AskAtom("Enter atom number: ");
-          dialog->queryVector("Enter relative coordinates.",&first->x,World::getInstance().getDomain(), false);
-          dialog->display();
-          for (int i=NDIM;i--;) {
-            first->x[i] += second->x[i];
-          }
-        } while (!(valid = mol->CheckBounds((const Vector *)&first->x)));
-        first->type = periode->AskElement();  // give type
-        mol->AddAtom(first);  // add to molecule
-      }
-      break;
-
-    case 'd': // two atoms, two angles and a distance
-        first = World::getInstance().createAtom();
-        valid = true;
-        do {
-          if (!valid) {
-            eLog() << Verbose(2) << "Resulting coordinates out of cell - " << first->x << endl;
-          }
-          Log() << Verbose(0) << "First, we need two atoms, the first atom is the central, while the second is the outer one." << endl;
-          second = mol->AskAtom("Enter central atom: ");
-          third = mol->AskAtom("Enter second atom (specifying the axis for first angle): ");
-          fourth = mol->AskAtom("Enter third atom (specifying a plane for second angle): ");
-          a = ask_value("Enter distance between central (first) and new atom: ");
-          b = ask_value("Enter angle between new, first and second atom (degrees): ");
-          b *= M_PI/180.;
-          bound(&b, 0., 2.*M_PI);
-          c = ask_value("Enter second angle between new and normal vector of plane defined by first, second and third atom (degrees): ");
-          c *= M_PI/180.;
-          bound(&c, -M_PI, M_PI);
-          Log() << Verbose(0) << "radius: " << a << "\t phi: " << b*180./M_PI << "\t theta: " << c*180./M_PI << endl;
-/*
-          second->Output(1,1,(ofstream *)&cout);
-          third->Output(1,2,(ofstream *)&cout);
-          fourth->Output(1,3,(ofstream *)&cout);
-          n.MakeNormalvector((const vector *)&second->x, (const vector *)&third->x, (const vector *)&fourth->x);
-          x.Copyvector(&second->x);
-          x.SubtractVector(&third->x);
-          x.Copyvector(&fourth->x);
-          x.SubtractVector(&third->x);
-
-          if (!z.SolveSystem(&x,&y,&n, b, c, a)) {
-            Log() << Verbose(0) << "Failure solving self-dependent linear system!" << endl;
-            continue;
-          }
-          Log() << Verbose(0) << "resulting relative coordinates: ";
-          z.Output();
-          Log() << Verbose(0) << endl;
-          */
-          // calc axis vector
-          x= second->x - third->x;
-          x.Normalize();
-          Log() << Verbose(0) << "x: " << x << endl;
-          z = Plane(second->x,third->x,fourth->x).getNormal();
-          Log() << Verbose(0) << "z: " << z << endl;
-          y = Plane(x,z,0).getNormal();
-          Log() << Verbose(0) << "y: " << y << endl;
-
-          // rotate vector around first angle
-          first->x = x;
-          first->x = Line(zeroVec,z).rotateVector(first->x,b - M_PI);
-          Log() << Verbose(0) << "Rotated vector: " << first->x << endl,
-          // remove the projection onto the rotation plane of the second angle
-          n = y;
-          n.Scale(first->x.ScalarProduct(y));
-          Log() << Verbose(0) << "N1: " << n << endl;
-          first->x -= n;
-          Log() << Verbose(0) << "Subtracted vector: " << first->x << endl;
-          n = z;
-          n.Scale(first->x.ScalarProduct(z));
-          Log() << Verbose(0) << "N2: " << n << endl;
-          first->x -= n;
-          Log() << Verbose(0) << "2nd subtracted vector: " << first->x << endl;
-
-          // rotate another vector around second angle
-          n = y;
-          n = Line(zeroVec,x).rotateVector(n,c - M_PI);
-          Log() << Verbose(0) << "2nd Rotated vector: " << n << endl;
-
-          // add the two linear independent vectors
-          first->x += n;
-          first->x.Normalize();
-          first->x.Scale(a);
-          first->x += second->x;
-
-          Log() << Verbose(0) << "resulting coordinates: " << first->x << endl;
-        } while (!(valid = mol->CheckBounds((const Vector *)&first->x)));
-        first->type = periode->AskElement();  // give type
-        mol->AddAtom(first);  // add to molecule
-        break;
-
-      case 'e': // least square distance position to a set of atoms
-        first = World::getInstance().createAtom();
-        atoms = new (Vector*[128]);
-        valid = true;
-        for(int i=128;i--;)
-          atoms[i] = NULL;
-        int i=0, j=0;
-        Log() << Verbose(0) << "Now we need at least three molecules.\n";
-        do {
-          Log() << Verbose(0) << "Enter " << i+1 << "th atom: ";
-          cin >> j;
-          if (j != -1) {
-            second = mol->FindAtom(j);
-            atoms[i++] = &(second->x);
-          }
-        } while ((j != -1) && (i<128));
-        if (i >= 2) {
-          LSQdistance(first->x,(const Vector **)atoms, i);
-
-          Log() << Verbose(0) << first->x;
-          first->type = periode->AskElement();  // give type
-          mol->AddAtom(first);  // add to molecule
-        } else {
-          World::getInstance().destroyAtom(first);
-          Log() << Verbose(0) << "Please enter at least two vectors!\n";
-        }
-        break;
-  };
-};
-
-/** Submenu for centering the atoms in the molecule.
- * \param *mol molecule with all the atoms
- */
-void oldmenu::CenterAtoms(molecule *mol)
-{
-  Vector x, y, helper;
-  char choice;  // menu choice char
-
-  Log() << Verbose(0) << "===========CENTER ATOMS=========================" << endl;
-  Log() << Verbose(0) << " a - on origin" << endl;
-  Log() << Verbose(0) << " b - on center of gravity" << endl;
-  Log() << Verbose(0) << " c - within box with additional boundary" << endl;
-  Log() << Verbose(0) << " d - within given simulation box" << endl;
-  Log() << Verbose(0) << "all else - go back" << endl;
-  Log() << Verbose(0) << "===============================================" << endl;
-  Log() << Verbose(0) << "INPUT: ";
-  cin >> choice;
-
-  switch (choice) {
-    default:
-      Log() << Verbose(0) << "Not a valid choice." << endl;
-      break;
-    case 'a':
-      Log() << Verbose(0) << "Centering atoms in config file on origin." << endl;
-      mol->CenterOrigin();
-      break;
-    case 'b':
-      Log() << Verbose(0) << "Centering atoms in config file on center of gravity." << endl;
-      mol->CenterPeriodic();
-      break;
-    case 'c':
-      Log() << Verbose(0) << "Centering atoms in config file within given additional boundary." << endl;
-      for (int i=0;i<NDIM;i++) {
-        Log() << Verbose(0) << "Enter axis " << i << " boundary: ";
-        cin >> y[i];
-      }
-      mol->CenterEdge(&x);  // make every coordinate positive
-      mol->Center += y; // translate by boundary
-      helper = (2*y)+x;
-      mol->SetBoxDimension(&helper);  // update Box of atoms by boundary
-      break;
-    case 'd':
-      Log() << Verbose(1) << "Centering atoms in config file within given simulation box." << endl;
-      for (int i=0;i<NDIM;i++) {
-        Log() << Verbose(0) << "Enter axis " << i << " boundary: ";
-        cin >> x[i];
-      }
-      // update Box of atoms by boundary
-      mol->SetBoxDimension(&x);
-      // center
-      mol->CenterInBox();
-      break;
-  }
-};
-
-/** Submenu for aligning the atoms in the molecule.
- * \param *periode periodentafel
- * \param *mol molecule with all the atoms
- */
-void oldmenu::AlignAtoms(periodentafel *periode, molecule *mol)
-{
-  atom *first, *second, *third;
-  Vector x,n;
-  char choice;  // menu choice char
-
-  Log() << Verbose(0) << "===========ALIGN ATOMS=========================" << endl;
-  Log() << Verbose(0) << " a - state three atoms defining align plane" << endl;
-  Log() << Verbose(0) << " b - state alignment vector" << endl;
-  Log() << Verbose(0) << " c - state two atoms in alignment direction" << endl;
-  Log() << Verbose(0) << " d - align automatically by least square fit" << endl;
-  Log() << Verbose(0) << "all else - go back" << endl;
-  Log() << Verbose(0) << "===============================================" << endl;
-  Log() << Verbose(0) << "INPUT: ";
-  cin >> choice;
-
-  switch (choice) {
-    default:
-    case 'a': // three atoms defining mirror plane
-      first = mol->AskAtom("Enter first atom: ");
-      second = mol->AskAtom("Enter second atom: ");
-      third = mol->AskAtom("Enter third atom: ");
-
-      n = Plane(first->x,second->x,third->x).getNormal();
-      break;
-    case 'b': // normal vector of mirror plane
-    {
-      Dialog *dialog = UIFactory::getInstance().makeDialog();
-      dialog->queryVector("Enter normal vector of mirror plane.",&n,World::getInstance().getDomain(),false);
-      dialog->display();
-      delete dialog;
-      n.Normalize();
-    }
-    break;
-
-    case 'c': // three atoms defining mirror plane
-      first = mol->AskAtom("Enter first atom: ");
-      second = mol->AskAtom("Enter second atom: ");
-
-      n = first->x - second->x;
-      n.Normalize();
-      break;
-    case 'd':
-      char shorthand[4];
-      Vector a;
-      struct lsq_params param;
-      do {
-        fprintf(stdout, "Enter the element of atoms to be chosen: ");
-        fscanf(stdin, "%3s", shorthand);
-      } while ((param.type = periode->FindElement(shorthand)) == NULL);
-      Log() << Verbose(0) << "Element is " << param.type->name << endl;
-      mol->GetAlignvector(&param);
-      for (int i=NDIM;i--;) {
-        x[i] = gsl_vector_get(param.x,i);
-        n[i] = gsl_vector_get(param.x,i+NDIM);
-      }
-      gsl_vector_free(param.x);
-      Log() << Verbose(0) << "Offset vector: " << x << endl;
-      n.Normalize();
-      break;
-  };
-  Log() << Verbose(0) << "Alignment vector: " << n << endl;
-  mol->Align(&n);
-};
-
-/** Submenu for mirroring the atoms in the molecule.
- * \param *mol molecule with all the atoms
- */
-void oldmenu::MirrorAtoms(molecule *mol)
-{
-  atom *first, *second, *third;
-  Vector n;
-  char choice;  // menu choice char
-
-  Log() << Verbose(0) << "===========MIRROR ATOMS=========================" << endl;
-  Log() << Verbose(0) << " a - state three atoms defining mirror plane" << endl;
-  Log() << Verbose(0) << " b - state normal vector of mirror plane" << endl;
-  Log() << Verbose(0) << " c - state two atoms in normal direction" << endl;
-  Log() << Verbose(0) << "all else - go back" << endl;
-  Log() << Verbose(0) << "===============================================" << endl;
-  Log() << Verbose(0) << "INPUT: ";
-  cin >> choice;
-
-  switch (choice) {
-    default:
-    case 'a': // three atoms defining mirror plane
-      first = mol->AskAtom("Enter first atom: ");
-      second = mol->AskAtom("Enter second atom: ");
-      third = mol->AskAtom("Enter third atom: ");
-
-      n = Plane(first->x,second->x,third->x).getNormal();
-      break;
-    case 'b': // normal vector of mirror plane
-    {
-      Dialog *dialog = UIFactory::getInstance().makeDialog();
-      dialog->queryVector("Enter normal vector of mirror plane.",&n,World::getInstance().getDomain(),false);
-      dialog->display();
-      delete dialog;
-      n.Normalize();
-    }
-    break;
-
-    case 'c': // three atoms defining mirror plane
-      first = mol->AskAtom("Enter first atom: ");
-      second = mol->AskAtom("Enter second atom: ");
-
-      n = first->x - second->x;
-      n.Normalize();
-      break;
-  };
-  Log() << Verbose(0) << "Normal vector: " << n << endl;
-  mol->Mirror((const Vector *)&n);
-};
-
-/** Submenu for removing the atoms from the molecule.
- * \param *mol molecule with all the atoms
- */
-void oldmenu::RemoveAtoms(molecule *mol)
-{
-  atom *second;
-  int axis;
-  double tmp1, tmp2;
-  char choice;  // menu choice char
-
-  Log() << Verbose(0) << "===========REMOVE ATOMS=========================" << endl;
-  Log() << Verbose(0) << " a - state atom for removal by number" << endl;
-  Log() << Verbose(0) << " b - keep only in radius around atom" << endl;
-  Log() << Verbose(0) << " c - remove this with one axis greater value" << endl;
-  Log() << Verbose(0) << "all else - go back" << endl;
-  Log() << Verbose(0) << "===============================================" << endl;
-  Log() << Verbose(0) << "INPUT: ";
-  cin >> choice;
-
-  switch (choice) {
-    default:
-    case 'a':
-      if (mol->RemoveAtom(mol->AskAtom("Enter number of atom within molecule: ")))
-        Log() << Verbose(1) << "Atom removed." << endl;
-      else
-        Log() << Verbose(1) << "Atom not found." << endl;
-      break;
-    case 'b':
-      {
-        second = mol->AskAtom("Enter number of atom as reference point: ");
-        Log() << Verbose(0) << "Enter radius: ";
-        cin >> tmp1;
-        molecule::iterator runner;
-        for (molecule::iterator iter = mol->begin(); iter != mol->end(); ) {
-          runner = iter++;
-          if ((*runner)->x.DistanceSquared((*runner)->x) > tmp1*tmp1) // distance to first above radius ...
-            mol->RemoveAtom((*runner));
-        }
-      }
-      break;
-    case 'c':
-      Log() << Verbose(0) << "Which axis is it: ";
-      cin >> axis;
-      Log() << Verbose(0) << "Lower boundary: ";
-      cin >> tmp1;
-      Log() << Verbose(0) << "Upper boundary: ";
-      cin >> tmp2;
-      molecule::iterator runner;
-      for (molecule::iterator iter = mol->begin(); iter != mol->end(); ) {
-        runner = iter++;
-        if (((*runner)->x[axis] < tmp1) || ((*runner)->x[axis] > tmp2)) {// out of boundary ...
-          //Log() << Verbose(0) << "Atom " << *(*runner) << " with " << (*runner)->x.x[axis] << " on axis " << axis << " is out of bounds [" << tmp1 << "," << tmp2 << "]." << endl;
-          mol->RemoveAtom((*runner));
-        }
-      }
-      break;
-  };
-  //mol->Output();
-  choice = 'r';
-};
-
-/** Submenu for measuring out the atoms in the molecule.
- * \param *periode periodentafel
- * \param *mol molecule with all the atoms
- */
-void oldmenu::MeasureAtoms(periodentafel *periode, molecule *mol, config *configuration)
-{
-  atom *first, *second, *third;
-  Vector x,y;
-  double min[256], tmp1, tmp2, tmp3;
-  int Z;
-  char choice;  // menu choice char
-
-  Log() << Verbose(0) << "===========MEASURE ATOMS=========================" << endl;
-  Log() << Verbose(0) << " a - calculate bond length between one atom and all others" << endl;
-  Log() << Verbose(0) << " b - calculate bond length between two atoms" << endl;
-  Log() << Verbose(0) << " c - calculate bond angle" << endl;
-  Log() << Verbose(0) << " d - calculate principal axis of the system" << endl;
-  Log() << Verbose(0) << " e - calculate volume of the convex envelope" << endl;
-  Log() << Verbose(0) << " f - calculate temperature from current velocity" << endl;
-  Log() << Verbose(0) << " g - output all temperatures per step from velocities" << endl;
-  Log() << Verbose(0) << " h - count the number of hydrogen bonds" << endl;
-  Log() << Verbose(0) << "all else - go back" << endl;
-  Log() << Verbose(0) << "===============================================" << endl;
-  Log() << Verbose(0) << "INPUT: ";
-  cin >> choice;
-
-  switch(choice) {
-    default:
-      Log() << Verbose(1) << "Not a valid choice." << endl;
-      break;
-    case 'a':
-      first = mol->AskAtom("Enter first atom: ");
-      for (int i=MAX_ELEMENTS;i--;)
-        min[i] = 0.;
-
-      for (molecule::const_iterator iter = mol->begin(); iter != mol->end(); ++iter) {
-        Z = (*iter)->type->Z;
-        tmp1 = 0.;
-        if (first != (*iter)) {
-          x = first->x - (*iter)->x;
-          tmp1 = x.Norm();
-        }
-        if ((tmp1 != 0.) && ((min[Z] == 0.) || (tmp1 < min[Z]))) min[Z] = tmp1;
-        //Log() << Verbose(0) << "Bond length between Atom " << first->nr << " and " << ((*iter)->nr << ": " << tmp1 << " a.u." << endl;
-      }
-      for (int i=MAX_ELEMENTS;i--;)
-        if (min[i] != 0.) Log() << Verbose(0) << "Minimum Bond length between " << first->type->name << " Atom " << first->nr << " and next Ion of type " << (periode->FindElement(i))->name << ": " << min[i] << " a.u." << endl;
-      break;
-
-    case 'b':
-      first = mol->AskAtom("Enter first atom: ");
-      second = mol->AskAtom("Enter second atom: ");
-      for (int i=NDIM;i--;)
-        min[i] = 0.;
-      x = first->x - second->x;
-      tmp1 = x.Norm();
-      Log() << Verbose(1) << "Distance vector is " << x << "." << "/n"
-            << "Norm of distance is " << tmp1 << "." << endl;
-      break;
-
-    case 'c':
-      Log() << Verbose(0) << "Evaluating bond angle between three - first, central, last - atoms." << endl;
-      first = mol->AskAtom("Enter first atom: ");
-      second = mol->AskAtom("Enter central atom: ");
-      third  = mol->AskAtom("Enter last atom: ");
-      tmp1 = tmp2 = tmp3 = 0.;
-      x = first->x - second->x;
-      y = third->x - second->x;
-      Log() << Verbose(0) << "Bond angle between first atom Nr." << first->nr << ", central atom Nr." << second->nr << " and last atom Nr." << third->nr << ": ";
-      Log() << Verbose(0) << (acos(x.ScalarProduct(y)/(y.Norm()*x.Norm()))/M_PI*180.) << " degrees" << endl;
-      break;
-    case 'd':
-      Log() << Verbose(0) << "Evaluating prinicipal axis." << endl;
-      Log() << Verbose(0) << "Shall we rotate? [0/1]: ";
-      cin >> Z;
-      if ((Z >=0) && (Z <=1))
-        mol->PrincipalAxisSystem((bool)Z);
-      else
-        mol->PrincipalAxisSystem(false);
-      break;
-    case 'e':
-      {
-        Log() << Verbose(0) << "Evaluating volume of the convex envelope.";
-        class Tesselation *TesselStruct = NULL;
-        const LinkedCell *LCList = NULL;
-        LCList = new LinkedCell(mol, 10.);
-        Boundaries *BoundaryPoints = NULL;
-        FindConvexBorder(mol, BoundaryPoints TesselStruct, LCList, NULL);
-        double clustervolume = VolumeOfConvexEnvelope(TesselStruct, configuration);
-        Log() << Verbose(0) << "The tesselated surface area is " << clustervolume << "." << endl;\
-        delete(LCList);
-        delete(TesselStruct);
-      }
-      break;
-    case 'f':
-      mol->OutputTemperatureFromTrajectories((ofstream *)&cout, mol->MDSteps-1, mol->MDSteps);
-      break;
-    case 'g':
-      {
-        char filename[255];
-        Log() << Verbose(0) << "Please enter filename: " << endl;
-        cin >> filename;
-        Log() << Verbose(1) << "Storing temperatures in " << filename << "." << endl;
-        ofstream *output = new ofstream(filename, ios::trunc);
-        if (!mol->OutputTemperatureFromTrajectories(output, 0, mol->MDSteps))
-          Log() << Verbose(2) << "File could not be written." << endl;
-        else
-          Log() << Verbose(2) << "File stored." << endl;
-        output->close();
-        delete(output);
-      }
-      break;
-    case 'h':
-      {
-        int Z1;
-        cout << "Please enter first interface element: ";
-        cin >> Z1;
-        const element * InterfaceElement = World::getInstance().getPeriode()->FindElement(Z1);
-        int Z2;
-        cout << "Please enter second interface element: ";
-        cin >> Z2;
-        const element * InterfaceElement2 = World::getInstance().getPeriode()->FindElement(Z2);
-        cout << endl << "There are " << CountHydrogenBridgeBonds(World::getInstance().getMolecules(), InterfaceElement, InterfaceElement2) << " hydrogen bridges with connections to " << (InterfaceElement != 0 ? InterfaceElement->name : "None") << " and " << (InterfaceElement2 != 0 ? InterfaceElement2->name : "None") << "." << endl;
-      }
-      break;
-  }
-};
-
-/** Submenu for measuring out the atoms in the molecule.
- * \param *mol molecule with all the atoms
- * \param *configuration configuration structure for the to be written config files of all fragments
- */
-void oldmenu::FragmentAtoms(molecule *mol, config *configuration)
-{
-  int Order1;
-  std::string path;
-  clock_t start, end;
-
-  Log() << Verbose(0) << "Fragmenting molecule with current connection matrix ..." << endl;
-  Log() << Verbose(0) << "What's the desired bond order: ";
-  cin >> Order1;
-  DoLog(0) && (Log() << Verbose(0) << "What's the output path and prefix [e.g. /home/foo/BondFragment]: ");
-  cin >> path;
-  if (mol->hasBondStructure()) {
-    start = clock();
-    mol->FragmentMolecule(Order1, path);
-    end = clock();
-    Log() << Verbose(0) << "Clocks for this operation: " << (end-start) << ", time: " << ((double)(end-start)/CLOCKS_PER_SEC) << "s." << endl;
-  } else
-    Log() << Verbose(0) << "Connection matrix has not yet been generated!" << endl;
-};
-
-/********************************************** Submenu routine **************************************/
-
-/** Submenu for manipulating atoms.
- * \param *periode periodentafel
- * \param *molecules list of molecules whose atoms are to be manipulated
- */
-void oldmenu::ManipulateAtoms(periodentafel *periode, MoleculeListClass *molecules, config *configuration)
-{
-  atom *first, *second;
-  molecule *mol = NULL;
-  Vector x,y,z,n; // coordinates for absolute point in cell volume
-  double *factor; // unit factor if desired
-  double bond, minBond;
-  char choice;  // menu choice char
-  bool valid;
-
-  Log() << Verbose(0) << "=========MANIPULATE ATOMS======================" << endl;
-  Log() << Verbose(0) << "a - add an atom" << endl;
-  Log() << Verbose(0) << "r - remove an atom" << endl;
-  Log() << Verbose(0) << "b - scale a bond between atoms" << endl;
-  Log() << Verbose(0) << "u - change an atoms element" << endl;
-  Log() << Verbose(0) << "l - measure lengths, angles, ... for an atom" << endl;
-  Log() << Verbose(0) << "all else - go back" << endl;
-  Log() << Verbose(0) << "===============================================" << endl;
-  if (molecules->NumberOfActiveMolecules() > 1)
-    eLog() << Verbose(2) << "There is more than one molecule active! Atoms will be added to each." << endl;
-  Log() << Verbose(0) << "INPUT: ";
-  cin >> choice;
-
-  switch (choice) {
-    default:
-      Log() << Verbose(0) << "Not a valid choice." << endl;
-      break;
-
-    case 'a': // add atom
-      for (MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++)
-        if ((*ListRunner)->ActiveFlag) {
-        mol = *ListRunner;
-        Log() << Verbose(0) << "Current molecule is: " << mol->IndexNr << "\t" << mol->name << endl;
-        AddAtoms(periode, mol);
-      }
-      break;
-
-    case 'b': // scale a bond
-      for (MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++)
-        if ((*ListRunner)->ActiveFlag) {
-        mol = *ListRunner;
-        Log() << Verbose(0) << "Current molecule is: " << mol->IndexNr << "\t" << mol->name << endl;
-        Log() << Verbose(0) << "Scaling bond length between two atoms." << endl;
-        first = mol->AskAtom("Enter first (fixed) atom: ");
-        second = mol->AskAtom("Enter second (shifting) atom: ");
-        minBond = 0.;
-        for (int i=NDIM;i--;)
-          minBond += (first->x[i]-second->x[i])*(first->x[i] - second->x[i]);
-        minBond = sqrt(minBond);
-        Log() << Verbose(0) << "Current Bond length between " << first->type->name << " Atom " << first->nr << " and " << second->type->name << " Atom " << second->nr << ": " << minBond << " a.u." << endl;
-        Log() << Verbose(0) << "Enter new bond length [a.u.]: ";
-        cin >> bond;
-        for (int i=NDIM;i--;) {
-          second->x[i] -= (second->x[i]-first->x[i])/minBond*(minBond-bond);
-        }
-        //Log() << Verbose(0) << "New coordinates of Atom " << second->nr << " are: ";
-        //second->Output(second->type->No, 1);
-      }
-      break;
-
-    case 'c': // unit scaling of the metric
-      for (MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++)
-        if ((*ListRunner)->ActiveFlag) {
-        mol = *ListRunner;
-        Log() << Verbose(0) << "Current molecule is: " << mol->IndexNr << "\t" << mol->name << endl;
-       Log() << Verbose(0) << "Angstroem -> Bohrradius: 1.8897261\t\tBohrradius -> Angstroem: 0.52917721" << endl;
-       Log() << Verbose(0) << "Enter three factors: ";
-       factor = new double[NDIM];
-       cin >> factor[0];
-       cin >> factor[1];
-       cin >> factor[2];
-       valid = true;
-       mol->Scale((const double ** const)&factor);
-       delete[](factor);
-      }
-     break;
-
-    case 'l': // measure distances or angles
-      for (MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++)
-        if ((*ListRunner)->ActiveFlag) {
-        mol = *ListRunner;
-        Log() << Verbose(0) << "Current molecule is: " << mol->IndexNr << "\t" << mol->name << endl;
-        MeasureAtoms(periode, mol, configuration);
-      }
-      break;
-
-    case 'r': // remove atom
-      for (MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++)
-        if ((*ListRunner)->ActiveFlag) {
-        mol = *ListRunner;
-        Log() << Verbose(0) << "Current molecule is: " << mol->IndexNr << "\t" << mol->name << endl;
-        RemoveAtoms(mol);
-      }
-      break;
-
-    case 'u': // change an atom's element
-      for (MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++)
-        if ((*ListRunner)->ActiveFlag) {
-        int Z;
-        mol = *ListRunner;
-        Log() << Verbose(0) << "Current molecule is: " << mol->IndexNr << "\t" << mol->name << endl;
-        first = NULL;
-        do {
-          Log() << Verbose(0) << "Change the element of which atom: ";
-          cin >> Z;
-        } while ((first = mol->FindAtom(Z)) == NULL);
-        Log() << Verbose(0) << "New element by atomic number Z: ";
-        cin >> Z;
-        first->setType(Z);
-        Log() << Verbose(0) << "Atom " << first->nr << "'s element is " << first->type->name << "." << endl;
-      }
-      break;
-  }
-};
-
-void oldmenu::duplicateCell(MoleculeListClass *molecules, config *configuration) {
-  molecule *mol = NULL;
-  int axis,faktor,count,j;
-  atom *first = NULL;
-  const element **Elements;
-  Vector x,y;
-  Vector **vectors;
-
-  for (MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++)
-    if ((*ListRunner)->ActiveFlag) {
-    mol = *ListRunner;
-    Log() << Verbose(0) << "Current molecule is: " << mol->IndexNr << "\t" << mol->name << endl;
-    Log() << Verbose(0) << "State the axis [(+-)123]: ";
-    cin >> axis;
-    Log() << Verbose(0) << "State the factor: ";
-    cin >> faktor;
-    if (mol->getAtomCount() != 0) {  // if there is more than none
-      count = mol->getAtomCount();  // is changed becausing of adding, thus has to be stored away beforehand
-      Elements = new const element *[count];
-      vectors = new Vector *[count];
-      j = 0;
-      for (molecule::const_iterator iter = mol->begin(); iter != mol->end(); ++iter) {
-        Elements[j] = (*iter)->type;
-        vectors[j] = &(*iter)->x;
-        j++;
-      }
-      if (count != j)
-        eLog() << Verbose(1) << "AtomCount " << count << " is not equal to number of atoms in molecule " << j << "!" << endl;
-      x.Zero();
-      y.Zero();
-      y[abs(axis)-1] = World::getInstance().getDomain()[(abs(axis) == 2) ? 2 : ((abs(axis) == 3) ? 5 : 0)] * abs(axis)/axis; // last term is for sign, first is for magnitude
-      for (int i=1;i<faktor;i++) {  // then add this list with respective translation factor times
-        x += y; // per factor one cell width further
-        for (int k=count;k--;) { // go through every atom of the original cell
-          first = World::getInstance().createAtom(); // create a new body
-          first->x = (*vectors[k]) + x;  // use coordinate of original atom
-          first->type = Elements[k];  // insert original element
-          mol->AddAtom(first);        // and add to the molecule (which increments ElementsInMolecule, AtomCount, ...)
-        }
-      }
-      if (mol->hasBondStructure())
-        mol->CreateAdjacencyList(mol->BondDistance, configuration->GetIsAngstroem(), &BondGraph::CovalentMinMaxDistance, NULL);
-      // free memory
-      delete[](Elements);
-      delete[](vectors);
-      // correct cell size
-      if (axis < 0) { // if sign was negative, we have to translate everything
-        x = y;
-        x.Scale(-(faktor-1));
-        mol->Translate(&x);
-      }
-      World::getInstance().getDomain()[(abs(axis) == 2) ? 2 : ((abs(axis) == 3) ? 5 : 0)] *= faktor;
-    }
-  }
-}
-
-/** Submenu for manipulating molecules.
- * \param *periode periodentafel
- * \param *molecules list of molecule to manipulate
- */
-void oldmenu::ManipulateMolecules(periodentafel *periode, MoleculeListClass *molecules, config *configuration)
-{
-  Vector x,y,z,n; // coordinates for absolute point in cell volume
-  char choice;  // menu choice char
-  molecule *mol = NULL;
-  MoleculeLeafClass *Subgraphs = NULL;
-
-  Log() << Verbose(0) << "=========MANIPULATE GLOBALLY===================" << endl;
-  Log() << Verbose(0) << "c - scale by unit transformation" << endl;
-  Log() << Verbose(0) << "d - duplicate molecule/periodic cell" << endl;
-  Log() << Verbose(0) << "f - fragment molecule many-body bond order style" << endl;
-  Log() << Verbose(0) << "g - center atoms in box" << endl;
-  Log() << Verbose(0) << "i - realign molecule" << endl;
-  Log() << Verbose(0) << "m - mirror all molecules" << endl;
-  Log() << Verbose(0) << "o - create connection matrix" << endl;
-  Log() << Verbose(0) << "t - translate molecule by vector" << endl;
-  Log() << Verbose(0) << "all else - go back" << endl;
-  Log() << Verbose(0) << "===============================================" << endl;
-  if (molecules->NumberOfActiveMolecules() > 1)
-    eLog() << Verbose(2) << "There is more than one molecule active! Atoms will be added to each." << endl;
-  Log() << Verbose(0) << "INPUT: ";
-  cin >> choice;
-
-  switch (choice) {
-    default:
-      Log() << Verbose(0) << "Not a valid choice." << endl;
-      break;
-
-    case 'd': // duplicate the periodic cell along a given axis, given times
-      duplicateCell(molecules, configuration);
-      break;
-
-    case 'f':
-      FragmentAtoms(mol, configuration);
-      break;
-
-    case 'g': // center the atoms
-      for (MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++)
-        if ((*ListRunner)->ActiveFlag) {
-        mol = *ListRunner;
-        Log() << Verbose(0) << "Current molecule is: " << mol->IndexNr << "\t" << mol->name << endl;
-        CenterAtoms(mol);
-      }
-      break;
-
-    case 'i': // align all atoms
-      for (MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++)
-        if ((*ListRunner)->ActiveFlag) {
-        mol = *ListRunner;
-        Log() << Verbose(0) << "Current molecule is: " << mol->IndexNr << "\t" << mol->name << endl;
-        AlignAtoms(periode, mol);
-      }
-      break;
-
-    case 'm': // mirror atoms along a given axis
-      for (MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++)
-        if ((*ListRunner)->ActiveFlag) {
-        mol = *ListRunner;
-        Log() << Verbose(0) << "Current molecule is: " << mol->IndexNr << "\t" << mol->name << endl;
-        MirrorAtoms(mol);
-      }
-      break;
-
-    case 'o': // create the connection matrix
-      for (MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++)
-        if ((*ListRunner)->ActiveFlag) {
-          mol = *ListRunner;
-          double bonddistance;
-          clock_t start,end;
-          Log() << Verbose(0) << "What's the maximum bond distance: ";
-          cin >> bonddistance;
-          start = clock();
-          mol->CreateAdjacencyList(bonddistance, configuration->GetIsAngstroem(), &BondGraph::CovalentMinMaxDistance, NULL);
-          end = clock();
-          Log() << Verbose(0) << "Clocks for this operation: " << (end-start) << ", time: " << ((double)(end-start)/CLOCKS_PER_SEC) << "s." << endl;
-        }
-      break;
-
-    case 't': // translate all atoms
-      for (MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++)
-        if ((*ListRunner)->ActiveFlag) {
-        mol = *ListRunner;
-        Log() << Verbose(0) << "Current molecule is: " << mol->IndexNr << "\t" << mol->name << endl;
-        Dialog *dialog = UIFactory::getInstance().makeDialog();
-        dialog->queryVector("Enter translation vector.",&x,World::getInstance().getDomain(),false);
-        if(dialog->display()){
-          mol->Center += x;
-        }
-        delete dialog;
-     }
-     break;
-  }
-  // Free all
-  if (Subgraphs != NULL) {  // free disconnected subgraph list of DFS analysis was performed
-    while (Subgraphs->next != NULL) {
-      Subgraphs = Subgraphs->next;
-      delete(Subgraphs->previous);
-    }
-    delete(Subgraphs);
-  }
-};
-
-
-void oldmenu::SimpleAddMolecules(MoleculeListClass *molecules) {
-  molecule *srcmol = NULL, *destmol = NULL;
-  Dialog *dialog = UIFactory::getInstance().makeDialog();
-  dialog->queryMolecule("molecule-by-id",&destmol, MapOfActions::getInstance().getDescription("molecule-by-id"));
-  dialog->queryMolecule("molecule-by-id",&srcmol, MapOfActions::getInstance().getDescription("molecule-by-id"));
-  if(dialog->display()) {
-    molecules->SimpleAdd(srcmol, destmol);
-  }
-  else {
-    Log() << Verbose(0) << "Adding of molecules canceled" << endl;
-  }
-  delete dialog;
-}
-
-void oldmenu::embeddMolecules(MoleculeListClass *molecules) {
-  molecule *srcmol = NULL, *destmol = NULL;
-  Dialog *dialog = UIFactory::getInstance().makeDialog();
-  dialog->queryMolecule("molecule-by-id",&destmol, MapOfActions::getInstance().getDescription("molecule-by-id"));
-  dialog->queryMolecule("molecule-by-id",&srcmol, MapOfActions::getInstance().getDescription("molecule-by-id"));
-  if(dialog->display()) {
-    molecules->EmbedMerge(destmol, srcmol);
-  }
-  else {
-    Log() << Verbose(0) << "embedding of molecules canceled" << endl;
-  }
-
-
-}
-
-void oldmenu::multiMergeMolecules(MoleculeListClass *molecules) {
-  int nr;
-  molecule *mol = NULL;
-  do {
-    Log() << Verbose(0) << "Enter index of molecule to merge into: ";
-    cin >> nr;
-    mol = molecules->ReturnIndex(nr);
-  } while ((mol == NULL) && (nr != -1));
-  if (nr != -1) {
-    int N = molecules->ListOfMolecules.size()-1;
-    int *src = new int(N);
-    for(MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++)
-      if ((*ListRunner)->IndexNr != nr)
-        src[N++] = (*ListRunner)->IndexNr;
-    molecules->SimpleMultiMerge(mol, src, N);
-    delete[](src);
-  }
-}
-
-void oldmenu::simpleMergeMolecules(MoleculeListClass *molecules) {
-  int src, dest;
-  molecule *srcmol = NULL, *destmol = NULL;
-  {
-    do {
-      Log() << Verbose(0) << "Enter index of destination molecule: ";
-      cin >> dest;
-      destmol = molecules->ReturnIndex(dest);
-    } while ((destmol == NULL) && (dest != -1));
-    do {
-      Log() << Verbose(0) << "Enter index of source molecule to merge into: ";
-      cin >> src;
-      srcmol = molecules->ReturnIndex(src);
-    } while ((srcmol == NULL) && (src != -1));
-    if ((src != -1) && (dest != -1))
-      molecules->SimpleMerge(srcmol, destmol);
-  }
-}
-
-/** Submenu for merging molecules.
- * \param *periode periodentafel
- * \param *molecules list of molecules to add to
- */
-void oldmenu::MergeMolecules(periodentafel *periode, MoleculeListClass *molecules)
-{
-  TextMenu *MergeMoleculesMenu = new TextMenu(Log() << Verbose(0), "Merge Molecules");
-
-  Action *simpleAddAction = new MethodAction("simpleAddAction",boost::bind(&oldmenu::SimpleAddMolecules,this,molecules),false);
-  new ActionMenuItem('a',"simple add of one molecule to another",MergeMoleculesMenu,simpleAddAction);
-
-  Action *embeddAction = new MethodAction("embeddAction",boost::bind(&oldmenu::embeddMolecules,this,molecules),false);
-  new ActionMenuItem('e',"embedding merge of two molecules",MergeMoleculesMenu,embeddAction);
-
-  Action *multiMergeAction = new MethodAction("multiMergeAction",boost::bind(&oldmenu::multiMergeMolecules,this,molecules),false);
-  new ActionMenuItem('m',"multi-merge of all molecules",MergeMoleculesMenu,multiMergeAction);
-
-  Action *scatterMergeAction = new ErrorAction("scatterMergeAction","Not Implemented yet",false);
-  new ActionMenuItem('s',"scatter merge of two molecules",MergeMoleculesMenu,scatterMergeAction);
-
-  Action *simpleMergeAction = new MethodAction("simpleMergeAction",boost::bind(&oldmenu::simpleMergeMolecules,this,molecules),false);
-  new ActionMenuItem('t',"simple merge of two molecules",MergeMoleculesMenu,simpleMergeAction);
-
-  Action *returnAction = new MethodAction("returnAction",boost::bind(&TextMenu::doQuit,MergeMoleculesMenu),false);
-  MenuItem *returnItem = new ActionMenuItem('q',"return to Main menu",MergeMoleculesMenu,returnAction);
-
-  MergeMoleculesMenu->addDefault(returnItem);
-
-  MergeMoleculesMenu->display();
-};
-
-
-/********************************************** Test routine **************************************/
-
-/** Is called always as option 'T' in the menu.
- * \param *molecules list of molecules
- */
-void oldmenu::testroutine(MoleculeListClass *molecules)
-{
-  // the current test routine checks the functionality of the KeySet&Graph concept:
-  // We want to have a multiindex (the KeySet) describing a unique subgraph
-  int i, comp, counter=0;
-
-  // create a clone
-  molecule *mol = NULL;
-  if (molecules->ListOfMolecules.size() != 0) // clone
-    mol = (molecules->ListOfMolecules.front())->CopyMolecule();
-  else {
-    eLog() << Verbose(0) << "I don't have anything to test on ... ";
-    performCriticalExit();
-    return;
-  }
-
-  // generate some KeySets
-  Log() << Verbose(0) << "Generating KeySets." << endl;
-  KeySet TestSets[mol->getAtomCount()+1];
-  i=1;
-  for (molecule::const_iterator iter = mol->begin(); iter != mol->end(); ++iter) {
-    for (int j=0;j<i;j++) {
-      TestSets[j].insert((*iter)->nr);
-    }
-    i++;
-  }
-  Log() << Verbose(0) << "Testing insertion of already present item in KeySets." << endl;
-  KeySetTestPair test;
-  molecule::const_iterator iter = mol->begin();
-  if (iter != mol->end()) {
-    test = TestSets[mol->getAtomCount()-1].insert((*iter)->nr);
-    if (test.second) {
-      Log() << Verbose(1) << "Insertion worked?!" << endl;
-    } else {
-      Log() << Verbose(1) << "Insertion rejected: Present object is " << (*test.first) << "." << endl;
-    }
-  } else {
-    eLog() << Verbose(1) << "No atoms to test double insertion." << endl;
-  }
-
-  // constructing Graph structure
-  Log() << Verbose(0) << "Generating Subgraph class." << endl;
-  Graph Subgraphs;
-
-  // insert KeySets into Subgraphs
-  Log() << Verbose(0) << "Inserting KeySets into Subgraph class." << endl;
-  for (int j=0;j<mol->getAtomCount();j++) {
-    Subgraphs.insert(GraphPair (TestSets[j],pair<int, double>(counter++, 1.)));
-  }
-  Log() << Verbose(0) << "Testing insertion of already present item in Subgraph." << endl;
-  GraphTestPair test2;
-  test2 = Subgraphs.insert(GraphPair (TestSets[mol->getAtomCount()],pair<int, double>(counter++, 1.)));
-  if (test2.second) {
-    Log() << Verbose(1) << "Insertion worked?!" << endl;
-  } else {
-    Log() << Verbose(1) << "Insertion rejected: Present object is " << (*(test2.first)).second.first << "." << endl;
-  }
-
-  // show graphs
-  Log() << Verbose(0) << "Showing Subgraph's contents, checking that it's sorted." << endl;
-  Graph::iterator A = Subgraphs.begin();
-  while (A !=  Subgraphs.end()) {
-    Log() << Verbose(0) << (*A).second.first << ": ";
-    KeySet::iterator key = (*A).first.begin();
-    comp = -1;
-    while (key != (*A).first.end()) {
-      if ((*key) > comp)
-        Log() << Verbose(0) << (*key) << " ";
-      else
-        Log() << Verbose(0) << (*key) << "! ";
-      comp = (*key);
-      key++;
-    }
-    Log() << Verbose(0) << endl;
-    A++;
-  }
-  World::getInstance().destroyMolecule(mol);
-};
-
-oldmenu::oldmenu()
-{
-  // TODO Auto-generated constructor stub
-}
-
-oldmenu::~oldmenu()
-{
-  // TODO Auto-generated destructor stub
-}
Index: c/Legacy/oldmenu.hpp
===================================================================
--- src/Legacy/oldmenu.hpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ 	(revision )
@@ -1,46 +1,0 @@
-/** \file menu.hpp
- * The class in this file is responsible for displaying the menu and enabling choices.
- *
- * This class is currently being refactored. Functions were copied from builder.cpp and are
- * to be imported into the menu class.
- *
- */
-
-#ifndef MENU_H_
-#define MENU_H_
-
-
-class MoleculeListClass;
-class periodentafel;
-class config;
-class molecule;
-
-class oldmenu
-{
-public:
-  oldmenu();
-  virtual ~oldmenu();
-
-  // methods taken from ManipulateMoleculse submenu
-  void duplicateCell(MoleculeListClass *molecules, config *configuration);
-
-  // methods taken from MergeMolecules submenu
-  void SimpleAddMolecules(MoleculeListClass *molecules);
-  void embeddMolecules(MoleculeListClass *molecules);
-  void multiMergeMolecules(MoleculeListClass *molecules);
-  void simpleMergeMolecules(MoleculeListClass *molecules);
-
-  void AddAtoms(periodentafel *, molecule *);
-  void AlignAtoms(periodentafel *, molecule *);
-  void CenterAtoms(molecule *);
-  void FragmentAtoms(molecule *, config *);
-  void ManipulateAtoms(periodentafel *, MoleculeListClass *, config *);
-  void MeasureAtoms(periodentafel *, molecule *, config *);
-  void MergeMolecules(periodentafel *, MoleculeListClass *);
-  void ManipulateMolecules(periodentafel *, MoleculeListClass *, config *);
-  void MirrorAtoms(molecule *);
-  void RemoveAtoms(molecule *);
-  void testroutine(MoleculeListClass *);
-};
-
-#endif /* MENU_H_ */
Index: c/Line.cpp
===================================================================
--- src/Line.cpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ 	(revision )
@@ -1,222 +1,0 @@
-/*
- * Line.cpp
- *
- *  Created on: Apr 30, 2010
- *      Author: crueger
- */
-
-#include "Helpers/MemDebug.hpp"
-
-#include "Line.hpp"
-
-#include <cmath>
-
-#include "vector.hpp"
-#include "log.hpp"
-#include "verbose.hpp"
-#include "gslmatrix.hpp"
-#include "info.hpp"
-#include "Exceptions/LinearDependenceException.hpp"
-#include "Exceptions/SkewException.hpp"
-#include "Plane.hpp"
-
-using namespace std;
-
-Line::Line(const Vector &_origin, const Vector &_direction) :
-  direction(new Vector(_direction))
-{
-  direction->Normalize();
-  origin.reset(new Vector(_origin.partition(*direction).second));
-}
-
-Line::Line(const Line &src) :
-  origin(new Vector(*src.origin)),
-  direction(new Vector(*src.direction))
-{}
-
-Line::~Line()
-{}
-
-
-double Line::distance(const Vector &point) const{
-  // get any vector from line to point
-  Vector helper = point - *origin;
-  // partition this vector along direction
-  // the residue points from the line to the point
-  return helper.partition(*direction).second.Norm();
-}
-
-Vector Line::getClosestPoint(const Vector &point) const{
-  // get any vector from line to point
-  Vector helper = point - *origin;
-  // partition this vector along direction
-  // add only the part along the direction
-  return *origin + helper.partition(*direction).first;
-}
-
-Vector Line::getDirection() const{
-  return *direction;
-}
-
-Vector Line::getOrigin() const{
-  return *origin;
-}
-
-vector<Vector> Line::getPointsOnLine() const{
-  vector<Vector> res;
-  res.reserve(2);
-  res.push_back(*origin);
-  res.push_back(*origin+*direction);
-  return res;
-}
-
-/** Calculates the intersection of the two lines that are both on the same plane.
- * This is taken from Weisstein, Eric W. "Line-Line Intersection." From MathWorld--A Wolfram Web Resource. http://mathworld.wolfram.com/Line-LineIntersection.html
- * \param *out output stream for debugging
- * \param *Line1a first vector of first line
- * \param *Line1b second vector of first line
- * \param *Line2a first vector of second line
- * \param *Line2b second vector of second line
- * \return true - \a this will contain the intersection on return, false - lines are parallel
- */
-Vector Line::getIntersection(const Line& otherLine) const{
-  Info FunctionInfo(__func__);
-
-  pointset line1Points = getPointsOnLine();
-
-  Vector Line1a = line1Points[0];
-  Vector Line1b = line1Points[1];
-
-  pointset line2Points = otherLine.getPointsOnLine();
-
-  Vector Line2a = line2Points[0];
-  Vector Line2b = line2Points[1];
-
-  Vector res;
-
-  auto_ptr<GSLMatrix> M = auto_ptr<GSLMatrix>(new GSLMatrix(4,4));
-
-  M->SetAll(1.);
-  for (int i=0;i<3;i++) {
-    M->Set(0, i, Line1a[i]);
-    M->Set(1, i, Line1b[i]);
-    M->Set(2, i, Line2a[i]);
-    M->Set(3, i, Line2b[i]);
-  }
-
-  //Log() << Verbose(1) << "Coefficent matrix is:" << endl;
-  //for (int i=0;i<4;i++) {
-  //  for (int j=0;j<4;j++)
-  //    cout << "\t" << M->Get(i,j);
-  //  cout << endl;
-  //}
-  if (fabs(M->Determinant()) > MYEPSILON) {
-    Log() << Verbose(1) << "Determinant of coefficient matrix is NOT zero." << endl;
-    throw SkewException(__FILE__,__LINE__);
-  }
-
-  Log() << Verbose(1) << "INFO: Line1a = " << Line1a << ", Line1b = " << Line1b << ", Line2a = " << Line2a << ", Line2b = " << Line2b << "." << endl;
-
-
-  // constuct a,b,c
-  Vector a = Line1b - Line1a;
-  Vector b = Line2b - Line2a;
-  Vector c = Line2a - Line1a;
-  Vector d = Line2b - Line1b;
-  Log() << Verbose(1) << "INFO: a = " << a << ", b = " << b << ", c = " << c << "." << endl;
-  if ((a.NormSquared() < MYEPSILON) || (b.NormSquared() < MYEPSILON)) {
-   res.Zero();
-   Log() << Verbose(1) << "At least one of the lines is ill-defined, i.e. offset equals second vector." << endl;
-   throw LinearDependenceException(__FILE__,__LINE__);
-  }
-
-  // check for parallelity
-  Vector parallel;
-  double factor = 0.;
-  if (fabs(a.ScalarProduct(b)*a.ScalarProduct(b)/a.NormSquared()/b.NormSquared() - 1.) < MYEPSILON) {
-    parallel = Line1a - Line2a;
-    factor = parallel.ScalarProduct(a)/a.Norm();
-    if ((factor >= -MYEPSILON) && (factor - 1. < MYEPSILON)) {
-      res = Line2a;
-      Log() << Verbose(1) << "Lines conincide." << endl;
-      return res;
-    } else {
-      parallel = Line1a - Line2b;
-      factor = parallel.ScalarProduct(a)/a.Norm();
-      if ((factor >= -MYEPSILON) && (factor - 1. < MYEPSILON)) {
-        res = Line2b;
-        Log() << Verbose(1) << "Lines conincide." << endl;
-        return res;
-      }
-    }
-    Log() << Verbose(1) << "Lines are parallel." << endl;
-    res.Zero();
-    throw LinearDependenceException(__FILE__,__LINE__);
-  }
-
-  // obtain s
-  double s;
-  Vector temp1, temp2;
-  temp1 = c;
-  temp1.VectorProduct(b);
-  temp2 = a;
-  temp2.VectorProduct(b);
-  Log() << Verbose(1) << "INFO: temp1 = " << temp1 << ", temp2 = " << temp2 << "." << endl;
-  if (fabs(temp2.NormSquared()) > MYEPSILON)
-    s = temp1.ScalarProduct(temp2)/temp2.NormSquared();
-  else
-    s = 0.;
-  Log() << Verbose(1) << "Factor s is " << temp1.ScalarProduct(temp2) << "/" << temp2.NormSquared() << " = " << s << "." << endl;
-
-  // construct intersection
-  res = a;
-  res.Scale(s);
-  res += Line1a;
-  Log() << Verbose(1) << "Intersection is at " << res << "." << endl;
-
-  return res;
-}
-
-/** Rotates the vector by an angle of \a alpha around this line.
- * \param rhs Vector to rotate
- * \param alpha rotation angle in radian
- */
-Vector Line::rotateVector(const Vector &rhs, double alpha) const{
-  Vector helper = rhs;
-
-  // translate the coordinate system so that the line goes through (0,0,0)
-  helper -= *origin;
-
-  // partition the vector into a part that gets rotated and a part that lies along the line
-  pair<Vector,Vector> parts = helper.partition(*direction);
-
-  // we just keep anything that is along the axis
-  Vector res = parts.first;
-
-  // the rest has to be rotated
-  Vector a = parts.second;
-  // we only have to do the rest, if we actually could partition the vector
-  if(!a.IsZero()){
-    // construct a vector that is orthogonal to a and direction and has length |a|
-    Vector y = a;
-    // direction is normalized, so the result has length |a|
-    y.VectorProduct(*direction);
-
-    res += cos(alpha) * a + sin(alpha) * y;
-  }
-
-  // translate the coordinate system back
-  res += *origin;
-  return res;
-}
-
-Plane Line::getOrthogonalPlane(const Vector &origin) const{
-  return Plane(getDirection(),origin);
-}
-
-Line makeLineThrough(const Vector &x1, const Vector &x2){
-  if(x1==x2){
-    throw LinearDependenceException(__FILE__,__LINE__);
-  }
-  return Line(x1,x1-x2);
-}
Index: c/Line.hpp
===================================================================
--- src/Line.hpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ 	(revision )
@@ -1,50 +1,0 @@
-/*
- * Line.hpp
- *
- *  Created on: Apr 30, 2010
- *      Author: crueger
- */
-
-#ifndef LINE_HPP_
-#define LINE_HPP_
-
-#include "Space.hpp"
-
-#include <memory>
-#include <vector>
-
-class Vector;
-class Plane;
-
-class Line : public Space
-{
-public:
-  Line(const Vector &_origin, const Vector &_direction);
-  Line(const Line& _src);
-  virtual ~Line();
-
-  virtual double distance(const Vector &point) const;
-  virtual Vector getClosestPoint(const Vector &point) const;
-
-  Vector getDirection() const;
-  Vector getOrigin() const;
-
-  std::vector<Vector> getPointsOnLine() const;
-
-  Vector getIntersection(const Line& otherLine) const;
-
-  Vector rotateVector(const Vector &rhs, double alpha) const;
-
-  Plane getOrthogonalPlane(const Vector &origin) const;
-
-private:
-  std::auto_ptr<Vector> origin;
-  std::auto_ptr<Vector> direction;
-};
-
-/**
- * Named constructor to make a line through two points
- */
-Line makeLineThrough(const Vector &x1, const Vector &x2);
-
-#endif /* LINE_HPP_ */
Index: src/LinearAlgebra/Line.cpp
===================================================================
--- src/LinearAlgebra/Line.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
+++ src/LinearAlgebra/Line.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -0,0 +1,268 @@
+/*
+ * Line.cpp
+ *
+ *  Created on: Apr 30, 2010
+ *      Author: crueger
+ */
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "Helpers/MemDebug.hpp"
+
+#include "LinearAlgebra/Line.hpp"
+
+#include <cmath>
+#include <iostream>
+
+#include "LinearAlgebra/Vector.hpp"
+#include "Helpers/Log.hpp"
+#include "Helpers/Verbose.hpp"
+#include "LinearAlgebra/gslmatrix.hpp"
+#include "Helpers/Info.hpp"
+#include "Exceptions/LinearDependenceException.hpp"
+#include "Exceptions/SkewException.hpp"
+#include "LinearAlgebra/Plane.hpp"
+
+using namespace std;
+
+Line::Line(const Vector &_origin, const Vector &_direction) :
+  direction(new Vector(_direction))
+{
+  direction->Normalize();
+  origin.reset(new Vector(_origin.partition(*direction).second));
+}
+
+Line::Line(const Line &src) :
+  origin(new Vector(*src.origin)),
+  direction(new Vector(*src.direction))
+{}
+
+Line::~Line()
+{}
+
+
+double Line::distance(const Vector &point) const{
+  // get any vector from line to point
+  Vector helper = point - *origin;
+  // partition this vector along direction
+  // the residue points from the line to the point
+  return helper.partition(*direction).second.Norm();
+}
+
+Vector Line::getClosestPoint(const Vector &point) const{
+  // get any vector from line to point
+  Vector helper = point - *origin;
+  // partition this vector along direction
+  // add only the part along the direction
+  return *origin + helper.partition(*direction).first;
+}
+
+Vector Line::getDirection() const{
+  return *direction;
+}
+
+Vector Line::getOrigin() const{
+  return *origin;
+}
+
+vector<Vector> Line::getPointsOnLine() const{
+  vector<Vector> res;
+  res.reserve(2);
+  res.push_back(*origin);
+  res.push_back(*origin+*direction);
+  return res;
+}
+
+/** Calculates the intersection of the two lines that are both on the same plane.
+ * This is taken from Weisstein, Eric W. "Line-Line Intersection." From MathWorld--A Wolfram Web Resource. http://mathworld.wolfram.com/Line-LineIntersection.html
+ * \param *out output stream for debugging
+ * \param *Line1a first vector of first line
+ * \param *Line1b second vector of first line
+ * \param *Line2a first vector of second line
+ * \param *Line2b second vector of second line
+ * \return true - \a this will contain the intersection on return, false - lines are parallel
+ */
+Vector Line::getIntersection(const Line& otherLine) const{
+  Info FunctionInfo(__func__);
+
+  pointset line1Points = getPointsOnLine();
+
+  Vector Line1a = line1Points[0];
+  Vector Line1b = line1Points[1];
+
+  pointset line2Points = otherLine.getPointsOnLine();
+
+  Vector Line2a = line2Points[0];
+  Vector Line2b = line2Points[1];
+
+  Vector res;
+
+  auto_ptr<GSLMatrix> M = auto_ptr<GSLMatrix>(new GSLMatrix(4,4));
+
+  M->SetAll(1.);
+  for (int i=0;i<3;i++) {
+    M->Set(0, i, Line1a[i]);
+    M->Set(1, i, Line1b[i]);
+    M->Set(2, i, Line2a[i]);
+    M->Set(3, i, Line2b[i]);
+  }
+
+  //Log() << Verbose(1) << "Coefficent matrix is:" << endl;
+  //for (int i=0;i<4;i++) {
+  //  for (int j=0;j<4;j++)
+  //    cout << "\t" << M->Get(i,j);
+  //  cout << endl;
+  //}
+  if (fabs(M->Determinant()) > MYEPSILON) {
+    Log() << Verbose(1) << "Determinant of coefficient matrix is NOT zero." << endl;
+    throw SkewException(__FILE__,__LINE__);
+  }
+
+  Log() << Verbose(1) << "INFO: Line1a = " << Line1a << ", Line1b = " << Line1b << ", Line2a = " << Line2a << ", Line2b = " << Line2b << "." << endl;
+
+
+  // constuct a,b,c
+  Vector a = Line1b - Line1a;
+  Vector b = Line2b - Line2a;
+  Vector c = Line2a - Line1a;
+  Vector d = Line2b - Line1b;
+  Log() << Verbose(1) << "INFO: a = " << a << ", b = " << b << ", c = " << c << "." << endl;
+  if ((a.NormSquared() < MYEPSILON) || (b.NormSquared() < MYEPSILON)) {
+   res.Zero();
+   Log() << Verbose(1) << "At least one of the lines is ill-defined, i.e. offset equals second vector." << endl;
+   throw LinearDependenceException(__FILE__,__LINE__);
+  }
+
+  // check for parallelity
+  Vector parallel;
+  double factor = 0.;
+  if (fabs(a.ScalarProduct(b)*a.ScalarProduct(b)/a.NormSquared()/b.NormSquared() - 1.) < MYEPSILON) {
+    parallel = Line1a - Line2a;
+    factor = parallel.ScalarProduct(a)/a.Norm();
+    if ((factor >= -MYEPSILON) && (factor - 1. < MYEPSILON)) {
+      res = Line2a;
+      Log() << Verbose(1) << "Lines conincide." << endl;
+      return res;
+    } else {
+      parallel = Line1a - Line2b;
+      factor = parallel.ScalarProduct(a)/a.Norm();
+      if ((factor >= -MYEPSILON) && (factor - 1. < MYEPSILON)) {
+        res = Line2b;
+        Log() << Verbose(1) << "Lines conincide." << endl;
+        return res;
+      }
+    }
+    Log() << Verbose(1) << "Lines are parallel." << endl;
+    res.Zero();
+    throw LinearDependenceException(__FILE__,__LINE__);
+  }
+
+  // obtain s
+  double s;
+  Vector temp1, temp2;
+  temp1 = c;
+  temp1.VectorProduct(b);
+  temp2 = a;
+  temp2.VectorProduct(b);
+  Log() << Verbose(1) << "INFO: temp1 = " << temp1 << ", temp2 = " << temp2 << "." << endl;
+  if (fabs(temp2.NormSquared()) > MYEPSILON)
+    s = temp1.ScalarProduct(temp2)/temp2.NormSquared();
+  else
+    s = 0.;
+  Log() << Verbose(1) << "Factor s is " << temp1.ScalarProduct(temp2) << "/" << temp2.NormSquared() << " = " << s << "." << endl;
+
+  // construct intersection
+  res = a;
+  res.Scale(s);
+  res += Line1a;
+  Log() << Verbose(1) << "Intersection is at " << res << "." << endl;
+
+  return res;
+}
+
+/** Rotates the vector by an angle of \a alpha around this line.
+ * \param rhs Vector to rotate
+ * \param alpha rotation angle in radian
+ */
+Vector Line::rotateVector(const Vector &rhs, double alpha) const{
+  Vector helper = rhs;
+
+  // translate the coordinate system so that the line goes through (0,0,0)
+  helper -= *origin;
+
+  // partition the vector into a part that gets rotated and a part that lies along the line
+  pair<Vector,Vector> parts = helper.partition(*direction);
+
+  // we just keep anything that is along the axis
+  Vector res = parts.first;
+
+  // the rest has to be rotated
+  Vector a = parts.second;
+  // we only have to do the rest, if we actually could partition the vector
+  if(!a.IsZero()){
+    // construct a vector that is orthogonal to a and direction and has length |a|
+    Vector y = a;
+    // direction is normalized, so the result has length |a|
+    y.VectorProduct(*direction);
+
+    res += cos(alpha) * a + sin(alpha) * y;
+  }
+
+  // translate the coordinate system back
+  res += *origin;
+  return res;
+}
+
+Plane Line::getOrthogonalPlane(const Vector &origin) const{
+  return Plane(getDirection(),origin);
+}
+
+std::vector<Vector> Line::getSphereIntersections() const{
+  std::vector<Vector> res;
+
+  // line is kept in normalized form, so we can skip a lot of calculations
+  double discriminant = 1-origin->NormSquared();
+  // we might have 2, 1 or 0 solutions, depending on discriminant
+  if(discriminant>=0){
+    if(discriminant==0){
+      res.push_back(*origin);
+    }
+    else{
+      Vector helper = sqrt(discriminant)*(*direction);
+      res.push_back(*origin+helper);
+      res.push_back(*origin-helper);
+    }
+  }
+  return res;
+}
+
+Line makeLineThrough(const Vector &x1, const Vector &x2){
+  if(x1==x2){
+    throw LinearDependenceException(__FILE__,__LINE__);
+  }
+  return Line(x1,x1-x2);
+}
+
+ostream& operator<<(ostream& ost, const Line& m)
+{
+  const Vector origin = m.getOrigin();
+  const Vector direction = m.getDirection();
+  ost << "(";
+  for (int i=0;i<NDIM;i++) {
+    ost << origin[i];
+    if (i != 2)
+      ost << ",";
+  }
+  ost << ") -> (";
+  for (int i=0;i<NDIM;i++) {
+    ost << direction[i];
+    if (i != 2)
+      ost << ",";
+  }
+  ost << ")";
+  return ost;
+};
+
Index: src/LinearAlgebra/Line.hpp
===================================================================
--- src/LinearAlgebra/Line.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
+++ src/LinearAlgebra/Line.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -0,0 +1,55 @@
+/*
+ * Line.hpp
+ *
+ *  Created on: Apr 30, 2010
+ *      Author: crueger
+ */
+
+#ifndef LINE_HPP_
+#define LINE_HPP_
+
+#include "LinearAlgebra/Space.hpp"
+
+#include <iosfwd>
+#include <memory>
+#include <vector>
+
+class Vector;
+class Plane;
+
+class Line : public Space
+{
+public:
+  Line(const Vector &_origin, const Vector &_direction);
+  Line(const Line& _src);
+  virtual ~Line();
+
+  virtual double distance(const Vector &point) const;
+  virtual Vector getClosestPoint(const Vector &point) const;
+
+  Vector getDirection() const;
+  Vector getOrigin() const;
+
+  std::vector<Vector> getPointsOnLine() const;
+
+  Vector getIntersection(const Line& otherLine) const;
+
+  Vector rotateVector(const Vector &rhs, double alpha) const;
+
+  Plane getOrthogonalPlane(const Vector &origin) const;
+
+  std::vector<Vector> getSphereIntersections() const;
+
+private:
+  std::auto_ptr<Vector> origin;
+  std::auto_ptr<Vector> direction;
+};
+
+std::ostream & operator << (std::ostream& ost, const Line &m);
+
+/**
+ * Named constructor to make a line through two points
+ */
+Line makeLineThrough(const Vector &x1, const Vector &x2);
+
+#endif /* LINE_HPP_ */
Index: src/LinearAlgebra/Makefile.am
===================================================================
--- src/LinearAlgebra/Makefile.am	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
+++ src/LinearAlgebra/Makefile.am	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -0,0 +1,83 @@
+# PLEASE adhere to the alphabetical ordering in this Makefile!
+# Also indentation by a single tab
+
+INCLUDES = -I$(top_srcdir)/src
+
+AM_LDFLAGS = $(CPPUNIT_LIBS) -ldl
+# Position-Independent Code necessary for shared library
+AM_CXXFLAGS = $(CPPUNIT_CFLAGS)
+
+LINALGSOURCE = \
+  ${HELPERSOURCE} \
+  gslmatrix.cpp \
+  gslvector.cpp \
+  Line.cpp \
+  linearsystemofequations.cpp \
+  Matrix.cpp \
+  Plane.cpp \
+  Space.cpp \
+  vector_ops.cpp \
+  Vector.cpp \
+  VectorInterface.cpp
+			   
+LINALGHEADER = \
+  gslmatrix.hpp \
+  gslvector.hpp \
+  Line.hpp \
+  linearsystemofequations.hpp \
+  Matrix.hpp \
+  Plane.hpp \
+  Space.hpp \
+  vector_ops.hpp \
+  Vector.hpp \
+  VectorInterface.hpp
+
+
+lib_LTLIBRARIES = libMolecuilderLinearAlgebra-@MOLECUILDER_API_VERSION@.la
+libMolecuilderLinearAlgebra_includedir = $(includedir)/molecuilder-$(MOLECUILDER_API_VERSION)/Actions/
+libMolecuilderLinearAlgebra_libs = ../Exceptions/libMolecuilderExceptions-@MOLECUILDER_API_VERSION@.la $(GSL_LIBS)
+nobase_libMolecuilderLinearAlgebra_include_HEADERS = ${LINALGHEADER}
+
+## Define the source file list for the "libexample-@MOLECUILDER_API_VERSION@.la"
+## target.  Note that @MOLECUILDER_API_VERSION@ is not interpreted by Automake and
+## will therefore be treated as if it were literally part of the target name,
+## and the variable name derived from that.
+## The file extension .cc is recognized by Automake, and makes it produce
+## rules which invoke the C++ compiler to produce a libtool object file (.lo)
+## from each source file.  Note that it is not necessary to list header files
+## which are already listed elsewhere in a _HEADERS variable assignment.
+libMolecuilderLinearAlgebra_@MOLECUILDER_API_VERSION@_la_SOURCES = ${LINALGSOURCE}
+
+## Instruct libtool to include ABI version information in the generated shared
+## library file (.so).  The library ABI version is defined in configure.ac, so
+## that all version information is kept in one place.
+libMolecuilderLinearAlgebra_@MOLECUILDER_API_VERSION@_la_LDFLAGS = -version-info $(MOLECUILDER_SO_VERSION)
+
+## The generated configuration header is installed in its own subdirectory of
+## $(libdir).  The reason for this is that the configuration information put
+## into this header file describes the target platform the installed library
+## has been built for.  Thus the file must not be installed into a location
+## intended for architecture-independent files, as defined by the Filesystem
+## Hierarchy Standard (FHS).
+## The nodist_ prefix instructs Automake to not generate rules for including
+## the listed files in the distribution on 'make dist'.  Files that are listed
+## in _HEADERS variables are normally included in the distribution, but the
+## configuration header file is generated at configure time and should not be
+## shipped with the source tarball.
+libMolecuilderLinearAlgebra_libincludedir = $(libdir)/molecuilder-$(MOLECUILDER_API_VERSION)/include
+nodist_libMolecuilderLinearAlgebra_libinclude_HEADERS = $(top_builddir)/libmolecuilder_config.h
+
+## Install the generated pkg-config file (.pc) into the expected location for
+## architecture-dependent package configuration information.  Occasionally,
+## pkg-config files are also used for architecture-independent data packages,
+## in which case the correct install location would be $(datadir)/pkgconfig.
+pkgconfigdir = $(libdir)/pkgconfig
+pkgconfig_DATA = $(top_builddir)/molecuilder-$(MOLECUILDER_API_VERSION).pc
+
+unity.cpp:
+	echo "" >  unity.cpp; \
+	list='$(LINALGSOURCE)'; for file in $$list; do \
+	  echo "#include \"$(srcdir)/$$file\"" >> unity.cpp; \
+	done;
+	
+MOSTLYCLEANFILES = unity.cpp
Index: src/LinearAlgebra/Matrix.cpp
===================================================================
--- src/LinearAlgebra/Matrix.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
+++ src/LinearAlgebra/Matrix.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -0,0 +1,349 @@
+/*
+ * Matrix.cpp
+ *
+ *  Created on: Jun 25, 2010
+ *      Author: crueger
+ */
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "Helpers/MemDebug.hpp"
+
+#include "LinearAlgebra/Matrix.hpp"
+#include "Helpers/Assert.hpp"
+#include "Exceptions/NotInvertibleException.hpp"
+#include "Helpers/fast_functions.hpp"
+#include "Helpers/Assert.hpp"
+#include "LinearAlgebra/Vector.hpp"
+#include "VectorContent.hpp"
+#include "MatrixContent.hpp"
+
+#include <gsl/gsl_blas.h>
+#include <gsl/gsl_eigen.h>
+#include <gsl/gsl_matrix.h>
+#include <gsl/gsl_multimin.h>
+#include <gsl/gsl_vector.h>
+#include <cmath>
+#include <iostream>
+
+using namespace std;
+
+Matrix::Matrix()
+{
+  content = new MatrixContent();
+  content->content = gsl_matrix_calloc(NDIM, NDIM);
+  createViews();
+}
+
+Matrix::Matrix(const double* src){
+  content = new MatrixContent();
+  content->content = gsl_matrix_alloc(NDIM, NDIM);
+  set(0,0, src[0]);
+  set(1,0, src[1]);
+  set(2,0, src[2]);
+
+  set(0,1, src[3]);
+  set(1,1, src[4]);
+  set(2,1, src[5]);
+
+  set(0,2, src[6]);
+  set(1,2, src[7]);
+  set(2,2, src[8]);
+  createViews();
+}
+
+Matrix::Matrix(const Matrix &src){
+  content = new MatrixContent();
+  content->content = gsl_matrix_alloc(NDIM, NDIM);
+  gsl_matrix_memcpy(content->content,src.content->content);
+  createViews();
+}
+
+Matrix::Matrix(MatrixContent* _content) :
+  content(_content)
+{
+  createViews();
+}
+
+Matrix::~Matrix()
+{
+  // delete all views
+  for(int i=NDIM;i--;){
+    delete rows_ptr[i];
+  }
+  for(int i=NDIM;i--;){
+    delete columns_ptr[i];
+  }
+  delete diagonal_ptr;
+  gsl_matrix_free(content->content);
+  delete content;
+}
+
+void Matrix::createViews(){
+  // create row views
+  for(int i=NDIM;i--;){
+    VectorContent *rowContent = new VectorViewContent(gsl_matrix_row(content->content,i));
+    rows_ptr[i] = new Vector(rowContent);
+  }
+  // create column views
+  for(int i=NDIM;i--;){
+    VectorContent *columnContent = new VectorViewContent(gsl_matrix_column(content->content,i));
+    columns_ptr[i] = new Vector(columnContent);
+  }
+  // create diagonal view
+  VectorContent *diagonalContent = new VectorViewContent(gsl_matrix_diagonal(content->content));
+  diagonal_ptr = new Vector(diagonalContent);
+}
+
+void Matrix::one(){
+  for(int i=NDIM;i--;){
+    for(int j=NDIM;j--;){
+      set(i,j,i==j);
+    }
+  }
+}
+
+void Matrix::zero(){
+  for(int i=NDIM;i--;){
+    for(int j=NDIM;j--;){
+      set(i,j,0.);
+    }
+  }
+}
+
+void Matrix::rotation(const double x, const double y, const double z)
+{
+  set(0,0, cos(y)*cos(z));
+  set(0,1, cos(z)*sin(x)*sin(y) - cos(x)*sin(z));
+  set(0,2, cos(x)*cos(z)*sin(y) + sin(x) * sin(z));
+  set(1,0, cos(y)*sin(z));
+  set(1,1, cos(x)*cos(z) + sin(x)*sin(y)*sin(z));
+  set(1,2, -cos(z)*sin(x) + cos(x)*sin(y)*sin(z));
+  set(2,0, -sin(y));
+  set(2,1, cos(y)*sin(x));
+  set(2,2, cos(x)*cos(y));
+}
+
+Matrix &Matrix::operator=(const Matrix &src){
+  if(&src!=this){
+    gsl_matrix_memcpy(content->content,src.content->content);
+  }
+  return *this;
+}
+
+const Matrix &Matrix::operator+=(const Matrix &rhs){
+  gsl_matrix_add(content->content, rhs.content->content);
+  return *this;
+}
+
+const Matrix &Matrix::operator-=(const Matrix &rhs){
+  gsl_matrix_sub(content->content, rhs.content->content);
+  return *this;
+}
+
+const Matrix &Matrix::operator*=(const Matrix &rhs){
+  (*this) = (*this)*rhs;
+  return *this;
+}
+
+const Matrix Matrix::operator+(const Matrix &rhs) const{
+  Matrix tmp = *this;
+  tmp+=rhs;
+  return tmp;
+}
+
+const Matrix Matrix::operator-(const Matrix &rhs) const{
+  Matrix tmp = *this;
+  tmp-=rhs;
+  return tmp;
+}
+
+const Matrix Matrix::operator*(const Matrix &rhs) const{
+  gsl_matrix *res = gsl_matrix_alloc(NDIM, NDIM);
+  gsl_blas_dgemm(CblasNoTrans, CblasNoTrans, 1.0, content->content, rhs.content->content, 0.0, res);
+  MatrixContent *content= new MatrixContent();
+  content->content = res;
+  return Matrix(content);
+}
+
+double &Matrix::at(size_t i, size_t j){
+  ASSERT(i>=0&&i<NDIM,"Index i for Matrix access out of range");
+  ASSERT(j>=0&&j<NDIM,"Index j for Matrix access out of range");
+  return *gsl_matrix_ptr (content->content, i, j);
+}
+
+const double Matrix::at(size_t i, size_t j) const{
+  ASSERT(i>=0&&i<NDIM,"Index i for Matrix access out of range");
+  ASSERT(j>=0&&j<NDIM,"Index j for Matrix access out of range");
+  return gsl_matrix_get(content->content, i, j);
+}
+
+Vector &Matrix::row(size_t i){
+  ASSERT(i>=0&&i<NDIM,"Index i for Matrix access out of range");
+  return *rows_ptr[i];
+}
+
+const Vector &Matrix::row(size_t i) const{
+  ASSERT(i>=0&&i<NDIM,"Index i for Matrix access out of range");
+  return *rows_ptr[i];
+}
+
+Vector &Matrix::column(size_t i){
+  ASSERT(i>=0&&i<NDIM,"Index i for Matrix access out of range");
+  return *columns_ptr[i];
+}
+
+const Vector &Matrix::column(size_t i) const{
+  ASSERT(i>=0&&i<NDIM,"Index i for Matrix access out of range");
+  return *columns_ptr[i];
+}
+
+Vector &Matrix::diagonal(){
+  return *diagonal_ptr;
+}
+
+const Vector &Matrix::diagonal() const{
+  return *diagonal_ptr;
+}
+
+void Matrix::set(size_t i, size_t j, const double value){
+  ASSERT(i>=0&&i<NDIM,"Index i for Matrix access out of range");
+  ASSERT(j>=0&&j<NDIM,"Index j for Matrix access out of range");
+  gsl_matrix_set(content->content,i,j,value);
+}
+
+double Matrix::determinant() const{
+  return at(0,0)*at(1,1)*at(2,2)
+       + at(0,1)*at(1,2)*at(2,0)
+       + at(0,2)*at(1,0)*at(2,1)
+       - at(2,0)*at(1,1)*at(0,2)
+       - at(2,1)*at(1,2)*at(0,0)
+       - at(2,2)*at(1,0)*at(0,1);
+}
+
+Matrix Matrix::transpose() const
+{
+  Matrix copy(*this);
+  copy.transpose();
+  return copy;
+}
+
+
+Matrix &Matrix::transpose()
+{
+  double tmp;
+  for (int i=0;i<NDIM;i++)
+    for (int j=i+1;j<NDIM;j++) {
+      tmp = at(j,i);
+      at(j,i) = at(i,j);
+      at(i,j) = tmp;
+    }
+  return *this;
+}
+
+
+Matrix Matrix::invert() const{
+  double det = determinant();
+  if(fabs(det)<MYEPSILON){
+    throw NotInvertibleException(__FILE__,__LINE__);
+  }
+
+  double detReci = 1./det;
+  Matrix res;
+  res.set(0,0,  detReci*RDET2(at(1,1),at(2,1),at(1,2),at(2,2)));    // A_11
+  res.set(1,0, -detReci*RDET2(at(1,0),at(2,0),at(1,2),at(2,2)));    // A_21
+  res.set(2,0,  detReci*RDET2(at(1,0),at(2,0),at(1,1),at(2,1)));    // A_31
+  res.set(0,1, -detReci*RDET2(at(0,1),at(2,1),at(0,2),at(2,2)));    // A_12
+  res.set(1,1,  detReci*RDET2(at(0,0),at(2,0),at(0,2),at(2,2)));    // A_22
+  res.set(2,1, -detReci*RDET2(at(0,0),at(2,0),at(0,1),at(2,1)));    // A_32
+  res.set(0,2,  detReci*RDET2(at(0,1),at(1,1),at(0,2),at(1,2)));    // A_13
+  res.set(1,2, -detReci*RDET2(at(0,0),at(1,0),at(0,2),at(1,2)));    // A_23
+  res.set(2,2,  detReci*RDET2(at(0,0),at(1,0),at(0,1),at(1,1)));    // A_33
+  return res;
+}
+
+Vector Matrix::transformToEigenbasis()
+{
+  gsl_eigen_symmv_workspace *T = gsl_eigen_symmv_alloc(NDIM);
+  gsl_vector *eval = gsl_vector_alloc(NDIM);
+  gsl_matrix *evec = gsl_matrix_alloc(NDIM, NDIM);
+  gsl_eigen_symmv(content->content, eval, evec, T);
+  gsl_eigen_symmv_free(T);
+  gsl_matrix_memcpy(content->content, evec);
+  Vector evalues(gsl_vector_get(eval,0), gsl_vector_get(eval,1), gsl_vector_get(eval,2));
+  return evalues;
+}
+
+const Matrix &Matrix::operator*=(const double factor){
+  gsl_matrix_scale(content->content, factor);
+  return *this;
+}
+
+const Matrix operator*(const double factor,const Matrix& mat){
+  Matrix tmp = mat;
+  tmp*=factor;
+  return tmp;
+}
+
+const Matrix operator*(const Matrix &mat,const double factor){
+  return factor*mat;
+}
+
+bool Matrix::operator==(const Matrix &rhs) const{
+  for(int i=NDIM;i--;){
+    for(int j=NDIM;j--;){
+      if(fabs(at(i,j)-rhs.at(i,j))>MYEPSILON){
+        return false;
+      }
+    }
+  }
+  return true;
+}
+
+/** Blows the 6-dimensional \a cell_size array up to a full NDIM by NDIM matrix.
+ * \param *symm 6-dim array of unique symmetric matrix components
+ * \return allocated NDIM*NDIM array with the symmetric matrix
+ */
+Matrix ReturnFullMatrixforSymmetric(const double * const symm)
+{
+  Matrix matrix;
+  matrix.set(0,0, symm[0]);
+  matrix.set(1,0, symm[1]);
+  matrix.set(2,0, symm[3]);
+  matrix.set(0,1, symm[1]);
+  matrix.set(1,1, symm[2]);
+  matrix.set(2,1, symm[4]);
+  matrix.set(0,2, symm[3]);
+  matrix.set(1,2, symm[4]);
+  matrix.set(2,2, symm[5]);
+  return matrix;
+};
+
+ostream &operator<<(ostream &ost,const Matrix &mat){
+  for(int i = 0;i<NDIM;++i){
+    ost << "\n";
+    for(int j = 0; j<NDIM;++j){
+      ost << mat.at(i,j);
+      if(j!=NDIM-1)
+        ost << "; ";
+    }
+  }
+  return ost;
+}
+
+Vector operator*(const Matrix &mat,const Vector &vec){
+  gsl_vector *res = gsl_vector_calloc(NDIM);
+  gsl_blas_dgemv( CblasNoTrans, 1.0, mat.content->content, vec.content->content, 0.0, res);
+  VectorContent *content = new VectorContent();
+  content->content = res;
+  return Vector(content);
+}
+
+Vector &operator*=(Vector& lhs,const Matrix &mat){
+  lhs = mat*lhs;
+  return lhs;
+}
+
Index: src/LinearAlgebra/Matrix.hpp
===================================================================
--- src/LinearAlgebra/Matrix.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
+++ src/LinearAlgebra/Matrix.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -0,0 +1,172 @@
+/*
+ * Matrix.hpp
+ *
+ *  Created on: Jun 25, 2010
+ *      Author: crueger
+ */
+
+#ifndef MATRIX_HPP_
+#define MATRIX_HPP_
+
+#include <iosfwd>
+#include "defs.hpp"
+
+/**
+ * Simple class to store matrices with a few extra functions
+ */
+
+class Vector;
+class MatrixContent;
+
+class Matrix
+{
+  friend Vector operator*(const Matrix&,const Vector&);
+public:
+  Matrix();
+
+  /**
+   * construct a matrix from a 3x3 double array that contains all Elements.
+   *
+   * The elements are laid out in the following way:
+   * array -> matrix
+   * 0 -> (0,0)
+   * 1 -> (1,0)
+   * 2 -> (2,0)
+   * 3 -> (0,1)
+   * 4 -> (1,1)
+   * 5 -> (2,1)
+   * 6 -> (0,2)
+   * 7 -> (1,2)
+   * 8 -> (2,2)
+   *
+   */
+  Matrix(const double*);
+  Matrix(const Matrix&);
+  virtual ~Matrix();
+
+  /**
+   * Set the matrix to a unit matrix.
+   */
+  void one();
+
+  /**
+   * Set all matrix entries to zero.
+   */
+  void zero();
+
+  /**
+   * Sets all matrix corresponding to a rotation matrix,
+   * first around the x-, then the y-, finally the z-axis
+   * with given angles.
+   */
+  void rotation(const double x, const double y, const double z);
+
+  /**
+   * Access the matrix at index (i,j)
+   */
+  double &at(size_t i, size_t j);
+  /**
+   * Access the matrix at index (i,j)
+   */
+  const double at(size_t i, size_t j) const;
+
+  /**
+   * Set the matrix at index (i,j).
+   *
+   * Slightly faster than at(i,j)=x
+   */
+  void set(size_t i, size_t j, const double value);
+
+  /**
+   * get the ith row of the matrix as a vector
+   */
+  Vector &row(size_t);
+  const Vector &row(size_t) const;
+
+  /**
+   * get the ith column of the matrix as a vector
+   */
+  Vector &column(size_t);
+  const Vector &column(size_t) const;
+
+  /**
+   * get the diagonal of the matrix as a vector
+   */
+  Vector &diagonal();
+  const Vector &diagonal() const;
+
+  /**
+   * Calculate the determinant of the matrix
+   */
+  double determinant() const;
+
+  /**
+   * Calculate the inverse of the matrix.
+   *
+   * Rather costly, so use precomputation as often as possible.
+   */
+  Matrix invert() const;
+
+  /**
+   * Diagonalizes a matrix and sets its rows to the resulting eigenvalues.
+   * The eigenvalues are returned as a vector.
+   *
+   * Rather costly, so use precomputation as often as possible.
+   */
+  Vector transformToEigenbasis();
+
+  /**
+   * Calculate the transpose of the matrix.
+   */
+  Matrix transpose() const;
+  Matrix &transpose();
+
+  // operators
+  Matrix &operator=(const Matrix&);
+
+  const Matrix &operator+=(const Matrix&);
+  const Matrix &operator-=(const Matrix&);
+  const Matrix &operator*=(const Matrix&);
+
+  const Matrix &operator*=(const double);
+
+  const Matrix operator+(const Matrix&) const;
+  const Matrix operator-(const Matrix&) const;
+  const Matrix operator*(const Matrix&) const;
+
+  bool operator==(const Matrix&) const;
+
+private:
+  Matrix(MatrixContent*);
+  void createViews();
+  MatrixContent *content;
+  // we keep around some Vector views of the matrix, to return references
+  Vector* rows_ptr[NDIM];
+  Vector* columns_ptr[NDIM];
+  Vector* diagonal_ptr;
+};
+
+const Matrix operator*(const double,const Matrix&);
+const Matrix operator*(const Matrix&,const double);
+
+/**
+ * Takes a symmetric matrix that stores the lower diagonal and produces a
+ * full matrix.
+ *
+ * The array is laid out as follows:
+ *
+ * array -> matrix
+ * 0 -> (0,0)
+ * 1 -> (1,0);(0,1)
+ * 2 -> (1,1)
+ * 3 -> (2,0);(0,2)
+ * 4 -> (2,1);(1,2)
+ * 5 -> (2,2)
+ */
+Matrix ReturnFullMatrixforSymmetric(const double * const cell_size);
+
+std::ostream &operator<<(std::ostream&,const Matrix&);
+Vector operator*(const Matrix&,const Vector&);
+Vector& operator*=(Vector&,const Matrix&);
+
+#endif /* MATRIX_HPP_ */
Index: src/LinearAlgebra/MatrixContent.hpp
===================================================================
--- src/LinearAlgebra/MatrixContent.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
+++ src/LinearAlgebra/MatrixContent.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -0,0 +1,25 @@
+/*
+ * MatrixContent.hpp
+ *
+ *  Created on: Jul 2, 2010
+ *      Author: crueger
+ */
+
+#ifndef MATRIXCONTENT_HPP_
+#define MATRIXCONTENT_HPP_
+
+/**
+ * !file
+ * The way GSL works does not allow for forward definitions of the structures.
+ * Because of this the pointer to the gsl_matrix struct is wrapped inside another
+ * (dumb) object that allows for forward definitions. All methods of this class
+ * are empty, to allow for a maximum of flexibility.
+ */
+
+#include <gsl/gsl_matrix.h>
+
+struct MatrixContent{
+  gsl_matrix * content;
+};
+
+#endif /* MATRIXCONTENT_HPP_ */
Index: src/LinearAlgebra/Plane.cpp
===================================================================
--- src/LinearAlgebra/Plane.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
+++ src/LinearAlgebra/Plane.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -0,0 +1,217 @@
+/*
+ * Plane.cpp
+ *
+ *  Created on: Apr 7, 2010
+ *      Author: crueger
+ */
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "Helpers/MemDebug.hpp"
+
+#include "LinearAlgebra/Plane.hpp"
+#include "LinearAlgebra/Vector.hpp"
+#include "defs.hpp"
+#include "Helpers/Info.hpp"
+#include "Helpers/Log.hpp"
+#include "Helpers/Verbose.hpp"
+#include "Helpers/Assert.hpp"
+#include <cmath>
+#include "LinearAlgebra/Line.hpp"
+#include "Exceptions/MultipleSolutionsException.hpp"
+
+/**
+ * generates a plane from three given vectors defining three points in space
+ */
+Plane::Plane(const Vector &y1, const Vector &y2, const Vector &y3) throw(LinearDependenceException) :
+  normalVector(new Vector())
+{
+  Vector x1 = y1 -y2;
+  Vector x2 = y3 -y2;
+  if ((fabs(x1.Norm()) < MYEPSILON) || (fabs(x2.Norm()) < MYEPSILON) || (fabs(x1.Angle(x2)) < MYEPSILON)) {
+    throw LinearDependenceException(__FILE__,__LINE__);
+  }
+//  Log() << Verbose(4) << "relative, first plane coordinates:";
+//  x1.Output((ofstream *)&cout);
+//  Log() << Verbose(0) << endl;
+//  Log() << Verbose(4) << "second plane coordinates:";
+//  x2.Output((ofstream *)&cout);
+//  Log() << Verbose(0) << endl;
+
+  normalVector->at(0) = (x1[1]*x2[2] - x1[2]*x2[1]);
+  normalVector->at(1) = (x1[2]*x2[0] - x1[0]*x2[2]);
+  normalVector->at(2) = (x1[0]*x2[1] - x1[1]*x2[0]);
+  normalVector->Normalize();
+
+  offset=normalVector->ScalarProduct(y1);
+}
+/**
+ * Constructs a plane from two direction vectors and a offset.
+ */
+Plane::Plane(const Vector &y1, const Vector &y2, double _offset) throw(ZeroVectorException,LinearDependenceException) :
+    normalVector(new Vector()),
+    offset(_offset)
+{
+  Vector x1 = y1;
+  Vector x2 = y2;
+  if ((fabs(x1.Norm()) < MYEPSILON) || (fabs(x2.Norm()) < MYEPSILON)) {
+    throw ZeroVectorException(__FILE__,__LINE__);
+  }
+
+  if((fabs(x1.Angle(x2)) < MYEPSILON)) {
+    throw LinearDependenceException(__FILE__,__LINE__);
+  }
+//  Log() << Verbose(4) << "relative, first plane coordinates:";
+//  x1.Output((ofstream *)&cout);
+//  Log() << Verbose(0) << endl;
+//  Log() << Verbose(4) << "second plane coordinates:";
+//  x2.Output((ofstream *)&cout);
+//  Log() << Verbose(0) << endl;
+
+  normalVector->at(0) = (x1[1]*x2[2] - x1[2]*x2[1]);
+  normalVector->at(1) = (x1[2]*x2[0] - x1[0]*x2[2]);
+  normalVector->at(2) = (x1[0]*x2[1] - x1[1]*x2[0]);
+  normalVector->Normalize();
+}
+
+Plane::Plane(const Vector &_normalVector, double _offset) throw(ZeroVectorException):
+  normalVector(new Vector(_normalVector)),
+  offset(_offset)
+{
+  if(normalVector->IsZero())
+    throw ZeroVectorException(__FILE__,__LINE__);
+  double factor = 1/normalVector->Norm();
+  // normalize the plane parameters
+  (*normalVector)*=factor;
+  offset*=factor;
+}
+
+Plane::Plane(const Vector &_normalVector, const Vector &_offsetVector) throw(ZeroVectorException):
+    normalVector(new Vector(_normalVector))
+{
+  if(normalVector->IsZero()){
+    throw ZeroVectorException(__FILE__,__LINE__);
+  }
+  normalVector->Normalize();
+  offset = normalVector->ScalarProduct(_offsetVector);
+}
+
+/**
+ * copy constructor
+ */
+Plane::Plane(const Plane& plane) :
+  normalVector(new Vector(*plane.normalVector)),
+  offset(plane.offset)
+{}
+
+
+Plane::~Plane()
+{}
+
+
+Vector Plane::getNormal() const{
+  return *normalVector;
+}
+
+double Plane::getOffset() const{
+  return offset;
+}
+
+Vector Plane::getOffsetVector() const {
+  return getOffset()*getNormal();
+}
+
+vector<Vector> Plane::getPointsOnPlane() const{
+  std::vector<Vector> res;
+  res.reserve(3);
+  // first point on the plane
+  res.push_back(getOffsetVector());
+  // get a vector that has direction of plane
+  Vector direction;
+  direction.GetOneNormalVector(getNormal());
+  res.push_back(res[0]+direction);
+  // get an orthogonal vector to direction and normal (has direction of plane)
+  direction.VectorProduct(getNormal());
+  direction.Normalize();
+  res.push_back(res[0] +direction);
+  return res;
+}
+
+
+/** Calculates the intersection point between a line defined by \a *LineVector and \a *LineVector2 and a plane defined by \a *Normal and \a *PlaneOffset.
+ * According to [Bronstein] the vectorial plane equation is:
+ *   -# \f$\stackrel{r}{\rightarrow} \cdot \stackrel{N}{\rightarrow} + D = 0\f$,
+ * where \f$\stackrel{r}{\rightarrow}\f$ is the vector to be testet, \f$\stackrel{N}{\rightarrow}\f$ is the plane's normal vector and
+ * \f$D = - \stackrel{a}{\rightarrow} \stackrel{N}{\rightarrow}\f$, the offset with respect to origin, if \f$\stackrel{a}{\rightarrow}\f$,
+ * is an offset vector onto the plane. The line is parametrized by \f$\stackrel{x}{\rightarrow} + k \stackrel{t}{\rightarrow}\f$, where
+ * \f$\stackrel{x}{\rightarrow}\f$ is the offset and \f$\stackrel{t}{\rightarrow}\f$ the directional vector (NOTE: No need to normalize
+ * the latter). Inserting the parametrized form into the plane equation and solving for \f$k\f$, which we insert then into the parametrization
+ * of the line yields the intersection point on the plane.
+ * \param *Origin first vector of line
+ * \param *LineVector second vector of line
+ * \return true -  \a this contains intersection point on return, false - line is parallel to plane (even if in-plane)
+ */
+Vector Plane::GetIntersection(const Line& line) const
+{
+  Info FunctionInfo(__func__);
+  Vector res;
+
+  double factor1 = getNormal().ScalarProduct(line.getDirection());
+  if(fabs(factor1)<MYEPSILON){
+    // the plane is parallel... under all circumstances this is bad luck
+    // we no have either no or infinite solutions
+    if(isContained(line.getOrigin())){
+      throw MultipleSolutionsException<Vector>(__FILE__,__LINE__,line.getOrigin());
+    }
+    else{
+      throw LinearDependenceException(__FILE__,__LINE__);
+    }
+  }
+
+  double factor2 = getNormal().ScalarProduct(line.getOrigin());
+  double scaleFactor = (offset-factor2)/factor1;
+
+  res = line.getOrigin() + scaleFactor * line.getDirection();
+
+  // tests to make sure the resulting vector really is on plane and line
+  ASSERT(isContained(res),"Calculated line-Plane intersection does not lie on plane.");
+  ASSERT(line.isContained(res),"Calculated line-Plane intersection does not lie on line.");
+  return res;
+};
+
+Vector Plane::mirrorVector(const Vector &rhs) const {
+  Vector helper = getVectorToPoint(rhs);
+  // substract twice the Vector to the plane
+  return rhs+2*helper;
+}
+
+Line Plane::getOrthogonalLine(const Vector &origin) const{
+  return Line(origin,getNormal());
+}
+
+/************ Methods inherited from Space ****************/
+
+double Plane::distance(const Vector &point) const{
+  double res = point.ScalarProduct(*normalVector)-offset;
+  return fabs(res);
+}
+
+Vector Plane::getClosestPoint(const Vector &point) const{
+  double factor = point.ScalarProduct(*normalVector)-offset;
+  if(fabs(factor) < MYEPSILON){
+    // the point itself lies on the plane
+    return point;
+  }
+  Vector difference = factor * (*normalVector);
+  return (point - difference);
+}
+
+// Operators
+
+ostream &operator << (ostream &ost,const Plane &p){
+  ost << "<" << p.getNormal() << ";x> - " << p.getOffset() << "=0";
+  return ost;
+}
Index: src/LinearAlgebra/Plane.hpp
===================================================================
--- src/LinearAlgebra/Plane.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
+++ src/LinearAlgebra/Plane.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -0,0 +1,77 @@
+/*
+ * Plane.hpp
+ *
+ *  Created on: Apr 7, 2010
+ *      Author: crueger
+ */
+
+#ifndef PLANE_HPP_
+#define PLANE_HPP_
+
+#include <memory>
+#include <vector>
+#include <iosfwd>
+#include "LinearAlgebra/Space.hpp"
+#include "Exceptions/LinearDependenceException.hpp"
+#include "Exceptions/ZeroVectorException.hpp"
+
+class Vector;
+class Line;
+
+class Plane : public Space
+{
+  typedef std::auto_ptr<Vector> vec_ptr;
+public:
+  Plane(const Vector &y1, const Vector &y2, const Vector &y3) throw(LinearDependenceException);
+  Plane(const Vector &y1, const Vector &y2, double _offset) throw(ZeroVectorException,LinearDependenceException);
+  Plane(const Vector &_normalVector, double _offset)  throw(ZeroVectorException);
+  Plane(const Vector &_normalVector, const Vector &_offsetVector) throw(ZeroVectorException);
+  Plane(const Plane& plane);
+  virtual ~Plane();
+
+  // Accessor Functions
+  /**
+   * returns normal Vector for a plane
+   */
+  Vector getNormal() const;
+  /**
+   * returns the distance of the plane from the origin
+   */
+  double getOffset() const;
+  /**
+   * returns a vector that points on the plane.
+   * Same as getOffset()*getNormal();
+   */
+  Vector getOffsetVector() const;
+
+  /**
+   * returns three seperate points on this plane
+   */
+  std::vector<Vector> getPointsOnPlane() const;
+
+  // some calculations
+  Vector GetIntersection(const Line &Line) const;
+
+  Vector mirrorVector(const Vector &rhs) const;
+
+  /**
+   * get a Line that is orthogonal to this plane, going through a chosen
+   * point.
+   *
+   * The point does not have to lie on the plane itself.
+   */
+  Line getOrthogonalLine(const Vector &origin) const;
+
+  /****** Methods inherited from Space ***********/
+
+  virtual double distance(const Vector &point) const;
+  virtual Vector getClosestPoint(const Vector &point) const;
+
+private:
+  vec_ptr normalVector;
+  double offset;
+};
+
+std::ostream &operator<< (std::ostream &ost,const Plane& p);
+
+#endif /* PLANE_HPP_ */
Index: src/LinearAlgebra/Space.cpp
===================================================================
--- src/LinearAlgebra/Space.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
+++ src/LinearAlgebra/Space.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -0,0 +1,35 @@
+/*
+ * Space.cpp
+ *
+ *  Created on: Apr 30, 2010
+ *      Author: crueger
+ */
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "Helpers/MemDebug.hpp"
+
+#include "LinearAlgebra/Space.hpp"
+#include "LinearAlgebra/Vector.hpp"
+
+Space::Space()
+{}
+
+Space::~Space()
+{}
+
+bool Space::hasZero() const{
+  return isContained(zeroVec);
+}
+
+Vector Space::getVectorToPoint(const Vector &origin) const{
+  Vector support = getClosestPoint(origin);
+  return support-origin;
+}
+
+bool Space::isContained(const Vector &point) const{
+  return (distance(point)) < MYEPSILON;
+}
Index: src/LinearAlgebra/Space.hpp
===================================================================
--- src/LinearAlgebra/Space.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
+++ src/LinearAlgebra/Space.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -0,0 +1,52 @@
+/*
+ * Space.hpp
+ *
+ *  Created on: Apr 30, 2010
+ *      Author: crueger
+ */
+
+#ifndef SPACE_HPP_
+#define SPACE_HPP_
+
+class Vector;
+
+class Space
+{
+public:
+  Space();
+  virtual ~Space();
+
+  /**
+   * Calculates the distance between a Space and a Vector.
+   */
+  virtual double distance(const Vector &point) const=0;
+
+  /**
+   * get the closest point inside the space to another point
+   */
+  virtual Vector getClosestPoint(const Vector &point) const=0;
+
+  /**
+   * get the shortest Vector from a point to a Space.
+   *
+   * The Vector always points from the given Vector to the point in space
+   * returned by Plane::getClosestPoint().
+   */
+  virtual Vector getVectorToPoint(const Vector &point) const;
+
+  /**
+   * Test wether a point is contained in the space.
+   *
+   * returns true, when the point lies inside and false
+   * otherwise.
+   */
+  virtual bool isContained(const Vector &point) const;
+
+  /**
+   * Tests if this space contains the center of the coordinate system.
+   */
+  virtual bool hasZero() const;
+
+};
+
+#endif /* SPACE_HPP_ */
Index: src/LinearAlgebra/Vector.cpp
===================================================================
--- src/LinearAlgebra/Vector.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
+++ src/LinearAlgebra/Vector.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -0,0 +1,575 @@
+/** \file vector.cpp
+ *
+ * Function implementations for the class vector.
+ *
+ */
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "Helpers/MemDebug.hpp"
+
+#include "LinearAlgebra/Vector.hpp"
+#include "VectorContent.hpp"
+#include "Helpers/Verbose.hpp"
+#include "World.hpp"
+#include "Helpers/Assert.hpp"
+#include "Helpers/fast_functions.hpp"
+#include "Exceptions/MathException.hpp"
+
+#include <iostream>
+#include <gsl/gsl_blas.h>
+#include <gsl/gsl_vector.h>
+
+
+using namespace std;
+
+
+/************************************ Functions for class vector ************************************/
+
+/** Constructor of class vector.
+ */
+Vector::Vector()
+{
+  content = new VectorContent();
+};
+
+/**
+ * Copy constructor
+ */
+
+Vector::Vector(const Vector& src)
+{
+  content = new VectorContent();
+  gsl_vector_memcpy(content->content, src.content->content);
+}
+
+/** Constructor of class vector.
+ */
+Vector::Vector(const double x1, const double x2, const double x3)
+{
+  content = new VectorContent();
+  gsl_vector_set(content->content,0,x1);
+  gsl_vector_set(content->content,1,x2);
+  gsl_vector_set(content->content,2,x3);
+};
+
+/** Constructor of class vector.
+ */
+Vector::Vector(const double x[3])
+{
+  content = new VectorContent();
+  gsl_vector_set(content->content,0,x[0]);
+  gsl_vector_set(content->content,1,x[1]);
+  gsl_vector_set(content->content,2,x[2]);
+};
+
+Vector::Vector(VectorContent *_content) :
+  content(_content)
+{}
+
+/**
+ * Assignment operator
+ */
+Vector& Vector::operator=(const Vector& src){
+  // check for self assignment
+  if(&src!=this){
+    gsl_vector_memcpy(content->content, src.content->content);
+  }
+  return *this;
+}
+
+/** Desctructor of class vector.
+ */
+Vector::~Vector() {
+  delete content;
+};
+
+/** Calculates square of distance between this and another vector.
+ * \param *y array to second vector
+ * \return \f$| x - y |^2\f$
+ */
+double Vector::DistanceSquared(const Vector &y) const
+{
+  double res = 0.;
+  for (int i=NDIM;i--;)
+    res += (at(i)-y[i])*(at(i)-y[i]);
+  return (res);
+};
+
+/** Calculates distance between this and another vector.
+ * \param *y array to second vector
+ * \return \f$| x - y |\f$
+ */
+double Vector::distance(const Vector &y) const
+{
+  return (sqrt(DistanceSquared(y)));
+};
+
+size_t Vector::GreatestComponent() const
+{
+  int greatest = 0;
+  for (int i=1;i<NDIM;i++) {
+    if (at(i) > at(greatest))
+      greatest = i;
+  }
+  return greatest;
+}
+
+size_t Vector::SmallestComponent() const
+{
+  int smallest = 0;
+  for (int i=1;i<NDIM;i++) {
+    if (at(i) < at(smallest))
+      smallest = i;
+  }
+  return smallest;
+}
+
+
+Vector Vector::getClosestPoint(const Vector &point) const{
+  // the closest point to a single point space is always the single point itself
+  return *this;
+}
+
+/** Calculates scalar product between this and another vector.
+ * \param *y array to second vector
+ * \return \f$\langle x, y \rangle\f$
+ */
+double Vector::ScalarProduct(const Vector &y) const
+{
+  double res = 0.;
+  gsl_blas_ddot(content->content, y.content->content, &res);
+  return (res);
+};
+
+
+/** Calculates VectorProduct between this and another vector.
+ *  -# returns the Product in place of vector from which it was initiated
+ *  -# ATTENTION: Only three dim.
+ *  \param *y array to vector with which to calculate crossproduct
+ *  \return \f$ x \times y \f&
+ */
+void Vector::VectorProduct(const Vector &y)
+{
+  Vector tmp;
+  for(int i=NDIM;i--;)
+    tmp[i] = at((i+1)%NDIM)*y[(i+2)%NDIM] - at((i+2)%NDIM)*y[(i+1)%NDIM];
+  (*this) = tmp;
+};
+
+
+/** projects this vector onto plane defined by \a *y.
+ * \param *y normal vector of plane
+ * \return \f$\langle x, y \rangle\f$
+ */
+void Vector::ProjectOntoPlane(const Vector &y)
+{
+  Vector tmp;
+  tmp = y;
+  tmp.Normalize();
+  tmp.Scale(ScalarProduct(tmp));
+  *this -= tmp;
+};
+
+/** Calculates the minimum distance of this vector to the plane.
+ * \sa Vector::GetDistanceVectorToPlane()
+ * \param *out output stream for debugging
+ * \param *PlaneNormal normal of plane
+ * \param *PlaneOffset offset of plane
+ * \return distance to plane
+ */
+double Vector::DistanceToSpace(const Space &space) const
+{
+  return space.distance(*this);
+};
+
+/** Calculates the projection of a vector onto another \a *y.
+ * \param *y array to second vector
+ */
+void Vector::ProjectIt(const Vector &y)
+{
+  (*this) += (-ScalarProduct(y))*y;
+};
+
+/** Calculates the projection of a vector onto another \a *y.
+ * \param *y array to second vector
+ * \return Vector
+ */
+Vector Vector::Projection(const Vector &y) const
+{
+  Vector helper = y;
+  helper.Scale((ScalarProduct(y)/y.NormSquared()));
+
+  return helper;
+};
+
+/** Calculates norm of this vector.
+ * \return \f$|x|\f$
+ */
+double Vector::Norm() const
+{
+  return (sqrt(NormSquared()));
+};
+
+/** Calculates squared norm of this vector.
+ * \return \f$|x|^2\f$
+ */
+double Vector::NormSquared() const
+{
+  return (ScalarProduct(*this));
+};
+
+/** Normalizes this vector.
+ */
+void Vector::Normalize()
+{
+  double factor = Norm();
+  (*this) *= 1/factor;
+};
+
+/** Zeros all components of this vector.
+ */
+void Vector::Zero()
+{
+  at(0)=at(1)=at(2)=0;
+};
+
+/** Zeros all components of this vector.
+ */
+void Vector::One(const double one)
+{
+  at(0)=at(1)=at(2)=one;
+};
+
+/** Checks whether vector has all components zero.
+ * @return true - vector is zero, false - vector is not
+ */
+bool Vector::IsZero() const
+{
+  return (fabs(at(0))+fabs(at(1))+fabs(at(2)) < MYEPSILON);
+};
+
+/** Checks whether vector has length of 1.
+ * @return true - vector is normalized, false - vector is not
+ */
+bool Vector::IsOne() const
+{
+  return (fabs(Norm() - 1.) < MYEPSILON);
+};
+
+/** Checks whether vector is normal to \a *normal.
+ * @return true - vector is normalized, false - vector is not
+ */
+bool Vector::IsNormalTo(const Vector &normal) const
+{
+  if (ScalarProduct(normal) < MYEPSILON)
+    return true;
+  else
+    return false;
+};
+
+/** Checks whether vector is normal to \a *normal.
+ * @return true - vector is normalized, false - vector is not
+ */
+bool Vector::IsEqualTo(const Vector &a) const
+{
+  bool status = true;
+  for (int i=0;i<NDIM;i++) {
+    if (fabs(at(i) - a[i]) > MYEPSILON)
+      status = false;
+  }
+  return status;
+};
+
+/** Calculates the angle between this and another vector.
+ * \param *y array to second vector
+ * \return \f$\acos\bigl(frac{\langle x, y \rangle}{|x||y|}\bigr)\f$
+ */
+double Vector::Angle(const Vector &y) const
+{
+  double norm1 = Norm(), norm2 = y.Norm();
+  double angle = -1;
+  if ((fabs(norm1) > MYEPSILON) && (fabs(norm2) > MYEPSILON))
+    angle = this->ScalarProduct(y)/norm1/norm2;
+  // -1-MYEPSILON occured due to numerical imprecision, catch ...
+  //Log() << Verbose(2) << "INFO: acos(-1) = " << acos(-1) << ", acos(-1+MYEPSILON) = " << acos(-1+MYEPSILON) << ", acos(-1-MYEPSILON) = " << acos(-1-MYEPSILON) << "." << endl;
+  if (angle < -1)
+    angle = -1;
+  if (angle > 1)
+    angle = 1;
+  return acos(angle);
+};
+
+
+double& Vector::operator[](size_t i){
+  ASSERT(i<=NDIM && i>=0,"Vector Index out of Range");
+  return *gsl_vector_ptr (content->content, i);
+}
+
+const double& Vector::operator[](size_t i) const{
+  ASSERT(i<=NDIM && i>=0,"Vector Index out of Range");
+  return *gsl_vector_ptr (content->content, i);
+}
+
+double& Vector::at(size_t i){
+  return (*this)[i];
+}
+
+const double& Vector::at(size_t i) const{
+  return (*this)[i];
+}
+
+VectorContent* Vector::get(){
+  return content;
+}
+
+/** Compares vector \a to vector \a b component-wise.
+ * \param a base vector
+ * \param b vector components to add
+ * \return a == b
+ */
+bool Vector::operator==(const Vector& b) const
+{
+  return IsEqualTo(b);
+};
+
+bool Vector::operator!=(const Vector& b) const
+{
+  return !IsEqualTo(b);
+}
+
+/** Sums vector \a to this lhs component-wise.
+ * \param a base vector
+ * \param b vector components to add
+ * \return lhs + a
+ */
+const Vector& Vector::operator+=(const Vector& b)
+{
+  this->AddVector(b);
+  return *this;
+};
+
+/** Subtracts vector \a from this lhs component-wise.
+ * \param a base vector
+ * \param b vector components to add
+ * \return lhs - a
+ */
+const Vector& Vector::operator-=(const Vector& b)
+{
+  this->SubtractVector(b);
+  return *this;
+};
+
+/** factor each component of \a a times a double \a m.
+ * \param a base vector
+ * \param m factor
+ * \return lhs.x[i] * m
+ */
+const Vector& operator*=(Vector& a, const double m)
+{
+  a.Scale(m);
+  return a;
+};
+
+/** Sums two vectors \a  and \b component-wise.
+ * \param a first vector
+ * \param b second vector
+ * \return a + b
+ */
+Vector const Vector::operator+(const Vector& b) const
+{
+  Vector x = *this;
+  x.AddVector(b);
+  return x;
+};
+
+/** Subtracts vector \a from \b component-wise.
+ * \param a first vector
+ * \param b second vector
+ * \return a - b
+ */
+Vector const Vector::operator-(const Vector& b) const
+{
+  Vector x = *this;
+  x.SubtractVector(b);
+  return x;
+};
+
+/** Factors given vector \a a times \a m.
+ * \param a vector
+ * \param m factor
+ * \return m * a
+ */
+Vector const operator*(const Vector& a, const double m)
+{
+  Vector x(a);
+  x.Scale(m);
+  return x;
+};
+
+/** Factors given vector \a a times \a m.
+ * \param m factor
+ * \param a vector
+ * \return m * a
+ */
+Vector const operator*(const double m, const Vector& a )
+{
+  Vector x(a);
+  x.Scale(m);
+  return x;
+};
+
+ostream& operator<<(ostream& ost, const Vector& m)
+{
+  ost << "(";
+  for (int i=0;i<NDIM;i++) {
+    ost << m[i];
+    if (i != 2)
+      ost << ",";
+  }
+  ost << ")";
+  return ost;
+};
+
+
+void Vector::ScaleAll(const double *factor)
+{
+  for (int i=NDIM;i--;)
+    at(i) *= factor[i];
+};
+
+void Vector::ScaleAll(const Vector &factor){
+  gsl_vector_mul(content->content, factor.content->content);
+}
+
+
+void Vector::Scale(const double factor)
+{
+  gsl_vector_scale(content->content,factor);
+};
+
+std::pair<Vector,Vector> Vector::partition(const Vector &rhs) const{
+  double factor = ScalarProduct(rhs)/rhs.NormSquared();
+  Vector res= factor * rhs;
+  return make_pair(res,(*this)-res);
+}
+
+std::pair<pointset,Vector> Vector::partition(const pointset &points) const{
+  Vector helper = *this;
+  pointset res;
+  for(pointset::const_iterator iter=points.begin();iter!=points.end();++iter){
+    pair<Vector,Vector> currPart = helper.partition(*iter);
+    res.push_back(currPart.first);
+    helper = currPart.second;
+  }
+  return make_pair(res,helper);
+}
+
+/** Creates this vector as the b y *factors' components scaled linear combination of the given three.
+ * this vector = x1*factors[0] + x2* factors[1] + x3*factors[2]
+ * \param *x1 first vector
+ * \param *x2 second vector
+ * \param *x3 third vector
+ * \param *factors three-component vector with the factor for each given vector
+ */
+void Vector::LinearCombinationOfVectors(const Vector &x1, const Vector &x2, const Vector &x3, const double * const factors)
+{
+  (*this) = (factors[0]*x1) +
+            (factors[1]*x2) +
+            (factors[2]*x3);
+};
+
+/** Calculates orthonormal vector to one given vectors.
+ * Just subtracts the projection onto the given vector from this vector.
+ * The removed part of the vector is Vector::Projection()
+ * \param *x1 vector
+ * \return true - success, false - vector is zero
+ */
+bool Vector::MakeNormalTo(const Vector &y1)
+{
+  bool result = false;
+  double factor = y1.ScalarProduct(*this)/y1.NormSquared();
+  Vector x1 = factor * y1;
+  SubtractVector(x1);
+  for (int i=NDIM;i--;)
+    result = result || (fabs(at(i)) > MYEPSILON);
+
+  return result;
+};
+
+/** Creates this vector as one of the possible orthonormal ones to the given one.
+ * Just scan how many components of given *vector are unequal to zero and
+ * try to get the skp of both to be zero accordingly.
+ * \param *vector given vector
+ * \return true - success, false - failure (null vector given)
+ */
+bool Vector::GetOneNormalVector(const Vector &GivenVector)
+{
+  int Components[NDIM]; // contains indices of non-zero components
+  int Last = 0;   // count the number of non-zero entries in vector
+  int j;  // loop variables
+  double norm;
+
+  for (j=NDIM;j--;)
+    Components[j] = -1;
+
+  // in two component-systems we need to find the one position that is zero
+  int zeroPos = -1;
+  // find two components != 0
+  for (j=0;j<NDIM;j++){
+    if (fabs(GivenVector[j]) > MYEPSILON)
+      Components[Last++] = j;
+    else
+      // this our zero Position
+      zeroPos = j;
+  }
+
+  switch(Last) {
+    case 3:  // threecomponent system
+      // the position of the zero is arbitrary in three component systems
+      zeroPos = Components[2];
+    case 2:  // two component system
+      norm = sqrt(1./(GivenVector[Components[1]]*GivenVector[Components[1]]) + 1./(GivenVector[Components[0]]*GivenVector[Components[0]]));
+      at(zeroPos) = 0.;
+      // in skp both remaining parts shall become zero but with opposite sign and third is zero
+      at(Components[1]) = -1./GivenVector[Components[1]] / norm;
+      at(Components[0]) = 1./GivenVector[Components[0]] / norm;
+      return true;
+      break;
+    case 1: // one component system
+      // set sole non-zero component to 0, and one of the other zero component pendants to 1
+      at((Components[0]+2)%NDIM) = 0.;
+      at((Components[0]+1)%NDIM) = 1.;
+      at(Components[0]) = 0.;
+      return true;
+      break;
+    default:
+      return false;
+  }
+};
+
+/** Adds vector \a *y componentwise.
+ * \param *y vector
+ */
+void Vector::AddVector(const Vector &y)
+{
+  gsl_vector_add(content->content, y.content->content);
+}
+
+/** Adds vector \a *y componentwise.
+ * \param *y vector
+ */
+void Vector::SubtractVector(const Vector &y)
+{
+  gsl_vector_sub(content->content, y.content->content);
+}
+
+
+// some comonly used vectors
+const Vector zeroVec(0,0,0);
+const Vector e1(1,0,0);
+const Vector e2(0,1,0);
+const Vector e3(0,0,1);
Index: src/LinearAlgebra/Vector.hpp
===================================================================
--- src/LinearAlgebra/Vector.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
+++ src/LinearAlgebra/Vector.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -0,0 +1,120 @@
+#ifndef VECTOR_HPP_
+#define VECTOR_HPP_
+
+using namespace std;
+
+/*********************************************** includes ***********************************/
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <iosfwd>
+
+#include <memory>
+#include <vector>
+
+#include "defs.hpp"
+#include "LinearAlgebra/Space.hpp"
+
+/********************************************** declarations *******************************/
+
+class Vector;
+class Matrix;
+struct VectorContent;
+
+typedef std::vector<Vector> pointset;
+
+/** Single vector.
+ * basically, just a x[3] but with helpful functions
+ */
+class Vector : public Space{
+  friend Vector operator*(const Matrix&,const Vector&);
+  friend class Matrix;
+public:
+  Vector();
+  Vector(const double x1, const double x2, const double x3);
+  Vector(const double x[3]);
+  Vector(const Vector& src);
+  virtual ~Vector();
+
+  // Method implemented by forwarding to the Representation
+
+  double DistanceSquared(const Vector &y) const;
+  double DistanceToSpace(const Space& space) const;
+  double ScalarProduct(const Vector &y) const;
+  double Angle(const Vector &y) const;
+  bool IsZero() const;
+  bool IsOne() const;
+  bool IsNormalTo(const Vector &normal) const;
+  bool IsEqualTo(const Vector &a) const;
+
+  void AddVector(const Vector &y);
+  void SubtractVector(const Vector &y);
+  void VectorProduct(const Vector &y);
+  void ProjectOntoPlane(const Vector &y);
+  void ProjectIt(const Vector &y);
+  Vector Projection(const Vector &y) const;
+  void ScaleAll(const double *factor);
+  void ScaleAll(const Vector &factor);
+  void Scale(const double factor);
+  bool GetOneNormalVector(const Vector &x1);
+  bool MakeNormalTo(const Vector &y1);
+  std::pair<Vector,Vector> partition(const Vector&) const;
+  std::pair<pointset,Vector> partition(const pointset&) const;
+  size_t GreatestComponent() const;
+  size_t SmallestComponent() const;
+
+  // Accessors ussually come in pairs... and sometimes even more than that
+  double& operator[](size_t i);
+  const double& operator[](size_t i) const;
+  double& at(size_t i);
+  const double& at(size_t i) const;
+
+  // Assignment operator
+  Vector &operator=(const Vector& src);
+
+  // Access to internal structure
+  VectorContent* get();
+
+  // Methods that are derived directly from other methods
+  double Norm() const;
+  double NormSquared() const;
+  void Normalize();
+  void Zero();
+  void One(const double one);
+  void LinearCombinationOfVectors(const Vector &x1, const Vector &x2, const Vector &x3, const double * const factors);
+
+  // operators for mathematical operations
+  bool operator==(const Vector& b) const;
+  bool operator!=(const Vector& b) const;
+  const Vector& operator+=(const Vector& b);
+  const Vector& operator-=(const Vector& b);
+  Vector const operator+(const Vector& b) const;
+  Vector const operator-(const Vector& b) const;
+
+  // Methods inherited from Space
+  virtual double distance(const Vector &point) const;
+  virtual Vector getClosestPoint(const Vector &point) const;
+
+protected:
+
+private:
+  Vector(VectorContent *);
+  VectorContent *content;
+
+};
+
+// some commonly used and fixed vectors
+const extern Vector zeroVec;
+const extern Vector e1;
+const extern Vector e2;
+const extern Vector e3;
+
+ostream & operator << (ostream& ost, const Vector &m);
+const Vector& operator*=(Vector& a, const double m);
+Vector const operator*(const Vector& a, const double m);
+Vector const operator*(const double m, const Vector& a);
+
+#endif /*VECTOR_HPP_*/
Index: src/LinearAlgebra/VectorContent.hpp
===================================================================
--- src/LinearAlgebra/VectorContent.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
+++ src/LinearAlgebra/VectorContent.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -0,0 +1,51 @@
+/*
+ * VectorContent.hpp
+ *
+ *  Created on: Jul 2, 2010
+ *      Author: crueger
+ */
+
+#ifndef VECTORCONTENT_HPP_
+#define VECTORCONTENT_HPP_
+
+/**
+ * !file
+ * The way GSL works does not allow for forward definitions of the structures.
+ * Because of this the pointer to the gsl_vector struct is wrapped inside another
+ * (dumb) object that allows for forward definitions.
+ */
+
+#include <gsl/gsl_vector.h>
+
+struct BaseCase{};
+
+struct VectorContent{
+  VectorContent(){
+    content =  gsl_vector_calloc (NDIM);
+  }
+  VectorContent(BaseCase){
+
+  }
+  virtual ~VectorContent(){
+    if(content){
+      gsl_vector_free(content);
+      content = 0;
+    }
+  }
+  gsl_vector *content;
+};
+
+struct VectorViewContent : public VectorContent{
+  VectorViewContent(gsl_vector_view _view) :
+    VectorContent(BaseCase()),
+    view(_view)
+  {
+    content=&view.vector;
+  }
+  virtual ~VectorViewContent(){
+    content=0;
+  }
+  gsl_vector_view view;
+};
+
+#endif /* VECTORCONTENT_HPP_ */
Index: src/LinearAlgebra/VectorInterface.cpp
===================================================================
--- src/LinearAlgebra/VectorInterface.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
+++ src/LinearAlgebra/VectorInterface.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -0,0 +1,30 @@
+/*
+ * VectorInterface.cpp
+ *
+ *  Created on: Jul 29, 2010
+ *      Author: heber
+ */
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "Helpers/MemDebug.hpp"
+
+#include "VectorInterface.hpp"
+
+#include <iostream>
+#include "LinearAlgebra/Vector.hpp"
+
+
+/** Constructor of class VectorInterface.
+ */
+VectorInterface::VectorInterface()
+{};
+
+/** Destructor for class VectorInterface.
+ */
+VectorInterface::~VectorInterface()
+{};
+
Index: src/LinearAlgebra/VectorInterface.hpp
===================================================================
--- src/LinearAlgebra/VectorInterface.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
+++ src/LinearAlgebra/VectorInterface.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -0,0 +1,61 @@
+/*
+ * VectorInterface.hpp
+ *
+ *  Created on: Jul 29, 2010
+ *      Author: heber
+ */
+
+#ifndef VECTORINTERFACE_HPP_
+#define VECTORINTERFACE_HPP_
+
+#include <cstring>
+#include <iostream>
+
+class Vector;
+
+/** Contains all functions of the class Vector as virtual definitions, to give any
+ * class derived from it the interface of a Vector, i.e. Vector-like abilities
+ * (i.e. the scaffold design pattern).
+ */
+class VectorInterface  {
+public:
+
+  // Accessors ussually come in pairs... and sometimes even more than that
+  virtual const double& operator[](size_t i) const = 0;
+  virtual const double& at(size_t i) const = 0;
+  virtual void set(size_t i, const double value) = 0;
+  virtual const Vector& getPosition() const = 0;
+
+  // Assignment operator
+  virtual void setPosition(const Vector& _vector) = 0;
+
+  // operators for mathematical operations
+  virtual const VectorInterface& operator+=(const Vector& b) = 0;
+  virtual const VectorInterface& operator-=(const Vector& b) = 0;
+  virtual Vector const operator+(const Vector& b) const = 0;
+  virtual Vector const operator-(const Vector& b) const = 0;
+
+  virtual void Zero() = 0;
+  virtual void One(const double one) = 0;
+  virtual void LinearCombinationOfVectors(const Vector &x1, const Vector &x2, const Vector &x3, const double * const factors) = 0;
+
+  virtual double distance(const Vector &point) const = 0;
+  virtual double DistanceSquared(const Vector &y) const = 0;
+  virtual double distance(const VectorInterface &_atom) const = 0;
+  virtual double DistanceSquared(const VectorInterface &_atom) const = 0;
+
+  virtual void ScaleAll(const double *factor) = 0;
+  virtual void ScaleAll(const Vector &factor) = 0;
+  virtual void Scale(const double factor) = 0;
+
+  virtual std::ostream & operator << (std::ostream &ost) const = 0;
+
+protected:
+  /** Constructor and destructor are protected as VectorInterface should never
+   * be instantiated by itself but only as a derived class.
+   */
+  VectorInterface();
+  ~VectorInterface();
+};
+
+#endif /* VECTORINTERFACE_HPP_ */
Index: src/LinearAlgebra/VectorSet.hpp
===================================================================
--- src/LinearAlgebra/VectorSet.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
+++ src/LinearAlgebra/VectorSet.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -0,0 +1,70 @@
+/*
+ * VectorSet.hpp
+ *
+ *  Created on: Jun 2, 2010
+ *      Author: crueger
+ */
+
+#ifndef VECTORSET_HPP_
+#define VECTORSET_HPP_
+
+
+#include <functional>
+#include <algorithm>
+#include <limits>
+
+/**
+ * A simple mixin to give any STL conforming structure fast Vector abilities
+ *
+ * TODO: make this work for maps
+ */
+
+#include "LinearAlgebra/Vector.hpp"
+#include <list>
+
+// this tests, whether we actually have a Vector
+template <class V>
+struct is_vector{};
+
+template <>
+struct is_vector<Vector>{
+  typedef void wrong_type;
+};
+
+template <class Set>
+class VectorSet : public Set
+{
+  // when our set carries something besides a vector this will produce an error
+  typedef typename is_vector<typename Set::value_type>::wrong_type check_for_vector;
+public:
+  // typedefs for STL conforming structure
+  typedef typename Set::iterator iterator;
+  typedef typename Set::const_iterator const_iterator;
+
+  VectorSet(){}
+  virtual ~VectorSet(){}
+
+  /**
+   * translate all Vectors within this set by a specified amount
+   */
+  void translate(const Vector &translater){
+    // this is needed to allow template lookup
+    transform(this->begin(),this->end(),this->begin(),std::bind1st(std::plus<Vector>(),translater));
+  }
+
+  double minDistSquared(const Vector &point){
+    if(!this->size())
+      return std::numeric_limits<double>::infinity();
+    std::list<double> helper;
+    helper.resize(this->size());
+    transform(this->begin(),this->end(),
+              helper.begin(),
+              std::bind2nd(std::mem_fun_ref(&Vector::DistanceSquared),point));
+    return *min_element(helper.begin(),helper.end());
+  }
+};
+
+// allows simpler definition of VectorSets
+#define VECTORSET(container_type) VectorSet<container_type<Vector> >
+
+#endif /* VECTORSET_HPP_ */
Index: src/LinearAlgebra/gslmatrix.cpp
===================================================================
--- src/LinearAlgebra/gslmatrix.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
+++ src/LinearAlgebra/gslmatrix.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -0,0 +1,253 @@
+/*
+ * gslmatrix.cpp
+ *
+ *  Created on: Jan 8, 2010
+ *      Author: heber
+ */
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "Helpers/MemDebug.hpp"
+
+using namespace std;
+
+#include "LinearAlgebra/gslmatrix.hpp"
+#include "Helpers/helpers.hpp"
+#include "Helpers/fast_functions.hpp"
+
+#include <cassert>
+#include <gsl/gsl_linalg.h>
+
+/** Constructor of class GSLMatrix.
+ * Allocates GSL structures
+ * \param m dimension of matrix
+ */
+GSLMatrix::GSLMatrix(size_t m, size_t n) : rows(m), columns(n)
+{
+  matrix = gsl_matrix_calloc(rows, columns);
+};
+
+/** Copy constructor of class GSLMatrix.
+ * Allocates GSL structures and copies components from \a *src.
+ * \param *src source matrix
+ */
+GSLMatrix::GSLMatrix(const GSLMatrix * const src) : rows(src->rows), columns(src->columns)
+{
+  matrix = gsl_matrix_alloc(rows, columns);
+  gsl_matrix_memcpy (matrix, src->matrix);
+};
+
+/** Destructor of class GSLMatrix.
+ * Frees GSL structures
+ */
+GSLMatrix::~GSLMatrix()
+{
+  gsl_matrix_free(matrix);
+  rows = 0;
+  columns = 0;
+};
+
+/** Assignment operator.
+ * \param &rhs right hand side
+ * \return object itself
+ */
+GSLMatrix& GSLMatrix::operator=(const GSLMatrix& rhs)
+{
+  if (this == &rhs)   // not necessary here, but identity assignment check is generally a good idea
+    return *this;
+  assert(rows == rhs.rows && columns == rhs.columns && "Number of rows and columns do not match!");
+
+  gsl_matrix_memcpy (matrix, rhs.matrix);
+
+  return *this;
+};
+
+/* ============================ Accessing =============================== */
+/** This function sets the matrix from a double array.
+ * Creates a matrix view of the array and performs a memcopy.
+ * \param *x array of values (no dimension check is performed)
+ */
+void GSLMatrix::SetFromDoubleArray(double * x)
+{
+  gsl_matrix_view m = gsl_matrix_view_array (x, rows, columns);
+  gsl_matrix_memcpy (matrix, &m.matrix);
+};
+
+/** This function returns the i-th element of a matrix.
+ * If \a m or \a n lies outside the allowed range of 0 to GSLMatrix::dimension-1 then the error handler is invoked and 0 is returned.
+ * \param m row index
+ * \param n colum index
+ * \return (m,n)-th element of matrix
+ */
+double GSLMatrix::Get(size_t m, size_t n)
+{
+  return gsl_matrix_get (matrix, m, n);
+};
+
+/** This function sets the value of the \a m -th element of a matrix to \a x.
+ *  If \a m or \a n lies outside the allowed range of 0 to GSLMatrix::dimension-1 then the error handler is invoked.
+ * \param m row index
+ * \param m column index
+ * \param x value to set element (m,n) to
+ */
+void GSLMatrix::Set(size_t m, size_t n, double x)
+{
+  gsl_matrix_set (matrix, m, n, x);
+};
+
+/** These functions return a pointer to the \a m-th element of a matrix.
+ *  If \a m or \a n lies outside the allowed range of 0 to GSLMatrix::dimension-1 then the error handler is invoked and a null pointer is returned.
+ * \param m index
+ * \return pointer to \a m-th element
+ */
+double *GSLMatrix::Pointer(size_t m, size_t n)
+{
+  return gsl_matrix_ptr (matrix, m, n);
+};
+
+/** These functions return a constant pointer to the \a m-th element of a matrix.
+ *  If \a m or \a n lies outside the allowed range of 0 to GSLMatrix::dimension-1 then the error handler is invoked and a null pointer is returned.
+ * \param m index
+ * \return const pointer to \a m-th element
+ */
+const double *GSLMatrix::const_Pointer(size_t m, size_t n)
+{
+  return gsl_matrix_const_ptr (matrix, m, n);
+};
+
+/* ========================== Initializing =============================== */
+/** This function sets all the elements of the matrix to the value \a x.
+ * \param *x
+ */
+void GSLMatrix::SetAll(double x)
+{
+  gsl_matrix_set_all (matrix, x);
+};
+
+/** This function sets all the elements of the matrix to zero.
+ */
+void GSLMatrix::SetZero()
+{
+  gsl_matrix_set_zero (matrix);
+};
+
+/** This function sets the elements of the matrix to the corresponding elements of the identity matrix, \f$m(i,j) = \delta(i,j)\f$, i.e. a unit diagonal with all off-diagonal elements zero.
+ * This applies to both square and rectangular matrices.
+ */
+void GSLMatrix::SetIdentity()
+{
+  gsl_matrix_set_identity (matrix);
+};
+
+/* ====================== Exchanging elements ============================ */
+/** This function exchanges the \a i-th and \a j-th row of the matrix in-place.
+ * \param i i-th row to swap with ...
+ * \param j ... j-th row to swap against
+ */
+bool GSLMatrix::SwapRows(size_t i, size_t j)
+{
+  return (gsl_matrix_swap_rows (matrix, i, j) == GSL_SUCCESS);
+};
+
+/** This function exchanges the \a i-th and \a j-th column of the matrix in-place.
+ * \param i i-th column to swap with ...
+ * \param j ... j-th column to swap against
+ */
+bool GSLMatrix::SwapColumns(size_t i, size_t j)
+{
+  return (gsl_matrix_swap_columns (matrix, i, j) == GSL_SUCCESS);
+};
+
+/** This function exchanges the \a i-th row and \a j-th column of the matrix in-place.
+ * The matrix must be square for this operation to be possible.
+ * \param i i-th row to swap with ...
+ * \param j ... j-th column to swap against
+ */
+bool GSLMatrix::SwapRowColumn(size_t i, size_t j)
+{
+  assert (rows == columns && "The matrix must be square for swapping row against column to be possible.");
+  return (gsl_matrix_swap_rowcol (matrix, i, j) == GSL_SUCCESS);
+};
+
+/** This function transposes the matrix.
+ * Note that the function is extended to the non-square case, where the matrix is re-allocated and copied.
+ */
+bool GSLMatrix::Transpose()
+{
+  if (rows == columns)// if square, use GSL
+    return (gsl_matrix_transpose (matrix) == GSL_SUCCESS);
+  else { // otherwise we have to copy a bit
+    gsl_matrix *dest = gsl_matrix_alloc(columns, rows);
+    for (size_t i=0;i<rows; i++)
+      for (size_t j=0;j<columns;j++) {
+        gsl_matrix_set(dest, j,i, gsl_matrix_get(matrix, i,j) );
+      }
+    gsl_matrix_free(matrix);
+    matrix = dest;
+    flip(rows, columns);
+    return true;
+  }
+};
+
+/* ============================ Properties ============================== */
+/** Checks whether matrix' elements are strictly null.
+ * \return true - is null, false - else
+ */
+bool GSLMatrix::IsNull()
+{
+  return gsl_matrix_isnull (matrix);
+};
+
+/** Checks whether matrix' elements are strictly positive.
+ * \return true - is positive, false - else
+ */
+bool GSLMatrix::IsPositive()
+{
+  return gsl_matrix_ispos (matrix);
+};
+
+/** Checks whether matrix' elements are strictly negative.
+ * \return true - is negative, false - else
+ */
+bool GSLMatrix::IsNegative()
+{
+  return gsl_matrix_isneg (matrix);
+};
+
+/** Checks whether matrix' elements are strictly non-negative.
+ * \return true - is non-negative, false - else
+ */
+bool GSLMatrix::IsNonNegative()
+{
+  return gsl_matrix_isnonneg (matrix);
+};
+
+/** This function performs a Cholesky decomposition to determine whether matrix is positive definite.
+ * We check whether GSL returns GSL_EDOM as error, indicating that decomposition failed due to matrix not being positive-definite.
+ * \return true - matrix is positive-definite, false - else
+ */
+bool GSLMatrix::IsPositiveDefinite()
+{
+  if (rows != columns)  // only possible for square matrices.
+    return false;
+  else
+    return (gsl_linalg_cholesky_decomp (matrix) != GSL_EDOM);
+};
+
+
+/** Calculates the determinant of the matrix.
+ * if matrix is square, uses LU decomposition.
+ */
+double GSLMatrix::Determinant()
+{
+  int signum = 0;
+  assert (rows == columns && "Determinant can only be calculated for square matrices.");
+  gsl_permutation *p = gsl_permutation_alloc(rows);
+  gsl_linalg_LU_decomp(matrix, p, &signum);
+  gsl_permutation_free(p);
+  return gsl_linalg_LU_det(matrix, signum); 
+};
+
Index: src/LinearAlgebra/gslmatrix.hpp
===================================================================
--- src/LinearAlgebra/gslmatrix.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
+++ src/LinearAlgebra/gslmatrix.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -0,0 +1,70 @@
+/*
+ * gslmatrix.hpp
+ *
+ *  Created on: Jan 8, 2010
+ *      Author: heber
+ */
+
+#ifndef GSLMATRIX_HPP_
+#define GSLMATRIX_HPP_
+
+using namespace std;
+
+/*********************************************** includes ***********************************/
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <gsl/gsl_matrix.h>
+
+/****************************************** forward declarations *****************************/
+
+class GSLMatrix;
+
+/********************************************** declarations *******************************/
+
+class GSLMatrix {
+  friend class LinearSystemOfEquations;
+
+public:
+  GSLMatrix(size_t m, size_t n);
+  GSLMatrix(const GSLMatrix * const src);
+  ~GSLMatrix();
+
+  // Accessing
+  void SetFromDoubleArray(double * x);
+  double Get(size_t m, size_t n);
+  void Set(size_t m, size_t n, double x);
+  double *Pointer(size_t m, size_t n);
+  const double *const_Pointer(size_t m, size_t n);
+
+  // Initializing
+  void SetAll(double x);
+  void SetZero();
+  void SetIdentity();
+
+  // Exchanging elements
+  bool SwapRows(size_t i, size_t j);
+  bool SwapColumns(size_t i, size_t j);
+  bool SwapRowColumn(size_t i, size_t j);
+  bool Transpose();
+  bool IsNull();
+  bool IsPositive();
+  bool IsNegative();
+  bool IsNonNegative();
+  bool IsPositiveDefinite();
+  double Determinant();
+
+  GSLMatrix& operator=(const GSLMatrix& rhs);
+
+private:
+  gsl_matrix *matrix;
+
+  size_t rows;
+  size_t columns;
+};
+
+
+#endif /* GSLMATRIX_HPP_ */
Index: src/LinearAlgebra/gslvector.cpp
===================================================================
--- src/LinearAlgebra/gslvector.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
+++ src/LinearAlgebra/gslvector.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -0,0 +1,312 @@
+/*
+ * gslvector.cpp
+ *
+ *  Created on: Jan 8, 2010
+ *      Author: heber
+ */
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "Helpers/MemDebug.hpp"
+
+#include <cassert>
+#include <cmath>
+#include <iostream>
+
+#include "LinearAlgebra/gslvector.hpp"
+#include "defs.hpp"
+#include "LinearAlgebra/Vector.hpp"
+#include "VectorContent.hpp"
+
+/** Constructor of class GSLVector.
+ * Allocates GSL structures
+ * \param m dimension of vector
+ */
+GSLVector::GSLVector(size_t m) : dimension(m)
+{
+  vector = gsl_vector_calloc(dimension);
+};
+
+/** Copy constructor of class GSLVector.
+ * Allocates GSL structures and copies components from \a *src.
+ * \param *src source vector
+ */
+GSLVector::GSLVector(const GSLVector * const src) : dimension(src->dimension)
+{
+  vector = gsl_vector_alloc(dimension);
+  gsl_vector_memcpy (vector, src->vector);
+};
+
+/** Copy constructor of class GSLVector.
+ * Allocates GSL structures and copies components from \a *src.
+ * \param *src source vector
+ */
+GSLVector::GSLVector(const GSLVector & src) : dimension(src.dimension)
+{
+  vector = gsl_vector_alloc(dimension);
+  gsl_vector_memcpy (vector, src.vector);
+};
+
+/** Destructor of class GSLVector.
+ * Frees GSL structures
+ */
+GSLVector::~GSLVector()
+{
+  gsl_vector_free(vector);
+};
+
+/* ============================ Accessing =============================== */
+/** This function sets the vector from a double array.
+ * Creates a vector view of the array and performs a memcopy.
+ * \param *x array of values (no dimension check is performed)
+ */
+void GSLVector::SetFromDoubleArray(double * x)
+{
+  gsl_vector_view m = gsl_vector_view_array (x, dimension);
+  gsl_vector_memcpy (vector, &m.vector);
+};
+
+/**
+ * This function sets the GSLvector from an ordinary vector.
+ *
+ * Takes access to the internal gsl_vector and copies it
+ */
+void GSLVector::SetFromVector(Vector &v){
+  gsl_vector_memcpy (vector, v.get()->content);
+}
+
+/** This function returns the i-th element of a vector.
+ * If \a m lies outside the allowed range of 0 to GSLVector::dimension-1 then the error handler is invoked and 0 is returned.
+ * \param m m-th element
+ * \return  m-th element of vector
+ */
+double GSLVector::Get(size_t m) const
+{
+  return gsl_vector_get (vector, m);
+};
+
+/** This function sets the value of the \a m -th element of a vector to \a x.
+ *  If \a m lies outside the allowed range of 0 to GSLVector::dimension-1 then the error handler is invoked.
+ * \param m-th element to set
+ * \param x value to set to
+ */
+void GSLVector::Set(size_t m, double x)
+{
+  gsl_vector_set (vector, m, x);
+};
+
+/** These functions return a pointer to the \a m-th element of a vector.
+ *  If \a m lies outside the allowed range of 0 to GSLVector::dimension-1 then the error handler is invoked and a null pointer is returned.
+ * \param m m-th element
+ * \return pointer to \a m-th element
+ */
+double *GSLVector::Pointer(size_t m) const
+{
+  return gsl_vector_ptr (vector, m);
+};
+
+/** These functions return a constant pointer to the \a m-th element of a vector.
+ *  If \a m lies outside the allowed range of 0 to GSLVector::dimension-1 then the error handler is invoked and a null pointer is returned.
+ * \param m m-th element
+ * \return const pointer to \a m-th element
+ */
+const double *GSLVector::const_Pointer(size_t m) const
+{
+  return gsl_vector_const_ptr (vector, m);
+};
+
+/** Returns the dimension of the vector.
+ * \return dimension of vector
+ */
+#ifdef HAVE_INLINE
+inline
+#endif
+size_t GSLVector::GetDimension() const
+{
+  return dimension;
+};
+
+/* ========================== Initializing =============================== */
+/** This function sets all the elements of the vector to the value \a x.
+ * \param *x
+ */
+void GSLVector::SetAll(double x)
+{
+  gsl_vector_set_all (vector, x);
+};
+
+/** This function sets all the elements of the vector to zero.
+ */
+void GSLVector::SetZero()
+{
+  gsl_vector_set_zero (vector);
+};
+
+/** This function makes a basis vector by setting all the elements of the vector to zero except for the i-th element which is set to one.
+ * \param i i-th component to set to unity (all other to zero)
+ * \return vector set
+ */
+int GSLVector::SetBasis(size_t i)
+{
+  return gsl_vector_set_basis (vector, i);
+};
+
+/* ====================== Exchanging elements ============================ */
+/** This function exchanges the \a i-th and \a j-th elements of the vector in-place.
+ * \param i i-th element to swap with ...
+ * \param j ... j-th element to swap against
+ */
+int GSLVector::SwapElements(size_t i, size_t j)
+{
+  return gsl_vector_swap_elements (vector, i, j);
+};
+
+/** This function reverses the order of the elements of the vector.
+ */
+int GSLVector::Reverse()
+{
+  return gsl_vector_reverse (vector);
+};
+
+
+/* ========================== Operators =============================== */
+/** Compares GSLVector \a to GSLVector \a b component-wise.
+ * \param a base GSLVector
+ * \param b GSLVector components to add
+ * \return a == b
+ */
+bool operator==(const GSLVector& a, const GSLVector& b)
+{
+  bool status = true;
+  assert(a.GetDimension() == b.GetDimension() && "Dimenions of GSLVectors to compare differ");
+  for (size_t i=0;i<a.GetDimension();i++)
+    status = status && (fabs(a.Get(i) - b.Get(i)) < MYEPSILON);
+  return status;
+};
+
+/** Sums GSLVector \a to this lhs component-wise.
+ * \param a base GSLVector
+ * \param b GSLVector components to add
+ * \return lhs + a
+ */
+const GSLVector& operator+=(GSLVector& a, const GSLVector& b)
+{
+  assert(a.GetDimension() == b.GetDimension() && "Dimenions of GSLVectors to compare differ");
+  for (size_t i=0;i<a.GetDimension();i++)
+    a.Set(i,a.Get(i)+b.Get(i));
+  return a;
+};
+
+/** Subtracts GSLVector \a from this lhs component-wise.
+ * \param a base GSLVector
+ * \param b GSLVector components to add
+ * \return lhs - a
+ */
+const GSLVector& operator-=(GSLVector& a, const GSLVector& b)
+{
+  assert(a.GetDimension() == b.GetDimension() && "Dimenions of GSLVectors to compare differ");
+  for (size_t i=0;i<a.GetDimension();i++)
+    a.Set(i,a.Get(i)-b.Get(i));
+  return a;
+};
+
+/** factor each component of \a a times a double \a m.
+ * \param a base GSLVector
+ * \param m factor
+ * \return lhs.Get(i) * m
+ */
+const GSLVector& operator*=(GSLVector& a, const double m)
+{
+  for (size_t i=0;i<a.GetDimension();i++)
+    a.Set(i,a.Get(i)*m);
+  return a;
+};
+
+/** Sums two GSLVectors \a  and \b component-wise.
+ * \param a first GSLVector
+ * \param b second GSLVector
+ * \return a + b
+ */
+GSLVector const operator+(const GSLVector& a, const GSLVector& b)
+{
+  GSLVector x(a);
+  for (size_t i=0;i<a.GetDimension();i++)
+    x.Set(i,a.Get(i)+b.Get(i));
+  return x;
+};
+
+/** Subtracts GSLVector \a from \b component-wise.
+ * \param a first GSLVector
+ * \param b second GSLVector
+ * \return a - b
+ */
+GSLVector const operator-(const GSLVector& a, const GSLVector& b)
+{
+  assert(a.GetDimension() == b.GetDimension() && "Dimenions of GSLVectors to compare differ");
+  GSLVector x(a);
+  for (size_t i=0;i<a.GetDimension();i++)
+    x.Set(i,a.Get(i)-b.Get(i));
+  return x;
+};
+
+/** Factors given GSLVector \a a times \a m.
+ * \param a GSLVector
+ * \param m factor
+ * \return m * a
+ */
+GSLVector const operator*(const GSLVector& a, const double m)
+{
+  GSLVector x(a);
+  for (size_t i=0;i<a.GetDimension();i++)
+    x.Set(i,a.Get(i)*m);
+  return x;
+};
+
+/** Factors given GSLVector \a a times \a m.
+ * \param m factor
+ * \param a GSLVector
+ * \return m * a
+ */
+GSLVector const operator*(const double m, const GSLVector& a )
+{
+  GSLVector x(a);
+  for (size_t i=0;i<a.GetDimension();i++)
+    x.Set(i,a.Get(i)*m);
+  return x;
+};
+
+ostream& operator<<(ostream& ost, const GSLVector& m)
+{
+  ost << "(";
+  for (size_t i=0;i<m.GetDimension();i++) {
+    ost << m.Get(i);
+    if (i != 2)
+      ost << ",";
+  }
+  ost << ")";
+  return ost;
+};
+
+/* ====================== Checking State ============================ */
+/** Checks whether vector has all components zero.
+ * @return true - vector is zero, false - vector is not
+ */
+bool GSLVector::IsZero() const
+{
+  return (fabs(Get(0))+fabs(Get(1))+fabs(Get(2)) < MYEPSILON);
+};
+
+/** Checks whether vector has length of 1.
+ * @return true - vector is normalized, false - vector is not
+ */
+bool GSLVector::IsOne() const
+{
+  double NormValue = 0.;
+  for (size_t i=dimension;--i;)
+    NormValue += Get(i)*Get(i);
+  return (fabs(NormValue - 1.) < MYEPSILON);
+};
+
Index: src/LinearAlgebra/gslvector.hpp
===================================================================
--- src/LinearAlgebra/gslvector.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
+++ src/LinearAlgebra/gslvector.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -0,0 +1,80 @@
+/*
+ * gslvector.hpp
+ *
+ *  Created on: Jan 8, 2010
+ *      Author: heber
+ */
+
+#ifndef GSLVECTOR_HPP_
+#define GSLVECTOR_HPP_
+
+using namespace std;
+
+/*********************************************** includes ***********************************/
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <iosfwd>
+#include <gsl/gsl_vector.h>
+
+/****************************************** forward declarations *****************************/
+
+class GSLVector;
+class Vector;
+
+/********************************************** declarations *******************************/
+
+class GSLVector {
+  friend class LinearSystemOfEquations;
+
+public:
+  GSLVector(size_t m);
+  GSLVector(const GSLVector * const src);
+  GSLVector(const GSLVector & src);
+  ~GSLVector();
+
+  // Accessing
+  void SetFromDoubleArray(double *x);
+  void SetFromVector(Vector &v);
+  double Get(size_t m) const;
+  void Set(size_t m, double x);
+  double *Pointer(size_t m) const;
+  const double *const_Pointer(size_t m) const;
+  size_t GetDimension() const;
+
+  // Initializing
+  void SetAll(double x);
+  void SetZero();
+  int SetBasis(size_t m);
+
+  // Exchanging elements
+  int SwapElements(size_t i, size_t j);
+  int Reverse();
+
+  // checking state
+  bool IsZero() const;
+  bool IsOne() const;
+
+private:
+  gsl_vector *vector;
+
+  const size_t dimension;
+};
+
+ostream & operator << (ostream& ost, const GSLVector &m);
+bool operator==(const GSLVector& a, const GSLVector& b);
+const GSLVector& operator+=(GSLVector& a, const GSLVector& b);
+const GSLVector& operator-=(GSLVector& a, const GSLVector& b);
+const GSLVector& operator*=(GSLVector& a, const double m);
+GSLVector const operator*(const GSLVector& a, const double m);
+GSLVector const operator*(const double m, const GSLVector& a);
+GSLVector const operator+(const GSLVector& a, const GSLVector& b);
+GSLVector const operator-(const GSLVector& a, const GSLVector& b);
+
+
+
+
+#endif /* GSLVECTOR_HPP_ */
Index: src/LinearAlgebra/linearsystemofequations.cpp
===================================================================
--- src/LinearAlgebra/linearsystemofequations.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
+++ src/LinearAlgebra/linearsystemofequations.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -0,0 +1,136 @@
+/*
+ * linearsystemofequations.cpp
+ *
+ *  Created on: Jan 8, 2010
+ *      Author: heber
+ */
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "Helpers/MemDebug.hpp"
+
+#include "defs.hpp"
+#include "LinearAlgebra/gslmatrix.hpp"
+#include "LinearAlgebra/gslvector.hpp"
+#include "LinearAlgebra/linearsystemofequations.hpp"
+#include "Helpers/logger.hpp"
+#include "LinearAlgebra/Vector.hpp"
+
+#include <cassert>
+#include <gsl/gsl_permutation.h>
+
+/** Constructor for class LinearSystemOfEquations.
+ * Allocates Vector and Matrix classes.
+ * \param m column dimension
+ * \param n row dimension
+ */
+LinearSystemOfEquations::LinearSystemOfEquations(int m, int n) : rows(m), columns(n), IsSymmetric(false)
+{
+  A = new GSLMatrix(m, n);
+  b = new GSLVector(m);
+  x = new GSLVector(n);
+};
+
+/** Destructor for class LinearSystemOfEquations.
+ * Destructs Vector and Matrix classes.
+ */
+LinearSystemOfEquations::~LinearSystemOfEquations()
+{
+  delete(A);
+  delete(b);
+  delete(x);
+};
+
+/** Sets whether matrix is to be regarded as symmetric.
+ * Note that we do not check whether it really is, just take upper diagonal.
+ * \param symmetric true or false
+ */
+bool LinearSystemOfEquations::SetSymmetric(bool symmetric)
+{
+  assert (rows == columns && "Rows and columns don't have equal size! Setting symmetric not possible.");
+  return (IsSymmetric = symmetric);
+};
+
+/** Initializes vector b to the components of the given vector.
+ * \param *x Vector with equal dimension (no check!)
+ */
+void LinearSystemOfEquations::Setb(Vector *x)
+{
+  assert ( columns == NDIM && "Vector class is always three-dimensional, unlike this LEqS!");
+  b->SetFromVector(*x);
+};
+
+/** Initializes vector b to the components of the given vector.
+ * \param *x array with equal dimension (no check!)
+ */
+void LinearSystemOfEquations::Setb(double *x)
+{
+  b->SetFromDoubleArray(x);
+};
+
+/** Initializes matrix a to the components of the given array.
+ * note that sort order should be
+ * \param *x array with equal dimension (no check!)
+ */
+void LinearSystemOfEquations::SetA(double *x)
+{
+  A->SetFromDoubleArray(x);
+};
+
+/** Returns the solution vector x \f$A \cdot x = b\f$ as an array of doubles.
+ * \param *array pointer allocated array for solution on return (no bounds check, dimension must match)
+ * \return true - solving possible, false - some error occured.
+ */
+bool LinearSystemOfEquations::GetSolutionAsArray(double *&array)
+{
+  bool status = Solve();
+
+  // copy solution
+  for (size_t i=0;i<x->dimension;i++) {
+    array[i] = x->Get(i);
+  }
+  return status;
+};
+
+/** Returns the solution vector x \f$A \cdot x = b\f$ as an array of doubles.
+ * \param &x solution vector on return (must be 3-dimensional)
+ * \return true - solving possible, false - some error occured.
+ */
+bool LinearSystemOfEquations::GetSolutionAsVector(Vector &v)
+{
+  assert(rows == NDIM && "Solution can only be returned as vector if number of columns is NDIM.");
+  bool status = Solve();
+
+  // copy solution
+  for (size_t i=0;i<x->dimension;i++)
+    v[i] = x->Get(i);
+  return status;
+};
+
+/** Solves the given system of \f$A \cdot x = b\f$.
+ * Use either LU or Householder decomposition.
+ * Solution is stored in LinearSystemOfEquations::x
+ * \return true - solving possible, false - some error occured.
+ */
+bool LinearSystemOfEquations::Solve()
+{
+  // calculate solution
+  int s;
+  if (IsSymmetric) { // use LU
+    gsl_permutation * p = gsl_permutation_alloc (x->dimension);
+    gsl_linalg_LU_decomp (A->matrix, p, &s);
+    gsl_linalg_LU_solve (A->matrix, p, b->vector, x->vector);
+    gsl_permutation_free (p);
+  } else {  // use Householder
+    //GSLMatrix *backup = new GSLMatrix(rows,columns);
+    //*backup = *A;
+    gsl_linalg_HH_solve (A->matrix, b->vector, x->vector);
+    //*A = *backup;
+    //delete(backup);
+  }
+  return true;
+};
+
Index: src/LinearAlgebra/linearsystemofequations.hpp
===================================================================
--- src/LinearAlgebra/linearsystemofequations.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
+++ src/LinearAlgebra/linearsystemofequations.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -0,0 +1,59 @@
+/*
+ * linearsystemofequations.hpp
+ *
+ *  Created on: Jan 8, 2010
+ *      Author: heber
+ */
+
+#ifndef LINEARSYSTEMSOFEQUATIONS_HPP
+#define LINEARSYSTEMSOFEQUATIONS_HPP
+
+/*********************************************** includes ***********************************/
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <gsl/gsl_linalg.h>
+
+/****************************************** forward declarations *****************************/
+
+class Vector;
+class GSLMatrix;
+class GSLVector;
+
+/********************************************** declarations *******************************/
+
+/** Solver class for a linear system of equations in the form \f$A \cdot x = b\F$.
+ *
+ */
+class LinearSystemOfEquations {
+public:
+  LinearSystemOfEquations(int n, int m);
+  ~LinearSystemOfEquations();
+
+  // setting
+  void Setb(Vector *x);
+  void Setb(double *x);
+  void SetA(double *x);
+  bool SetSymmetric(bool symmetric);
+
+  // solving
+  bool GetSolutionAsArray(double *&array);
+  bool GetSolutionAsVector(Vector &v);
+
+  GSLVector *b;
+  GSLVector *x;
+  GSLMatrix *A;
+
+private:
+  bool Solve();
+
+  int rows;
+  int columns;
+
+  bool IsSymmetric;
+};
+
+#endif /* LINEARSYSTEMSOFEQUATIONS_HPP */
Index: src/LinearAlgebra/vector_ops.cpp
===================================================================
--- src/LinearAlgebra/vector_ops.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
+++ src/LinearAlgebra/vector_ops.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -0,0 +1,120 @@
+/*
+ * vector_ops.cpp
+ *
+ *  Created on: Apr 1, 2010
+ *      Author: crueger
+ */
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "Helpers/MemDebug.hpp"
+
+#include "LinearAlgebra/Vector.hpp"
+#include "LinearAlgebra/Plane.hpp"
+#include "Helpers/Log.hpp"
+#include "Helpers/Verbose.hpp"
+#include "LinearAlgebra/gslmatrix.hpp"
+#include "leastsquaremin.hpp"
+#include "Helpers/Info.hpp"
+#include "Helpers/fast_functions.hpp"
+#include "Exceptions/LinearDependenceException.hpp"
+#include "Exceptions/SkewException.hpp"
+
+#include <gsl/gsl_linalg.h>
+#include <gsl/gsl_matrix.h>
+#include <gsl/gsl_permutation.h>
+#include <gsl/gsl_vector.h>
+#include <gsl/gsl_multimin.h>
+
+/**
+ * !@file
+ * These files defines several common operation on vectors that should not
+ * become part of the main vector class, because they are either to complex
+ * or need methods from other subsystems that should not be moved to
+ * the LinAlg-Subsystem
+ */
+
+/** Creates a new vector as the one with least square distance to a given set of \a vectors.
+ * \param *vectors set of vectors
+ * \param num number of vectors
+ * \return true if success, false if failed due to linear dependency
+ */
+bool LSQdistance(Vector &res,const Vector **vectors, int num)
+{
+  int j;
+
+  for (j=0;j<num;j++) {
+    Log() << Verbose(1) << j << "th atom's vector: " << vectors[j] << endl;
+  }
+
+  int np = 3;
+  struct LSQ_params par;
+
+   const gsl_multimin_fminimizer_type *T =
+     gsl_multimin_fminimizer_nmsimplex;
+   gsl_multimin_fminimizer *s = NULL;
+   gsl_vector *ss, *y;
+   gsl_multimin_function minex_func;
+
+   size_t iter = 0, i;
+   int status;
+   double size;
+
+   /* Initial vertex size vector */
+   ss = gsl_vector_alloc (np);
+   y = gsl_vector_alloc (np);
+
+   /* Set all step sizes to 1 */
+   gsl_vector_set_all (ss, 1.0);
+
+   /* Starting point */
+   par.vectors = vectors;
+   par.num = num;
+
+   for (i=NDIM;i--;)
+    gsl_vector_set(y, i, (vectors[0]->at(i) - vectors[1]->at(i))/2.);
+
+   /* Initialize method and iterate */
+   minex_func.f = &LSQ;
+   minex_func.n = np;
+   minex_func.params = (void *)&par;
+
+   s = gsl_multimin_fminimizer_alloc (T, np);
+   gsl_multimin_fminimizer_set (s, &minex_func, y, ss);
+
+   do
+     {
+       iter++;
+       status = gsl_multimin_fminimizer_iterate(s);
+
+       if (status)
+         break;
+
+       size = gsl_multimin_fminimizer_size (s);
+       status = gsl_multimin_test_size (size, 1e-2);
+
+       if (status == GSL_SUCCESS)
+         {
+           printf ("converged to minimum at\n");
+         }
+
+       printf ("%5d ", (int)iter);
+       for (i = 0; i < (size_t)np; i++)
+         {
+           printf ("%10.3e ", gsl_vector_get (s->x, i));
+         }
+       printf ("f() = %7.3f size = %.3f\n", s->fval, size);
+     }
+   while (status == GSL_CONTINUE && iter < 100);
+
+  for (i=(size_t)np;i--;)
+    res[i] = gsl_vector_get(s->x, i);
+   gsl_vector_free(y);
+   gsl_vector_free(ss);
+   gsl_multimin_fminimizer_free (s);
+
+  return true;
+};
Index: src/LinearAlgebra/vector_ops.hpp
===================================================================
--- src/LinearAlgebra/vector_ops.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
+++ src/LinearAlgebra/vector_ops.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -0,0 +1,13 @@
+/*
+ * vector_ops.hpp
+ *
+ *  Created on: Apr 1, 2010
+ *      Author: crueger
+ */
+
+#ifndef VECTOR_OPS_HPP_
+#define VECTOR_OPS_HPP_
+
+bool LSQdistance(Vector &res,const Vector **vectors, int num);
+
+#endif /* VECTOR_OPS_HPP_ */
Index: src/Makefile.am
===================================================================
--- src/Makefile.am	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/Makefile.am	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -2,13 +2,9 @@
 # Also indentation by a single tab
 
-SUBDIRS = Actions UIElements
-
-# this includes source files that need to be present at multiple points
-HELPERSOURCE =  \
-  Helpers/Assert.cpp \
-  Helpers/MemDebug.cpp
-		        
+SUBDIRS = Actions Exceptions Helpers LinearAlgebra Parser UIElements
+
 ATOMSOURCE = \
   atom.cpp \
+  AtomicInfo.cpp \
   atom_atominfo.cpp \
   atom_bondedparticle.cpp \
@@ -21,4 +17,5 @@
 ATOMHEADER = \
   atom.hpp \
+  AtomicInfo.hpp \
   atom_atominfo.hpp \
   atom_bondedparticle.hpp \
@@ -30,18 +27,4 @@
   atom_trajectoryparticleinfo.hpp
 
-LINALGSOURCE = \
-  ${HELPERSOURCE} \
-  gslmatrix.cpp \
-  gslvector.cpp \
-  linearsystemofequations.cpp \
-  Space.cpp \
-  vector.cpp
-			   
-LINALGHEADER = gslmatrix.hpp \
-  gslvector.hpp \
-  linearsystemofequations.hpp \
-  Space.hpp \
-  vector.hpp
-			   
 ANALYSISSOURCE = \
   analysis_bonds.cpp \
@@ -75,23 +58,4 @@
   Actions/MethodAction.hpp \
   Actions/Process.hpp
-  
-
-PARSERSOURCE = \
-  Parser/ChangeTracker.cpp \
-  Parser/FormatParser.cpp \
-  Parser/FormatParserStorage.cpp \
-  Parser/MpqcParser.cpp \
-  Parser/PcpParser.cpp \
-  Parser/TremoloParser.cpp \
-  Parser/XyzParser.cpp
-
-PARSERHEADER = \
-  Parser/ChangeTracker.hpp \
-  Parser/FormatParser.hpp \
-  Parser/FormatParserStorage.hpp \
-  Parser/MpqcParser.hpp \
-  Parser/PcpParser.hpp \
-  Parser/TremoloParser.hpp \
-  Parser/XyzParser.hpp
 
 PATTERNSOURCE = \
@@ -101,59 +65,58 @@
   Patterns/Observer.hpp \
   Patterns/Singleton.hpp
-
-QTUIMOC_HEADER = UIElements/QT4/QTDialog.hpp \
-				 UIElements/QT4/QTMainWindow.hpp \
-				 UIElements/Menu/QT4/QTMenu.hpp \
-				 UIElements/Views/QT4/QTWorldView.hpp \
-				 UIElements/Views/QT4/GLMoleculeView.hpp \
-				 UIElements/Views/QT4/QTMoleculeView.hpp \
-				 UIElements/Views/QT4/QTStatusBar.hpp
- 
-QTUIMOC_TARGETS = QTMainWindow.moc.cpp \
-	              QTMenu.moc.cpp\
-	              QTDialog.moc.cpp \
-	              QTWorldView.moc.cpp \
-	              GLMoleculeView.moc.cpp \
-	              QTMoleculeView.moc.cpp \
-	              QTStatusBar.moc.cpp
-
+  
+SHAPESOURCE = \
+  Shapes/BaseShapes.cpp \
+  Shapes/Shape.cpp \
+  Shapes/ShapeOps.cpp
+SHAPEHEADER = \
+  Shapes/BaseShapes.hpp \
+  Shapes/Shape.hpp \
+  Shapes/ShapeOps.hpp
+
+  
 DESCRIPTORSOURCE = Descriptors/AtomDescriptor.cpp \
   Descriptors/AtomIdDescriptor.cpp \
+  Descriptors/AtomSelectionDescriptor.cpp \
+  Descriptors/AtomShapeDescriptor.cpp \
   Descriptors/AtomTypeDescriptor.cpp \
   Descriptors/MoleculeDescriptor.cpp \
+  Descriptors/MoleculeFormulaDescriptor.cpp \
   Descriptors/MoleculeIdDescriptor.cpp \
   Descriptors/MoleculeNameDescriptor.cpp \
-  Descriptors/MoleculePtrDescriptor.cpp 
+  Descriptors/MoleculePtrDescriptor.cpp \
+  Descriptors/MoleculeSelectionDescriptor.cpp
 				   
 
 DESCRIPTORHEADER = Descriptors/AtomDescriptor.hpp \
   Descriptors/AtomIdDescriptor.hpp \
+  Descriptors/AtomSelectionDescriptor.hpp \
+  Descriptors/AtomShapeDescriptor.hpp \
   Descriptors/AtomTypeDescriptor.hpp \
   Descriptors/MoleculeDescriptor.hpp \
+  Descriptors/MoleculeFormulaDescriptor.hpp \
   Descriptors/MoleculeIdDescriptor.hpp \
   Descriptors/MoleculeNameDescriptor.hpp \
-  Descriptors/MoleculePtrDescriptor.hpp
-				   
-EXCEPTIONSOURCE = Exceptions/CustomException.cpp \
-				  Exceptions/LinearDependenceException.cpp \
-				  Exceptions/MathException.cpp \
-				  Exceptions/SkewException.cpp \
-				  Exceptions/ZeroVectorException.cpp
+  Descriptors/MoleculePtrDescriptor.hpp \
+  Descriptors/MoleculeSelectionDescriptor.cpp
+
+
+QTUIMOC_HEADER = UIElements/QT4/QTDialog.hpp \
+	UIElements/QT4/QTMainWindow.hpp \
+	UIElements/Menu/QT4/QTMenu.hpp \
+	UIElements/Views/QT4/QTWorldView.hpp \
+	UIElements/Views/QT4/GLMoleculeView.hpp \
+	UIElements/Views/QT4/QTMoleculeView.hpp \
+	UIElements/Views/QT4/QTStatusBar.hpp
 				  
-EXCEPTIONHEADER = Exceptions/CustomException.hpp \
-				  Exceptions/LinearDependenceException.hpp \
-				  Exceptions/MathException.hpp \
-				  Exceptions/SkewException.hpp \
-				  Exceptions/ZeroVectorException.hpp
-				  
-QTUISOURCE = ${QTUIMOC_TARGETS} \
-			 UIElements/QT4/QTMainWindow.cpp \
-			 UIElements/QT4/QTDialog.cpp \
-			 UIElements/QT4/QTUIFactory.cpp \
-			 UIElements/Menu/QT4/QTMenu.cpp \
-			 UIElements/Views/QT4/QTWorldView.cpp \
-			 UIElements/Views/QT4/GLMoleculeView.cpp \
-			 UIElements/Views/QT4/QTMoleculeView.cpp \
-			 UIElements/Views/QT4/QTStatusBar.cpp
+QTUISOURCE = allmocs.moc.cpp \
+	UIElements/QT4/QTMainWindow.cpp \
+	UIElements/QT4/QTDialog.cpp \
+	UIElements/QT4/QTUIFactory.cpp \
+	UIElements/Menu/QT4/QTMenu.cpp \
+	UIElements/Views/QT4/QTWorldView.cpp \
+	UIElements/Views/QT4/GLMoleculeView.cpp \
+	UIElements/Views/QT4/QTMoleculeView.cpp \
+	UIElements/Views/QT4/QTStatusBar.cpp
              
 QTUIHEADER = ${QTUIMOC_HEADER} UIElements/QT4/QTUIFactory.hpp
@@ -161,31 +124,49 @@
 QTUI_DEFS =
 
-SOURCE = \
+TESSELATIONSOURCE = \
+  BoundaryLineSet.cpp \
+  BoundaryPointSet.cpp \
+  BoundaryPolygonSet.cpp \
+  BoundaryTriangleSet.cpp \
+  CandidateForTesselation.cpp \
+  PointCloud.cpp \
+  tesselation.cpp \
+  tesselationhelpers.cpp \
+  TesselPoint.cpp
+  
+TESSELATIONHEADER = \
+  BoundaryLineSet.hpp \
+  BoundaryPointSet.hpp \
+  BoundaryPolygonSet.hpp \
+  BoundaryTriangleSet.hpp \
+  CandidateForTesselation.hpp \
+  PointCloud.hpp \
+  tesselation.hpp \
+  tesselationhelpers.hpp \
+  TesselPoint.hpp
+
+MOLECUILDERSOURCE = \
   ${ANALYSISSOURCE} \
   ${ACTIONSSOURCE} \
   ${ATOMSOURCE} \
   ${PATTERNSOURCE} \
-  ${PARSERSOURCE} \
+  ${SHAPESOURCE} \
   ${DESCRIPTORSOURCE} \
-  ${HELPERSOURCE} \
-  ${EXCEPTIONSOURCE} \
+  ${TESSELATIONSOURCE} \
   bond.cpp \
   bondgraph.cpp \
   boundary.cpp \
+  Box.cpp \
   CommandLineParser.cpp \
   config.cpp \
   ConfigFileBuffer.cpp \
+  defs.cpp \
   element.cpp \
   elements_db.cpp \
   ellipsoid.cpp \
-  errorlogger.cpp \
+  Formula.cpp \
   graph.cpp \
-  helpers.cpp \
-  info.cpp \
   leastsquaremin.cpp \
-  Line.cpp \
   linkedcell.cpp \
-  log.cpp \
-  logger.cpp \
   moleculelist.cpp \
   molecule.cpp \
@@ -197,26 +178,21 @@
   parser.cpp \
   periodentafel.cpp \
-  Plane.cpp \
-  Space.cpp \
-  tesselation.cpp \
-  tesselationhelpers.cpp \
   ThermoStatContainer.cpp \
   triangleintersectionlist.cpp \
-  vector.cpp \
-  vector_ops.cpp \
-  verbose.cpp \
+  UIElements/UIFactory.cpp \
   World.cpp
 
-HEADER = \
+MOLECUILDERHEADER = \
   ${ANALYSISHEADER} \
   ${ACTIONSHEADER} \
   ${ATOMHEADER} \
-  ${PARSERHEADER} \
   ${PATTERNHEADER} \
+  ${SHAPEHEADER} \
   ${DESCRIPTORHEADER} \
-  ${EXCEPTIONHEADER} \
+  ${TESSELATIONHEADER} \
   bond.hpp \
   bondgraph.hpp \
   boundary.hpp \
+  Box.hpp \
   CommandLineParser.hpp \
   config.hpp \
@@ -226,33 +202,71 @@
   elements_db.hpp \
   ellipsoid.hpp \
-  errorlogger.hpp \
+  Formula.hpp \
   graph.hpp \
-  helpers.hpp \
-  info.hpp \
   leastsquaremin.hpp \
-  Line.hpp \
   linkedcell.hpp \
   lists.hpp \
-  log.hpp \
-  logger.hpp \
   molecule.hpp \
   molecule_template.hpp \
   parser.hpp \
   periodentafel.hpp \
-  Plane.hpp \
   stackclass.hpp \
-  tesselation.hpp \
-  tesselationhelpers.hpp \
   ThermoStatContainer.hpp \
   triangleintersectionlist.hpp \
-  verbose.hpp \
-  vector_ops.hpp \
+  UIElements/UIFactory.hpp \
   World.hpp 
 
-# the following files are no longer used:
-#  memoryallocator.hpp \
-#  memoryallocator.cpp \
-#  memoryusageobserver.hpp \
-#  memoryusageobserver.cpp
+lib_LTLIBRARIES = libMolecuilder-@MOLECUILDER_API_VERSION@.la
+libMolecuilder_includedir = $(includedir)/molecuilder-$(MOLECUILDER_API_VERSION)/Actions/
+libMolecuilder_LIBS = \
+	LinearAlgebra/libMolecuilderLinearAlgebra-@MOLECUILDER_API_VERSION@.la \
+	${BOOST_PROGRAM_OPTIONS_LIB}
+
+#	UIElements/libMolecuilderUI.a \
+	Actions/libMolecuilderActions-@MOLECUILDER_API_VERSION@.la \
+	Parser/libMolecuilderParser-@MOLECUILDER_API_VERSION@.la \
+	Exceptions/libMolecuilderExceptions-@MOLECUILDER_API_VERSION@.la \
+	Helpers/libMolecuilderHelpers-@MOLECUILDER_API_VERSION@.la \
+	$(BOOST_LIB) \
+	${BOOST_THREAD_LIB}
+
+nobase_libMolecuilder_include_HEADERS = ${MOLECUILDERHEADER}
+
+## Define the source file list for the "libexample-@MOLECUILDER_API_VERSION@.la"
+## target.  Note that @MOLECUILDER_API_VERSION@ is not interpreted by Automake and
+## will therefore be treated as if it were literally part of the target name,
+## and the variable name derived from that.
+## The file extension .cc is recognized by Automake, and makes it produce
+## rules which invoke the C++ compiler to produce a libtool object file (.lo)
+## from each source file.  Note that it is not necessary to list header files
+## which are already listed elsewhere in a _HEADERS variable assignment.
+libMolecuilder_@MOLECUILDER_API_VERSION@_la_SOURCES = ${MOLECUILDERSOURCE} $(srcdir)/version.c
+
+## Instruct libtool to include ABI version information in the generated shared
+## library file (.so).  The library ABI version is defined in configure.ac, so
+## that all version information is kept in one place.
+libMolecuilder_@MOLECUILDER_API_VERSION@_la_LDFLAGS = -version-info $(MOLECUILDER_SO_VERSION)
+
+## The generated configuration header is installed in its own subdirectory of
+## $(libdir).  The reason for this is that the configuration information put
+## into this header file describes the target platform the installed library
+## has been built for.  Thus the file must not be installed into a location
+## intended for architecture-independent files, as defined by the Filesystem
+## Hierarchy Standard (FHS).
+## The nodist_ prefix instructs Automake to not generate rules for including
+## the listed files in the distribution on 'make dist'.  Files that are listed
+## in _HEADERS variables are normally included in the distribution, but the
+## configuration header file is generated at configure time and should not be
+## shipped with the source tarball.
+libMolecuilder_libincludedir = $(libdir)/molecuilder-$(MOLECUILDER_API_VERSION)/include
+nodist_libMolecuilder_libinclude_HEADERS = $(top_builddir)/libmolecuilder_config.h
+
+## Install the generated pkg-config file (.pc) into the expected location for
+## architecture-dependent package configuration information.  Occasionally,
+## pkg-config files are also used for architecture-independent data packages,
+## in which case the correct install location would be $(datadir)/pkgconfig.
+pkgconfigdir = $(libdir)/pkgconfig
+pkgconfig_DATA = $(top_builddir)/molecuilder-$(MOLECUILDER_API_VERSION).pc
+
 
 BOOST_LIB = $(BOOST_LDFLAGS) $(BOOST_MPL_LIB)
@@ -260,14 +274,11 @@
 INCLUDES = -I$(top_srcdir)/src/unittests -I$(top_srcdir)/src/Actions -I$(top_srcdir)/src/UIElements
 
-noinst_LIBRARIES = libmolecuilder.a libgslwrapper.a libmenu.a libparser.a
+noinst_LIBRARIES = libmenu.a
 bin_PROGRAMS = molecuilder molecuildergui joiner analyzer
+EXTRA_PROGRAMS = unity
 
 molecuilderdir = ${bindir}
 
-libmolecuilder_a_SOURCES = ${SOURCE} ${HEADER}
-
 libmenu_a_SOURCES = ${UISOURCE} ${UIHEADER} 
-libparser_a_SOURCES = ${PARSERSOURCE} ${PARSERHEADER}
-libgslwrapper_a_SOURCES = ${LINALGSOURCE} ${LINALGHEADER}
 
 molecuilder_DATA = elements.db valence.db orbitals.db Hbonddistance.db Hbondangle.db
@@ -276,20 +287,62 @@
 #molecuilder_CXXFLAGS += -DNO_CACHING
 molecuilder_LDFLAGS = $(BOOST_LIB)
-molecuilder_SOURCES = ${LEGACYSOURCE} builder.cpp
-molecuilder_SOURCES += $(srcdir)/version.c
-molecuilder_LDADD = UIElements/libMolecuilderUI.a Actions/libMolecuilderActions.a libmolecuilder.a libparser.a libgslwrapper.a $(BOOST_LIB) ${BOOST_THREAD_LIB} ${BOOST_PROGRAM_OPTIONS_LIB}
+molecuilder_SOURCES = builder.cpp
+molecuilder_LDADD = \
+	UIElements/libMolecuilderUI-@MOLECUILDER_API_VERSION@.la \
+	Actions/libMolecuilderActions-@MOLECUILDER_API_VERSION@.la \
+	libMolecuilder-@MOLECUILDER_API_VERSION@.la \
+	Parser/libMolecuilderParser-@MOLECUILDER_API_VERSION@.la \
+	LinearAlgebra/libMolecuilderLinearAlgebra-@MOLECUILDER_API_VERSION@.la \
+	Exceptions/libMolecuilderExceptions-@MOLECUILDER_API_VERSION@.la \
+	Helpers/libMolecuilderHelpers-@MOLECUILDER_API_VERSION@.la \
+	$(BOOST_LIB) \
+	${BOOST_THREAD_LIB} \
+	${BOOST_PROGRAM_OPTIONS_LIB}
+
 
 #Stuff for building the GUI using QT
-molecuildergui_SOURCES = ${QTUISOURCE} ${LEGACYSOURCE} builder.cpp
-molecuildergui_SOURCES += $(srcdir)/version.c
+molecuildergui_SOURCES = ${QTUISOURCE} builder.cpp
 molecuildergui_CXXFLAGS = ${QT_CXXFLAGS} ${GLU_CXXFLAGS} -DUSE_GUI_QT
 molecuildergui_LDFLAGS = $(BOOST_LIB) ${QT_LDFLAGS} ${GLU_LDFLAGS}
-molecuildergui_LDADD = UIElements/libMolecuilderUI.a Actions/libMolecuilderActions.a libmolecuilder.a libparser.a libgslwrapper.a $(BOOST_LIB) ${BOOST_THREAD_LIB} ${BOOST_PROGRAM_OPTIONS_LIB}  ${GUI_LIBS}
-
-joiner_SOURCES = joiner.cpp datacreator.cpp parser.cpp datacreator.hpp helpers.hpp parser.hpp periodentafel.hpp
-joiner_LDADD = libmolecuilder.a $(BOOST_LIB) ${BOOST_THREAD_LIB}
-
-analyzer_SOURCES = analyzer.cpp datacreator.cpp parser.cpp helpers.hpp periodentafel.hpp parser.hpp datacreator.hpp 
-analyzer_LDADD = libmolecuilder.a $(BOOST_LIB) ${BOOST_THREAD_LIB}
+
+unity_SOURCES = unity.cpp
+unity_LDADD = $(BOOST_LIB) ${BOOST_THREAD_LIB} ${BOOST_PROGRAM_OPTIONS_LIB}
+
+molecuildergui_LDADD = \
+	UIElements/libMolecuilderUI-@MOLECUILDER_API_VERSION@.la \
+	Actions/libMolecuilderActions-@MOLECUILDER_API_VERSION@.la \
+	libMolecuilder-@MOLECUILDER_API_VERSION@.la \
+	Parser/libMolecuilderParser-@MOLECUILDER_API_VERSION@.la \
+	LinearAlgebra/libMolecuilderLinearAlgebra-@MOLECUILDER_API_VERSION@.la \
+	Exceptions/libMolecuilderExceptions-@MOLECUILDER_API_VERSION@.la \
+	Helpers/libMolecuilderHelpers-@MOLECUILDER_API_VERSION@.la \
+	$(BOOST_LIB) \
+	${BOOST_THREAD_LIB} \
+	${BOOST_PROGRAM_OPTIONS_LIB} \
+	${GUI_LIBS}
+
+joiner_SOURCES = joiner.cpp datacreator.cpp datacreator.hpp periodentafel.hpp
+joiner_LDADD = \
+	Actions/libMolecuilderActions-@MOLECUILDER_API_VERSION@.la \
+	libMolecuilder-@MOLECUILDER_API_VERSION@.la \
+	Parser/libMolecuilderParser-@MOLECUILDER_API_VERSION@.la \
+	LinearAlgebra/libMolecuilderLinearAlgebra-@MOLECUILDER_API_VERSION@.la \
+	Exceptions/libMolecuilderExceptions-@MOLECUILDER_API_VERSION@.la \
+	Helpers/libMolecuilderHelpers-@MOLECUILDER_API_VERSION@.la \
+	$(BOOST_LIB) \
+	${BOOST_THREAD_LIB} \
+	${BOOST_PROGRAM_OPTIONS_LIB}
+
+analyzer_SOURCES = analyzer.cpp datacreator.cpp periodentafel.hpp datacreator.hpp 
+analyzer_LDADD = \
+	Actions/libMolecuilderActions-@MOLECUILDER_API_VERSION@.la \
+	libMolecuilder-@MOLECUILDER_API_VERSION@.la \
+	Parser/libMolecuilderParser-@MOLECUILDER_API_VERSION@.la \
+	LinearAlgebra/libMolecuilderLinearAlgebra-@MOLECUILDER_API_VERSION@.la \
+	Exceptions/libMolecuilderExceptions-@MOLECUILDER_API_VERSION@.la \
+	Helpers/libMolecuilderHelpers-@MOLECUILDER_API_VERSION@.la \
+	$(BOOST_LIB) \
+	${BOOST_THREAD_LIB} \
+	${BOOST_PROGRAM_OPTIONS_LIB}
 
 #Rules needed for QT4
@@ -297,5 +350,6 @@
 # Therfore `%'-rules do not seem to work
 #Quick fix to get it done otherwise
-${QTUIMOC_TARGETS}: ${QTUIMOC_HEADER}
+allmocs.moc.cpp: ${QTUIMOC_HEADER}
+	echo "" > allmocs.moc.cpp;\
 	list='$(QTUIMOC_HEADER)'; for header in $$list; do \
 	echo "Making mocfile for $$header"; \
@@ -303,8 +357,7 @@
 	$(MOC) $(srcdir)/$$header -o $$target \
 	|| eval $$failcom; \
+	echo "#include \"$$target\"" >> allmocs.moc.cpp; \
 	done;
 
-MOSTLYCLEANFILES = ${QTUIMOC_TARGETS}
-	
 #EXTRA_DIST = ${molecuilder_DATA}
 
@@ -325,2 +378,18 @@
 
 
+unity.cpp: ${MOLECUILDERSOURCE} ${MOLECUILDERHEADER}
+	echo "#include \"$(srcdir)/Helpers/MemDebug.cpp\"" >  unity.cpp; \
+	list='$(MOLECUILDERSOURCE)'; for file in $$list; do \
+  	echo "#include \"$(srcdir)/$$file\"" >> unity.cpp; \
+	done; \
+	subdirs='$(SUBDIRS)';for directory in $$subdirs; do\
+		olddir=$$PWD;\
+		cd $$directory && make unity.cpp;\
+		cd $$olddir;\
+		echo "#include \"$$directory/unity.cpp\"" >> unity.cpp;\
+	done;\
+	echo "#include \"$(srcdir)/builder.cpp\"" >> unity.cpp;
+	echo "#include \"$(srcdir)/version.c\"" >> unity.cpp;
+
+MOSTLYCLEANFILES = allmocs.moc.cpp unity.cpp 
+	
Index: src/Parser/ChangeTracker.cpp
===================================================================
--- src/Parser/ChangeTracker.cpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/Parser/ChangeTracker.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -6,8 +6,15 @@
  */
 
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
 #include "Helpers/MemDebug.hpp"
+
 #include "Parser/ChangeTracker.hpp"
 #include "Patterns/Singleton_impl.hpp"
-
+#include "Helpers/Log.hpp"
+#include "Helpers/Verbose.hpp"
 
 /**
@@ -15,7 +22,7 @@
  */
 ChangeTracker::ChangeTracker() :
-  Observable("ChangeTracker")
+  Observable("ChangeTracker"),
+  isConsistent(true)
 {
-  isConsistent = true;
   World::getInstance().signOn(this);
 }
@@ -49,4 +56,5 @@
  */
 void ChangeTracker::saveStatus() {
+  DoLog(0) && (Log() << Verbose(0) << "Saving changes." << std::endl);
   if (hasChanged()) {
     notifyAll();
Index: src/Parser/FormatParser.cpp
===================================================================
--- src/Parser/FormatParser.cpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/Parser/FormatParser.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -5,4 +5,9 @@
  *      Author: metzler
  */
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
 
 #include "Helpers/MemDebug.hpp"
@@ -17,8 +22,8 @@
  */
 FormatParser::FormatParser() :
-  Observer("FormatParser")
+  Observer("FormatParser"),
+  saveStream(NULL)
 {
   ChangeTracker::getInstance().signOn(this);
-  saveStream = NULL;
 }
 
Index: src/Parser/FormatParserStorage.cpp
===================================================================
--- src/Parser/FormatParserStorage.cpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/Parser/FormatParserStorage.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -6,4 +6,11 @@
  */
 
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "Helpers/MemDebug.hpp"
+
 #include <iostream>
 #include <fstream>
@@ -17,6 +24,6 @@
 #include "Parser/XyzParser.hpp"
 
-#include "log.hpp"
-#include "verbose.hpp"
+#include "Helpers/Log.hpp"
+#include "Helpers/Verbose.hpp"
 
 #include "Helpers/Assert.hpp"
Index: src/Parser/Makefile.am
===================================================================
--- src/Parser/Makefile.am	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
+++ src/Parser/Makefile.am	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -0,0 +1,74 @@
+# PLEASE adhere to the alphabetical ordering in this Makefile!
+# Also indentation by a single tab
+
+INCLUDES = -I$(top_srcdir)/src
+
+AM_LDFLAGS = $(CPPUNIT_LIBS) -ldl
+AM_CXXFLAGS = $(CPPUNIT_CFLAGS)
+
+PARSERSOURCE = \
+  ChangeTracker.cpp \
+  FormatParser.cpp \
+  FormatParserStorage.cpp \
+  MpqcParser.cpp \
+  PcpParser.cpp \
+  TremoloParser.cpp \
+  XyzParser.cpp
+
+PARSERHEADER = \
+  ChangeTracker.hpp \
+  FormatParser.hpp \
+  FormatParserStorage.hpp \
+  MpqcParser.hpp \
+  PcpParser.hpp \
+  TremoloParser.hpp \
+  XyzParser.hpp
+
+
+lib_LTLIBRARIES = libMolecuilderParser-@MOLECUILDER_API_VERSION@.la
+libMolecuilderParser_includedir = $(includedir)/molecuilder-$(MOLECUILDER_API_VERSION)/Actions/
+nobase_libMolecuilderParser_include_HEADERS = ${PARSERHEADER}
+
+## Define the source file list for the "libexample-@MOLECUILDER_API_VERSION@.la"
+## target.  Note that @MOLECUILDER_API_VERSION@ is not interpreted by Automake and
+## will therefore be treated as if it were literally part of the target name,
+## and the variable name derived from that.
+## The file extension .cc is recognized by Automake, and makes it produce
+## rules which invoke the C++ compiler to produce a libtool object file (.lo)
+## from each source file.  Note that it is not necessary to list header files
+## which are already listed elsewhere in a _HEADERS variable assignment.
+libMolecuilderParser_@MOLECUILDER_API_VERSION@_la_SOURCES = ${PARSERSOURCE}
+
+## Instruct libtool to include ABI version information in the generated shared
+## library file (.so).  The library ABI version is defined in configure.ac, so
+## that all version information is kept in one place.
+libMolecuilderParser_@MOLECUILDER_API_VERSION@_la_LDFLAGS = -version-info $(MOLECUILDER_SO_VERSION)
+
+## The generated configuration header is installed in its own subdirectory of
+## $(libdir).  The reason for this is that the configuration information put
+## into this header file describes the target platform the installed library
+## has been built for.  Thus the file must not be installed into a location
+## intended for architecture-independent files, as defined by the Filesystem
+## Hierarchy Standard (FHS).
+## The nodist_ prefix instructs Automake to not generate rules for including
+## the listed files in the distribution on 'make dist'.  Files that are listed
+## in _HEADERS variables are normally included in the distribution, but the
+## configuration header file is generated at configure time and should not be
+## shipped with the source tarball.
+libMolecuilderParser_libincludedir = $(libdir)/molecuilder-$(MOLECUILDER_API_VERSION)/include
+nodist_libMolecuilderParser_libinclude_HEADERS = $(top_builddir)/libmolecuilder_config.h
+
+## Install the generated pkg-config file (.pc) into the expected location for
+## architecture-dependent package configuration information.  Occasionally,
+## pkg-config files are also used for architecture-independent data packages,
+## in which case the correct install location would be $(datadir)/pkgconfig.
+pkgconfigdir = $(libdir)/pkgconfig
+pkgconfig_DATA = $(top_builddir)/molecuilder-$(MOLECUILDER_API_VERSION).pc
+
+unity.cpp:
+	echo "" >  unity.cpp; \
+	list='$(PARSERSOURCE)'; for file in $$list; do \
+	  echo "#include \"$(srcdir)/$$file\"" >> unity.cpp; \
+	done;
+	
+MOSTLYCLEANFILES = unity.cpp
Index: src/Parser/MpqcParser.cpp
===================================================================
--- src/Parser/MpqcParser.cpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/Parser/MpqcParser.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -6,4 +6,11 @@
  */
 
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "Helpers/MemDebug.hpp"
+
 #include "MpqcParser.hpp"
 
@@ -11,8 +18,8 @@
 #include "config.hpp"
 #include "element.hpp"
-#include "log.hpp"
+#include "Helpers/Log.hpp"
+#include "Helpers/Verbose.hpp"
+#include "LinearAlgebra/Vector.hpp"
 #include "periodentafel.hpp"
-#include "vector.hpp"
-#include "verbose.hpp"
 #include "World.hpp"
 
@@ -22,14 +29,11 @@
  */
 MpqcParser::MpqcParser() : HessianPresent(false)
-{
-
-}
+{}
 
 /** Destructor of MpqcParser.
  *
  */
-MpqcParser::~MpqcParser() {
-
-}
+MpqcParser::~MpqcParser()
+{}
 
 /** Load an MPQC config file into the World.
@@ -43,4 +47,6 @@
 void MpqcParser::save(ostream *file)
 {
+  DoLog(0) && (Log() << Verbose(0) << "Saving changes to MPQC ." << std::endl);
+
   if (HessianPresent)
     saveHessian(file);
@@ -60,5 +66,5 @@
   // calculate center
   for (vector<atom *>::iterator runner = allatoms.begin();runner != allatoms.end(); ++runner)
-    center += (*runner)->x;
+    center += (*runner)->getPosition();
   center.Scale(1./allatoms.size());
 
@@ -108,5 +114,5 @@
   // calculate center
   for (vector<atom *>::iterator runner = allatoms.begin();runner != allatoms.end(); ++runner)
-    center += (*runner)->x;
+    center += (*runner)->getPosition();
   center.Scale(1./allatoms.size());
 
Index: src/Parser/MpqcParser.hpp
===================================================================
--- src/Parser/MpqcParser.hpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/Parser/MpqcParser.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -11,5 +11,5 @@
 #include "FormatParser.hpp"
 
-#include <iostream>
+#include <iosfwd>
 
 /**
Index: src/Parser/PcpParser.cpp
===================================================================
--- src/Parser/PcpParser.cpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/Parser/PcpParser.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -6,6 +6,15 @@
  */
 
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "Helpers/MemDebug.hpp"
+
 #include <iostream>
-
+#include <iomanip>
+
+//#include "Actions/FragmentationAction/SubgraphDissectionAction.hpp"
 #include "atom.hpp"
 #include "config.hpp"
@@ -13,82 +22,112 @@
 #include "element.hpp"
 #include "Helpers/Assert.hpp"
-#include "log.hpp"
+#include "Helpers/Log.hpp"
+#include "Helpers/Verbose.hpp"
+#include "LinearAlgebra/Matrix.hpp"
 #include "molecule.hpp"
 #include "PcpParser.hpp"
 #include "periodentafel.hpp"
 #include "ThermoStatContainer.hpp"
-#include "verbose.hpp"
 #include "World.hpp"
+#include "Box.hpp"
+
+
+PcpParser::StructParallelization::StructParallelization() :
+  ProcPEGamma(8),
+  ProcPEPsi(1)
+{}
+
+PcpParser::StructParallelization::~StructParallelization()
+{}
+
+PcpParser::StructPaths::StructPaths() :
+  databasepath(NULL),
+  configname(NULL),
+  mainname(NULL),
+  defaultpath(NULL),
+  pseudopotpath(NULL)
+{}
+
+PcpParser::StructPaths::~StructPaths()
+{}
+
+PcpParser::StructSwitches::StructSwitches() :
+  DoConstrainedMD(0),
+  DoOutVis(0),
+  DoOutMes(1),
+  DoOutNICS(0),
+  DoOutOrbitals(0),
+  DoOutCurrent(0),
+  DoFullCurrent(0),
+  DoPerturbation(0),
+  DoWannier(0)
+{}
+
+PcpParser::StructSwitches::~StructSwitches()
+{}
+
+PcpParser::StructLocalizedOrbitals::StructLocalizedOrbitals() :
+  CommonWannier(0),
+  SawtoothStart(0.01),
+  VectorPlane(0),
+  VectorCut(0),
+  UseAddGramSch(1),
+  Seed(1),
+  EpsWannier(1e-7)
+{}
+
+PcpParser::StructLocalizedOrbitals::~StructLocalizedOrbitals()
+{}
+
+PcpParser::StructStepCounts::StructStepCounts() :
+  MaxMinStopStep(1),
+  InitMaxMinStopStep(1),
+  OutVisStep(10),
+  OutSrcStep(5),
+  MaxPsiStep(0),
+  MaxOuterStep(0),
+  MaxMinStep(100),
+  RelEpsTotalEnergy(1e-07),
+  RelEpsKineticEnergy(1e-05),
+  MaxMinGapStopStep(0),
+  MaxInitMinStep(100),
+  InitRelEpsTotalEnergy(1e-05),
+  InitRelEpsKineticEnergy(0.0001),
+  InitMaxMinGapStopStep(0)
+{}
+
+PcpParser::StructStepCounts::~StructStepCounts()
+{}
+
+PcpParser::StructPlaneWaveSpecifics::StructPlaneWaveSpecifics() :
+  PsiType(0),
+  MaxPsiDouble(0),
+  PsiMaxNoUp(0),
+  PsiMaxNoDown(0),
+  ECut(128),
+  MaxLevel(5),
+  RiemannTensor(0),
+  LevRFactor(0),
+  RiemannLevel(0),
+  Lev0Factor(2),
+  RTActualUse(0),
+  AddPsis(0),
+  RCut(20)
+{}
+
+PcpParser::StructPlaneWaveSpecifics::~StructPlaneWaveSpecifics()
+{}
 
 /** Constructor of PcpParser.
  *
  */
-PcpParser::PcpParser()
-{
-  Parallelization.ProcPEGamma = 8;
-  Parallelization.ProcPEPsi = 1;
-
-  Paths.databasepath = NULL;
-  Paths.configname = NULL;
-  Paths.mainname = NULL;
-  Paths.defaultpath = NULL;
-  Paths.pseudopotpath = NULL;
-
-  Switches.DoConstrainedMD = 0;
-  Switches.DoOutVis = 0;
-  Switches.DoOutMes = 1;
-  Switches.DoOutNICS = 0;
-  Switches.DoOutOrbitals = 0;
-  Switches.DoOutCurrent = 0;
-  Switches.DoFullCurrent = 0;
-  Switches.DoPerturbation = 0;
-  Switches.DoWannier = 0;
-
-  LocalizedOrbitals.CommonWannier = 0;
-  LocalizedOrbitals.SawtoothStart = 0.01;
-  LocalizedOrbitals.VectorPlane = 0;
-  LocalizedOrbitals.VectorCut = 0;
-  LocalizedOrbitals.UseAddGramSch = 1;
-  LocalizedOrbitals.Seed = 1;
-  LocalizedOrbitals.EpsWannier = 1e-7;
-
-  StepCounts.MaxMinStopStep = 1;
-  StepCounts.InitMaxMinStopStep = 1;
-  StepCounts.OutVisStep = 10;
-  StepCounts.OutSrcStep = 5;
-  StepCounts.MaxPsiStep = 0;
-  StepCounts.MaxOuterStep = 0;
-  StepCounts.MaxMinStep = 100;
-  StepCounts.RelEpsTotalEnergy = 1e-07;
-  StepCounts.RelEpsKineticEnergy = 1e-05;
-  StepCounts.MaxMinGapStopStep = 0;
-  StepCounts.MaxInitMinStep = 100;
-  StepCounts.InitRelEpsTotalEnergy = 1e-05;
-  StepCounts.InitRelEpsKineticEnergy = 0.0001;
-  StepCounts.InitMaxMinGapStopStep = 0;
-
-  PlaneWaveSpecifics.PsiType = 0;
-  PlaneWaveSpecifics.MaxPsiDouble = 0;
-  PlaneWaveSpecifics.PsiMaxNoUp = 0;
-  PlaneWaveSpecifics.PsiMaxNoDown = 0;
-  PlaneWaveSpecifics.ECut = 128;
-  PlaneWaveSpecifics.MaxLevel = 5;
-  PlaneWaveSpecifics.RiemannTensor = 0;
-  PlaneWaveSpecifics.LevRFactor = 0;
-  PlaneWaveSpecifics.RiemannLevel = 0;
-  PlaneWaveSpecifics.Lev0Factor = 2;
-  PlaneWaveSpecifics.RTActualUse = 0;
-  PlaneWaveSpecifics.AddPsis = 0;
-  PlaneWaveSpecifics.RCut = 20;
-  PlaneWaveSpecifics.PsiType = 0;
-
-  FastParsing = false;
-
-  Deltat = 0.01;
-  IsAngstroem = 1;
-  RelativeCoord = 0;
-  StructOpt = 0;
-  MaxTypes = 0;
-}
+PcpParser::PcpParser() :
+  FastParsing(false),
+  Deltat(0.01),
+  IsAngstroem(1),
+  RelativeCoord(0),
+  StructOpt(0),
+  MaxTypes(0)
+{}
 
 /** Destructor of PcpParser.
@@ -210,5 +249,5 @@
   // Unit cell and magnetic field
   ParseForParameter(verbose,FileBuffer, "BoxLength", 0, 3, 3, lower_trigrid, BoxLength, 1, critical); /* Lattice->RealBasis */
-  double * const cell_size = World::getInstance().getDomain();
+  double *cell_size = new double[6];
   cell_size[0] = BoxLength[0];
   cell_size[1] = BoxLength[3];
@@ -217,4 +256,6 @@
   cell_size[4] = BoxLength[7];
   cell_size[5] = BoxLength[8];
+  World::getInstance().setDomain(cell_size);
+  delete[] cell_size;
   //if (1) fprintf(stderr,"\n");
 
@@ -316,5 +357,5 @@
   // 4. dissect the molecule into connected subgraphs
   // don't do this here ...
-  //MolList->DissectMoleculeIntoConnectedSubgraphs(mol,this);
+  //FragmentationSubgraphDissection();
   //delete(mol);
 
@@ -327,5 +368,7 @@
 void PcpParser::save(std::ostream* file)
 {
-  const double * const cell_size = World::getInstance().getDomain();
+  DoLog(0) && (Log() << Verbose(0) << "Saving changes to pcp." << std::endl);
+
+  const Matrix &domain = World::getInstance().getDomain().getM();
   class ThermoStatContainer *Thermostats = World::getInstance().getThermostats();
   if (!file->fail()) {
@@ -412,7 +455,7 @@
     *file << endl;
     *file << "BoxLength\t\t\t# (Length of a unit cell)" << endl;
-    *file << cell_size[0] << "\t" << endl;
-    *file << cell_size[1] << "\t" << cell_size[2] << "\t" << endl;
-    *file << cell_size[3] << "\t" << cell_size[4] << "\t" << cell_size[5] << "\t" << endl;
+    *file << domain.at(0,0) << "\t" << endl;
+    *file << domain.at(1,0) << "\t" << domain.at(1,1) << "\t" << endl;
+    *file << domain.at(2,0) << "\t" << domain.at(2,1) << "\t" << domain.at(2,2) << "\t" << endl;
     // FIXME
     *file << endl;
@@ -455,5 +498,5 @@
   PlaneWaveSpecifics.MaxPsiDouble = PlaneWaveSpecifics.PsiMaxNoDown = PlaneWaveSpecifics.PsiMaxNoUp = PlaneWaveSpecifics.PsiType = 0;
   for (vector<atom *>::iterator runner = allatoms.begin(); runner != allatoms.end(); ++runner) {
-    PlaneWaveSpecifics.MaxPsiDouble += (*runner)->type->NoValenceOrbitals;
+    PlaneWaveSpecifics.MaxPsiDouble += (*runner)->getType()->NoValenceOrbitals;
   }
   cout << PlaneWaveSpecifics.MaxPsiDouble << endl;
@@ -490,5 +533,5 @@
   // insert all found elements into the map
   for (vector<atom *>::iterator AtomRunner = allatoms.begin();AtomRunner != allatoms.end();++AtomRunner) {
-    Inserter = PresentElements.insert(pair<int, int>((*AtomRunner)->type->Z, 1));
+    Inserter = PresentElements.insert(pair<int, int>((*AtomRunner)->getType()->Z, 1));
     if (!Inserter.second) // increase if present
       Inserter.first->second += 1;
@@ -505,5 +548,5 @@
     const element * const elemental = World::getInstance().getPeriode()->FindElement(iter->first);
     ZtoIndexMap.insert( pair<int,int> (iter->first, counter) );
-    *file << "Ion_Type" << counter++ << "\t" << iter->second << "\t" << elemental->Z << "\t1.0\t3\t3\t" << fixed << setprecision(11) << showpoint << elemental->mass << "\t" << elemental->name << "\t" << elemental->symbol <<endl;
+    *file << "Ion_Type" << counter++ << "\t" << iter->second << "\t" << elemental->Z << "\t1.0\t3\t3\t" << fixed << setprecision(11) << showpoint << elemental->mass << "\t" << elemental->getName() << "\t" << elemental->getSymbol() <<endl;
   }
 }
@@ -521,13 +564,13 @@
   int nr = 0;
   for (vector<atom *>::iterator AtomRunner = allatoms.begin();AtomRunner != allatoms.end();++AtomRunner) {
-    Inserter = ZtoCountMap.insert( pair<int, int>((*AtomRunner)->type->Z, 1) );
+    Inserter = ZtoCountMap.insert( pair<int, int>((*AtomRunner)->getType()->Z, 1) );
     if (!Inserter.second)
       Inserter.first->second += 1;
-    const int Z = (*AtomRunner)->type->Z;
+    const int Z = (*AtomRunner)->getType()->Z;
     *file << "Ion_Type" << ZtoIndexMap[Z] << "_" << ZtoCountMap[Z] << "\t"  << fixed << setprecision(9) << showpoint;
-    *file << (*AtomRunner)->x[0] << "\t" << (*AtomRunner)->x[1] << "\t" << (*AtomRunner)->x[2];
+    *file << (*AtomRunner)->at(0) << "\t" << (*AtomRunner)->at(1) << "\t" << (*AtomRunner)->at(2);
     *file << "\t" << (*AtomRunner)->FixedIon;
-    if ((*AtomRunner)->v.Norm() > MYEPSILON)
-      *file << "\t" << scientific << setprecision(6) << (*AtomRunner)->v[0] << "\t" << (*AtomRunner)->v[1] << "\t" << (*AtomRunner)->v[2] << "\t";
+    if ((*AtomRunner)->AtomicVelocity.Norm() > MYEPSILON)
+      *file << "\t" << scientific << setprecision(6) << (*AtomRunner)->AtomicVelocity[0] << "\t" << (*AtomRunner)->AtomicVelocity[1] << "\t" << (*AtomRunner)->AtomicVelocity[2] << "\t";
     *file << " # molecule nr " << nr++ << endl;
   }
Index: src/Parser/PcpParser.hpp
===================================================================
--- src/Parser/PcpParser.hpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/Parser/PcpParser.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -9,5 +9,5 @@
 #define PCPPARSER_HPP_
 
-#include <iostream>
+#include <iosfwd>
 #include "Parser/FormatParser.hpp"
 
@@ -31,5 +31,9 @@
   void CalculateOrbitals(vector<atom *> &allatoms);
 
-  struct StructParallelization {
+  class StructParallelization {
+  public:
+    StructParallelization();
+    ~StructParallelization();
+
     int ProcPEGamma;
     int ProcPEPsi;
@@ -39,5 +43,9 @@
    * Contains all the paths and names
    */
-  struct StructPaths {
+  class StructPaths {
+  public:
+    StructPaths();
+    ~StructPaths();
+
     char *databasepath;
     char *configname;
@@ -50,5 +58,9 @@
    * Contains all Do/Don't switches
    */
-  struct StructSwitches {
+  class StructSwitches {
+  public:
+    StructSwitches();
+    ~StructSwitches();
+
     int DoConstrainedMD;
     int DoOutVis;
@@ -65,5 +77,9 @@
    * Contains parameters regarding localization of orbitals or magnetic perturbation
    */
-  struct StructLocalizedOrbitals {
+  class StructLocalizedOrbitals {
+  public:
+    StructLocalizedOrbitals();
+    ~StructLocalizedOrbitals();
+
     int CommonWannier;
     double SawtoothStart;
@@ -78,5 +94,9 @@
    * Contains all step count and other epsilon threshold parameters
    */
-  struct StructStepCounts {
+  class StructStepCounts {
+  public:
+    StructStepCounts();
+    ~StructStepCounts();
+
     int MaxMinStopStep;
     int InitMaxMinStopStep;
@@ -101,5 +121,9 @@
    * Contains all parameters specific to the plane wave basis set
    */
-  struct StructPlaneWaveSpecifics {
+  class StructPlaneWaveSpecifics {
+  public:
+    StructPlaneWaveSpecifics();
+    ~StructPlaneWaveSpecifics();
+
     int PsiType;
     int MaxPsiDouble;
Index: src/Parser/TremoloParser.cpp
===================================================================
--- src/Parser/TremoloParser.cpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/Parser/TremoloParser.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -6,7 +6,14 @@
  */
 
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
 #include "Helpers/MemDebug.hpp"
 
 #include "Helpers/Assert.hpp"
+#include "Helpers/Log.hpp"
+#include "Helpers/Verbose.hpp"
 #include "TremoloParser.hpp"
 #include "World.hpp"
@@ -21,5 +28,4 @@
 
 using namespace std;
-using namespace boost;
 
 /**
@@ -99,4 +105,6 @@
  */
 void TremoloParser::save(ostream* file) {
+  DoLog(0) && (Log() << Verbose(0) << "Saving changes to tremolo." << std::endl);
+
   vector<atom*>::iterator atomIt;
   vector<string>::iterator it;
@@ -140,13 +148,13 @@
       case TremoloKey::x :
         // for the moment, assume there are always three dimensions
-        *file << currentAtom->x[0] << "\t";
-        *file << currentAtom->x[1] << "\t";
-        *file << currentAtom->x[2] << "\t";
+        *file << currentAtom->at(0) << "\t";
+        *file << currentAtom->at(1) << "\t";
+        *file << currentAtom->at(2) << "\t";
         break;
       case TremoloKey::u :
         // for the moment, assume there are always three dimensions
-        *file << currentAtom->v[0] << "\t";
-        *file << currentAtom->v[1] << "\t";
-        *file << currentAtom->v[2] << "\t";
+        *file << currentAtom->AtomicVelocity[0] << "\t";
+        *file << currentAtom->AtomicVelocity[1] << "\t";
+        *file << currentAtom->AtomicVelocity[2] << "\t";
         break;
       case TremoloKey::Type :
@@ -225,4 +233,5 @@
   string word;
   int oldId;
+  double tmp;
 
   lineStream << line;
@@ -232,13 +241,14 @@
       case TremoloKey::x :
         // for the moment, assume there are always three dimensions
-        lineStream >> newAtom->x[0];
-        lineStream >> newAtom->x[1];
-        lineStream >> newAtom->x[2];
+        for (int i=0;i<NDIM;i++) {
+          lineStream >> tmp;
+          newAtom->set(i, tmp);
+        }
         break;
       case TremoloKey::u :
         // for the moment, assume there are always three dimensions
-        lineStream >> newAtom->v[0];
-        lineStream >> newAtom->v[1];
-        lineStream >> newAtom->v[2];
+        lineStream >> newAtom->AtomicVelocity[0];
+        lineStream >> newAtom->AtomicVelocity[1];
+        lineStream >> newAtom->AtomicVelocity[2];
         break;
       case TremoloKey::Type :
@@ -385,23 +395,23 @@
 
 
-TremoloAtomInfoContainer::TremoloAtomInfoContainer() {
-  F = "0";
-  stress = "0";
-  imprData = "-";
-  GroupMeasureTypeNo = "0";
-  extType = "-";
-  name = "-";
-  resName = "-";
-  chainID = "0";
-  resSeq = "0";
-  occupancy = "0";
-  tempFactor = "0";
-  segID = "0";
-  Charge = "0";
-  charge = "0";
-  GrpTypeNo = "0";
-  torsion = "-";
-  neighbors = vector<int>(0, 5);
-}
+TremoloAtomInfoContainer::TremoloAtomInfoContainer() :
+  F("0"),
+  stress("0"),
+  imprData("-"),
+  GroupMeasureTypeNo("0"),
+  extType("-"),
+  name("-"),
+  resName("-"),
+  chainID("0"),
+  resSeq("0"),
+  occupancy("0"),
+  tempFactor("0"),
+  segID("0"),
+  Charge("0"),
+  charge("0"),
+  GrpTypeNo("0"),
+  torsion("-"),
+  neighbors(vector<int>(0, 5))
+{}
 
 void TremoloAtomInfoContainer::set(TremoloKey::atomDataKey key, string value) {
Index: src/Parser/XyzParser.cpp
===================================================================
--- src/Parser/XyzParser.cpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/Parser/XyzParser.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -6,9 +6,17 @@
  */
 
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
 #include "Helpers/MemDebug.hpp"
 
+#include "Helpers/Log.hpp"
+#include "Helpers/Verbose.hpp"
 #include "XyzParser.hpp"
 #include "World.hpp"
 #include "atom.hpp"
+#include "molecule.hpp"
 #include "element.hpp"
 #include "periodentafel.hpp"
@@ -19,7 +27,7 @@
  * Constructor.
  */
-XyzParser::XyzParser() {
-  comment = "";
-}
+XyzParser::XyzParser() :
+  comment("")
+{}
 
 /**
@@ -35,7 +43,9 @@
  */
 void XyzParser::load(istream* file) {
-  atom* newAtom;
+  atom* newAtom = NULL;
+  molecule* newmol = NULL;
   int numberOfAtoms;
   char commentBuffer[512], type[3];
+  double tmp;
 
   // the first line tells number of atoms, the second line is always a comment
@@ -44,8 +54,17 @@
   comment = commentBuffer;
 
+  newmol = World::getInstance().createMolecule();
+  newmol->ActiveFlag = true;
+  // TODO: Remove the insertion into molecule when saving does not depend on them anymore. Also, remove molecule.hpp include
+  World::getInstance().getMolecules()->insert(newmol);
   for (int i = 0; i < numberOfAtoms; i++) {
     newAtom = World::getInstance().createAtom();
-    *file >> type >> ws >> newAtom->x[0] >> ws >> newAtom->x[1] >> ws >> newAtom->x[2];
+    *file >> type;
+    for (int j=0;j<NDIM;j++) {
+      *file >> tmp;
+      newAtom->set(j, tmp);
+    }
     newAtom->setType(World::getInstance().getPeriode()->FindElement(type));
+    newmol->AddAtom(newAtom);
   }
 }
@@ -57,4 +76,5 @@
  */
 void XyzParser::save(ostream* file) {
+  DoLog(0) && (Log() << Verbose(0) << "Saving changes to xyz." << std::endl);
   if (comment == "") {
     time_t now = time((time_t *)NULL);   // Get the system time and put it into 'now' as 'calender time'
@@ -72,5 +92,5 @@
   vector<atom*> atoms = World::getInstance().getAllAtoms();
   for(vector<atom*>::iterator it = atoms.begin(); it != atoms.end(); it++) {
-    *file << noshowpoint << (*it)->getType()->symbol << "\t" << (*it)->x[0] << "\t" << (*it)->x[1] << "\t" << (*it)->x[2] << endl;
+    *file << noshowpoint << (*it)->getType()->getSymbol() << "\t" << (*it)->at(0) << "\t" << (*it)->at(1) << "\t" << (*it)->at(2) << endl;
   }
 }
Index: src/Patterns/Cacheable.hpp
===================================================================
--- src/Patterns/Cacheable.hpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/Patterns/Cacheable.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -12,5 +12,4 @@
 #include <boost/function.hpp>
 #include <boost/shared_ptr.hpp>
-#include <iostream>
 
 #include "Helpers/Assert.hpp"
Index: src/Patterns/ObservedContainer.hpp
===================================================================
--- src/Patterns/ObservedContainer.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
+++ src/Patterns/ObservedContainer.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -0,0 +1,95 @@
+/*
+ * AtomSet.hpp
+ *
+ *  Created on: Jul 8, 2010
+ *      Author: crueger
+ */
+
+#ifndef OBSERVEDCONTAINER_HPP_
+#define OBSERVEDCONTAINER_HPP_
+
+#include "types.hpp"
+
+#include <utility>
+#include "Patterns/ObservedIterator.hpp"
+#include "Descriptors/SelectiveIterator.hpp"
+
+class World;
+class atom;
+class AtomDescriptor;
+
+/**
+ * Forward to std::map<atomId_t,atom*> that allows production of observed and
+ * unobserved iterators to all atoms.
+ *
+ * Imported via typedef into class World. Defined here to avoid bloating of the
+ * World class
+ */
+template <class Container>
+class ObservedContainer
+{
+  friend class World;
+
+public:
+  typedef Container set_t;
+  // this iterator can be used for internal purposes...
+  // no lock used here
+  typedef typename set_t::iterator                              internal_iterator;
+  typedef typename std::reverse_iterator<internal_iterator>     reverse_internal_iterator;
+
+  // typedefs for iterator structure
+  typedef ObservedIterator<set_t>                               iterator;
+  typedef typename set_t::const_iterator                        const_iterator;
+  typedef std::reverse_iterator<iterator>                       reverse_iterator;
+  typedef typename std::reverse_iterator<const_iterator>        const_reverse_iterator;
+
+  // some more typedefs for STL-Structure
+  typedef typename set_t::key_type               key_type;
+  typedef typename set_t::mapped_type            mapped_type;
+  typedef typename set_t::value_type             value_type;
+  typedef typename set_t::key_compare            key_compare;
+  typedef typename set_t::allocator_type         allocator_type;
+
+  ObservedContainer(Observable*);
+  ObservedContainer(const ObservedContainer&);
+  virtual ~ObservedContainer();
+
+  // all the functions from STL-map (forwards to content)
+  ObservedContainer& operator=(const ObservedContainer&);
+
+  iterator                      begin();
+  const_iterator                begin()         const;
+  iterator                      end();
+  const_iterator                end()           const;
+  reverse_iterator              rbegin();
+  const_reverse_iterator        rbegin()        const;
+  reverse_iterator              rend();
+  const_reverse_iterator        rend()          const;
+
+  bool empty() const;
+  size_t size() const;
+  size_t max_size() const;
+
+  mapped_type &operator[](const key_type&);
+
+  std::pair<iterator,bool> insert (const value_type&);
+
+  size_t erase ( const key_type& x );
+  void clear();
+
+  iterator              find ( const key_type& x );
+  const_iterator        find ( const key_type& x ) const;
+
+  size_t count ( const key_type& x ) const;
+  internal_iterator             begin_internal();
+  internal_iterator             end_internal();
+  reverse_internal_iterator     rbegin_internal();
+  reverse_internal_iterator     rend_internal();
+
+  set_t &getContent();
+private:
+  set_t content;
+  Observable *obs;
+};
+
+#endif /* OBSERVEDCONTAINER_HPP_ */
Index: src/Patterns/ObservedContainer_impl.hpp
===================================================================
--- src/Patterns/ObservedContainer_impl.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
+++ src/Patterns/ObservedContainer_impl.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -0,0 +1,215 @@
+/*
+ * AtomSet_impl.hpp
+ *
+ *  Created on: Jul 8, 2010
+ *      Author: crueger
+ */
+
+#ifndef OBSERVEDCONTAINER_IMPL_HPP_
+#define OBSERVEDCONTAINER_IMPL_HPP_
+
+#include "Patterns/ObservedContainer.hpp"
+
+template <class Container>
+inline ObservedContainer<Container>::ObservedContainer(Observable* _obs) :
+  obs(_obs)
+{}
+
+template <class Container>
+inline ObservedContainer<Container>::ObservedContainer(const ObservedContainer<Container> &src) :
+  content(src.content),
+  obs(src.obs)
+{}
+
+template <class Container>
+inline ObservedContainer<Container>::~ObservedContainer()
+{}
+
+template <class Container>
+inline
+ObservedContainer<Container>&
+ObservedContainer<Container>::operator=(const ObservedContainer<Container> &rhs){
+  content=rhs.content;
+  return *this;
+}
+
+template <class Container>
+inline
+typename ObservedContainer<Container>::iterator
+ObservedContainer<Container>::begin(){
+  return ObservedContainer<Container>::iterator(content.begin(),obs);
+}
+
+template <class Container>
+inline
+typename ObservedContainer<Container>::const_iterator
+ObservedContainer<Container>::begin() const{
+  return content.begin();
+}
+
+template <class Container>
+inline
+typename ObservedContainer<Container>::iterator
+ObservedContainer<Container>::end(){
+  return ObservedContainer<Container>::iterator(content.end(),obs);
+}
+
+template <class Container>
+inline
+typename ObservedContainer<Container>::const_iterator
+ObservedContainer<Container>::end() const{
+  return content.end();
+}
+
+template <class Container>
+inline
+typename ObservedContainer<Container>::reverse_iterator
+ObservedContainer<Container>::rbegin(){
+  return reverse_iterator(begin());
+}
+
+template <class Container>
+inline
+typename ObservedContainer<Container>::const_reverse_iterator
+ObservedContainer<Container>::rbegin() const{
+  return const_reverse_iterator(begin());
+}
+
+template <class Container>
+inline
+typename ObservedContainer<Container>::reverse_iterator
+ObservedContainer<Container>::rend(){
+  return reverse_iterator(end());
+}
+
+template <class Container>
+inline
+typename ObservedContainer<Container>::const_reverse_iterator
+ObservedContainer<Container>::rend() const{
+  return const_reverse_iterator(end());
+}
+
+template <class Container>
+inline bool ObservedContainer<Container>::empty() const{
+  return content.empty();
+}
+
+template <class Container>
+inline size_t ObservedContainer<Container>::size() const{
+  return content.size();
+}
+
+template <class Container>
+inline size_t ObservedContainer<Container>::max_size() const{
+  return content.max_size();
+}
+
+template <class Container>
+inline
+typename ObservedContainer<Container>::mapped_type &
+ObservedContainer<Container>::operator[](const key_type &key){
+  return content[key];
+}
+
+template <class Container>
+inline
+std::pair<typename ObservedContainer<Container>::iterator,bool>
+ObservedContainer<Container>::insert (const value_type &value){
+  std::pair<typename set_t::iterator,bool> res = content.insert(value);
+  return std::make_pair(iterator(res.first,obs),res.second);
+}
+
+template <class Container>
+inline size_t ObservedContainer<Container>::erase ( const key_type& x ){
+  return content.erase(x);
+}
+
+template <class Container>
+inline void ObservedContainer<Container>::clear(){
+  content.clear();
+}
+
+template <class Container>
+inline
+typename ObservedContainer<Container>::iterator
+ObservedContainer<Container>::find ( const key_type& x ){
+  return iterator(content.find(x),obs);
+}
+
+template <class Container>
+inline
+typename ObservedContainer<Container>::const_iterator
+ObservedContainer<Container>::find ( const key_type& x ) const{
+  return content.find(x);
+}
+
+template <class Container>
+inline size_t ObservedContainer<Container>::count ( const key_type& x ) const{
+  return content.count(x);
+}
+
+/************ Unprotected access ***************/
+
+template <class Container>
+inline
+typename ObservedContainer<Container>::internal_iterator
+ObservedContainer<Container>::begin_internal(){
+  return content.begin();
+}
+
+template <class Container>
+inline
+typename ObservedContainer<Container>::internal_iterator
+ObservedContainer<Container>::end_internal(){
+  return content.end();
+}
+
+template <class Container>
+inline
+typename ObservedContainer<Container>::reverse_internal_iterator
+ObservedContainer<Container>::rbegin_internal(){
+  return content.rbegin();
+}
+
+template <class Container>
+inline
+typename ObservedContainer<Container>::reverse_internal_iterator
+ObservedContainer<Container>::rend_internal(){
+  return content.rend();
+}
+
+template <class Container>
+inline
+typename ObservedContainer<Container>::set_t &
+ObservedContainer<Container>::getContent(){
+  return content;
+}
+
+/************ Explicit instantiation ***************/
+
+#define CONSTRUCT_OBSERVEDCONTAINER(name) \
+    template ObservedContainer< name >& ObservedContainer< name >::operator=(const ObservedContainer< name >&); \
+    template ObservedContainer< name >::iterator ObservedContainer< name >::begin(); \
+    template ObservedContainer< name >::const_iterator ObservedContainer< name >::begin() const; \
+    template ObservedContainer< name >::iterator ObservedContainer< name >::end(); \
+    template ObservedContainer< name >::const_iterator ObservedContainer< name >::end() const; \
+    template ObservedContainer< name >::reverse_iterator ObservedContainer< name >::rbegin(); \
+    template ObservedContainer< name >::const_reverse_iterator ObservedContainer< name >::rbegin() const; \
+    template ObservedContainer< name >::reverse_iterator ObservedContainer< name >::rend(); \
+    template ObservedContainer< name >::const_reverse_iterator ObservedContainer< name >::rend() const; \
+    template bool ObservedContainer< name >::empty() const; \
+    template size_t ObservedContainer< name >::size() const; \
+    template size_t ObservedContainer< name >::max_size() const; \
+    template ObservedContainer< name >::mapped_type &ObservedContainer< name >::operator[](const key_type&); \
+    template std::pair<ObservedContainer< name >::iterator,bool> ObservedContainer< name >::insert (const value_type&); \
+    template size_t ObservedContainer< name >::erase ( const key_type& x ); \
+    template void ObservedContainer< name >::clear(); \
+    template ObservedContainer< name >::iterator ObservedContainer< name >::find ( const key_type& x ); \
+    template ObservedContainer< name >::const_iterator ObservedContainer< name >::find ( const key_type& x ) const; \
+    template size_t ObservedContainer< name >::count ( const key_type& x ) const; \
+    template ObservedContainer< name >::internal_iterator ObservedContainer< name >::begin_internal(); \
+    template ObservedContainer< name >::reverse_internal_iterator ObservedContainer< name >::rbegin_internal(); \
+    template ObservedContainer< name >::internal_iterator ObservedContainer< name >::end_internal(); \
+    template ObservedContainer< name >::reverse_internal_iterator ObservedContainer< name >::rend_internal(); \
+
+#endif /* OBSERVEDCONTAINER_IMPL_HPP_ */
Index: src/Patterns/ObservedIterator.hpp
===================================================================
--- src/Patterns/ObservedIterator.hpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/Patterns/ObservedIterator.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -108,4 +108,9 @@
   }
 
+  value_type *operator->(){
+    acquireLock();
+    return &(*iter);
+  }
+
   // when we turn into a const iterator we can loose our lock
   operator typename _Set::const_iterator() {
Index: src/Patterns/Observer.cpp
===================================================================
--- src/Patterns/Observer.cpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/Patterns/Observer.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -6,8 +6,12 @@
  */
 
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
 #include "Helpers/MemDebug.hpp"
 
 #include "Observer.hpp"
-
 
 #include <iostream>
Index: src/Patterns/Observer.hpp
===================================================================
--- src/Patterns/Observer.hpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/Patterns/Observer.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -170,5 +170,5 @@
   //! @cond
   // Structure for RAII-Style notification
-protected:
+public:
   /**
    * This structure implements the Observer-mechanism RAII-Idiom.
@@ -241,4 +241,5 @@
 #define OBSERVE Observable::_Observable_protector PASTE(_scope_obs_protector_,__LINE__)(this)
 #define NOTIFY(notification) do{Observable::enque_notification_internal(this,notification);}while(0)
+#define LOCK_OBSERVABLE(observable) Observable::_Observable_protector PASTE(_scope_obs_protector_,__LINE__)(&(observable))
 
 #endif /* OBSERVER_HPP_ */
Index: src/Patterns/Registry.hpp
===================================================================
--- src/Patterns/Registry.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
+++ src/Patterns/Registry.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -0,0 +1,76 @@
+/*
+ * Registry.hpp
+ *
+ *  Based on Registry<Action> by Till Crueger.
+ *
+ *  The registry pattern is basically just a singleton map, wherein instantiations
+ *  of a class can be registered, unregistered and retrieved.
+ *
+ *  Created on: Jul 28, 2010
+ *      Author: heber
+ */
+
+#ifndef REGISTRY_HPP_
+#define REGISTRY_HPP_
+
+#include <map>
+
+/**
+ * This template produces a generic registry pattern.
+ *
+ * <h1> Registry Howto </h1>
+ *
+ * The registry is a class where instances of other classes are stored and be retrieved
+ * when desired. For this purpose a registry should always be a singleton (i.e. use both
+ * this registry and the singleton pattern to declare a registry class). It basically
+ * is simply a singleton container of a map, where the pointers to the class instances are
+ * stored by a string key and can be retrieved thereby.
+ *
+ * The available functions are, if your class to be stored in registry is foo :
+ *
+ * - <code>foo* Registry<foo>::getByName()</code> : returns the instance of a specific
+ *    class foo instance as a pointer associated with the given name
+ * - <code>bool Registry<foo>::isPresentByName()</code> : returns whether an instance
+ *    of class foo is present under the given name.
+ * - <code>map<string,foo*>::iterator Registry<foo>::getBeginIter()</code> : returns an
+ *    iterator to the beginning of the storage map (STL).
+ * - <code>map<string,foo*>::const_iterator Registry<foo>::getBeginIter()</code> : returns a
+ *    constant iterator to the beginning of the storage map (STL).
+ * - <code>map<string,foo*>::const_iterator Registry<foo>::getEndIter()</code> : returns an
+ *    iterator to the one step past the last element of the storage map (STL).
+ * - <code>map<string,foo*>::const_iterator Registry<foo>::getEndIter()</code> : returns a
+ *    constant iterator to the one step past the last element of the storage map (STL).
+ *
+ * In order to use this pattern, additionally to the requirements of the Singleton pattern,
+ * do this:
+ *   -# in the declaration derive your class from Registry<foo>, where foo is the class to be
+ *      stored
+ *   -# in the definition add CONSTRUCT_REGISTRY(foo) to the code such that the templated
+ *      functions get instantiated there (otherwise you'll get undefined reference errors).
+ *
+ */
+
+template <class T>
+class Registry
+{
+public:
+  Registry();
+  ~Registry();
+
+  T* getByName(const std::string name);
+  bool isPresentByName(const std::string name);
+  void registerInstance(T*);
+  void unregisterInstance(T*);
+
+  typename std::map<const std::string,T*>::iterator getBeginIter();
+  typename std::map<const std::string,T*>::const_iterator getBeginIter() const;
+  typename std::map<const std::string,T*>::iterator getEndIter();
+  typename std::map<const std::string,T*>::const_iterator getEndIter() const;
+
+private:
+  typename std::map<const std::string,T*> InstanceMap;
+};
+
+template <class T> std::ostream& operator<<(std::ostream& ost, const Registry<T>& m);
+
+#endif /* REGISTRY_HPP_ */
Index: src/Patterns/Registry_impl.hpp
===================================================================
--- src/Patterns/Registry_impl.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
+++ src/Patterns/Registry_impl.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -0,0 +1,141 @@
+/*
+ * Registry_impl.hpp
+ *
+ *  Created on: Jul 28, 2010
+ *      Author: heber
+ */
+
+#ifndef REGISTRY_IMPL_HPP_
+#define REGISTRY_IMPL_HPP_
+
+#include "Helpers/MemDebug.hpp"
+
+#include "Patterns/Registry.hpp"
+#include "Patterns/Singleton_impl.hpp"
+
+#include "Helpers/Assert.hpp"
+#include <iosfwd>
+
+/** Constructor for class Registry.
+ */
+template <class T> Registry<T>::Registry()
+{}
+
+/** Destructor for class Registry.
+ */
+template <class T> Registry<T>::~Registry()
+{
+  typename std::map<const std::string,T*>::iterator iter;
+  for(iter=InstanceMap.begin();iter!=InstanceMap.end();++iter) {
+    delete iter->second;
+  }
+  InstanceMap.clear();
+}
+
+/** Returns pointer to an instance named by \a name.
+ * \param name name of instance
+ * \return pointer to instance
+ */
+template <class T> T* Registry<T>::getByName(const std::string name){
+  typename std::map<const std::string,T*>::iterator iter;
+  iter = InstanceMap.find(name);
+  ASSERT(iter!=InstanceMap.end(),"Query for an instance not stored in registry");
+  return iter->second;
+}
+
+/** States whether instance is present or not.
+ * \note This is needed as Registry<T>::getByName() ASSERT()s that instance is in std::map.
+ * \param name name of instance
+ * \return true - v present, false - instance absent
+ */
+template <class T>bool Registry<T>::isPresentByName(const std::string name){
+  typename std::map<const std::string,T*>::iterator iter;
+  iter = InstanceMap.find(name);
+  return iter!=InstanceMap.end();
+}
+
+/** Registers an instance with the Registry.
+ * \param *instance pointer to T.
+ */
+template <class T>void Registry<T>::registerInstance(T* instance){
+  std::pair<typename std::map<const std::string,T*>::iterator,bool> ret;
+  //cout << "Trying to register instance with name " << instance->getName() << "." << endl;
+  ret = InstanceMap.insert(typename std::pair<const std::string,T*>(instance->getName(),instance));
+  ASSERT(ret.second,"Two instances with the same name added to registry");
+}
+
+/** Unregisters an instance.
+ * \param *instance pointer to instance.
+ */
+template <class T>void Registry<T>::unregisterInstance(T* instance){
+  //cout << "Unregistering instance with name " << instance->getName() << "." << endl;
+  InstanceMap.erase(instance->getName());
+}
+
+/** Returns an iterator pointing to the start of the std::map of instance's.
+ * \return begin iterator
+ */
+template <class T>
+typename std::map<const std::string,T*>::iterator Registry<T>::getBeginIter()
+{
+  return InstanceMap.begin();
+}
+
+/** Returns an iterator pointing to the end of the std::map of instance's.
+ * \return end iterator
+ */
+template <class T>
+typename std::map<const std::string,T*>::iterator Registry<T>::getEndIter()
+{
+  return InstanceMap.end();
+}
+
+/** Returns a const iterator pointing to the start of the std::map of instance's.
+ * \return constant begin iterator
+ */
+template <class T>
+typename std::map<const std::string,T*>::const_iterator Registry<T>::getBeginIter() const
+{
+  return InstanceMap.begin();
+}
+
+/** Returns a const iterator pointing to the end of the std::map of instance's.
+ * \return constant end iterator
+ */
+template <class T>
+typename std::map<const std::string,T*>::const_iterator Registry<T>::getEndIter() const
+{
+  return InstanceMap.end();
+}
+
+/** Prints the contents of the Registry \a &m to \a &ost.
+ * \param &ost output stream
+ * \param &m reference to Registry
+ * \return reference to the above out stream for concatenation
+ */
+template <class T>
+std::ostream& operator<<(std::ostream& ost, const Registry<T>& m)
+{
+  ost << "Registry contains:" << std::endl;
+  for (typename std::map<const std::string,T*>::const_iterator iter = m.getBeginIter(); iter != m.getEndIter(); ++iter) {
+    ost << "\t" << iter->first << " with pointer " << iter->second << std::endl;
+  }
+  return ost;
+};
+
+/**
+ * This define allows simple instantiation of the necessary registryfunctions
+ * at a chosen place.
+ */
+#define CONSTRUCT_REGISTRY(name) \
+    template name* Registry<name>::getByName(const std::string name); \
+    template bool Registry<name>::isPresentByName(const std::string name); \
+    template void Registry<name>::registerInstance(name*); \
+    template void Registry<name>::unregisterInstance(name*); \
+    template std::map<const std::string,name*>::iterator Registry<name>::getBeginIter(); \
+    template std::map<const std::string,name*>::const_iterator Registry<name>::getBeginIter() const; \
+    template std::map<const std::string,name*>::iterator Registry<name>::getEndIter(); \
+    template std::map<const std::string,name*>::const_iterator Registry<name>::getEndIter() const;
+
+
+#endif /* REGISTRY_IMPL_HPP_ */
Index: c/Plane.cpp
===================================================================
--- src/Plane.cpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ 	(revision )
@@ -1,212 +1,0 @@
-/*
- * Plane.cpp
- *
- *  Created on: Apr 7, 2010
- *      Author: crueger
- */
-
-#include "Helpers/MemDebug.hpp"
-
-#include "Plane.hpp"
-#include "vector.hpp"
-#include "defs.hpp"
-#include "info.hpp"
-#include "log.hpp"
-#include "verbose.hpp"
-#include "Helpers/Assert.hpp"
-#include <cmath>
-#include "Line.hpp"
-#include "Exceptions/MultipleSolutionsException.hpp"
-
-/**
- * generates a plane from three given vectors defining three points in space
- */
-Plane::Plane(const Vector &y1, const Vector &y2, const Vector &y3) throw(LinearDependenceException) :
-  normalVector(new Vector())
-{
-  Vector x1 = y1 -y2;
-  Vector x2 = y3 -y2;
-  if ((fabs(x1.Norm()) < MYEPSILON) || (fabs(x2.Norm()) < MYEPSILON) || (fabs(x1.Angle(x2)) < MYEPSILON)) {
-    throw LinearDependenceException(__FILE__,__LINE__);
-  }
-//  Log() << Verbose(4) << "relative, first plane coordinates:";
-//  x1.Output((ofstream *)&cout);
-//  Log() << Verbose(0) << endl;
-//  Log() << Verbose(4) << "second plane coordinates:";
-//  x2.Output((ofstream *)&cout);
-//  Log() << Verbose(0) << endl;
-
-  normalVector->at(0) = (x1[1]*x2[2] - x1[2]*x2[1]);
-  normalVector->at(1) = (x1[2]*x2[0] - x1[0]*x2[2]);
-  normalVector->at(2) = (x1[0]*x2[1] - x1[1]*x2[0]);
-  normalVector->Normalize();
-
-  offset=normalVector->ScalarProduct(y1);
-}
-/**
- * Constructs a plane from two direction vectors and a offset.
- */
-Plane::Plane(const Vector &y1, const Vector &y2, double _offset) throw(ZeroVectorException,LinearDependenceException) :
-    normalVector(new Vector()),
-    offset(_offset)
-{
-  Vector x1 = y1;
-  Vector x2 = y2;
-  if ((fabs(x1.Norm()) < MYEPSILON) || (fabs(x2.Norm()) < MYEPSILON)) {
-    throw ZeroVectorException(__FILE__,__LINE__);
-  }
-
-  if((fabs(x1.Angle(x2)) < MYEPSILON)) {
-    throw LinearDependenceException(__FILE__,__LINE__);
-  }
-//  Log() << Verbose(4) << "relative, first plane coordinates:";
-//  x1.Output((ofstream *)&cout);
-//  Log() << Verbose(0) << endl;
-//  Log() << Verbose(4) << "second plane coordinates:";
-//  x2.Output((ofstream *)&cout);
-//  Log() << Verbose(0) << endl;
-
-  normalVector->at(0) = (x1[1]*x2[2] - x1[2]*x2[1]);
-  normalVector->at(1) = (x1[2]*x2[0] - x1[0]*x2[2]);
-  normalVector->at(2) = (x1[0]*x2[1] - x1[1]*x2[0]);
-  normalVector->Normalize();
-}
-
-Plane::Plane(const Vector &_normalVector, double _offset) throw(ZeroVectorException):
-  normalVector(new Vector(_normalVector)),
-  offset(_offset)
-{
-  if(normalVector->IsZero())
-    throw ZeroVectorException(__FILE__,__LINE__);
-  double factor = 1/normalVector->Norm();
-  // normalize the plane parameters
-  (*normalVector)*=factor;
-  offset*=factor;
-}
-
-Plane::Plane(const Vector &_normalVector, const Vector &_offsetVector) throw(ZeroVectorException):
-    normalVector(new Vector(_normalVector))
-{
-  if(normalVector->IsZero()){
-    throw ZeroVectorException(__FILE__,__LINE__);
-  }
-  normalVector->Normalize();
-  offset = normalVector->ScalarProduct(_offsetVector);
-}
-
-/**
- * copy constructor
- */
-Plane::Plane(const Plane& plane) :
-  normalVector(new Vector(*plane.normalVector)),
-  offset(plane.offset)
-{}
-
-
-Plane::~Plane()
-{}
-
-
-Vector Plane::getNormal() const{
-  return *normalVector;
-}
-
-double Plane::getOffset() const{
-  return offset;
-}
-
-Vector Plane::getOffsetVector() const {
-  return getOffset()*getNormal();
-}
-
-vector<Vector> Plane::getPointsOnPlane() const{
-  std::vector<Vector> res;
-  res.reserve(3);
-  // first point on the plane
-  res.push_back(getOffsetVector());
-  // get a vector that has direction of plane
-  Vector direction;
-  direction.GetOneNormalVector(getNormal());
-  res.push_back(res[0]+direction);
-  // get an orthogonal vector to direction and normal (has direction of plane)
-  direction.VectorProduct(getNormal());
-  direction.Normalize();
-  res.push_back(res[0] +direction);
-  return res;
-}
-
-
-/** Calculates the intersection point between a line defined by \a *LineVector and \a *LineVector2 and a plane defined by \a *Normal and \a *PlaneOffset.
- * According to [Bronstein] the vectorial plane equation is:
- *   -# \f$\stackrel{r}{\rightarrow} \cdot \stackrel{N}{\rightarrow} + D = 0\f$,
- * where \f$\stackrel{r}{\rightarrow}\f$ is the vector to be testet, \f$\stackrel{N}{\rightarrow}\f$ is the plane's normal vector and
- * \f$D = - \stackrel{a}{\rightarrow} \stackrel{N}{\rightarrow}\f$, the offset with respect to origin, if \f$\stackrel{a}{\rightarrow}\f$,
- * is an offset vector onto the plane. The line is parametrized by \f$\stackrel{x}{\rightarrow} + k \stackrel{t}{\rightarrow}\f$, where
- * \f$\stackrel{x}{\rightarrow}\f$ is the offset and \f$\stackrel{t}{\rightarrow}\f$ the directional vector (NOTE: No need to normalize
- * the latter). Inserting the parametrized form into the plane equation and solving for \f$k\f$, which we insert then into the parametrization
- * of the line yields the intersection point on the plane.
- * \param *Origin first vector of line
- * \param *LineVector second vector of line
- * \return true -  \a this contains intersection point on return, false - line is parallel to plane (even if in-plane)
- */
-Vector Plane::GetIntersection(const Line& line) const
-{
-  Info FunctionInfo(__func__);
-  Vector res;
-
-  double factor1 = getNormal().ScalarProduct(line.getDirection());
-  if(fabs(factor1)<MYEPSILON){
-    // the plane is parallel... under all circumstances this is bad luck
-    // we no have either no or infinite solutions
-    if(isContained(line.getOrigin())){
-      throw MultipleSolutionsException<Vector>(__FILE__,__LINE__,line.getOrigin());
-    }
-    else{
-      throw LinearDependenceException(__FILE__,__LINE__);
-    }
-  }
-
-  double factor2 = getNormal().ScalarProduct(line.getOrigin());
-  double scaleFactor = (offset-factor2)/factor1;
-
-  res = line.getOrigin() + scaleFactor * line.getDirection();
-
-  // tests to make sure the resulting vector really is on plane and line
-  ASSERT(isContained(res),"Calculated line-Plane intersection does not lie on plane.");
-  ASSERT(line.isContained(res),"Calculated line-Plane intersection does not lie on line.");
-  return res;
-};
-
-Vector Plane::mirrorVector(const Vector &rhs) const {
-  Vector helper = getVectorToPoint(rhs);
-  // substract twice the Vector to the plane
-  return rhs+2*helper;
-}
-
-Line Plane::getOrthogonalLine(const Vector &origin) const{
-  return Line(origin,getNormal());
-}
-
-/************ Methods inherited from Space ****************/
-
-double Plane::distance(const Vector &point) const{
-  double res = point.ScalarProduct(*normalVector)-offset;
-  return fabs(res);
-}
-
-Vector Plane::getClosestPoint(const Vector &point) const{
-  double factor = point.ScalarProduct(*normalVector)-offset;
-  if(fabs(factor) < MYEPSILON){
-    // the point itself lies on the plane
-    return point;
-  }
-  Vector difference = factor * (*normalVector);
-  return (point - difference);
-}
-
-// Operators
-
-ostream &operator << (ostream &ost,const Plane &p){
-  ost << "<" << p.getNormal() << ";x> - " << p.getOffset() << "=0";
-  return ost;
-}
Index: c/Plane.hpp
===================================================================
--- src/Plane.hpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ 	(revision )
@@ -1,77 +1,0 @@
-/*
- * Plane.hpp
- *
- *  Created on: Apr 7, 2010
- *      Author: crueger
- */
-
-#ifndef PLANE_HPP_
-#define PLANE_HPP_
-
-#include <memory>
-#include <vector>
-#include <iostream>
-#include "Space.hpp"
-#include "Exceptions/LinearDependenceException.hpp"
-#include "Exceptions/ZeroVectorException.hpp"
-
-class Vector;
-class Line;
-
-class Plane : public Space
-{
-  typedef std::auto_ptr<Vector> vec_ptr;
-public:
-  Plane(const Vector &y1, const Vector &y2, const Vector &y3) throw(LinearDependenceException);
-  Plane(const Vector &y1, const Vector &y2, double _offset) throw(ZeroVectorException,LinearDependenceException);
-  Plane(const Vector &_normalVector, double _offset)  throw(ZeroVectorException);
-  Plane(const Vector &_normalVector, const Vector &_offsetVector) throw(ZeroVectorException);
-  Plane(const Plane& plane);
-  virtual ~Plane();
-
-  // Accessor Functions
-  /**
-   * returns normal Vector for a plane
-   */
-  Vector getNormal() const;
-  /**
-   * returns the distance of the plane from the origin
-   */
-  double getOffset() const;
-  /**
-   * returns a vector that points on the plane.
-   * Same as getOffset()*getNormal();
-   */
-  Vector getOffsetVector() const;
-
-  /**
-   * returns three seperate points on this plane
-   */
-  std::vector<Vector> getPointsOnPlane() const;
-
-  // some calculations
-  Vector GetIntersection(const Line &Line) const;
-
-  Vector mirrorVector(const Vector &rhs) const;
-
-  /**
-   * get a Line that is orthogonal to this plane, going through a chosen
-   * point.
-   *
-   * The point does not have to lie on the plane itself.
-   */
-  Line getOrthogonalLine(const Vector &origin) const;
-
-  /****** Methods inherited from Space ***********/
-
-  virtual double distance(const Vector &point) const;
-  virtual Vector getClosestPoint(const Vector &point) const;
-
-private:
-  vec_ptr normalVector;
-  double offset;
-};
-
-std::ostream &operator<< (std::ostream &ost,const Plane& p);
-
-#endif /* PLANE_HPP_ */
Index: src/PointCloud.cpp
===================================================================
--- src/PointCloud.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
+++ src/PointCloud.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -0,0 +1,32 @@
+/*
+ * PointCloud.cpp
+ *
+ *  Created on: Jul 29, 2010
+ *      Author: heber
+ */
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "Helpers/MemDebug.hpp"
+
+#include "PointCloud.hpp"
+
+/** Constructor of class PointCloud.
+ */
+PointCloud::PointCloud()
+{
+  //Info FunctionInfo(__func__);
+}
+;
+
+/** Destructor for class PointCloud.
+ */
+PointCloud::~PointCloud()
+{
+  //Info FunctionInfo(__func__);
+}
+;
+
Index: src/PointCloud.hpp
===================================================================
--- src/PointCloud.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
+++ src/PointCloud.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -0,0 +1,35 @@
+/*
+ * PointCloud.hpp
+ *
+ *  Created on: Jul 29, 2010
+ *      Author: heber
+ */
+
+#ifndef POINTCLOUD_HPP_
+#define POINTCLOUD_HPP_
+
+#include <cstdio>
+
+class TesselPoint;
+class Vector;
+
+/** Super-class for all point clouds structures, also molecules. They have to inherit this structure and implement the virtual function to access the Vectors.
+ * This basically encapsulates a list structure.
+ */
+class PointCloud {
+public:
+  PointCloud();
+  virtual ~PointCloud();
+
+  virtual const char * const GetName() const { return "unknown"; };
+  virtual Vector *GetCenter() const { return NULL; };
+  virtual TesselPoint *GetPoint() const { return NULL; };
+  virtual int GetMaxId() const { return 0; };
+  virtual void GoToNext() const {};
+  virtual void GoToFirst() const {};
+  virtual bool IsEmpty() const { return true; };
+  virtual bool IsEnd() const { return true; };
+};
+
+
+#endif /* POINTCLOUD_HPP_ */
Index: src/Shapes/BaseShapes.cpp
===================================================================
--- src/Shapes/BaseShapes.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
+++ src/Shapes/BaseShapes.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -0,0 +1,77 @@
+/*
+ * BaseShapes_impl.cpp
+ *
+ *  Created on: Jun 18, 2010
+ *      Author: crueger
+ */
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "Helpers/MemDebug.hpp"
+
+#include "Shapes/BaseShapes.hpp"
+#include "Shapes/BaseShapes_impl.hpp"
+
+#include <cmath>
+
+#include "Helpers/Assert.hpp"
+#include "LinearAlgebra/Vector.hpp"
+
+bool Sphere_impl::isInside(const Vector &point){
+  return point.NormSquared()<=1;
+}
+
+
+/**
+ * algorithm taken from http://www.cgafaq.info/wiki/Evenly_distributed_points_on_sphere
+ * \param N number of points on surface
+ */
+std::vector<Vector> Sphere_impl::getHomogeneousPointsOnSurface(const int N) const {
+  std::vector<Vector> PointsOnSurface;
+
+  const double dlength = M_PI*(3.-sqrt(5.));
+  double length = 0;
+  const double dz = 2.0/N;
+  double z = 1. - dz/2.;
+  Vector point;
+  for (int ka = 0; ka<N; ka++){
+    const double r = sqrt(1.-z*z);
+    point.Zero();
+    point[0] = cos(length)*r;
+    point[1] = sin(length)*r;
+    point[2] = z;
+    PointsOnSurface.push_back(point);
+    z = z - dz;
+    length = length + dlength;
+  }
+
+  ASSERT(PointsOnSurface.size() == N, "Sphere_impl::getHomogeneousPointsOnSurface() did not create enough points.");
+  return PointsOnSurface;
+}
+
+
+Shape Sphere(){
+  Shape::impl_ptr impl = Shape::impl_ptr(new Sphere_impl());
+  return Shape(impl);
+}
+
+bool Cuboid_impl::isInside(const Vector &point){
+  return (point[0]>=0 && point[0]<=1) && (point[1]>=0 && point[1]<=1) && (point[2]>=0 && point[2]<=1);
+}
+
+/**
+ * \param N number of points on surface
+ */
+std::vector<Vector> Cuboid_impl::getHomogeneousPointsOnSurface(const int N) const {
+  std::vector<Vector> PointsOnSurface;
+  ASSERT(false, "Cuboid_impl::getHomogeneousPointsOnSurface() not implemented yet");
+  return PointsOnSurface;
+}
+
+Shape Cuboid(){
+  Shape::impl_ptr impl = Shape::impl_ptr(new Cuboid_impl());
+  return Shape(impl);
+}
Index: src/Shapes/BaseShapes.hpp
===================================================================
--- src/Shapes/BaseShapes.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
+++ src/Shapes/BaseShapes.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -0,0 +1,16 @@
+/*
+ * BaseShapes.hpp
+ *
+ *  Created on: Jun 18, 2010
+ *      Author: crueger
+ */
+
+#ifndef BASESHAPES_HPP_
+#define BASESHAPES_HPP_
+
+#include "Shapes/Shape.hpp"
+
+Shape Sphere();
+Shape Cuboid();
+
+#endif /* BASESHAPES_HPP_ */
Index: src/Shapes/BaseShapes_impl.hpp
===================================================================
--- src/Shapes/BaseShapes_impl.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
+++ src/Shapes/BaseShapes_impl.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -0,0 +1,23 @@
+/*
+ * BaseShapes_impl.hpp
+ *
+ *  Created on: Jun 18, 2010
+ *      Author: crueger
+ */
+
+#ifndef BASESHAPES_IMPL_HPP_
+#define BASESHAPES_IMPL_HPP_
+
+#include "Shapes/Shape_impl.hpp"
+
+class Sphere_impl : public Shape_impl {
+  virtual bool isInside(const Vector &point);
+  virtual std::vector<Vector> getHomogeneousPointsOnSurface(const int N) const;
+};
+
+class Cuboid_impl : public Shape_impl {
+  virtual bool isInside(const Vector &point);
+  virtual std::vector<Vector> getHomogeneousPointsOnSurface(const int N) const;
+};
+
+#endif /* BASESHAPES_IMPL_HPP_ */
Index: src/Shapes/Shape.cpp
===================================================================
--- src/Shapes/Shape.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
+++ src/Shapes/Shape.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -0,0 +1,159 @@
+/*
+ * Shape.cpp
+ *
+ *  Created on: Jun 18, 2010
+ *      Author: crueger
+ */
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "Helpers/MemDebug.hpp"
+
+#include "Shape.hpp"
+#include "Shape_impl.hpp"
+
+
+#include "Helpers/Assert.hpp"
+#include "LinearAlgebra/Vector.hpp"
+
+Shape::Shape(const Shape& src) :
+  impl(src.getImpl())
+{}
+
+Shape::~Shape(){}
+
+bool Shape::isInside(const Vector &point) const{
+  return impl->isInside(point);
+}
+
+std::vector<Vector> Shape::getHomogeneousPointsOnSurface(const int N) const {
+  return impl->getHomogeneousPointsOnSurface(N);
+}
+
+Shape::Shape(Shape::impl_ptr _impl) :
+    impl(_impl)
+{}
+
+Shape &Shape::operator=(const Shape& rhs){
+  if(&rhs!=this){
+    impl=rhs.getImpl();
+  }
+  return *this;
+}
+
+Shape::impl_ptr Shape::getImpl() const{
+  return impl;
+}
+
+// allows arbitrary friendship, but only if implementation is known
+Shape::impl_ptr getShapeImpl(const Shape &shape){
+  return shape.getImpl();
+}
+
+/***************************** Some simple Shapes ***************************/
+
+Shape Everywhere(){
+  static Shape::impl_ptr impl = Shape::impl_ptr(new Everywhere_impl());
+  return Shape(impl);
+}
+
+Shape Nowhere(){
+  static Shape::impl_ptr impl = Shape::impl_ptr(new Nowhere_impl());
+  return Shape(impl);
+}
+
+/****************************** Operators ***********************************/
+
+// AND
+
+AndShape_impl::AndShape_impl(const Shape::impl_ptr &_lhs, const Shape::impl_ptr &_rhs) :
+  lhs(_lhs),rhs(_rhs)
+{}
+
+AndShape_impl::~AndShape_impl(){}
+
+bool AndShape_impl::isInside(const Vector &point){
+  return lhs->isInside(point) && rhs->isInside(point);
+}
+
+std::vector<Vector> AndShape_impl::getHomogeneousPointsOnSurface(const int N) const {
+  std::vector<Vector> PointsOnSurface_lhs = lhs->getHomogeneousPointsOnSurface(N);
+  std::vector<Vector> PointsOnSurface_rhs = rhs->getHomogeneousPointsOnSurface(N);
+  std::vector<Vector> PointsOnSurface;
+
+  for (std::vector<Vector>::const_iterator iter = PointsOnSurface_lhs.begin(); iter != PointsOnSurface_lhs.end(); ++iter) {
+    if (rhs->isInside(*iter))
+      PointsOnSurface.push_back(*iter);
+  }
+  for (std::vector<Vector>::const_iterator iter = PointsOnSurface_rhs.begin(); iter != PointsOnSurface_rhs.end(); ++iter) {
+    if (lhs->isInside(*iter))
+      PointsOnSurface.push_back(*iter);
+  }
+
+  return PointsOnSurface;
+}
+
+
+Shape operator&&(const Shape &lhs,const Shape &rhs){
+  Shape::impl_ptr newImpl = Shape::impl_ptr(new AndShape_impl(getShapeImpl(lhs),getShapeImpl(rhs)));
+  return Shape(newImpl);
+}
+
+// OR
+
+OrShape_impl::OrShape_impl(const Shape::impl_ptr &_lhs, const Shape::impl_ptr &_rhs) :
+  lhs(_lhs),rhs(_rhs)
+{}
+
+OrShape_impl::~OrShape_impl(){}
+
+bool OrShape_impl::isInside(const Vector &point){
+  return rhs->isInside(point) || lhs->isInside(point);
+}
+
+std::vector<Vector> OrShape_impl::getHomogeneousPointsOnSurface(const int N) const {
+  std::vector<Vector> PointsOnSurface_lhs = lhs->getHomogeneousPointsOnSurface(N);
+  std::vector<Vector> PointsOnSurface_rhs = rhs->getHomogeneousPointsOnSurface(N);
+  std::vector<Vector> PointsOnSurface;
+
+  for (std::vector<Vector>::const_iterator iter = PointsOnSurface_lhs.begin(); iter != PointsOnSurface_lhs.end(); ++iter) {
+    if (!rhs->isInside(*iter))
+      PointsOnSurface.push_back(*iter);
+  }
+  for (std::vector<Vector>::const_iterator iter = PointsOnSurface_rhs.begin(); iter != PointsOnSurface_rhs.end(); ++iter) {
+    if (!lhs->isInside(*iter))
+      PointsOnSurface.push_back(*iter);
+  }
+
+  return PointsOnSurface;
+}
+
+Shape operator||(const Shape &lhs,const Shape &rhs){
+  Shape::impl_ptr newImpl = Shape::impl_ptr(new OrShape_impl(getShapeImpl(lhs),getShapeImpl(rhs)));
+  return Shape(newImpl);
+}
+
+// NOT
+
+NotShape_impl::NotShape_impl(const Shape::impl_ptr &_arg) :
+  arg(_arg)
+{}
+
+NotShape_impl::~NotShape_impl(){}
+
+bool NotShape_impl::isInside(const Vector &point){
+  return !arg->isInside(point);
+}
+
+std::vector<Vector> NotShape_impl::getHomogeneousPointsOnSurface(const int N) const {
+  // surfaces are the same, only normal direction is different
+  return arg->getHomogeneousPointsOnSurface(N);
+}
+
+Shape operator!(const Shape &arg){
+  Shape::impl_ptr newImpl = Shape::impl_ptr(new NotShape_impl(getShapeImpl(arg)));
+  return Shape(newImpl);
+}
Index: src/Shapes/Shape.hpp
===================================================================
--- src/Shapes/Shape.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
+++ src/Shapes/Shape.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -0,0 +1,47 @@
+/*
+ * Shape.hpp
+ *
+ *  Created on: Jun 18, 2010
+ *      Author: crueger
+ */
+
+#ifndef SHAPE_HPP_
+#define SHAPE_HPP_
+
+#include <boost/shared_ptr.hpp>
+
+#include <vector>
+
+class Vector;
+class Shape_impl;
+
+class Shape
+{
+public:
+  typedef boost::shared_ptr<Shape_impl> impl_ptr;
+  friend impl_ptr getShapeImpl(const Shape&);
+
+  Shape(impl_ptr);
+  Shape(const Shape&);
+  virtual ~Shape();
+
+  bool isInside(const Vector &point) const;
+  std::vector<Vector> getHomogeneousPointsOnSurface(const int N) const;
+
+  Shape &operator=(const Shape& rhs);
+
+protected:
+  impl_ptr getImpl() const;
+
+private:
+  impl_ptr impl;
+};
+
+Shape Everywhere();
+Shape Nowhere();
+
+Shape operator&&(const Shape&,const Shape&);
+Shape operator||(const Shape&,const Shape&);
+Shape operator!(const Shape&);
+
+#endif /* SHAPE_HPP_ */
Index: src/Shapes/ShapeOps.cpp
===================================================================
--- src/Shapes/ShapeOps.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
+++ src/Shapes/ShapeOps.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -0,0 +1,132 @@
+/*
+ * ShapeOps.cpp
+ *
+ *  Created on: Jun 18, 2010
+ *      Author: crueger
+ */
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "Helpers/MemDebug.hpp"
+
+#include "Shapes/ShapeOps.hpp"
+#include "Shapes/ShapeOps_impl.hpp"
+
+#include "Helpers/Assert.hpp"
+
+/********************* Resize ********************/
+
+Resize_impl::Resize_impl(const Shape::impl_ptr &_arg,double _size) :
+  arg(_arg), size(_size)
+{
+  ASSERT(size>0,"Cannot resize a Shape to size zero or below");
+}
+
+Resize_impl::~Resize_impl(){}
+
+bool Resize_impl::isInside(const Vector& point){
+  return arg->isInside((1/size) * point);
+}
+
+std::vector<Vector> Resize_impl::getHomogeneousPointsOnSurface(const int N) const {
+  std::vector<Vector> PointsOnSurface = arg->getHomogeneousPointsOnSurface(N);
+  for(std::vector<Vector>::iterator iter = PointsOnSurface.begin(); iter != PointsOnSurface.end(); ++iter) {
+    *iter *= size;
+  }
+  return PointsOnSurface;
+}
+
+
+Shape resize(const Shape &arg,double size){
+  Shape::impl_ptr impl = Shape::impl_ptr(new Resize_impl(getShapeImpl(arg),size));
+  return Shape(impl);
+}
+
+/*************************** translate *******************/
+
+Translate_impl::Translate_impl(const Shape::impl_ptr &_arg, const Vector &_offset) :
+  arg(_arg),offset(_offset)
+{}
+
+Translate_impl::~Translate_impl(){}
+
+bool Translate_impl::isInside(const Vector& point){
+  return arg->isInside(point-offset);
+}
+
+std::vector<Vector> Translate_impl::getHomogeneousPointsOnSurface(const int N) const {
+  std::vector<Vector> PointsOnSurface = arg->getHomogeneousPointsOnSurface(N);
+  for(std::vector<Vector>::iterator iter = PointsOnSurface.begin(); iter != PointsOnSurface.end(); ++iter) {
+    *iter += offset;
+  }
+  return PointsOnSurface;
+}
+
+Shape translate(const Shape &arg, const Vector &offset){
+  Shape::impl_ptr impl = Shape::impl_ptr(new Translate_impl(getShapeImpl(arg),offset));
+  return Shape(impl);
+}
+
+/*********************** stretch ******************/
+
+Stretch_impl::Stretch_impl(const Shape::impl_ptr &_arg, const Vector &_factors) :
+  arg(_arg),factors(_factors)
+{
+  ASSERT(factors[0]>0,"cannot stretch a shape by a negative amount");
+  ASSERT(factors[1]>0,"cannot stretch a shape by a negative amount");
+  ASSERT(factors[2]>0,"cannot stretch a shape by a negative amount");
+  for(int i = NDIM;i--;){
+    reciFactors[i] = 1/factors[i];
+  }
+}
+
+Stretch_impl::~Stretch_impl(){}
+
+bool Stretch_impl::isInside(const Vector& point){
+  Vector helper=point;
+  helper.ScaleAll(reciFactors);
+  return arg->isInside(helper);
+}
+
+std::vector<Vector> Stretch_impl::getHomogeneousPointsOnSurface(const int N) const {
+  std::vector<Vector> PointsOnSurface = arg->getHomogeneousPointsOnSurface(N);
+  for(std::vector<Vector>::iterator iter = PointsOnSurface.begin(); iter != PointsOnSurface.end(); ++iter) {
+    (*iter).ScaleAll(reciFactors);
+  }
+  return PointsOnSurface;
+}
+
+Shape stretch(const Shape &arg, const Vector &factors){
+  Shape::impl_ptr impl = Shape::impl_ptr(new Stretch_impl(getShapeImpl(arg),factors));
+  return Shape(impl);
+}
+
+/************************* transform *****************/
+
+Transform_impl::Transform_impl(const Shape::impl_ptr &_arg, const Matrix &_transformation) :
+  arg(_arg),transformation(_transformation)
+{
+  transformationInv = transformation.invert();
+}
+
+Transform_impl::~Transform_impl(){}
+
+bool Transform_impl::isInside(const Vector& point){
+  return arg->isInside(transformationInv * point);
+}
+
+std::vector<Vector> Transform_impl::getHomogeneousPointsOnSurface(const int N) const {
+  std::vector<Vector> PointsOnSurface = arg->getHomogeneousPointsOnSurface(N);
+  for(std::vector<Vector>::iterator iter = PointsOnSurface.begin(); iter != PointsOnSurface.end(); ++iter) {
+    *iter = transformation * (*iter);
+  }
+  return PointsOnSurface;
+}
+
+Shape transform(const Shape &arg, const Matrix &transformation){
+  Shape::impl_ptr impl = Shape::impl_ptr(new Transform_impl(getShapeImpl(arg),transformation));
+  return Shape(impl);
+}
Index: src/Shapes/ShapeOps.hpp
===================================================================
--- src/Shapes/ShapeOps.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
+++ src/Shapes/ShapeOps.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -0,0 +1,20 @@
+/*
+ * ShapeOps.hpp
+ *
+ *  Created on: Jun 18, 2010
+ *      Author: crueger
+ */
+
+#ifndef SHAPEOPS_HPP_
+#define SHAPEOPS_HPP_
+
+#include "Shapes/Shape.hpp"
+
+class Matrix;
+
+Shape resize(const Shape&,double);
+Shape translate(const Shape&, const Vector&);
+Shape stretch(const Shape&, const Vector&);
+Shape transform(const Shape&,const Matrix&);
+
+#endif /* SHAPEOPS_HPP_ */
Index: src/Shapes/ShapeOps_impl.hpp
===================================================================
--- src/Shapes/ShapeOps_impl.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
+++ src/Shapes/ShapeOps_impl.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -0,0 +1,65 @@
+/*
+ * ShapeOps_impl.hpp
+ *
+ *  Created on: Jun 18, 2010
+ *      Author: crueger
+ */
+
+#ifndef SHAPEOPS_IMPL_HPP_
+#define SHAPEOPS_IMPL_HPP_
+
+#include "Shapes/Shape_impl.hpp"
+#include "LinearAlgebra/Vector.hpp"
+#include "LinearAlgebra/Matrix.hpp"
+
+class Resize_impl :  public Shape_impl
+{
+public:
+  Resize_impl(const Shape::impl_ptr&,double);
+  virtual ~Resize_impl();
+  virtual bool isInside(const Vector& point);
+  virtual std::vector<Vector> getHomogeneousPointsOnSurface(const int N) const;
+private:
+  Shape::impl_ptr arg;
+  double size;
+};
+
+class Translate_impl :  public Shape_impl
+{
+public:
+  Translate_impl(const Shape::impl_ptr&, const Vector&);
+  virtual ~Translate_impl();
+  virtual bool isInside(const Vector& point);
+  virtual std::vector<Vector> getHomogeneousPointsOnSurface(const int N) const;
+private:
+  Shape::impl_ptr arg;
+  Vector offset;
+};
+
+class Stretch_impl : public Shape_impl
+{
+public:
+  Stretch_impl(const Shape::impl_ptr&, const Vector&);
+  virtual ~Stretch_impl();
+  virtual bool isInside(const Vector& point);
+  virtual std::vector<Vector> getHomogeneousPointsOnSurface(const int N) const;
+private:
+  Shape::impl_ptr arg;
+  Vector factors;
+  Vector reciFactors;
+};
+
+class Transform_impl : public Shape_impl
+{
+public:
+  Transform_impl(const Shape::impl_ptr&, const Matrix&);
+  virtual ~Transform_impl();
+  virtual bool isInside(const Vector& point);
+  virtual std::vector<Vector> getHomogeneousPointsOnSurface(const int N) const;
+private:
+  Shape::impl_ptr arg;
+  Matrix transformation;
+  Matrix transformationInv;
+};
+
+#endif /* SHAPEOPS_IMPL_HPP_ */
Index: src/Shapes/Shape_impl.hpp
===================================================================
--- src/Shapes/Shape_impl.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
+++ src/Shapes/Shape_impl.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -0,0 +1,80 @@
+/*
+ * Shape_impl.hpp
+ *
+ *  Created on: Jun 18, 2010
+ *      Author: crueger
+ */
+
+#ifndef SHAPE_IMPL_HPP_
+#define SHAPE_IMPL_HPP_
+
+#include <vector>
+
+#include "Shapes/Shape.hpp"
+
+class Vector;
+
+class Shape_impl {
+public:
+  Shape_impl(){};
+  virtual ~Shape_impl(){};
+  virtual bool isInside(const Vector &point)=0;
+  virtual std::vector<Vector> getHomogeneousPointsOnSurface(const int N) const=0;
+};
+
+class Everywhere_impl : public Shape_impl {
+public:
+  virtual bool isInside(const Vector &point){
+    return true;
+  }
+  virtual std::vector<Vector> getHomogeneousPointsOnSurface(const int N) const {
+    std::vector<Vector> PointsOnSurface;
+    return PointsOnSurface;
+  }
+};
+
+class Nowhere_impl : public Shape_impl {
+  virtual bool isInside(const Vector &point){
+    return false;
+  }
+  virtual std::vector<Vector> getHomogeneousPointsOnSurface(const int N) const {
+    std::vector<Vector> PointsOnSurface;
+    return PointsOnSurface;
+  }
+};
+
+class AndShape_impl : public Shape_impl {
+public:
+  AndShape_impl(const Shape::impl_ptr&, const Shape::impl_ptr&);
+  virtual ~AndShape_impl();
+  virtual bool isInside(const Vector &point);
+  virtual std::vector<Vector> getHomogeneousPointsOnSurface(const int N) const;
+private:
+  Shape::impl_ptr lhs;
+  Shape::impl_ptr rhs;
+};
+
+class OrShape_impl : public Shape_impl {
+public:
+  OrShape_impl(const Shape::impl_ptr&, const Shape::impl_ptr&);
+  virtual ~OrShape_impl();
+  virtual bool isInside(const Vector &point);
+  virtual std::vector<Vector> getHomogeneousPointsOnSurface(const int N) const;
+private:
+  Shape::impl_ptr lhs;
+  Shape::impl_ptr rhs;
+};
+
+class NotShape_impl : public Shape_impl {
+public:
+  NotShape_impl(const Shape::impl_ptr&);
+  virtual ~NotShape_impl();
+  virtual bool isInside(const Vector &point);
+  virtual std::vector<Vector> getHomogeneousPointsOnSurface(const int N) const;
+private:
+  Shape::impl_ptr arg;
+};
+
+Shape::impl_ptr getShapeImpl(const Shape&);
+
+#endif /* SHAPE_IMPL_HPP_ */
Index: c/Space.cpp
===================================================================
--- src/Space.cpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ 	(revision )
@@ -1,30 +1,0 @@
-/*
- * Space.cpp
- *
- *  Created on: Apr 30, 2010
- *      Author: crueger
- */
-
-#include "Helpers/MemDebug.hpp"
-
-#include "Space.hpp"
-#include "vector.hpp"
-
-Space::Space()
-{}
-
-Space::~Space()
-{}
-
-bool Space::hasZero() const{
-  return isContained(zeroVec);
-}
-
-Vector Space::getVectorToPoint(const Vector &origin) const{
-  Vector support = getClosestPoint(origin);
-  return support-origin;
-}
-
-bool Space::isContained(const Vector &point) const{
-  return (distance(point)) < MYEPSILON;
-}
Index: c/Space.hpp
===================================================================
--- src/Space.hpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ 	(revision )
@@ -1,52 +1,0 @@
-/*
- * Space.hpp
- *
- *  Created on: Apr 30, 2010
- *      Author: crueger
- */
-
-#ifndef SPACE_HPP_
-#define SPACE_HPP_
-
-class Vector;
-
-class Space
-{
-public:
-  Space();
-  virtual ~Space();
-
-  /**
-   * Calculates the distance between a Space and a Vector.
-   */
-  virtual double distance(const Vector &point) const=0;
-
-  /**
-   * get the closest point inside the space to another point
-   */
-  virtual Vector getClosestPoint(const Vector &point) const=0;
-
-  /**
-   * get the shortest Vector from a point to a Space.
-   *
-   * The Vector always points from the given Vector to the point in space
-   * returned by Plane::getClosestPoint().
-   */
-  virtual Vector getVectorToPoint(const Vector &point) const;
-
-  /**
-   * Test wether a point is contained in the space.
-   *
-   * returns true, when the point lies inside and false
-   * otherwise.
-   */
-  virtual bool isContained(const Vector &point) const;
-
-  /**
-   * Tests if this space contains the center of the coordinate system.
-   */
-  virtual bool hasZero() const;
-
-};
-
-#endif /* SPACE_HPP_ */
Index: src/TesselPoint.cpp
===================================================================
--- src/TesselPoint.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
+++ src/TesselPoint.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -0,0 +1,43 @@
+/*
+ * TesselPoint.cpp
+ *
+ *  Created on: Jul 30, 2010
+ *      Author: heber
+ */
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "Helpers/MemDebug.hpp"
+
+#include "TesselPoint.hpp"
+
+#include <iostream>
+
+
+/** Constructor of class TesselPoint.
+ */
+TesselPoint::TesselPoint()
+{};
+
+/** Destructor for class TesselPoint.
+ */
+TesselPoint::~TesselPoint()
+{};
+
+std::ostream & TesselPoint::operator << (std::ostream &ost) const
+{
+  ParticleInfo::operator<<(ost);
+  ost << "," << getPosition();
+  return ost;
+}
+
+std::ostream & operator << (std::ostream &ost, const TesselPoint &a)
+{
+  a.ParticleInfo::operator<<(ost);
+  ost << "," << a.getPosition();
+  return ost;
+}
+
Index: src/TesselPoint.hpp
===================================================================
--- src/TesselPoint.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
+++ src/TesselPoint.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -0,0 +1,27 @@
+/*
+ * TesselPoint.hpp
+ *
+ *  Created on: Jul 30, 2010
+ *      Author: heber
+ */
+
+#ifndef TESSELPOINT_HPP_
+#define TESSELPOINT_HPP_
+
+#include "atom_atominfo.hpp"
+#include "atom_particleinfo.hpp"
+
+class TesselPoint;
+
+class TesselPoint : public virtual ParticleInfo, public virtual AtomInfo
+{
+public:
+  TesselPoint();
+  ~TesselPoint();
+
+  std::ostream & operator << (std::ostream &ost) const;
+};
+
+std::ostream & operator << (std::ostream &ost, const TesselPoint &t);
+
+#endif /* TESSELPOINT_HPP_ */
Index: src/ThermoStatContainer.cpp
===================================================================
--- src/ThermoStatContainer.cpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/ThermoStatContainer.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -6,17 +6,31 @@
  */
 
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "Helpers/MemDebug.hpp"
+
 #include <cstring>
 
 #include "ConfigFileBuffer.hpp"
 #include "config.hpp"
-#include "log.hpp"
+#include "Helpers/Log.hpp"
 #include "ThermoStatContainer.hpp"
-#include "verbose.hpp"
+#include "Helpers/Verbose.hpp"
 
 /** Constructor for class ThermoStatContainer.
  *
  */
-ThermoStatContainer::ThermoStatContainer() : Thermostat(4), ThermostatImplemented(NULL),
-ThermostatNames(NULL), TempFrequency(2.5), alpha(0.), HooverMass(0.), TargetTemp(0.00095004455), ScaleTempStep(25)
+ThermoStatContainer::ThermoStatContainer() :
+  Thermostat(4),
+  ThermostatImplemented(NULL),
+  ThermostatNames(NULL),
+  TempFrequency(2.5),
+  alpha(0.),
+  HooverMass(0.),
+  TargetTemp(0.00095004455),
+  ScaleTempStep(25)
 {
   ThermostatImplemented = new int[MaxThermostats];
Index: src/ThermoStatContainer.hpp
===================================================================
--- src/ThermoStatContainer.hpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/ThermoStatContainer.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -16,5 +16,5 @@
 class ConfigFileBuffer;
 
-#define MaxThermostats 6      //!< maximum number of thermostat entries in Ions#ThermostatNames and Ions#ThermostatImplemented
+enum { MaxThermostats=6 };      //!< maximum number of thermostat entries in Ions#ThermostatNames and Ions#ThermostatImplemented
 enum thermostats { None, Woodcock, Gaussian, Langevin, Berendsen, NoseHoover };   //!< Thermostat names for output
 
Index: src/UIElements/CommandLineUI/CommandLineDialog.cpp
===================================================================
--- src/UIElements/CommandLineUI/CommandLineDialog.cpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/UIElements/CommandLineUI/CommandLineDialog.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -6,4 +6,9 @@
  */
 
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
 #include "Helpers/MemDebug.hpp"
 
@@ -23,13 +28,15 @@
 #include "CommandLineParser.hpp"
 #include "defs.hpp"
-#include "log.hpp"
+#include "Helpers/Log.hpp"
+#include "LinearAlgebra/Matrix.hpp"
 #include "periodentafel.hpp"
-#include "verbose.hpp"
+#include "Helpers/Verbose.hpp"
 #include "World.hpp"
+#include "Box.hpp"
 
 #include "atom.hpp"
 #include "element.hpp"
 #include "molecule.hpp"
-#include "vector.hpp"
+#include "LinearAlgebra/Vector.hpp"
 
 using namespace std;
@@ -49,42 +56,66 @@
 }
 
-void CommandLineDialog::queryInt(const char* title, int* target, string _description){
-  registerQuery(new IntCommandLineQuery(title,target, _description));
-}
-
-void CommandLineDialog::queryBoolean(const char* title, bool* target, string _description){
-  registerQuery(new BooleanCommandLineQuery(title,target, _description));
-}
-
-void CommandLineDialog::queryDouble(const char* title, double* target, string _description){
-  registerQuery(new DoubleCommandLineQuery(title,target, _description));
-}
-
-void CommandLineDialog::queryString(const char* title, string* target, string _description){
-  registerQuery(new StringCommandLineQuery(title,target, _description));
-}
-
-void CommandLineDialog::queryStrings(const char* title, vector<string> * target, string _description){
-  registerQuery(new StringsCommandLineQuery(title,target, _description));
-}
-
-void CommandLineDialog::queryAtom(const char* title, atom **target, string _description) {
-  registerQuery(new AtomCommandLineQuery(title,target, _description));
-}
-
-void CommandLineDialog::queryMolecule(const char* title, molecule **target, string _description) {
-  registerQuery(new MoleculeCommandLineQuery(title,target, _description));
-}
-
-void CommandLineDialog::queryVector(const char* title, Vector *target,const double *const cellSize, bool check, string _description) {
-  registerQuery(new VectorCommandLineQuery(title,target,cellSize,check, _description));
-}
-
-void CommandLineDialog::queryBox(const char* title, double ** const cellSize, string _description) {
-  registerQuery(new BoxCommandLineQuery(title,cellSize,_description));
-}
-
-void CommandLineDialog::queryElement(const char* title, std::vector<element *> *target, string _description){
-  registerQuery(new ElementCommandLineQuery(title,target, _description));
+void CommandLineDialog::queryInt(const char* title, string _description){
+  registerQuery(new IntCommandLineQuery(title, _description));
+}
+
+void CommandLineDialog::queryInts(const char* title, string _description){
+  registerQuery(new IntsCommandLineQuery(title, _description));
+}
+
+void CommandLineDialog::queryBoolean(const char* title, string _description){
+  registerQuery(new BooleanCommandLineQuery(title, _description));
+}
+
+void CommandLineDialog::queryDouble(const char* title, string _description){
+  registerQuery(new DoubleCommandLineQuery(title, _description));
+}
+
+void CommandLineDialog::queryDoubles(const char* title, string _description){
+  registerQuery(new DoublesCommandLineQuery(title, _description));
+}
+
+void CommandLineDialog::queryString(const char* title, string _description){
+  registerQuery(new StringCommandLineQuery(title, _description));
+}
+
+void CommandLineDialog::queryStrings(const char* title, string _description){
+  registerQuery(new StringsCommandLineQuery(title, _description));
+}
+
+void CommandLineDialog::queryAtom(const char* title, string _description) {
+  registerQuery(new AtomCommandLineQuery(title, _description));
+}
+
+void CommandLineDialog::queryAtoms(const char* title, string _description) {
+  registerQuery(new AtomsCommandLineQuery(title, _description));
+}
+
+void CommandLineDialog::queryMolecule(const char* title, string _description) {
+  registerQuery(new MoleculeCommandLineQuery(title, _description));
+}
+
+void CommandLineDialog::queryMolecules(const char* title, string _description) {
+  registerQuery(new MoleculesCommandLineQuery(title, _description));
+}
+
+void CommandLineDialog::queryVector(const char* title, bool check, string _description) {
+  registerQuery(new VectorCommandLineQuery(title,check, _description));
+}
+
+void CommandLineDialog::queryVectors(const char* title, bool check, string _description) {
+  registerQuery(new VectorsCommandLineQuery(title,check, _description));
+}
+
+void CommandLineDialog::queryBox(const char* title, string _description) {
+  registerQuery(new BoxCommandLineQuery(title,_description));
+}
+
+void CommandLineDialog::queryElement(const char* title, string _description){
+  registerQuery(new ElementCommandLineQuery(title, _description));
+}
+
+void CommandLineDialog::queryElements(const char* title, string _description){
+  registerQuery(new ElementsCommandLineQuery(title, _description));
 }
 
@@ -102,6 +133,6 @@
 }
 
-CommandLineDialog::IntCommandLineQuery::IntCommandLineQuery(string title,int *_target, string _description) :
-    Dialog::IntQuery(title,_target, _description)
+CommandLineDialog::IntCommandLineQuery::IntCommandLineQuery(string title, string _description) :
+    Dialog::IntQuery(title, _description)
 {}
 
@@ -118,6 +149,22 @@
 }
 
-CommandLineDialog::BooleanCommandLineQuery::BooleanCommandLineQuery(string title,bool *_target, string _description) :
-    Dialog::BooleanQuery(title,_target, _description)
+CommandLineDialog::IntsCommandLineQuery::IntsCommandLineQuery(string title, string _description) :
+    Dialog::IntsQuery(title, _description)
+{}
+
+CommandLineDialog::IntsCommandLineQuery::~IntsCommandLineQuery() {}
+
+bool CommandLineDialog::IntsCommandLineQuery::handle() {
+  if (CommandLineParser::getInstance().vm.count(getTitle())) {
+    tmp = CommandLineParser::getInstance().vm[getTitle()].as< std::vector<int> >();
+    return true;
+  } else {
+    DoeLog(1) && (eLog() << Verbose(1) << "CommandLineUI parsing error: Missing integers for " << getTitle() << "." << endl);
+    return false;
+  }
+}
+
+CommandLineDialog::BooleanCommandLineQuery::BooleanCommandLineQuery(string title, string _description) :
+    Dialog::BooleanQuery(title, _description)
 {}
 
@@ -134,6 +181,6 @@
 }
 
-CommandLineDialog::StringCommandLineQuery::StringCommandLineQuery(string title,string *_target, string _description) :
-    Dialog::StringQuery(title,_target, _description)
+CommandLineDialog::StringCommandLineQuery::StringCommandLineQuery(string title, string _description) :
+    Dialog::StringQuery(title, _description)
 {}
 
@@ -150,6 +197,6 @@
 }
 
-CommandLineDialog::StringsCommandLineQuery::StringsCommandLineQuery(string title,vector<string> *_target, string _description) :
-    Dialog::StringsQuery(title,_target, _description)
+CommandLineDialog::StringsCommandLineQuery::StringsCommandLineQuery(string title, string _description) :
+    Dialog::StringsQuery(title, _description)
 {}
 
@@ -161,11 +208,11 @@
     return true;
   } else {
-    DoeLog(1) && (eLog() << Verbose(1) << "CommandLineUI parsing error: Missing string for " << getTitle() << "." << endl);
-    return false;
-  }
-}
-
-CommandLineDialog::DoubleCommandLineQuery::DoubleCommandLineQuery(string title,double *_target, string _description) :
-    Dialog::DoubleQuery(title,_target, _description)
+    DoeLog(1) && (eLog() << Verbose(1) << "CommandLineUI parsing error: Missing strings for " << getTitle() << "." << endl);
+    return false;
+  }
+}
+
+CommandLineDialog::DoubleCommandLineQuery::DoubleCommandLineQuery(string title, string _description) :
+    Dialog::DoubleQuery(title, _description)
 {}
 
@@ -182,6 +229,22 @@
 }
 
-CommandLineDialog::AtomCommandLineQuery::AtomCommandLineQuery(string title, atom **_target, string _description) :
-    Dialog::AtomQuery(title,_target, _description)
+CommandLineDialog::DoublesCommandLineQuery::DoublesCommandLineQuery(string title, string _description) :
+    Dialog::DoublesQuery(title, _description)
+{}
+
+CommandLineDialog::DoublesCommandLineQuery::~DoublesCommandLineQuery() {}
+
+bool CommandLineDialog::DoublesCommandLineQuery::handle() {
+  if (CommandLineParser::getInstance().vm.count(getTitle())) {
+    tmp = CommandLineParser::getInstance().vm[getTitle()].as< std::vector<double> >();
+    return true;
+  } else {
+    DoeLog(1) && (eLog() << Verbose(1) << "CommandLineUI parsing error: Missing doubles for " << getTitle() << "." << endl);
+    return false;
+  }
+}
+
+CommandLineDialog::AtomCommandLineQuery::AtomCommandLineQuery(string title, string _description) :
+    Dialog::AtomQuery(title, _description)
 {}
 
@@ -200,6 +263,28 @@
 }
 
-CommandLineDialog::MoleculeCommandLineQuery::MoleculeCommandLineQuery(string title, molecule **_target, string _description) :
-    Dialog::MoleculeQuery(title,_target, _description)
+CommandLineDialog::AtomsCommandLineQuery::AtomsCommandLineQuery(string title, string _description) :
+    Dialog::AtomsQuery(title, _description)
+{}
+
+CommandLineDialog::AtomsCommandLineQuery::~AtomsCommandLineQuery() {}
+
+bool CommandLineDialog::AtomsCommandLineQuery::handle() {
+  std::vector<int> IdxOfAtom;
+  if (CommandLineParser::getInstance().vm.count(getTitle())) {
+    IdxOfAtom = CommandLineParser::getInstance().vm[getTitle()].as< std::vector<int> >();
+    for (std::vector<int>::iterator iter = IdxOfAtom.begin(); iter != IdxOfAtom.end(); ++iter) {
+      temp = World::getInstance().getAtom(AtomById(*iter));
+      if (temp)
+        tmp.push_back(temp);
+    }
+    return true;
+  } else {
+    DoeLog(1) && (eLog() << Verbose(1) << "CommandLineUI parsing error: Missing atoms for " << getTitle() << "." << endl);
+    return false;
+  }
+}
+
+CommandLineDialog::MoleculeCommandLineQuery::MoleculeCommandLineQuery(string title, string _description) :
+    Dialog::MoleculeQuery(title, _description)
 {}
 
@@ -210,9 +295,5 @@
   if (CommandLineParser::getInstance().vm.count(getTitle())) {
     IdxOfMol = CommandLineParser::getInstance().vm[getTitle()].as<int>();
-    cout << "IdxOfMol " << IdxOfMol << endl;
-    if (IdxOfMol >= 0)
-      tmp = World::getInstance().getMolecule(MoleculeById(IdxOfMol));
-    else
-      tmp = NULL;
+    tmp = World::getInstance().getMolecule(MoleculeById(IdxOfMol));
     return true;
   } else {
@@ -222,6 +303,28 @@
 }
 
-CommandLineDialog::VectorCommandLineQuery::VectorCommandLineQuery(string title, Vector *_target, const double *const _cellSize, bool _check, string _description) :
-    Dialog::VectorQuery(title,_target,_cellSize,_check, _description)
+CommandLineDialog::MoleculesCommandLineQuery::MoleculesCommandLineQuery(string title, string _description) :
+    Dialog::MoleculesQuery(title, _description)
+{}
+
+CommandLineDialog::MoleculesCommandLineQuery::~MoleculesCommandLineQuery() {}
+
+bool CommandLineDialog::MoleculesCommandLineQuery::handle() {
+  std::vector<int> IdxOfMol;
+  if (CommandLineParser::getInstance().vm.count(getTitle())) {
+    IdxOfMol = CommandLineParser::getInstance().vm[getTitle()].as< std::vector<int> >();
+    for (std::vector<int>::iterator iter = IdxOfMol.begin(); iter != IdxOfMol.end(); ++iter) {
+      temp = World::getInstance().getMolecule(MoleculeById(*iter));
+      if (temp)
+        tmp.push_back(temp);
+    }
+    return true;
+  } else {
+    DoeLog(1) && (eLog() << Verbose(1) << "CommandLineUI parsing error: Missing molecules for " << getTitle() << "." << endl);
+    return false;
+  }
+}
+
+CommandLineDialog::VectorCommandLineQuery::VectorCommandLineQuery(string title, bool _check, string _description) :
+    Dialog::VectorQuery(title,_check, _description)
 {}
 
@@ -233,7 +336,11 @@
   if (CommandLineParser::getInstance().vm.count(getTitle())) {
     temp = CommandLineParser::getInstance().vm[getTitle()].as< VectorValue >();
-    tmp->at(0) = temp.x;
-    tmp->at(1) = temp.y;
-    tmp->at(2) = temp.z;
+    tmp[0] = temp.x;
+    tmp[1] = temp.y;
+    tmp[2] = temp.z;
+    if ((check) && (!World::getInstance().getDomain().isInside(tmp))) {
+      DoeLog(1) && (eLog() << Verbose(1) << "Vector " << tmp << " would be outside of box domain." << endl);
+      return false;
+    }
     return true;
   } else {
@@ -243,7 +350,33 @@
 }
 
-
-CommandLineDialog::BoxCommandLineQuery::BoxCommandLineQuery(string title, double ** const _cellSize, string _description) :
-    Dialog::BoxQuery(title,_cellSize, _description)
+CommandLineDialog::VectorsCommandLineQuery::VectorsCommandLineQuery(string title, bool _check, string _description) :
+    Dialog::VectorsQuery(title,_check, _description)
+{}
+
+CommandLineDialog::VectorsCommandLineQuery::~VectorsCommandLineQuery()
+{}
+
+bool CommandLineDialog::VectorsCommandLineQuery::handle() {
+  std::vector<VectorValue> temporary;
+  if (CommandLineParser::getInstance().vm.count(getTitle())) {
+    temporary = CommandLineParser::getInstance().vm[getTitle()].as< std::vector<VectorValue> >();
+    for(std::vector<VectorValue>::iterator iter = temporary.begin(); iter != temporary.end(); ++iter) {
+      temp[0] = (*iter).x;
+      temp[1] = (*iter).y;
+      temp[2] = (*iter).z;
+      if ((!check) || (World::getInstance().getDomain().isInside(temp)))
+        tmp.push_back(temp);
+      else
+        DoeLog(1) && (eLog() << Verbose(1) << "Vector " << temp << " would be outside of box domain." << endl);
+    }
+    return true;
+  } else {
+    DoeLog(1) && (eLog() << Verbose(1) << "CommandLineUI parsing error: Missing vectors for " << getTitle() << "." << endl);
+    return false;
+  }
+}
+
+CommandLineDialog::BoxCommandLineQuery::BoxCommandLineQuery(string title, string _description) :
+    Dialog::BoxQuery(title, _description)
 {}
 
@@ -255,10 +388,15 @@
   if (CommandLineParser::getInstance().vm.count(getTitle())) {
     temp = CommandLineParser::getInstance().vm[getTitle()].as< BoxValue >();
-    tmp[0] = temp.xx;
-    tmp[1] = temp.xy;
-    tmp[2] = temp.xz;
-    tmp[3] = temp.yy;
-    tmp[4] = temp.yz;
-    tmp[5] = temp.zz;
+    Matrix M;
+    M.set(0,0, temp.xx);
+    M.set(0,1, temp.yx);
+    M.set(0,2, temp.zx);
+    M.set(1,0, temp.yx);
+    M.set(1,1, temp.yy);
+    M.set(1,2, temp.zy);
+    M.set(2,0, temp.zx);
+    M.set(2,1, temp.zy);
+    M.set(2,2, temp.zz);
+    tmp.setM(M);
     return true;
   } else {
@@ -268,6 +406,6 @@
 }
 
-CommandLineDialog::ElementCommandLineQuery::ElementCommandLineQuery(string title, std::vector<element *> *target, string _description) :
-    Dialog::ElementQuery(title,target, _description)
+CommandLineDialog::ElementCommandLineQuery::ElementCommandLineQuery(string title, string _description) :
+    Dialog::ElementQuery(title, _description)
 {}
 
@@ -278,16 +416,36 @@
   // TODO: vector of ints and removing first is not correctly implemented yet. How to remove from a vector?
   periodentafel *periode = World::getInstance().getPeriode();
-  element *elemental = NULL;
+  if (CommandLineParser::getInstance().vm.count(getTitle())) {
+    int Z = CommandLineParser::getInstance().vm[getTitle()].as< int >();
+    tmp = periode->FindElement(Z);
+    ASSERT(tmp != NULL, "Invalid element specified in ElementCommandLineQuery");
+    return true;
+  } else {
+    DoeLog(1) && (eLog() << Verbose(1) << "CommandLineUI parsing error: Missing element for " << getTitle() << "." << endl);
+    return false;
+  }
+}
+
+CommandLineDialog::ElementsCommandLineQuery::ElementsCommandLineQuery(string title, string _description) :
+    Dialog::ElementsQuery(title, _description)
+{}
+
+CommandLineDialog::ElementsCommandLineQuery::~ElementsCommandLineQuery()
+{}
+
+bool CommandLineDialog::ElementsCommandLineQuery::handle() {
+  // TODO: vector of ints and removing first is not correctly implemented yet. How to remove from a vector?
+  periodentafel *periode = World::getInstance().getPeriode();
   if (CommandLineParser::getInstance().vm.count(getTitle())) {
     vector<int> AllElements = CommandLineParser::getInstance().vm[getTitle()].as< vector<int> >();
     for (vector<int>::iterator ZRunner = AllElements.begin(); ZRunner != AllElements.end(); ++ZRunner) {
-      elemental = periode->FindElement(*ZRunner);
-      ASSERT(elemental != NULL, "Invalid element specified in ElementCommandLineQuery");
-      elements.push_back(elemental);
+      temp = periode->FindElement(*ZRunner);
+      ASSERT(temp != NULL, "Invalid element specified in ElementCommandLineQuery");
+      tmp.push_back(temp);
     }
     return true;
   } else {
-    DoeLog(1) && (eLog() << Verbose(1) << "CommandLineUI parsing error: Missing element for " << getTitle() << "." << endl);
-    return false;
-  }
-}
+    DoeLog(1) && (eLog() << Verbose(1) << "CommandLineUI parsing error: Missing elements for " << getTitle() << "." << endl);
+    return false;
+  }
+}
Index: src/UIElements/CommandLineUI/CommandLineDialog.hpp
===================================================================
--- src/UIElements/CommandLineUI/CommandLineDialog.hpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/UIElements/CommandLineUI/CommandLineDialog.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -28,14 +28,20 @@
 
   virtual void queryEmpty(const char *, std::string = "");
-  virtual void queryInt(const char *, int *, std::string = "");
-  virtual void queryBoolean(const char *, bool *, std::string = "");
-  virtual void queryString(const char*, std::string *, std::string = "");
-  virtual void queryStrings(const char*, std::vector<std::string> *, std::string = "");
-  virtual void queryDouble(const char*, double*, std::string = "");
-  virtual void queryAtom(const char*,atom**, std::string = "");
-  virtual void queryMolecule(const char*,molecule**,std::string = "");
-  virtual void queryVector(const char*,Vector *,const double * const,bool, std::string = "");
-  virtual void queryBox(const char*,double ** const, std::string = "");
-  virtual void queryElement(const char*, std::vector<element *> *, std::string = "");
+  virtual void queryInt(const char *, std::string = "");
+  virtual void queryInts(const char *, std::string = "");
+  virtual void queryBoolean(const char *, std::string = "");
+  virtual void queryString(const char*, std::string = "");
+  virtual void queryStrings(const char*, std::string = "");
+  virtual void queryDouble(const char*, std::string = "");
+  virtual void queryDoubles(const char*, std::string = "");
+  virtual void queryAtom(const char*, std::string = "");
+  virtual void queryAtoms(const char*, std::string = "");
+  virtual void queryMolecule(const char*, std::string = "");
+  virtual void queryMolecules(const char*, std::string = "");
+  virtual void queryVector(const char*, bool, std::string = "");
+  virtual void queryVectors(const char*, bool, std::string = "");
+  virtual void queryBox(const char*, std::string = "");
+  virtual void queryElement(const char*, std::string = "");
+  virtual void queryElements(const char*, std::string = "");
 
 protected:
@@ -50,6 +56,13 @@
   class IntCommandLineQuery : public Dialog::IntQuery {
   public:
-    IntCommandLineQuery(std::string title, int *_target, std::string _description = "");
+    IntCommandLineQuery(std::string title, std::string _description = "");
     virtual ~IntCommandLineQuery();
+    virtual bool handle();
+  };
+
+  class IntsCommandLineQuery : public Dialog::IntsQuery {
+  public:
+    IntsCommandLineQuery(std::string title, std::string _description = "");
+    virtual ~IntsCommandLineQuery();
     virtual bool handle();
   };
@@ -57,5 +70,5 @@
   class BooleanCommandLineQuery : public Dialog::BooleanQuery {
   public:
-    BooleanCommandLineQuery(std::string title, bool *_target, std::string _description = "");
+    BooleanCommandLineQuery(std::string title, std::string _description = "");
     virtual ~BooleanCommandLineQuery();
     virtual bool handle();
@@ -64,6 +77,13 @@
   class DoubleCommandLineQuery : public Dialog::DoubleQuery {
   public:
-    DoubleCommandLineQuery(std::string title, double *_target, std::string _description = "");
+    DoubleCommandLineQuery(std::string title, std::string _description = "");
     virtual ~DoubleCommandLineQuery();
+    virtual bool handle();
+  };
+
+  class DoublesCommandLineQuery : public Dialog::DoublesQuery {
+  public:
+    DoublesCommandLineQuery(std::string title, std::string _description = "");
+    virtual ~DoublesCommandLineQuery();
     virtual bool handle();
   };
@@ -71,5 +91,5 @@
   class StringCommandLineQuery : public Dialog::StringQuery {
   public:
-    StringCommandLineQuery(std::string title, std::string *_target, std::string _description = "");
+    StringCommandLineQuery(std::string title, std::string _description = "");
     virtual ~StringCommandLineQuery();
     virtual bool handle();
@@ -78,5 +98,5 @@
   class StringsCommandLineQuery : public Dialog::StringsQuery {
   public:
-    StringsCommandLineQuery(std::string title, std::vector<std::string> *_target, std::string _description = "");
+    StringsCommandLineQuery(std::string title, std::string _description = "");
     virtual ~StringsCommandLineQuery();
     virtual bool handle();
@@ -85,6 +105,13 @@
   class AtomCommandLineQuery : public Dialog::AtomQuery {
   public:
-    AtomCommandLineQuery(std::string title, atom **_target, std::string _description = "");
+    AtomCommandLineQuery(std::string title, std::string _description = "");
     virtual ~AtomCommandLineQuery();
+    virtual bool handle();
+  };
+
+  class AtomsCommandLineQuery : public Dialog::AtomsQuery {
+  public:
+    AtomsCommandLineQuery(std::string title, std::string _description = "");
+    virtual ~AtomsCommandLineQuery();
     virtual bool handle();
   };
@@ -92,6 +119,13 @@
   class MoleculeCommandLineQuery : public Dialog::MoleculeQuery {
   public:
-    MoleculeCommandLineQuery(std::string title, molecule **_target, std::string _description = "");
+    MoleculeCommandLineQuery(std::string title, std::string _description = "");
     virtual ~MoleculeCommandLineQuery();
+    virtual bool handle();
+  };
+
+  class MoleculesCommandLineQuery : public Dialog::MoleculesQuery {
+  public:
+    MoleculesCommandLineQuery(std::string title, std::string _description = "");
+    virtual ~MoleculesCommandLineQuery();
     virtual bool handle();
   };
@@ -99,6 +133,13 @@
   class VectorCommandLineQuery : public Dialog::VectorQuery {
   public:
-    VectorCommandLineQuery(std::string title,Vector *_target,const double *const _cellSize,bool _check, std::string _description = "");
+    VectorCommandLineQuery(std::string title,bool _check, std::string _description = "");
     virtual ~VectorCommandLineQuery();
+    virtual bool handle();
+  };
+
+  class VectorsCommandLineQuery : public Dialog::VectorsQuery {
+  public:
+    VectorsCommandLineQuery(std::string title,bool _check, std::string _description = "");
+    virtual ~VectorsCommandLineQuery();
     virtual bool handle();
   };
@@ -106,5 +147,5 @@
   class BoxCommandLineQuery : public Dialog::BoxQuery {
   public:
-    BoxCommandLineQuery(std::string title,double ** const _cellSize, std::string _description = "");
+    BoxCommandLineQuery(std::string title, std::string _description = "");
     virtual ~BoxCommandLineQuery();
     virtual bool handle();
@@ -113,6 +154,13 @@
   class ElementCommandLineQuery : public Dialog::ElementQuery {
   public:
-    ElementCommandLineQuery(std::string title, std::vector<element *> *_target, std::string _description = "");
+    ElementCommandLineQuery(std::string title, std::string _description = "");
     virtual ~ElementCommandLineQuery();
+    virtual bool handle();
+  };
+
+  class ElementsCommandLineQuery : public Dialog::ElementsQuery {
+  public:
+    ElementsCommandLineQuery(std::string title, std::string _description = "");
+    virtual ~ElementsCommandLineQuery();
     virtual bool handle();
   };
Index: src/UIElements/CommandLineUI/CommandLineStatusIndicator.cpp
===================================================================
--- src/UIElements/CommandLineUI/CommandLineStatusIndicator.cpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/UIElements/CommandLineUI/CommandLineStatusIndicator.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -5,4 +5,9 @@
  *      Author: heber
  */
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
 
 #include "Helpers/MemDebug.hpp"
Index: src/UIElements/CommandLineUI/CommandLineUIFactory.cpp
===================================================================
--- src/UIElements/CommandLineUI/CommandLineUIFactory.cpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/UIElements/CommandLineUI/CommandLineUIFactory.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -5,4 +5,9 @@
  *      Author: heber
  */
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
 
 #include "Helpers/MemDebug.hpp"
Index: src/UIElements/CommandLineUI/CommandLineWindow.cpp
===================================================================
--- src/UIElements/CommandLineUI/CommandLineWindow.cpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/UIElements/CommandLineUI/CommandLineWindow.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -5,4 +5,9 @@
  *      Author: heber
  */
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
 
 #include "Helpers/MemDebug.hpp"
@@ -44,5 +49,5 @@
   for (std::list<std::string>::iterator CommandRunner = CommandLineParser::getInstance().SequenceOfActions.begin(); CommandRunner != CommandLineParser::getInstance().SequenceOfActions.end(); ++CommandRunner) {
     cout << "Checking presence of " << *CommandRunner << ": ";
-    if (ActionRegistry::getInstance().isActionByNamePresent(*CommandRunner)) {
+    if (ActionRegistry::getInstance().isActionPresentByName(*CommandRunner)) {
       cout << "calling " << *CommandRunner << endl;
       ActionRegistry::getInstance().getActionByName(*CommandRunner)->call();
Index: src/UIElements/Dialog.cpp
===================================================================
--- src/UIElements/Dialog.cpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/UIElements/Dialog.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -6,12 +6,21 @@
  */
 
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
 #include "Helpers/MemDebug.hpp"
 
 #include "Dialog.hpp"
-
+#include "Actions/ValueStorage.hpp"
+
+#include "Helpers/Verbose.hpp"
 #include "atom.hpp"
 #include "element.hpp"
 #include "molecule.hpp"
-#include "vector.hpp"
+#include "LinearAlgebra/Vector.hpp"
+#include "LinearAlgebra/Matrix.hpp"
+#include "Box.hpp"
 
 using namespace std;
@@ -64,4 +73,8 @@
 }
 
+bool Dialog::hasQueries(){
+  return queries.size();
+}
+
 /****************** Query types Infrastructure **************************/
 
@@ -94,6 +107,6 @@
 // Int Queries
 
-Dialog::IntQuery::IntQuery(string title,int *_target, std::string description) :
-    Query(title, description), target(_target)
+Dialog::IntQuery::IntQuery(string title, std::string description) :
+    Query(title, description)
 {}
 
@@ -101,11 +114,23 @@
 
 void Dialog::IntQuery::setResult() {
-  *target = tmp;
-}
-
-// Int Queries
-
-Dialog::BooleanQuery::BooleanQuery(string title,bool *_target, std::string description) :
-    Query(title, description), target(_target)
+  ValueStorage::getInstance().setCurrentValue(title.c_str(), tmp);
+}
+
+// Ints Queries
+
+Dialog::IntsQuery::IntsQuery(string title, std::string description) :
+    Query(title, description)
+{}
+
+Dialog::IntsQuery::~IntsQuery() {}
+
+void Dialog::IntsQuery::setResult() {
+  ValueStorage::getInstance().setCurrentValue(title.c_str(), tmp);
+}
+
+// Bool Queries
+
+Dialog::BooleanQuery::BooleanQuery(string title,std::string description) :
+    Query(title, description)
 {}
 
@@ -113,11 +138,11 @@
 
 void Dialog::BooleanQuery::setResult() {
-  *target = tmp;
+  ValueStorage::getInstance().setCurrentValue(title.c_str(), tmp);
 }
 
 // String Queries
 
-Dialog::StringQuery::StringQuery(string title,string *_target, std::string _description) :
-    Query(title, _description), target(_target)
+Dialog::StringQuery::StringQuery(string title,std::string _description) :
+    Query(title, _description)
 {}
 
@@ -125,11 +150,11 @@
 
 void Dialog::StringQuery::setResult() {
-  *target = tmp;
+  ValueStorage::getInstance().setCurrentValue(title.c_str(), tmp);
 }
 
 // Strings Queries
 
-Dialog::StringsQuery::StringsQuery(string title,vector<string> *_target, std::string _description) :
-    Query(title, _description), target(_target)
+Dialog::StringsQuery::StringsQuery(string title,std::string _description) :
+    Query(title, _description)
 {}
 
@@ -137,11 +162,11 @@
 
 void Dialog::StringsQuery::setResult() {
-  *target = tmp;
+  ValueStorage::getInstance().setCurrentValue(title.c_str(), tmp);
 }
 
 // Double Queries
 
-Dialog::DoubleQuery::DoubleQuery(string title,double *_target, std::string _description) :
-    Query(title, _description), target(_target)
+Dialog::DoubleQuery::DoubleQuery(string title, std::string _description) :
+    Query(title, _description)
 {}
 
@@ -149,5 +174,17 @@
 
 void Dialog::DoubleQuery::setResult() {
-  *target = tmp;
+  ValueStorage::getInstance().setCurrentValue(title.c_str(), tmp);
+}
+
+// Doubles Queries
+
+Dialog::DoublesQuery::DoublesQuery(string title, std::string _description) :
+    Query(title, _description)
+{}
+
+Dialog::DoublesQuery::~DoublesQuery() {};
+
+void Dialog::DoublesQuery::setResult() {
+  ValueStorage::getInstance().setCurrentValue(title.c_str(), tmp);
 }
 
@@ -155,9 +192,7 @@
 // Atom Queries
 
-Dialog::AtomQuery::AtomQuery(string title, atom **_target, std::string _description) :
+Dialog::AtomQuery::AtomQuery(string title, std::string _description) :
     Query(title, _description),
-    tmp(0),
-    target(_target)
-
+    tmp(0)
 {}
 
@@ -165,14 +200,25 @@
 
 void Dialog::AtomQuery::setResult() {
-  *target = tmp;
+  ValueStorage::getInstance().setCurrentValue(title.c_str(), tmp);
+}
+
+// Atoms Queries
+
+Dialog::AtomsQuery::AtomsQuery(string title, std::string _description) :
+    Query(title, _description),
+    tmp(0)
+{}
+
+Dialog::AtomsQuery::~AtomsQuery() {}
+
+void Dialog::AtomsQuery::setResult() {
+  ValueStorage::getInstance().setCurrentValue(title.c_str(), tmp);
 }
 
 // Molecule Queries
 
-Dialog::MoleculeQuery::MoleculeQuery(string title, molecule **_target, std::string _description) :
+Dialog::MoleculeQuery::MoleculeQuery(string title, std::string _description) :
     Query(title, _description),
-    tmp(0),
-    target(_target)
-
+    tmp(0)
 {}
 
@@ -180,51 +226,64 @@
 
 void Dialog::MoleculeQuery::setResult() {
-  *target = tmp;
+  ValueStorage::getInstance().setCurrentValue(title.c_str(), tmp);
+}
+
+// Molecules Queries
+
+Dialog::MoleculesQuery::MoleculesQuery(string title, std::string _description) :
+    Query(title, _description),
+    tmp(0)
+{}
+
+Dialog::MoleculesQuery::~MoleculesQuery() {}
+
+void Dialog::MoleculesQuery::setResult() {
+  ValueStorage::getInstance().setCurrentValue(title.c_str(), tmp);
 }
 
 // Vector Queries
 
-Dialog::VectorQuery::VectorQuery(std::string title,Vector *_target,const double *const _cellSize,bool _check, std::string _description) :
+Dialog::VectorQuery::VectorQuery(std::string title,bool _check, std::string _description) :
   Query(title, _description),
-  cellSize(_cellSize),
-  check(_check),
-  target(_target)
-{
-  tmp = new Vector();
-}
+  check(_check)
+{}
 
 Dialog::VectorQuery::~VectorQuery()
-{
-  delete tmp;
-}
+{}
 
 void Dialog::VectorQuery::setResult() {
-  *target = *tmp;
+  ValueStorage::getInstance().setCurrentValue(title.c_str(), tmp);
+}
+
+// Vectors Queries
+
+Dialog::VectorsQuery::VectorsQuery(std::string title,bool _check, std::string _description) :
+  Query(title, _description),
+  check(_check)
+{}
+
+Dialog::VectorsQuery::~VectorsQuery()
+{}
+
+void Dialog::VectorsQuery::setResult() {
+  ValueStorage::getInstance().setCurrentValue(title.c_str(), tmp);
 }
 
 // Box Queries
 
-Dialog::BoxQuery::BoxQuery(std::string title, double ** const _cellSize, std::string _description) :
-  Query(title, _description),
-  target(_cellSize)
-{
-    tmp = new double[6];
-}
+Dialog::BoxQuery::BoxQuery(std::string title, std::string _description) :
+  Query(title, _description)
+{}
 
 Dialog::BoxQuery::~BoxQuery()
-{
-  delete[] tmp;
-}
+{}
 
 void Dialog::BoxQuery::setResult() {
-  for (int i=0;i<6;i++) {
-    (*target)[i] = tmp[i];
-  }
+  ValueStorage::getInstance().setCurrentValue(title.c_str(), tmp);
 }
 
 // Element Queries
-Dialog::ElementQuery::ElementQuery(std::string title, std::vector<element *> *_target, std::string _description) :
-  Query(title, _description),
-  target(_target)
+Dialog::ElementQuery::ElementQuery(std::string title, std::string _description) :
+  Query(title, _description)
   {}
 
@@ -232,4 +291,15 @@
 
 void Dialog::ElementQuery::setResult(){
-  *target=elements;
-}
+  ValueStorage::getInstance().setCurrentValue(title.c_str(), tmp);
+}
+
+// Elements Queries
+Dialog::ElementsQuery::ElementsQuery(std::string title, std::string _description) :
+  Query(title, _description)
+  {}
+
+Dialog::ElementsQuery::~ElementsQuery(){}
+
+void Dialog::ElementsQuery::setResult(){
+  ValueStorage::getInstance().setCurrentValue(title.c_str(), tmp);
+}
Index: src/UIElements/Dialog.hpp
===================================================================
--- src/UIElements/Dialog.hpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/UIElements/Dialog.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -13,8 +13,11 @@
 #include<vector>
 
+#include "Box.hpp"
+#include "LinearAlgebra/Vector.hpp"
+
 class atom;
+class Box;
 class element;
 class molecule;
-class Vector;
 
 
@@ -36,14 +39,20 @@
 
   virtual void queryEmpty(const char *, std::string = "")=0;
-  virtual void queryBoolean(const char *, bool *, std::string = "")=0;
-  virtual void queryInt(const char *, int *, std::string = "")=0;
-  virtual void queryDouble(const char*,double *, std::string = "")=0;
-  virtual void queryString(const char*, std::string *, std::string = "")=0;
-  virtual void queryStrings(const char*, std::vector<std::string> *, std::string = "")=0;
-  virtual void queryAtom(const char*,atom**,std::string = "")=0;
-  virtual void queryMolecule(const char*,molecule**, std::string = "")=0;
-  virtual void queryVector(const char*,Vector *,const double *const,bool, std::string = "")=0;
-  virtual void queryBox(const char*,double ** const, std::string = "")=0;
-  virtual void queryElement(const char*, std::vector<element *> *, std::string = "")=0;
+  virtual void queryBoolean(const char *, std::string = "")=0;
+  virtual void queryInt(const char *, std::string = "")=0;
+  virtual void queryInts(const char *, std::string = "")=0;
+  virtual void queryDouble(const char*, std::string = "")=0;
+  virtual void queryDoubles(const char*, std::string = "")=0;
+  virtual void queryString(const char*, std::string = "")=0;
+  virtual void queryStrings(const char*, std::string = "")=0;
+  virtual void queryAtom(const char*,std::string = "")=0;
+  virtual void queryAtoms(const char*,std::string = "")=0;
+  virtual void queryMolecule(const char*, std::string = "")=0;
+  virtual void queryMolecules(const char*, std::string = "")=0;
+  virtual void queryVector(const char*,bool, std::string = "")=0;
+  virtual void queryVectors(const char*,bool, std::string = "")=0;
+  virtual void queryBox(const char*, std::string = "")=0;
+  virtual void queryElement(const char*, std::string = "")=0;
+  virtual void queryElements(const char*, std::string = "")=0;
 
   virtual bool display();
@@ -51,4 +60,6 @@
   virtual bool checkAll();
   virtual void setAll();
+
+  virtual bool hasQueries();
 
 protected:
@@ -91,5 +102,5 @@
   class BooleanQuery : public Query {
   public:
-    BooleanQuery(std::string title,bool *_target, std::string _description = "");
+    BooleanQuery(std::string title, std::string _description = "");
     virtual ~BooleanQuery();
     virtual bool handle()=0;
@@ -97,11 +108,9 @@
   protected:
     bool tmp;
-  private:
-    bool *target;
   };
 
   class IntQuery : public Query {
   public:
-    IntQuery(std::string title,int *_target, std::string _description = "");
+    IntQuery(std::string title, std::string _description = "");
     virtual ~IntQuery();
     virtual bool handle()=0;
@@ -109,11 +118,20 @@
   protected:
     int tmp;
-  private:
-    int *target;
+  };
+
+  class IntsQuery : public Query {
+  public:
+    IntsQuery(std::string title, std::string _description = "");
+    virtual ~IntsQuery();
+    virtual bool handle()=0;
+    virtual void setResult();
+  protected:
+    int temp;
+    std::vector<int> tmp;
   };
 
   class DoubleQuery : public Query {
   public:
-    DoubleQuery(std::string title,double *_target, std::string _description = "");
+    DoubleQuery(std::string title, std::string _description = "");
     virtual ~DoubleQuery();
     virtual bool handle()=0;
@@ -121,11 +139,20 @@
   protected:
     double tmp;
-  private:
-    double *target;
+  };
+
+  class DoublesQuery : public Query {
+  public:
+    DoublesQuery(std::string title, std::string _description = "");
+    virtual ~DoublesQuery();
+    virtual bool handle()=0;
+    virtual void setResult();
+  protected:
+    double temp;
+    std::vector<double> tmp;
   };
 
   class StringQuery : public Query {
   public:
-    StringQuery(std::string title,std::string *_target, std::string _description = "");
+    StringQuery(std::string title, std::string _description = "");
     virtual ~StringQuery();
     virtual bool handle()=0;
@@ -133,11 +160,9 @@
   protected:
     std::string tmp;
-  private:
-    std::string *target;
   };
 
   class StringsQuery : public Query {
   public:
-    StringsQuery(std::string title,std::vector<std::string> *_target, std::string _description = "");
+    StringsQuery(std::string title, std::string _description = "");
     virtual ~StringsQuery();
     virtual bool handle()=0;
@@ -146,11 +171,9 @@
     std::string temp;
     std::vector<std::string> tmp;
-  private:
-    std::vector<std::string> *target;
   };
 
   class MoleculeQuery : public Query {
   public:
-    MoleculeQuery(std::string title, molecule **_target, std::string _description = "");
+    MoleculeQuery(std::string title, std::string _description = "");
     virtual ~MoleculeQuery();
     virtual bool handle()=0;
@@ -158,11 +181,20 @@
   protected:
     molecule *tmp;
-  private:
-    molecule **target;
+  };
+
+  class MoleculesQuery : public Query {
+  public:
+    MoleculesQuery(std::string title, std::string _description = "");
+    virtual ~MoleculesQuery();
+    virtual bool handle()=0;
+    virtual void setResult();
+  protected:
+    molecule * temp;
+    std::vector<molecule *> tmp;
   };
 
   class AtomQuery : public Query {
   public:
-    AtomQuery(std::string title, atom **_target, std::string _description = "");
+    AtomQuery(std::string title, std::string _description = "");
     virtual ~AtomQuery();
     virtual bool handle()=0;
@@ -170,44 +202,69 @@
   protected:
     atom *tmp;
-  private:
-    atom **target;
+  };
+
+  class AtomsQuery : public Query {
+  public:
+    AtomsQuery(std::string title, std::string _description = "");
+    virtual ~AtomsQuery();
+    virtual bool handle()=0;
+    virtual void setResult();
+  protected:
+    atom *temp;
+    std::vector<atom *> tmp;
   };
 
   class VectorQuery : public Query {
   public:
-      VectorQuery(std::string title,Vector *_target,const double *const _cellSize,bool _check, std::string _description = "");
+      VectorQuery(std::string title,bool _check, std::string _description = "");
       virtual ~VectorQuery();
       virtual bool handle()=0;
       virtual void setResult();
     protected:
-      Vector *tmp;
-      const double *const cellSize;
+      Vector tmp;
       bool check;
-    private:
-      Vector *target;
+  };
+
+  class VectorsQuery : public Query {
+  public:
+      VectorsQuery(std::string title,bool _check, std::string _description = "");
+      virtual ~VectorsQuery();
+      virtual bool handle()=0;
+      virtual void setResult();
+    protected:
+      Vector temp;
+      std::vector<Vector> tmp;
+      bool check;
   };
 
   class BoxQuery : public Query {
   public:
-      BoxQuery(std::string title,double ** const _cellSize, std::string _description = "");
+      BoxQuery(std::string title, std::string _description = "");
       virtual ~BoxQuery();
       virtual bool handle()=0;
       virtual void setResult();
     protected:
-      double *tmp;
-    private:
-      double **target;
+      Box tmp;
   };
 
   class ElementQuery : public Query {
   public:
-    ElementQuery(std::string title, std::vector<element *> *_target, std::string _description = "");
+    ElementQuery(std::string title, std::string _description = "");
     virtual ~ElementQuery();
     virtual bool handle()=0;
     virtual void setResult();
   protected:
-    std::vector<element *> elements;
-  private:
-    std::vector<element *> * const target;
+    const element * tmp;
+  };
+
+  class ElementsQuery : public Query {
+  public:
+    ElementsQuery(std::string title, std::string _description = "");
+    virtual ~ElementsQuery();
+    virtual bool handle()=0;
+    virtual void setResult();
+  protected:
+    const element *temp;
+    std::vector<const element *> tmp;
   };
 
Index: src/UIElements/MainWindow.cpp
===================================================================
--- src/UIElements/MainWindow.cpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/UIElements/MainWindow.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -5,4 +5,9 @@
  *      Author: crueger
  */
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
 
 #include "Helpers/MemDebug.hpp"
Index: src/UIElements/Makefile.am
===================================================================
--- src/UIElements/Makefile.am	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/UIElements/Makefile.am	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -5,7 +5,4 @@
 AM_LDFLAGS = $(CPPUNIT_LIBS) -ldl
 AM_CXXFLAGS = $(CPPUNIT_CFLAGS)
-
-noinst_LIBRARIES = libMolecuilderUI.a
-libMolecuilderUI_a_SOURCES = ${UISOURCE} ${UIHEADER}
 
 VIEWSOURCE = \
@@ -45,6 +42,5 @@
   ${VIEWSOURCE} \
   Dialog.cpp \
-  MainWindow.cpp \
-  UIFactory.cpp
+  MainWindow.cpp
   
 UIHEADER = \
@@ -55,6 +51,5 @@
   ${VIEWHEADER} \
   Dialog.hpp \
-  MainWindow.hpp \
-  UIFactory.hpp
+  MainWindow.hpp
 
 TEXTUISOURCE = \
@@ -80,3 +75,52 @@
   CommandLineUI/CommandLineWindow.hpp
 
+lib_LTLIBRARIES = libMolecuilderUI-@MOLECUILDER_API_VERSION@.la
+libMolecuilderUI_includedir = $(includedir)/molecuilder-$(MOLECUILDER_API_VERSION)/Actions/
+libMolecuilderUI_LIBS = \
+	Actions/libMolecuilderActions-@MOLECUILDER_API_VERSION@.la
 
+nobase_libMolecuilderUI_include_HEADERS = ${UIHEADER}
+
+## Define the source file list for the "libexample-@MOLECUILDER_API_VERSION@.la"
+## target.  Note that @MOLECUILDER_API_VERSION@ is not interpreted by Automake and
+## will therefore be treated as if it were literally part of the target name,
+## and the variable name derived from that.
+## The file extension .cc is recognized by Automake, and makes it produce
+## rules which invoke the C++ compiler to produce a libtool object file (.lo)
+## from each source file.  Note that it is not necessary to list header files
+## which are already listed elsewhere in a _HEADERS variable assignment.
+libMolecuilderUI_@MOLECUILDER_API_VERSION@_la_SOURCES = ${UISOURCE}
+
+## Instruct libtool to include ABI version information in the generated shared
+## library file (.so).  The library ABI version is defined in configure.ac, so
+## that all version information is kept in one place.
+libMolecuilderUI_@MOLECUILDER_API_VERSION@_la_LDFLAGS = -version-info $(MOLECUILDER_SO_VERSION)
+
+## The generated configuration header is installed in its own subdirectory of
+## $(libdir).  The reason for this is that the configuration information put
+## into this header file describes the target platform the installed library
+## has been built for.  Thus the file must not be installed into a location
+## intended for architecture-independent files, as defined by the Filesystem
+## Hierarchy Standard (FHS).
+## The nodist_ prefix instructs Automake to not generate rules for including
+## the listed files in the distribution on 'make dist'.  Files that are listed
+## in _HEADERS variables are normally included in the distribution, but the
+## configuration header file is generated at configure time and should not be
+## shipped with the source tarball.
+libMolecuilderUI_libincludedir = $(libdir)/molecuilder-$(MOLECUILDER_API_VERSION)/include
+nodist_libMolecuilderUI_libinclude_HEADERS = $(top_builddir)/libmolecuilder_config.h
+
+## Install the generated pkg-config file (.pc) into the expected location for
+## architecture-dependent package configuration information.  Occasionally,
+## pkg-config files are also used for architecture-independent data packages,
+## in which case the correct install location would be $(datadir)/pkgconfig.
+pkgconfigdir = $(libdir)/pkgconfig
+pkgconfig_DATA = $(top_builddir)/molecuilder-$(MOLECUILDER_API_VERSION).pc
+
+unity.cpp:
+	echo "" >  unity.cpp; \
+	list='$(UISOURCE)'; for file in $$list; do \
+	  echo "#include \"$(srcdir)/$$file\"" >> unity.cpp; \
+	done;
+	
+MOSTLYCLEANFILES = unity.cpp
Index: src/UIElements/Menu/ActionMenuItem.cpp
===================================================================
--- src/UIElements/Menu/ActionMenuItem.cpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/UIElements/Menu/ActionMenuItem.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -5,4 +5,9 @@
  *      Author: crueger
  */
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
 
 #include "Helpers/MemDebug.hpp"
Index: src/UIElements/Menu/DisplayMenuItem.cpp
===================================================================
--- src/UIElements/Menu/DisplayMenuItem.cpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/UIElements/Menu/DisplayMenuItem.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -5,4 +5,9 @@
  *      Author: crueger
  */
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
 
 #include "Helpers/MemDebug.hpp"
@@ -16,7 +21,7 @@
 
 DisplayMenuItem::DisplayMenuItem(Menu* _menu, StringView *_view):
-MenuItem('\0',"",_menu),
-view(_view),
-title("")
+  MenuItem('\0',"",_menu),
+  view(_view),
+  title("")
 {
 }
Index: src/UIElements/Menu/Menu.cpp
===================================================================
--- src/UIElements/Menu/Menu.cpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/UIElements/Menu/Menu.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -5,4 +5,9 @@
  *      Author: crueger
  */
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
 
 #include "Helpers/MemDebug.hpp"
Index: src/UIElements/Menu/MenuItem.cpp
===================================================================
--- src/UIElements/Menu/MenuItem.cpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/UIElements/Menu/MenuItem.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -5,4 +5,9 @@
  *      Author: crueger
  */
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
 
 #include "Helpers/MemDebug.hpp"
@@ -18,6 +23,6 @@
  */
 MenuItem::MenuItem(char _trigger, const char* _description,Menu* menu) :
-trigger(_trigger),
-added(false)
+  trigger(_trigger),
+  added(false)
 {
   description = new string(_description);
Index: src/UIElements/Menu/QT4/QTMenu.cpp
===================================================================
--- src/UIElements/Menu/QT4/QTMenu.cpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/UIElements/Menu/QT4/QTMenu.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -6,7 +6,15 @@
  */
 
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
 #include "Menu/QT4/QTMenu.hpp"
 
 #include <Qt/qaction.h>
+
+#include "Helpers/MemDebug.hpp"
+
 #include "Menu/MenuItem.hpp"
 
Index: src/UIElements/Menu/SeperatorItem.cpp
===================================================================
--- src/UIElements/Menu/SeperatorItem.cpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/UIElements/Menu/SeperatorItem.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -5,4 +5,9 @@
  *      Author: crueger
  */
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
 
 #include "Helpers/MemDebug.hpp"
@@ -17,7 +22,7 @@
 
 SeperatorItem::SeperatorItem(Menu* menu):
-MenuItem('\0',"",menu),
-spacer(STD_SEPERATOR_SPACER),
-length(STD_MENU_LENGTH)
+  MenuItem('\0',"",menu),
+  spacer(STD_SEPERATOR_SPACER),
+  length(STD_MENU_LENGTH)
 {
   // TODO Auto-generated constructor stub
@@ -26,7 +31,7 @@
 
 SeperatorItem::SeperatorItem(Menu* menu,char _spacer, int _length):
-MenuItem('\0',"",menu),
-spacer(_spacer),
-length(_length)
+  MenuItem('\0',"",menu),
+  spacer(_spacer),
+  length(_length)
 {
   // TODO Auto-generated constructor stub
Index: src/UIElements/Menu/SubMenuItem.cpp
===================================================================
--- src/UIElements/Menu/SubMenuItem.cpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/UIElements/Menu/SubMenuItem.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -6,4 +6,9 @@
  */
 
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
 #include "Helpers/MemDebug.hpp"
 
@@ -11,6 +16,6 @@
 
 SubMenuItem::SubMenuItem(char _trigger,const char* _description,Menu* _parent, Menu* _theMenu) :
-MenuItem(_trigger,_description,_parent),
-theMenu(_theMenu)
+  MenuItem(_trigger,_description,_parent),
+  theMenu(_theMenu)
 {
 }
Index: src/UIElements/Menu/TextMenu.cpp
===================================================================
--- src/UIElements/Menu/TextMenu.cpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/UIElements/Menu/TextMenu.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -5,4 +5,9 @@
  *      Author: crueger
  */
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
 
 #include "Helpers/MemDebug.hpp"
@@ -113,6 +118,6 @@
 
 TextMenu::LeaveAction::LeaveAction(TextMenu* _menu) :
-Action(nameBase+_menu->getTitle()),
-menu(_menu)
+  Action(nameBase+_menu->getTitle()),
+  menu(_menu)
 {}
 
@@ -126,4 +131,10 @@
   return false;
 }
+
+Dialog* TextMenu::LeaveAction::fillDialog(Dialog *dialog){
+  ASSERT(dialog,"No Dialog given when filling action dialog");
+  return dialog;
+}
+
 
 Action::state_ptr TextMenu::LeaveAction::performCall(){
Index: src/UIElements/Menu/TextMenu.hpp
===================================================================
--- src/UIElements/Menu/TextMenu.hpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/UIElements/Menu/TextMenu.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -10,5 +10,5 @@
 
 #include <list>
-#include <ostream>
+#include <iosfwd>
 #include <string>
 
@@ -35,4 +35,6 @@
     bool shouldUndo();
 
+  protected:
+    virtual Dialog* fillDialog(Dialog *dialog);
   private:
     virtual Action::state_ptr performCall();
Index: src/UIElements/QT4/IntQTQuery.ui
===================================================================
--- src/UIElements/QT4/IntQTQuery.ui	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
+++ src/UIElements/QT4/IntQTQuery.ui	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -0,0 +1,68 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>Form</class>
+ <widget class="QWidget" name="Form">
+  <property name="geometry">
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>400</width>
+    <height>300</height>
+   </rect>
+  </property>
+  <property name="windowTitle">
+   <string>Form</string>
+  </property>
+  <widget class="QLabel" name="label">
+   <property name="geometry">
+    <rect>
+     <x>20</x>
+     <y>30</y>
+     <width>59</width>
+     <height>17</height>
+    </rect>
+   </property>
+   <property name="text">
+    <string>TextLabel</string>
+   </property>
+  </widget>
+  <widget class="QLineEdit" name="lineEdit">
+   <property name="geometry">
+    <rect>
+     <x>100</x>
+     <y>20</y>
+     <width>113</width>
+     <height>27</height>
+    </rect>
+   </property>
+  </widget>
+  <widget class="QPushButton" name="pushButton">
+   <property name="geometry">
+    <rect>
+     <x>20</x>
+     <y>70</y>
+     <width>92</width>
+     <height>27</height>
+    </rect>
+   </property>
+   <property name="text">
+    <string>OK</string>
+   </property>
+  </widget>
+  <widget class="QPushButton" name="pushButton_2">
+   <property name="geometry">
+    <rect>
+     <x>140</x>
+     <y>70</y>
+     <width>92</width>
+     <height>27</height>
+    </rect>
+   </property>
+   <property name="text">
+    <string>Cancel</string>
+   </property>
+  </widget>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>
Index: src/UIElements/QT4/IntsQTQuery.ui
===================================================================
--- src/UIElements/QT4/IntsQTQuery.ui	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
+++ src/UIElements/QT4/IntsQTQuery.ui	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -0,0 +1,151 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>Form</class>
+ <widget class="QWidget" name="Form">
+  <property name="geometry">
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>740</width>
+    <height>444</height>
+   </rect>
+  </property>
+  <property name="windowTitle">
+   <string>Form</string>
+  </property>
+  <widget class="QWidget" name="horizontalLayoutWidget">
+   <property name="geometry">
+    <rect>
+     <x>10</x>
+     <y>240</y>
+     <width>421</width>
+     <height>51</height>
+    </rect>
+   </property>
+   <layout class="QHBoxLayout" name="horizontalLayout">
+    <item>
+     <spacer name="horizontalSpacer">
+      <property name="orientation">
+       <enum>Qt::Horizontal</enum>
+      </property>
+      <property name="sizeHint" stdset="0">
+       <size>
+        <width>40</width>
+        <height>20</height>
+       </size>
+      </property>
+     </spacer>
+    </item>
+    <item>
+     <widget class="QPushButton" name="pushButton">
+      <property name="text">
+       <string>OK</string>
+      </property>
+     </widget>
+    </item>
+    <item>
+     <widget class="QPushButton" name="pushButton_2">
+      <property name="text">
+       <string>Cancel</string>
+      </property>
+     </widget>
+    </item>
+   </layout>
+  </widget>
+  <widget class="QWidget" name="verticalLayoutWidget">
+   <property name="geometry">
+    <rect>
+     <x>280</x>
+     <y>0</y>
+     <width>160</width>
+     <height>221</height>
+    </rect>
+   </property>
+   <layout class="QVBoxLayout" name="verticalLayout">
+    <item>
+     <widget class="QLabel" name="label">
+      <property name="text">
+       <string>Enter Integer:</string>
+      </property>
+      <property name="buddy">
+       <cstring>lineEdit</cstring>
+      </property>
+     </widget>
+    </item>
+    <item>
+     <widget class="QLineEdit" name="lineEdit">
+      <property name="minimumSize">
+       <size>
+        <width>100</width>
+        <height>20</height>
+       </size>
+      </property>
+      <property name="toolTip">
+       <string>Enter an integer and press Add.</string>
+      </property>
+     </widget>
+    </item>
+    <item>
+     <widget class="QPushButton" name="pushButton_3">
+      <property name="enabled">
+       <bool>false</bool>
+      </property>
+      <property name="text">
+       <string>Add</string>
+      </property>
+     </widget>
+    </item>
+    <item>
+     <widget class="QPushButton" name="pushButton_4">
+      <property name="enabled">
+       <bool>false</bool>
+      </property>
+      <property name="text">
+       <string>Remove</string>
+      </property>
+     </widget>
+    </item>
+    <item>
+     <spacer name="verticalSpacer">
+      <property name="orientation">
+       <enum>Qt::Vertical</enum>
+      </property>
+      <property name="sizeHint" stdset="0">
+       <size>
+        <width>20</width>
+        <height>40</height>
+       </size>
+      </property>
+     </spacer>
+    </item>
+   </layout>
+  </widget>
+  <widget class="QWidget" name="verticalLayoutWidget_2">
+   <property name="geometry">
+    <rect>
+     <x>10</x>
+     <y>0</y>
+     <width>261</width>
+     <height>221</height>
+    </rect>
+   </property>
+   <layout class="QVBoxLayout" name="verticalLayout_2">
+    <item>
+     <widget class="QLabel" name="label_2">
+      <property name="text">
+       <string>Current List of Integers:</string>
+      </property>
+     </widget>
+    </item>
+    <item>
+     <widget class="QListWidget" name="listWidget"/>
+    </item>
+   </layout>
+  </widget>
+ </widget>
+ <tabstops>
+  <tabstop>pushButton</tabstop>
+ </tabstops>
+ <resources/>
+ <connections/>
+</ui>
Index: src/UIElements/QT4/QTDialog.cpp
===================================================================
--- src/UIElements/QT4/QTDialog.cpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/UIElements/QT4/QTDialog.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -6,5 +6,12 @@
  */
 
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
 #include "UIElements/QT4/QTDialog.hpp"
+
+#include <boost/lexical_cast.hpp>
 
 #include <string>
@@ -17,7 +24,10 @@
 #include <QtGui/QDoubleSpinBox>
 #include <Qt/qlineedit.h>
+#include <Qt/qlistwidget.h>
 #include <Qt/qdialogbuttonbox.h>
 #include <Qt/qpushbutton.h>
 #include <Qt/qcombobox.h>
+
+#include <boost/lexical_cast.hpp>
 
 #include "Helpers/MemDebug.hpp"
@@ -28,5 +38,8 @@
 #include "element.hpp"
 #include "molecule.hpp"
+#include "Descriptors/AtomIdDescriptor.hpp"
 #include "Descriptors/MoleculeIdDescriptor.hpp"
+#include "LinearAlgebra/Matrix.hpp"
+#include "Box.hpp"
 
 
@@ -83,56 +96,86 @@
 }
 
-void QTDialog::queryBoolean(char const*, bool*,string){
+void QTDialog::queryBoolean(char const*,string){
   // TODO
   ASSERT(false, "Not implemented yet");
 }
 
-void QTDialog::queryAtom(char const*, atom**, string){
+void QTDialog::queryAtom(char const*, string){
   // TODO
   ASSERT(false, "Not implemented yet");
 }
 
-void QTDialog::queryBox(char const*, double**, string){
+void QTDialog::queryAtoms(char const*, string){
   // TODO
   ASSERT(false, "Not implemented yet");
 }
 
-
-void QTDialog::queryInt(const char *title, int *target,string)
-{
-  registerQuery(new IntQTQuery(title,target,inputLayout,this));
-}
-
-void QTDialog::queryDouble(const char* title, double* target,string){
-  registerQuery(new DoubleQTQuery(title,target,inputLayout,this));
-}
-
-void QTDialog::queryString(const char* title, std::string *target,string)
-{
-  registerQuery(new StringQTQuery(title,target,inputLayout,this));
-}
-
-void QTDialog::queryStrings(const char* title, std::vector<std::string> *target,string)
-{
-  registerQuery(new StringsQTQuery(title,target,inputLayout,this));
-}
-
-void QTDialog::queryMolecule(const char *title,molecule **target,string)
-{
-  registerQuery(new MoleculeQTQuery(title,target,inputLayout,this));
-}
-
-void QTDialog::queryVector(const char* title, Vector *target,const double *const cellSize, bool check,string) {
-  registerQuery(new VectorQTQuery(title,target,cellSize,check,inputLayout,this));
-}
-
-void QTDialog::queryElement(const char* title, std::vector<element *> *target,string){
-  registerQuery(new ElementQTQuery(title,target,inputLayout,this));
+void QTDialog::queryBox(char const*, string){
+  // TODO
+  ASSERT(false, "Not implemented yet");
+}
+
+
+void QTDialog::queryInt(const char *title,string)
+{
+  registerQuery(new IntQTQuery(title,inputLayout,this));
+}
+
+void QTDialog::queryInts(const char *title,string)
+{
+  registerQuery(new IntsQTQuery(title,inputLayout,this));
+}
+
+void QTDialog::queryDouble(const char* title,string){
+  registerQuery(new DoubleQTQuery(title,inputLayout,this));
+}
+
+void QTDialog::queryDoubles(const char* title,string){
+  registerQuery(new DoublesQTQuery(title,inputLayout,this));
+}
+
+void QTDialog::queryString(const char* title,string)
+{
+  registerQuery(new StringQTQuery(title,inputLayout,this));
+}
+
+void QTDialog::queryStrings(const char* title,string)
+{
+  registerQuery(new StringsQTQuery(title,inputLayout,this));
+}
+
+void QTDialog::queryMolecule(const char *title,string)
+{
+  registerQuery(new MoleculeQTQuery(title,inputLayout,this));
+}
+
+void QTDialog::queryMolecules(const char *title,string)
+{
+  // TODO
+  ASSERT(false, "Not implemented yet");
+}
+
+void QTDialog::queryVector(const char* title, bool check,string) {
+  registerQuery(new VectorQTQuery(title,check,inputLayout,this));
+}
+
+void QTDialog::queryVectors(const char* title, bool check,string) {
+  // TODO
+  ASSERT(false, "Not implemented yet");
+}
+
+void QTDialog::queryElement(const char* title, string){
+  registerQuery(new ElementQTQuery(title,inputLayout,this));
+}
+
+void QTDialog::queryElements(const char* title, string){
+  // TODO
+  ASSERT(false, "Not implemented yet");
 }
 
 /************************** Query Objects *******************************/
 
-QTDialog::IntQTQuery::IntQTQuery(string _title,int *_target,QBoxLayout *_parent,QTDialog *_dialog) :
-    Dialog::IntQuery(_title,_target),
+QTDialog::IntQTQuery::IntQTQuery(string _title,QBoxLayout *_parent,QTDialog *_dialog) :
+    Dialog::IntQuery(_title),
     parent(_parent)
 {
@@ -155,12 +198,58 @@
 }
 
-// Handling is easy since the GUI makes it impossible to enter invalid values
-bool QTDialog::IntQTQuery::handle()
-{
-  return true;
-}
-
-QTDialog::DoubleQTQuery::DoubleQTQuery(string title,double *_target,QBoxLayout *_parent,QTDialog *_dialog) :
-    Dialog::DoubleQuery(title,_target),
+bool QTDialog::IntQTQuery::handle() {
+  return true;
+}
+
+
+QTDialog::IntsQTQuery::IntsQTQuery(string _title,QBoxLayout *_parent,QTDialog *_dialog) :
+    Dialog::IntsQuery(_title),
+    parent(_parent)
+{
+  QHBoxLayout * thisHLayout = new QHBoxLayout();
+  QVBoxLayout * thisV1Layout = new QVBoxLayout();
+  QVBoxLayout * thisV2Layout = new QVBoxLayout();
+
+  QLabel *titleLabel = new QLabel(QString(getTitle().c_str()));
+  QLabel *inputLabel = new QLabel("Enter to add");
+  QListWidget* inputList = new QListWidget();
+  inputList->setSelectionMode(QAbstractItemView::ExtendedSelection);
+  QLineEdit* inputBox = new QLineEdit();
+  inputLabel->setBuddy(inputBox);
+  titleLabel->setBuddy(inputList);
+  QPushButton* AddButton = new QPushButton("Add");
+  AddButton->setEnabled(false);
+  QPushButton* RemoveButton = new QPushButton("Remove");
+  RemoveButton->setEnabled(false);
+
+  thisV1Layout->addWidget(titleLabel);
+  thisV1Layout->addWidget(inputList);
+  thisV2Layout->addWidget(inputLabel);
+  thisV2Layout->addWidget(inputBox);
+  thisV2Layout->addWidget(AddButton);
+  thisV2Layout->addWidget(RemoveButton);
+  parent->addLayout(thisHLayout);
+  thisHLayout->addLayout(thisV1Layout);
+  thisHLayout->addLayout(thisV2Layout);
+
+  pipe = new QTQueryListPipe<int>(&tmp,_dialog,inputBox,inputList,AddButton,RemoveButton);
+  connect(inputBox,SIGNAL(textChanged(const QString&)),pipe,SLOT(IntegerEntered(const QString&)));
+  connect(inputList,SIGNAL(itemSelectionChanged()),pipe,SLOT(IntegerSelected()));
+  connect(AddButton,SIGNAL(Clicked()),pipe,SLOT(AddValue()));
+  connect(RemoveButton,SIGNAL(Clicked()),pipe,SLOT(RemoveRow()));
+}
+
+QTDialog::IntsQTQuery::~IntsQTQuery()
+{
+  delete pipe;
+}
+
+bool QTDialog::IntsQTQuery::handle() {
+  return true;
+}
+
+
+QTDialog::DoubleQTQuery::DoubleQTQuery(string title,QBoxLayout *_parent,QTDialog *_dialog) :
+    Dialog::DoubleQuery(title),
     parent(_parent)
 {
@@ -190,6 +279,52 @@
 
 
-QTDialog::StringQTQuery::StringQTQuery(string _title,string *_target,QBoxLayout *_parent,QTDialog *_dialog) :
-    Dialog::StringQuery(_title,_target),
+QTDialog::DoublesQTQuery::DoublesQTQuery(string title,QBoxLayout *_parent,QTDialog *_dialog) :
+    Dialog::DoublesQuery(title),
+    parent(_parent)
+{
+  QHBoxLayout * thisHLayout = new QHBoxLayout();
+  QVBoxLayout * thisV1Layout = new QVBoxLayout();
+  QVBoxLayout * thisV2Layout = new QVBoxLayout();
+
+  QLabel *titleLabel = new QLabel(QString(getTitle().c_str()));
+  QLabel *inputLabel = new QLabel("Enter to add");
+  QListWidget* inputList = new QListWidget();
+  inputList->setSelectionMode(QAbstractItemView::ExtendedSelection);
+  QLineEdit* inputBox = new QLineEdit();
+  inputLabel->setBuddy(inputBox);
+  titleLabel->setBuddy(inputList);
+  QPushButton* AddButton = new QPushButton("Add");
+  AddButton->setEnabled(false);
+  QPushButton* RemoveButton = new QPushButton("Remove");
+  RemoveButton->setEnabled(false);
+
+  thisV1Layout->addWidget(titleLabel);
+  thisV1Layout->addWidget(inputList);
+  thisV2Layout->addWidget(inputLabel);
+  thisV2Layout->addWidget(inputBox);
+  thisV2Layout->addWidget(AddButton);
+  thisV2Layout->addWidget(RemoveButton);
+  parent->addLayout(thisHLayout);
+  thisHLayout->addLayout(thisV1Layout);
+  thisHLayout->addLayout(thisV2Layout);
+
+  pipe = new QTQueryListPipe<double>(&tmp,_dialog,inputBox,inputList,AddButton,RemoveButton);
+  connect(inputBox,SIGNAL(textChanged(const QString&)),pipe,SLOT(IntegerEntered(const QString&)));
+  connect(inputList,SIGNAL(itemSelectionChanged()),pipe,SLOT(IntegerSelected()));
+  connect(AddButton,SIGNAL(Clicked()),pipe,SLOT(AddValue()));
+  connect(RemoveButton,SIGNAL(Clicked()),pipe,SLOT(RemoveRow()));}
+
+QTDialog::DoublesQTQuery::~DoublesQTQuery()
+{
+  delete pipe;
+}
+
+bool QTDialog::DoublesQTQuery::handle() {
+  return true;
+}
+
+
+QTDialog::StringQTQuery::StringQTQuery(string _title,QBoxLayout *_parent,QTDialog *_dialog) :
+    Dialog::StringQuery(_title),
     parent(_parent)
 {
@@ -217,19 +352,39 @@
 }
 
-QTDialog::StringsQTQuery::StringsQTQuery(string _title,vector<string> *_target,QBoxLayout *_parent,QTDialog *_dialog) :
-    Dialog::StringsQuery(_title,_target),
-    parent(_parent)
-{
-  thisLayout = new QHBoxLayout();
-  titleLabel = new QLabel(QString(getTitle().c_str()));
-  inputBox = new QLineEdit();
-  parent->addLayout(thisLayout);
-  thisLayout->addWidget(titleLabel);
-  thisLayout->addWidget(inputBox);
-
-  pipe = new StringQTQueryPipe(&temp,_dialog);
-  pipe->update(inputBox->text());
-  connect(inputBox,SIGNAL(textChanged(const QString&)),pipe,SLOT(update(const QString&)));
-}
+QTDialog::StringsQTQuery::StringsQTQuery(string _title,QBoxLayout *_parent,QTDialog *_dialog) :
+    Dialog::StringsQuery(_title),
+    parent(_parent)
+{
+  QHBoxLayout * thisHLayout = new QHBoxLayout();
+  QVBoxLayout * thisV1Layout = new QVBoxLayout();
+  QVBoxLayout * thisV2Layout = new QVBoxLayout();
+
+  QLabel *titleLabel = new QLabel(QString(getTitle().c_str()));
+  QLabel *inputLabel = new QLabel("Enter to add");
+  QListWidget* inputList = new QListWidget();
+  inputList->setSelectionMode(QAbstractItemView::ExtendedSelection);
+  QLineEdit* inputBox = new QLineEdit();
+  inputLabel->setBuddy(inputBox);
+  titleLabel->setBuddy(inputList);
+  QPushButton* AddButton = new QPushButton("Add");
+  AddButton->setEnabled(false);
+  QPushButton* RemoveButton = new QPushButton("Remove");
+  RemoveButton->setEnabled(false);
+
+  thisV1Layout->addWidget(titleLabel);
+  thisV1Layout->addWidget(inputList);
+  thisV2Layout->addWidget(inputLabel);
+  thisV2Layout->addWidget(inputBox);
+  thisV2Layout->addWidget(AddButton);
+  thisV2Layout->addWidget(RemoveButton);
+  parent->addLayout(thisHLayout);
+  thisHLayout->addLayout(thisV1Layout);
+  thisHLayout->addLayout(thisV2Layout);
+
+  pipe = new QTQueryListPipe<std::string>(&tmp,_dialog,inputBox,inputList,AddButton,RemoveButton);
+  connect(inputBox,SIGNAL(textChanged(const QString&)),pipe,SLOT(IntegerEntered(const QString&)));
+  connect(inputList,SIGNAL(itemSelectionChanged()),pipe,SLOT(IntegerSelected()));
+  connect(AddButton,SIGNAL(Clicked()),pipe,SLOT(AddValue()));
+  connect(RemoveButton,SIGNAL(Clicked()),pipe,SLOT(RemoveRow()));}
 
 QTDialog::StringsQTQuery::~StringsQTQuery()
@@ -255,6 +410,6 @@
 }
 
-QTDialog::MoleculeQTQuery::MoleculeQTQuery(string _title, molecule **_target, QBoxLayout *_parent,QTDialog *_dialog) :
-    Dialog::MoleculeQuery(_title,_target),
+QTDialog::MoleculeQTQuery::MoleculeQTQuery(string _title, QBoxLayout *_parent,QTDialog *_dialog) :
+    Dialog::MoleculeQuery(_title),
     parent(_parent)
 {
@@ -291,11 +446,44 @@
 }
 
-QTDialog::VectorQTQuery::VectorQTQuery(std::string title, Vector *_target, const double *const _cellSize, bool _check,QBoxLayout *_parent,QTDialog *_dialog) :
-    Dialog::VectorQuery(title,_target,_cellSize,_check),
-    parent(_parent)
-{
-  // About the j: I don't know why it was done this way, but it was used this way in Vector::AskPosition, so I reused it
-  int j = -1;
-  const char *coords[3] = {"x:","y:","z:"};
+QTDialog::MoleculesQTQuery::MoleculesQTQuery(string _title, QBoxLayout *_parent,QTDialog *_dialog) :
+    Dialog::MoleculesQuery(_title),
+    parent(_parent)
+{
+  thisLayout = new QHBoxLayout();
+  titleLabel = new QLabel(QString(getTitle().c_str()));
+  inputBox = new QComboBox();
+  // add all molecules to the combo box
+  vector<molecule*> molecules = World::getInstance().getAllMolecules();
+  for(vector<molecule*>::iterator iter  = molecules.begin();
+      iter != molecules.end();
+      ++iter) {
+    stringstream sstr;
+    sstr << (*iter)->IndexNr << "\t" << (*iter)->getName();
+    inputBox->addItem(QString(sstr.str().c_str()),QVariant((*iter)->IndexNr));
+  }
+  parent->addLayout(thisLayout);
+  thisLayout->addWidget(titleLabel);
+  thisLayout->addWidget(inputBox);
+
+  pipe = new MoleculesQTQueryPipe(&tmp,_dialog,inputBox);
+  pipe->update(inputBox->currentIndex());
+  connect(inputBox,SIGNAL(currentIndexChanged(int)),pipe,SLOT(update(int)));
+}
+
+QTDialog::MoleculesQTQuery::~MoleculesQTQuery()
+{
+  delete pipe;
+}
+
+// Handling is easy, since the GUI makes it impossible to select invalid values
+bool QTDialog::MoleculesQTQuery::handle()
+{
+  return true;
+}
+
+QTDialog::VectorQTQuery::VectorQTQuery(std::string title, bool _check,QBoxLayout *_parent,QTDialog *_dialog) :
+    Dialog::VectorQuery(title,_check),
+    parent(_parent)
+{
   mainLayout= new QHBoxLayout();
   titleLabel = new QLabel(QString(getTitle().c_str()));
@@ -303,19 +491,16 @@
   subLayout = new QVBoxLayout();
   mainLayout->addLayout(subLayout);
-  for(int i=0; i<3; i++) {
-    j+=i+1;
-    coordLayout[i] = new QHBoxLayout();
-    subLayout->addLayout(coordLayout[i]);
-    coordLabel[i] = new QLabel(QString(coords[i]));
-    coordLayout[i]->addWidget(coordLabel[i]);
-    coordInput[i] = new QDoubleSpinBox();
-    coordInput[i]->setRange(0,cellSize[j]);
-    coordInput[i]->setDecimals(3);
-    coordLayout[i]->addWidget(coordInput[i]);
-    pipe[i] = new DoubleQTQueryPipe(&((*tmp)[i]),_dialog);
-    pipe[i]->update(coordInput[i]->value());
-    connect(coordInput[i],SIGNAL(valueChanged(double)),pipe[i],SLOT(update(double)));
-
-  }
+  QComboBox* inputBox = new QComboBox();
+  coordLayout = new QHBoxLayout();
+  subLayout->addLayout(coordLayout);
+  coordLabel = new QLabel(QString("x,y,z"));
+  coordLayout->addWidget(coordLabel);
+  coordInput = new QDoubleSpinBox();
+//  coordInput->setRange(0,M.at(i,i));
+  coordInput->setDecimals(3);
+  coordLayout->addWidget(coordInput);
+  pipe = new VectorQTQueryPipe(&(tmp),_dialog,inputBox);
+  //pipe->update(coordInput->value());
+  connect(coordInput,SIGNAL(valueChanged(double)),pipe,SLOT(update(double)));
   parent->addLayout(mainLayout);
 }
@@ -329,6 +514,38 @@
 
 
-QTDialog::ElementQTQuery::ElementQTQuery(std::string _title, vector<element *> *_target, QBoxLayout *_parent, QTDialog *_dialog) :
-    Dialog::ElementQuery(_title,_target),
+QTDialog::VectorsQTQuery::VectorsQTQuery(std::string title, bool _check,QBoxLayout *_parent,QTDialog *_dialog) :
+    Dialog::VectorsQuery(title,_check),
+    parent(_parent)
+{
+  mainLayout= new QHBoxLayout();
+  titleLabel = new QLabel(QString(getTitle().c_str()));
+  mainLayout->addWidget(titleLabel);
+  subLayout = new QVBoxLayout();
+  mainLayout->addLayout(subLayout);
+  QComboBox* inputBox = new QComboBox();
+  coordLayout = new QHBoxLayout();
+  subLayout->addLayout(coordLayout);
+  coordLabel = new QLabel(QString("x,y,z"));
+  coordLayout->addWidget(coordLabel);
+  coordInput = new QDoubleSpinBox();
+//  coordInput->setRange(0,M.at(i,i));
+  coordInput->setDecimals(3);
+  coordLayout->addWidget(coordInput);
+  pipe = new VectorsQTQueryPipe(&(tmp),_dialog,inputBox);
+  //pipe->update(coordInput->value());
+  connect(coordInput,SIGNAL(valueChanged(double)),pipe,SLOT(update(double)));
+  parent->addLayout(mainLayout);
+}
+
+QTDialog::VectorsQTQuery::~VectorsQTQuery()
+{}
+
+bool QTDialog::VectorsQTQuery::handle() {
+  return true;
+}
+
+
+QTDialog::ElementQTQuery::ElementQTQuery(std::string _title, QBoxLayout *_parent, QTDialog *_dialog) :
+    Dialog::ElementQuery(_title),
     parent(_parent)
 {
@@ -342,5 +559,5 @@
   {
     stringstream sstr;
-    sstr << (*iter).first << "\t" << (*iter).second->name;
+    sstr << (*iter).first << "\t" << (*iter).second->getName();
     inputBox->addItem(QString(sstr.str().c_str()),QVariant((*iter).first));
   }
@@ -349,5 +566,5 @@
   thisLayout->addWidget(inputBox);
 
-  pipe = new ElementQTQueryPipe(&elements,_dialog,inputBox);
+  pipe = new ElementQTQueryPipe(&tmp,_dialog,inputBox);
   pipe->update(inputBox->currentIndex());
   connect(inputBox,SIGNAL(currentIndexChanged(int)),pipe,SLOT(update(int)));
@@ -363,5 +580,108 @@
 }
 
+
+QTDialog::ElementsQTQuery::ElementsQTQuery(std::string _title, QBoxLayout *_parent, QTDialog *_dialog) :
+    Dialog::ElementsQuery(_title),
+    parent(_parent)
+{
+  periodentafel *periode = World::getInstance().getPeriode();
+  thisLayout = new QHBoxLayout();
+  titleLabel = new QLabel(QString(getTitle().c_str()));
+  inputBox = new QComboBox();
+  for(periodentafel::const_iterator iter = periode->begin();
+      iter!=periode->end();
+      ++iter)
+  {
+    stringstream sstr;
+    sstr << (*iter).first << "\t" << (*iter).second->getName();
+    inputBox->addItem(QString(sstr.str().c_str()),QVariant((*iter).first));
+  }
+  parent->addLayout(thisLayout);
+  thisLayout->addWidget(titleLabel);
+  thisLayout->addWidget(inputBox);
+
+  pipe = new ElementsQTQueryPipe(&tmp,_dialog,inputBox);
+  pipe->update(inputBox->currentIndex());
+  connect(inputBox,SIGNAL(currentIndexChanged(int)),pipe,SLOT(update(int)));
+}
+
+QTDialog::ElementsQTQuery::~ElementsQTQuery()
+{
+  delete pipe;
+}
+
+bool QTDialog::ElementsQTQuery::handle(){
+  return true;
+}
+
 /*************************** Plumbing *******************************/
+
+
+template<typename T> QTQueryListPipe<T>::QTQueryListPipe(std::vector<T> *_content, QTDialog *_dialog, QLineEdit *_inputBox, QListWidget *_inputList, QPushButton *_AddButton, QPushButton *_RemoveButton) :
+  content(_content),
+  dialog(_dialog),
+  inputBox(_inputBox),
+  inputList(_inputList),
+  AddButton(_AddButton),
+  RemoveButton(_RemoveButton)
+{}
+
+template<typename T> QTQueryListPipe<T>::~QTQueryListPipe()
+{}
+
+template<typename T> void QTQueryListPipe<T>::IntegerEntered(const QString&)
+{
+  AddButton->setEnabled(true);
+}
+
+template<typename T> void QTQueryListPipe<T>::IntegerSelected()
+{
+  if (inputList->selectedItems().empty())
+    RemoveButton->setEnabled(false);
+  else
+    RemoveButton->setEnabled(true);
+}
+
+template<typename T> void QTQueryListPipe<T>::AddInteger() {
+  // type-check
+  std::string text = inputBox->text().toStdString();
+  int number = 0;
+  try {
+    number = boost::lexical_cast<int>(text);
+  } catch (boost::bad_lexical_cast&) {
+    return;
+  };
+  // add item to both
+  inputList->addItem(QString(number));
+  AddValue(number);
+}
+
+template<typename T> void QTQueryListPipe<T>::AddValue(T item) {
+  content->push_back(item);
+
+  dialog->update();
+}
+
+template<typename T> void QTQueryListPipe<T>::RemoveInteger() {
+  QList<QListWidgetItem *> items = inputList->selectedItems();
+  for (QList<QListWidgetItem *>::iterator iter = items.begin(); !items.empty(); iter = items.begin()) {
+    // obtain which position item has (by making it current item)
+    inputList->setCurrentItem(*iter);
+    // remove
+    QTQueryListPipe<T>::RemoteRow(inputList->currentRow()); // template parameters needs to be known, such that compiler knows which to call
+    inputList->removeItemWidget(*iter);
+  }
+}
+
+template<typename T> void QTQueryListPipe<T>::RemoveRow(int row) {
+  int counter = 0;
+  typename std::vector<T>::iterator iter = content->begin();
+  for (; iter != content->end(); ++iter)
+    if (counter++ == row)
+      break;
+  if (iter != content->end())
+      content->erase(iter);
+}
+
 
 StringQTQueryPipe::StringQTQueryPipe(string *_content, QTDialog *_dialog) :
@@ -403,4 +723,66 @@
   dialog->update();
 }
+
+VectorQTQueryPipe::VectorQTQueryPipe(Vector *_content, QTDialog *_dialog, QComboBox *_theBox) :
+  content(_content),
+  dialog(_dialog),
+  theBox(_theBox)
+{}
+
+VectorQTQueryPipe::~VectorQTQueryPipe()
+{}
+
+void VectorQTQueryPipe::update() {
+  dialog->update();
+}
+
+VectorsQTQueryPipe::VectorsQTQueryPipe(std::vector<Vector> *_content, QTDialog *_dialog, QComboBox *_theBox) :
+  content(_content),
+  dialog(_dialog),
+  theBox(_theBox)
+{}
+
+VectorsQTQueryPipe::~VectorsQTQueryPipe()
+{}
+
+void VectorsQTQueryPipe::update() {
+  dialog->update();
+}
+
+AtomQTQueryPipe::AtomQTQueryPipe(atom **_content, QTDialog *_dialog, QComboBox *_theBox) :
+  content(_content),
+  dialog(_dialog),
+  theBox(_theBox)
+{}
+
+AtomQTQueryPipe::~AtomQTQueryPipe()
+{}
+
+void AtomQTQueryPipe::update(int newIndex) {
+  QVariant data = theBox->itemData(newIndex);
+  int idx = data.toInt();
+  (*content) = World::getInstance().getAtom(AtomById(idx));
+  dialog->update();
+}
+
+
+AtomsQTQueryPipe::AtomsQTQueryPipe(std::vector<atom *>*_content, QTDialog *_dialog, QComboBox *_theBox) :
+  content(_content),
+  dialog(_dialog),
+  theBox(_theBox)
+{}
+
+AtomsQTQueryPipe::~AtomsQTQueryPipe()
+{}
+
+void AtomsQTQueryPipe::update(int newIndex) {
+  QVariant data = theBox->itemData(newIndex);
+  int idx = data.toInt();
+  atom *Walker = World::getInstance().getAtom(AtomById(idx));
+  if (Walker)
+    (*content).push_back(Walker) ;
+  dialog->update();
+}
+
 
 MoleculeQTQueryPipe::MoleculeQTQueryPipe(molecule **_content, QTDialog *_dialog, QComboBox *_theBox) :
@@ -420,11 +802,28 @@
 }
 
-ElementQTQueryPipe::ElementQTQueryPipe(std::vector<element *> *_content, QTDialog *_dialog, QComboBox *_theBox) :
+
+MoleculesQTQueryPipe::MoleculesQTQueryPipe(std::vector<molecule *>*_content, QTDialog *_dialog, QComboBox *_theBox) :
   content(_content),
   dialog(_dialog),
   theBox(_theBox)
-{
-  content->resize(1);
-}
+{}
+
+MoleculesQTQueryPipe::~MoleculesQTQueryPipe()
+{}
+
+void MoleculesQTQueryPipe::update(int newIndex) {
+  QVariant data = theBox->itemData(newIndex);
+  int idx = data.toInt();
+  molecule *mol = World::getInstance().getMolecule(MoleculeById(idx));
+  if (mol)
+    (*content).push_back(mol);
+  dialog->update();
+}
+
+ElementQTQueryPipe::ElementQTQueryPipe(const element **_content, QTDialog *_dialog, QComboBox *_theBox) :
+  content(_content),
+  dialog(_dialog),
+  theBox(_theBox)
+{}
 
 ElementQTQueryPipe::~ElementQTQueryPipe()
@@ -434,6 +833,25 @@
   QVariant data = theBox->itemData(newIndex);
   int idx = data.toInt();
-  (*content)[0] = World::getInstance().getPeriode()->FindElement(idx);
-  dialog->update();
-}
-
+  *content = World::getInstance().getPeriode()->FindElement(idx);
+  dialog->update();
+}
+
+ElementsQTQueryPipe::ElementsQTQueryPipe(std::vector<const element *>*_content, QTDialog *_dialog, QComboBox *_theBox) :
+  content(_content),
+  dialog(_dialog),
+  theBox(_theBox)
+{}
+
+ElementsQTQueryPipe::~ElementsQTQueryPipe()
+{}
+
+void ElementsQTQueryPipe::update(int newIndex) {
+  QVariant data = theBox->itemData(newIndex);
+  int idx = data.toInt();
+  const element *elemental = World::getInstance().getPeriode()->FindElement(idx);
+  if(elemental)
+    (*content).push_back(elemental);
+  dialog->update();
+}
+
+
Index: src/UIElements/QT4/QTDialog.hpp
===================================================================
--- src/UIElements/QT4/QTDialog.hpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/UIElements/QT4/QTDialog.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -17,4 +17,5 @@
 class QDoubleSpinBox;
 class QLineEdit;
+class QListWidget;
 class QComboBox;
 class QDialogButtonBox;
@@ -22,9 +23,18 @@
 
 // Forward declarations for plumbing
+template<typename T> class QTQueryListPipe;
 class StringQTQueryPipe;
+class StringsQTQueryPipe;
 class IntQTQueryPipe;
 class DoubleQTQueryPipe;
+class DoublesQTQueryPipe;
+class AtomQTQueryPipe;
+class AtomsQTQueryPipe;
 class MoleculeQTQueryPipe;
+class MoleculesQTQueryPipe;
 class ElementQTQueryPipe;
+class ElementsQTQueryPipe;
+class VectorQTQueryPipe;
+class VectorsQTQueryPipe;
 
 class QTDialog : public QDialog, public Dialog
@@ -36,14 +46,20 @@
 
   virtual void queryEmpty(const char*, std::string);
-  virtual void queryBoolean(const char *, bool *, std::string = "");
-  virtual void queryInt(const char *, int *,std::string = "");
-  virtual void queryDouble(const char*,double *,std::string = "");
-  virtual void queryString(const char*, std::string *,std::string = "");
-  virtual void queryStrings(const char*, std::vector<std::string> *,std::string = "");
-  virtual void queryAtom(const char*,atom**,std::string = "");
-  virtual void queryMolecule(const char*,molecule**,std::string = "");
-  virtual void queryVector(const char*,Vector *,const double *const,bool,std::string = "");
-  virtual void queryBox(const char*,double ** const, std::string = "");
-  virtual void queryElement(const char*,std::vector<element *> *_target,std::string = "");
+  virtual void queryBoolean(const char *, std::string = "");
+  virtual void queryInt(const char *,std::string = "");
+  virtual void queryInts(const char *,std::string = "");
+  virtual void queryDouble(const char*,std::string = "");
+  virtual void queryDoubles(const char*,std::string = "");
+  virtual void queryString(const char*,std::string = "");
+  virtual void queryStrings(const char*,std::string = "");
+  virtual void queryAtom(const char*,std::string = "");
+  virtual void queryAtoms(const char*,std::string = "");
+  virtual void queryMolecule(const char*,std::string = "");
+  virtual void queryMolecules(const char*,std::string = "");
+  virtual void queryVector(const char*,bool,std::string = "");
+  virtual void queryVectors(const char*,bool,std::string = "");
+  virtual void queryBox(const char*, std::string = "");
+  virtual void queryElement(const char*,std::string = "");
+  virtual void queryElements(const char*,std::string = "");
 
   virtual bool display();
@@ -54,5 +70,5 @@
   class IntQTQuery : public Dialog::IntQuery {
     public:
-      IntQTQuery(std::string _title, int *_target,QBoxLayout *_parent,QTDialog *_dialog);
+      IntQTQuery(std::string _title,QBoxLayout *_parent,QTDialog *_dialog);
       virtual ~IntQTQuery();
       virtual bool handle();
@@ -66,7 +82,24 @@
     };
 
+  class IntsQTQuery : public Dialog::IntsQuery {
+    public:
+      IntsQTQuery(std::string _title,QBoxLayout *_parent,QTDialog *_dialog);
+      virtual ~IntsQTQuery();
+      virtual bool handle();
+      void IntegerEntered(const QString&);
+      void IntegerSelected();
+      void AddInteger();
+      void RemoveInteger();
+    private:
+      QBoxLayout *parent;
+      QBoxLayout *thisLayout;
+      QLabel *titleLabel;
+
+      QTQueryListPipe<int> *pipe;
+    };
+
     class DoubleQTQuery : public Dialog::DoubleQuery {
     public:
-      DoubleQTQuery(std::string title, double *_target,QBoxLayout *_parent,QTDialog *_dialog);
+      DoubleQTQuery(std::string title,QBoxLayout *_parent,QTDialog *_dialog);
       virtual ~DoubleQTQuery();
       virtual bool handle();
@@ -80,7 +113,21 @@
     };
 
+    class DoublesQTQuery : public Dialog::DoublesQuery {
+    public:
+      DoublesQTQuery(std::string title,QBoxLayout *_parent,QTDialog *_dialog);
+      virtual ~DoublesQTQuery();
+      virtual bool handle();
+    private:
+      QBoxLayout *parent;
+      QBoxLayout *thisLayout;
+      QLabel *titleLabel;
+      QDoubleSpinBox *inputBox;
+
+      QTQueryListPipe<double> *pipe;
+    };
+
     class StringQTQuery : public Dialog::StringQuery {
     public:
-      StringQTQuery(std::string _title, std::string *_target, QBoxLayout *_parent,QTDialog *_dialog);
+      StringQTQuery(std::string _title, QBoxLayout *_parent,QTDialog *_dialog);
       virtual ~StringQTQuery();
       virtual bool handle();
@@ -96,5 +143,5 @@
     class StringsQTQuery : public Dialog::StringsQuery {
     public:
-      StringsQTQuery(std::string _title, std::vector<std::string> *_target, QBoxLayout *_parent,QTDialog *_dialog);
+      StringsQTQuery(std::string _title, QBoxLayout *_parent,QTDialog *_dialog);
       virtual ~StringsQTQuery();
       virtual bool handle();
@@ -105,10 +152,38 @@
       QLineEdit *inputBox;
 
-      StringQTQueryPipe *pipe;
+      QTQueryListPipe<std::string> *pipe;
+    };
+
+    class AtomQTQuery : public Dialog::AtomQuery {
+    public:
+      AtomQTQuery(std::string _title, QBoxLayout *_parent,QTDialog *_dialog);
+      virtual ~AtomQTQuery();
+      virtual bool handle();
+    private:
+      QBoxLayout *parent;
+      QBoxLayout *thisLayout;
+      QLabel *titleLabel;
+      QComboBox *inputBox;
+
+      AtomQTQueryPipe *pipe;
+    };
+
+    class AtomsQTQuery : public Dialog::AtomsQuery {
+    public:
+      AtomsQTQuery(std::string _title, QBoxLayout *_parent,QTDialog *_dialog);
+      virtual ~AtomsQTQuery();
+      virtual bool handle();
+    private:
+      QBoxLayout *parent;
+      QBoxLayout *thisLayout;
+      QLabel *titleLabel;
+      QComboBox *inputBox;
+
+      AtomsQTQueryPipe *pipe;
     };
 
     class MoleculeQTQuery : public Dialog::MoleculeQuery {
     public:
-      MoleculeQTQuery(std::string _title, molecule **_target, QBoxLayout *_parent,QTDialog *_dialog);
+      MoleculeQTQuery(std::string _title, QBoxLayout *_parent,QTDialog *_dialog);
       virtual ~MoleculeQTQuery();
       virtual bool handle();
@@ -122,7 +197,21 @@
     };
 
+    class MoleculesQTQuery : public Dialog::MoleculesQuery {
+    public:
+      MoleculesQTQuery(std::string _title, QBoxLayout *_parent,QTDialog *_dialog);
+      virtual ~MoleculesQTQuery();
+      virtual bool handle();
+    private:
+      QBoxLayout *parent;
+      QBoxLayout *thisLayout;
+      QLabel *titleLabel;
+      QComboBox *inputBox;
+
+      MoleculesQTQueryPipe *pipe;
+    };
+
     class VectorQTQuery : public Dialog::VectorQuery {
     public:
-      VectorQTQuery(std::string title,Vector *_target,const double *const _cellSize,bool _check,QBoxLayout *,QTDialog *);
+      VectorQTQuery(std::string title,bool _check,QBoxLayout *,QTDialog *);
       virtual ~VectorQTQuery();
       virtual bool handle();
@@ -132,14 +221,31 @@
       QLabel *titleLabel;
       QBoxLayout *subLayout;
-      QBoxLayout *coordLayout[3];
-      QLabel *coordLabel[3];
-      QDoubleSpinBox *coordInput[3];
-
-      DoubleQTQueryPipe *pipe[3];
+      QBoxLayout *coordLayout;
+      QLabel *coordLabel;
+      QDoubleSpinBox *coordInput;
+
+      VectorQTQueryPipe *pipe;
+    };
+
+    class VectorsQTQuery : public Dialog::VectorsQuery {
+    public:
+      VectorsQTQuery(std::string title,bool _check,QBoxLayout *,QTDialog *);
+      virtual ~VectorsQTQuery();
+      virtual bool handle();
+    private:
+      QBoxLayout *parent;
+      QBoxLayout *mainLayout;
+      QLabel *titleLabel;
+      QBoxLayout *subLayout;
+      QBoxLayout *coordLayout;
+      QLabel *coordLabel;
+      QDoubleSpinBox *coordInput;
+
+      VectorsQTQueryPipe *pipe;
     };
 
     class ElementQTQuery : public Dialog::ElementQuery {
     public:
-      ElementQTQuery(std::string _title, std::vector<element *> *_target, QBoxLayout *_parent, QTDialog *_dialog);
+      ElementQTQuery(std::string _title, QBoxLayout *_parent, QTDialog *_dialog);
       virtual ~ElementQTQuery();
       virtual bool handle();
@@ -151,4 +257,18 @@
 
       ElementQTQueryPipe *pipe;
+    };
+
+    class ElementsQTQuery : public Dialog::ElementsQuery {
+    public:
+      ElementsQTQuery(std::string _title, QBoxLayout *_parent, QTDialog *_dialog);
+      virtual ~ElementsQTQuery();
+      virtual bool handle();
+    private:
+      QBoxLayout *parent;
+      QBoxLayout *thisLayout;
+      QLabel *titleLabel;
+      QComboBox *inputBox;
+
+      ElementsQTQueryPipe *pipe;
     };
 
@@ -164,4 +284,27 @@
 // since MOC doesn't like nested classes
 
+
+template<typename T> class QTQueryListPipe : public QWidget {
+  public:
+    QTQueryListPipe(std::vector<T> *_content, QTDialog *_dialog, QLineEdit *_inputBox, QListWidget *_inputList, QPushButton *_AddButton, QPushButton *_RemoveButton);
+    virtual ~QTQueryListPipe();
+    void AddInteger();
+    void RemoveInteger();
+    void IntegerSelected();
+    void IntegerEntered(const QString&);
+
+  private:
+    void AddValue(T item);
+    void RemoveRow(int row);
+
+    std::vector<T> *content;
+    QTDialog *dialog;
+    QLineEdit *inputBox;
+    QListWidget *inputList;
+    QPushButton *AddButton;
+    QPushButton *RemoveButton;
+};
+
+
 class StringQTQueryPipe : public QWidget {
   Q_OBJECT
@@ -194,4 +337,5 @@
 };
 
+
 class DoubleQTQueryPipe : public QWidget {
   Q_OBJECT
@@ -209,4 +353,37 @@
 };
 
+class AtomQTQueryPipe : public QWidget {
+  Q_OBJECT
+public:
+  AtomQTQueryPipe(atom **_content, QTDialog *_dialog, QComboBox *_theBox);
+  virtual ~AtomQTQueryPipe();
+
+public slots:
+  void update(int);
+
+private:
+  atom **content;
+  QTDialog *dialog;
+  QComboBox *theBox;
+
+};
+
+
+class AtomsQTQueryPipe : public QWidget {
+  Q_OBJECT
+public:
+  AtomsQTQueryPipe(std::vector<atom *>*_content, QTDialog *_dialog, QComboBox *_theBox);
+  virtual ~AtomsQTQueryPipe();
+
+public slots:
+  void update(int);
+
+private:
+  std::vector<atom *>*content;
+  QTDialog *dialog;
+  QComboBox *theBox;
+
+};
+
 class MoleculeQTQueryPipe : public QWidget {
   Q_OBJECT
@@ -225,8 +402,54 @@
 };
 
+class MoleculesQTQueryPipe : public QWidget {
+  Q_OBJECT
+public:
+  MoleculesQTQueryPipe(std::vector<molecule *>*_content, QTDialog *_dialog, QComboBox *_theBox);
+  virtual ~MoleculesQTQueryPipe();
+
+public slots:
+  void update(int);
+
+private:
+  std::vector<molecule *>*content;
+  QTDialog *dialog;
+  QComboBox *theBox;
+
+};
+
+class VectorQTQueryPipe : public QWidget {
+  Q_OBJECT
+public:
+  VectorQTQueryPipe(Vector *_content, QTDialog *_dialog, QComboBox *_theBox);
+  virtual ~VectorQTQueryPipe();
+
+public slots:
+  void update();
+
+private:
+  Vector *content;
+  QTDialog *dialog;
+  QComboBox *theBox;
+};
+
+class VectorsQTQueryPipe : public QWidget {
+  Q_OBJECT
+public:
+  VectorsQTQueryPipe(std::vector<Vector>*_content, QTDialog *_dialog, QComboBox *_theBox);
+  virtual ~VectorsQTQueryPipe();
+
+public slots:
+  void update();
+
+private:
+  std::vector<Vector> *content;
+  QTDialog *dialog;
+  QComboBox *theBox;
+};
+
 class ElementQTQueryPipe : public QWidget {
   Q_OBJECT
 public:
-  ElementQTQueryPipe(std::vector<element *> *_content, QTDialog *_dialog, QComboBox *_theBox);
+  ElementQTQueryPipe(const element **_content, QTDialog *_dialog, QComboBox *_theBox);
   virtual ~ElementQTQueryPipe();
 
@@ -235,5 +458,20 @@
 
 private:
-  std::vector<element *> *content;
+  const element **content;
+  QTDialog *dialog;
+  QComboBox *theBox;
+};
+
+class ElementsQTQueryPipe : public QWidget {
+  Q_OBJECT
+public:
+  ElementsQTQueryPipe(std::vector<const element *>*_content, QTDialog *_dialog, QComboBox *_theBox);
+  virtual ~ElementsQTQueryPipe();
+
+public slots:
+  void update(int);
+
+private:
+  std::vector<const element *>*content;
   QTDialog *dialog;
   QComboBox *theBox;
Index: src/UIElements/QT4/QTMainWindow.cpp
===================================================================
--- src/UIElements/QT4/QTMainWindow.cpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/UIElements/QT4/QTMainWindow.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -5,4 +5,9 @@
  *      Author: crueger
  */
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
 
 #include "QTMainWindow.hpp"
@@ -19,6 +24,9 @@
 #include<boost/bind.hpp>
 
+#include "Helpers/MemDebug.hpp"
+
 #include "atom.hpp"
 #include "molecule.hpp"
+#include "Helpers/Verbose.hpp"
 #include "Actions/Action.hpp"
 #include "Actions/ActionRegistry.hpp"
@@ -31,6 +39,4 @@
 #include "Views/QT4/QTMoleculeView.hpp"
 #include "Views/QT4/QTStatusBar.hpp"
-#include "Helpers/MemDebug.hpp"
-
 
 using namespace std;
Index: src/UIElements/QT4/QTUIFactory.cpp
===================================================================
--- src/UIElements/QT4/QTUIFactory.cpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/UIElements/QT4/QTUIFactory.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -6,22 +6,30 @@
  */
 
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
 #include <iostream>
 #include <cassert>
 
-using namespace std;
+#include <qapplication.h>
 
-#include <qapplication.h>
 
 #include "UIElements/QT4/QTUIFactory.hpp"
 #include "UIElements/QT4/QTMainWindow.hpp"
 #include "UIElements/QT4/QTDialog.hpp"
+
+#include "Helpers/MemDebug.hpp"
+
 #include "version.h"
 #include "defs.hpp"
-#include "Helpers/MemDebug.hpp"
 
-QTUIFactory::QTUIFactory()
+using namespace std;
+
+QTUIFactory::QTUIFactory() :
+  argc(1)
 {
   // For now we just fake the command line parameters to make QT happy
-  argc=1;
   argv = new char*[1];
   argv[0] = new char[256];
Index: src/UIElements/TextUI/TextDialog.cpp
===================================================================
--- src/UIElements/TextUI/TextDialog.cpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/UIElements/TextUI/TextDialog.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -6,4 +6,9 @@
  */
 
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
 #include "Helpers/MemDebug.hpp"
 
@@ -14,17 +19,25 @@
 #include <Descriptors/MoleculeDescriptor.hpp>
 #include <Descriptors/MoleculeIdDescriptor.hpp>
+#include <boost/lexical_cast.hpp>
 #include "TextUI/TextDialog.hpp"
 
 #include "World.hpp"
 #include "periodentafel.hpp"
-#include "log.hpp"
-#include "verbose.hpp"
+#include "Helpers/Log.hpp"
+#include "Helpers/Verbose.hpp"
 
 #include "atom.hpp"
 #include "element.hpp"
 #include "molecule.hpp"
-#include "vector.hpp"
+#include "LinearAlgebra/Vector.hpp"
+#include "LinearAlgebra/Matrix.hpp"
+#include "Box.hpp"
+
+#include <boost/lexical_cast.hpp>
 
 using namespace std;
+
+using boost::lexical_cast;
+using boost::bad_lexical_cast;
 
 
@@ -42,42 +55,66 @@
 }
 
-void TextDialog::queryBoolean(const char* title, bool* target, string description){
-  registerQuery(new BooleanTextQuery(title,target,description));
-}
-
-void TextDialog::queryInt(const char* title, int* target, string description){
-  registerQuery(new IntTextQuery(title,target,description));
-}
-
-void TextDialog::queryDouble(const char* title, double* target, string description){
-  registerQuery(new DoubleTextQuery(title,target,description));
-}
-
-void TextDialog::queryString(const char* title, string* target, string description){
-  registerQuery(new StringTextQuery(title,target,description));
-}
-
-void TextDialog::queryStrings(const char* title, vector<string>* target, string description){
-  registerQuery(new StringsTextQuery(title,target,description));
-}
-
-void TextDialog::queryAtom(const char* title, atom **target, string description) {
-  registerQuery(new AtomTextQuery(title,target,description));
-}
-
-void TextDialog::queryMolecule(const char* title, molecule **target, string description) {
-  registerQuery(new MoleculeTextQuery(title,target,description));
-}
-
-void TextDialog::queryVector(const char* title, Vector *target,const double *const cellSize, bool check, string description) {
-  registerQuery(new VectorTextQuery(title,target,cellSize,check,description));
-}
-
-void TextDialog::queryBox(const char* title,double ** const cellSize, string description) {
-  registerQuery(new BoxTextQuery(title,cellSize,description));
-}
-
-void TextDialog::queryElement(const char* title, std::vector<element *> *target, string description){
-  registerQuery(new ElementTextQuery(title,target,description));
+void TextDialog::queryBoolean(const char* title, string description){
+  registerQuery(new BooleanTextQuery(title,description));
+}
+
+void TextDialog::queryInt(const char* title, string description){
+  registerQuery(new IntTextQuery(title,description));
+}
+
+void TextDialog::queryInts(const char* title, string description){
+  registerQuery(new IntsTextQuery(title,description));
+}
+
+void TextDialog::queryDouble(const char* title, string description){
+  registerQuery(new DoubleTextQuery(title,description));
+}
+
+void TextDialog::queryDoubles(const char* title, string description){
+  registerQuery(new DoublesTextQuery(title,description));
+}
+
+void TextDialog::queryString(const char* title, string description){
+  registerQuery(new StringTextQuery(title,description));
+}
+
+void TextDialog::queryStrings(const char* title, string description){
+  registerQuery(new StringsTextQuery(title,description));
+}
+
+void TextDialog::queryAtom(const char* title, string description) {
+  registerQuery(new AtomTextQuery(title,description));
+}
+
+void TextDialog::queryAtoms(const char* title, string description) {
+  registerQuery(new AtomsTextQuery(title,description));
+}
+
+void TextDialog::queryMolecule(const char* title, string description) {
+  registerQuery(new MoleculeTextQuery(title,description));
+}
+
+void TextDialog::queryMolecules(const char* title, string description) {
+  registerQuery(new MoleculesTextQuery(title,description));
+}
+
+void TextDialog::queryVector(const char* title, bool check, string description) {
+  registerQuery(new VectorTextQuery(title,check,description));
+}
+
+void TextDialog::queryVectors(const char* title, bool check, string description) {
+  registerQuery(new VectorsTextQuery(title,check,description));
+}
+
+void TextDialog::queryBox(const char* title, string description) {
+  registerQuery(new BoxTextQuery(title,description));
+}
+
+void TextDialog::queryElement(const char* title, string description){
+  registerQuery(new ElementTextQuery(title,description));
+}
+
+void TextDialog::queryElements(const char* title, string description){
+  registerQuery(new ElementsTextQuery(title,description));
 }
 
@@ -95,6 +132,6 @@
 }
 
-TextDialog::IntTextQuery::IntTextQuery(string title, int * _target, std::string _description) :
-    Dialog::IntQuery(title,_target,_description)
+TextDialog::IntTextQuery::IntTextQuery(string title, std::string _description) :
+    Dialog::IntQuery(title,_description)
 {}
 
@@ -119,6 +156,35 @@
 }
 
-TextDialog::BooleanTextQuery::BooleanTextQuery(string title, bool * _target, std::string _description) :
-    Dialog::BooleanQuery(title,_target,_description)
+TextDialog::IntsTextQuery::IntsTextQuery(string title, std::string _description) :
+    Dialog::IntsQuery(title,_description)
+{}
+
+TextDialog::IntsTextQuery::~IntsTextQuery() {}
+
+bool TextDialog::IntsTextQuery::handle() {
+  Log() << Verbose(0) << getTitle();
+  std::string line;
+  getline(cin,line);
+  // dissect by " "
+  string::iterator olditer = line.begin();
+  for(string::iterator iter = line.begin(); iter != line.end(); ++iter) {
+    if (*iter == ' ') {
+      std::istringstream stream(string(iter, olditer));
+      stream >> temp;
+      tmp.push_back(temp);
+      olditer = iter;
+    }
+  }
+  if (olditer != line.begin()) { // insert last part also
+    std::istringstream stream(string(olditer, line.end()));
+    stream >> temp;
+    tmp.push_back(temp);
+  }
+
+  return true;
+}
+
+TextDialog::BooleanTextQuery::BooleanTextQuery(string title, std::string _description) :
+    Dialog::BooleanQuery(title,_description)
 {}
 
@@ -148,6 +214,6 @@
 }
 
-TextDialog::StringTextQuery::StringTextQuery(string title,string *_target, std::string _description) :
-    Dialog::StringQuery(title,_target,_description)
+TextDialog::StringTextQuery::StringTextQuery(string title, std::string _description) :
+    Dialog::StringQuery(title,_description)
 {}
 
@@ -160,6 +226,6 @@
 }
 
-TextDialog::StringsTextQuery::StringsTextQuery(string title,vector<string> *_target, std::string _description) :
-    Dialog::StringsQuery(title,_target,_description)
+TextDialog::StringsTextQuery::StringsTextQuery(string title, std::string _description) :
+    Dialog::StringsQuery(title,_description)
 {}
 
@@ -169,5 +235,5 @@
   Log() << Verbose(0) << getTitle();
   getline(cin,temp);
-  // dissect by ","
+  // dissect by " "
   string::iterator olditer = temp.begin();
   for(string::iterator iter = temp.begin(); iter != temp.end(); ++iter) {
@@ -183,6 +249,6 @@
 }
 
-TextDialog::DoubleTextQuery::DoubleTextQuery(string title,double *_target, std::string _description) :
-    Dialog::DoubleQuery(title,_target,_description)
+TextDialog::DoubleTextQuery::DoubleTextQuery(string title, std::string _description) :
+    Dialog::DoubleQuery(title,_description)
 {}
 
@@ -206,6 +272,36 @@
 }
 
-TextDialog::AtomTextQuery::AtomTextQuery(string title, atom **_target, std::string _description) :
-    Dialog::AtomQuery(title,_target,_description)
+
+TextDialog::DoublesTextQuery::DoublesTextQuery(string title, std::string _description) :
+    Dialog::DoublesQuery(title,_description)
+{}
+
+TextDialog::DoublesTextQuery::~DoublesTextQuery() {}
+
+bool TextDialog::DoublesTextQuery::handle() {
+  Log() << Verbose(0) << getTitle();
+  std::string line;
+  getline(cin,line);
+  // dissect by " "
+  string::iterator olditer = line.begin();
+  for(string::iterator iter = line.begin(); iter != line.end(); ++iter) {
+    if (*iter == ' ') {
+      std::istringstream stream(string(iter, olditer));
+      stream >> temp;
+      tmp.push_back(temp);
+      olditer = iter;
+    }
+  }
+  if (olditer != line.begin()) { // insert last part also
+    std::istringstream stream(string(olditer, line.end()));
+    stream >> temp;
+    tmp.push_back(temp);
+  }
+
+  return true;
+}
+
+TextDialog::AtomTextQuery::AtomTextQuery(string title, std::string _description) :
+    Dialog::AtomQuery(title,_description)
 {}
 
@@ -213,5 +309,5 @@
 
 bool TextDialog::AtomTextQuery::handle() {
-  int idxOfAtom=0;
+  int idxOfAtom=-1;
   bool badInput = false;
   do{
@@ -229,5 +325,5 @@
     tmp = World::getInstance().getAtom(AtomById(idxOfAtom));
     if(!tmp && idxOfAtom!=-1){
-      Log() << Verbose(0) << "Invalid Atom Index" << endl;
+      Log() << Verbose(0) << "Invalid Atom Index" << idxOfAtom << endl;
       badInput = true;
     }
@@ -238,6 +334,46 @@
 }
 
-TextDialog::MoleculeTextQuery::MoleculeTextQuery(string title, molecule **_target, std::string _description) :
-    Dialog::MoleculeQuery(title,_target,_description)
+
+TextDialog::AtomsTextQuery::AtomsTextQuery(string title, std::string _description) :
+    Dialog::AtomsQuery(title,_description)
+{}
+
+TextDialog::AtomsTextQuery::~AtomsTextQuery() {}
+
+bool TextDialog::AtomsTextQuery::handle() {
+  int idxOfAtom=-1;
+  Log() << Verbose(0) << getTitle();
+  std::string line;
+  getline(cin,line);
+  // dissect by " "
+  string::iterator olditer = line.begin();
+  for(string::iterator iter = line.begin(); iter != line.end(); ++iter) {
+    if (*iter == ' ') {
+      std::istringstream stream(string(iter, olditer));
+      stream >> idxOfAtom;
+      temp = World::getInstance().getAtom(AtomById(idxOfAtom));
+      if(!temp && idxOfAtom!=-1){
+        Log() << Verbose(0) << "Invalid Atom Index" << idxOfAtom << endl;
+        break;
+      }
+      tmp.push_back(temp);
+      olditer = iter;
+    }
+  }
+  if (olditer != line.begin()) { // insert last part also
+    std::istringstream stream(string(olditer, line.end()));
+    stream >> idxOfAtom;
+    temp = World::getInstance().getAtom(AtomById(idxOfAtom));
+    if(!temp && idxOfAtom!=-1) {
+      Log() << Verbose(0) << "Invalid Atom Index" << idxOfAtom << endl;
+      tmp.push_back(temp);
+    }
+  }
+
+  return (idxOfAtom!=-1);
+}
+
+TextDialog::MoleculeTextQuery::MoleculeTextQuery(string title, std::string _description) :
+    Dialog::MoleculeQuery(title,_description)
 {}
 
@@ -270,6 +406,46 @@
 }
 
-TextDialog::VectorTextQuery::VectorTextQuery(std::string title, Vector *_target, const double *const _cellSize, bool _check, std::string _description) :
-    Dialog::VectorQuery(title,_target,_cellSize,_check,_description)
+
+TextDialog::MoleculesTextQuery::MoleculesTextQuery(string title, std::string _description) :
+    Dialog::MoleculesQuery(title,_description)
+{}
+
+TextDialog::MoleculesTextQuery::~MoleculesTextQuery() {}
+
+bool TextDialog::MoleculesTextQuery::handle() {
+  int idxOfMol=-1;
+  Log() << Verbose(0) << getTitle();
+  std::string line;
+  getline(cin,line);
+  // dissect by " "
+  string::iterator olditer = line.begin();
+  for(string::iterator iter = line.begin(); iter != line.end(); ++iter) {
+    if (*iter == ' ') {
+      std::istringstream stream(string(iter, olditer));
+      stream >> idxOfMol;
+      temp = World::getInstance().getMolecule(MoleculeById(idxOfMol));
+      if(!temp && idxOfMol!=-1){
+        Log() << Verbose(0) << "Invalid Molecule Index" << idxOfMol << endl;
+        break;
+      }
+      tmp.push_back(temp);
+      olditer = iter;
+    }
+  }
+  if (olditer != line.begin()) { // insert last part also
+    std::istringstream stream(string(olditer, line.end()));
+    stream >> idxOfMol;
+    temp = World::getInstance().getMolecule(MoleculeById(idxOfMol));
+    if(!temp && idxOfMol!=-1){
+      Log() << Verbose(0) << "Invalid Molecule Index" << idxOfMol << endl;
+      tmp.push_back(temp);
+    }
+  }
+
+  return (idxOfMol!=-1);
+}
+
+TextDialog::VectorTextQuery::VectorTextQuery(std::string title, bool _check, std::string _description) :
+    Dialog::VectorQuery(title,_check,_description)
 {}
 
@@ -278,20 +454,86 @@
 
 bool TextDialog::VectorTextQuery::handle() {
-  Log() << Verbose(0) << getTitle();
-
-  char coords[3] = {'x','y','z'};
-  int j = -1;
-  for (int i=0;i<3;i++) {
-    j += i+1;
-    do {
-      Log() << Verbose(0) << coords[i] << "[0.." << cellSize[j] << "]: ";
-      cin >> (*tmp)[i];
-    } while ((((*tmp)[i] < 0) || ((*tmp)[i] >= cellSize[j])) && (check));
-  }
-  return true;
-}
-
-TextDialog::BoxTextQuery::BoxTextQuery(std::string title, double ** const _cellSize, std::string _description) :
-    Dialog::BoxQuery(title,_cellSize,_description)
+  std::cout << getTitle();
+  const Matrix &M = World::getInstance().getDomain().getM();
+  char coords[3] = {'x', 'y', 'z'};
+  for (int i=0;i<3;i++)
+    std::cout << coords[i] << "[0.." << M.at(i,i) << ( (i!=2) ? "], " : "]: ");
+
+  std::string line;
+  getline(cin,line);
+
+  // dissect by ","
+  double coord = 0.;
+  int counter = 0;
+  string::iterator olditer = line.begin();
+  for(string::iterator iter = line.begin(); (iter != line.end()) && (counter != 3); ++iter) {
+    if (*iter == ',') {
+      std::istringstream stream(string(iter, olditer));
+      stream >> coord;
+      tmp[counter++] = coord;
+      olditer = iter;
+    }
+  }
+  if ((olditer != line.begin()) && (counter != 3)) { // insert last part also
+    std::istringstream stream(string(olditer, line.end()));
+    stream >> coord;
+    tmp[counter++] = coord;
+  }
+
+  // check vector
+  return World::getInstance().getDomain().isInside(tmp);
+}
+
+TextDialog::VectorsTextQuery::VectorsTextQuery(std::string title, bool _check, std::string _description) :
+    Dialog::VectorsQuery(title,_check,_description)
+{}
+
+TextDialog::VectorsTextQuery::~VectorsTextQuery()
+{}
+
+bool TextDialog::VectorsTextQuery::handle() {
+  std::cout << getTitle();
+  char coords[3] = {'x', 'y', 'z'};
+  const Matrix &M = World::getInstance().getDomain().getM();
+  for (int i=0;i<3;i++)
+    std::cout << coords[i] << "[0.." << M.at(i,i) << ( (i!=2) ? "], " : "]: ");
+
+  std::string line;
+  getline(cin,line);
+
+  // dissect by ","
+  double coord = 0.;
+  string::iterator olditerspace = line.begin();
+  string::iterator olditercomma = line.begin();
+  int counter = 0;
+  for(string::iterator vectoriter = line.begin(); vectoriter != line.end(); ++vectoriter) {
+    if (*vectoriter == ',')
+      counter++;
+    if ((*vectoriter == ' ') && (counter == 2)) {
+      counter = 0;
+      for(string::iterator componentiter = olditerspace; (componentiter != vectoriter) && (counter !=3); ++componentiter) {
+        if (*componentiter == ',') {
+          std::istringstream stream(string(componentiter, olditercomma));
+          stream >> coord;
+          temp[counter++] = coord;
+          olditercomma = componentiter;
+        }
+      }
+      if ((olditercomma != line.begin()) && (counter != 3)) { // insert last part also
+        std::istringstream stream(string(olditercomma, vectoriter));
+        stream >> coord;
+        temp[counter++] = coord;
+      }
+      if (World::getInstance().getDomain().isInside(temp))
+        tmp.push_back(temp);
+      olditerspace = vectoriter;
+    }
+  }
+
+  return true;
+}
+
+TextDialog::BoxTextQuery::BoxTextQuery(std::string title, std::string _description) :
+    Dialog::BoxQuery(title,_description)
 {}
 
@@ -302,14 +544,26 @@
   Log() << Verbose(0) << getTitle();
 
-  std::string coords[6] = {"xx","xy","xz", "yy", "yz", "zz"};
+  double temp[6];
+  std::string coords[6] = {"xx","yx","yy", "zx", "zy", "zz"};
   for (int i=0;i<6;i++) {
     Log() << Verbose(0) << coords[i] << ": ";
-    cin >> tmp[i];
-  }
-  return true;
-}
-
-TextDialog::ElementTextQuery::ElementTextQuery(std::string title, std::vector<element *> *_target, std::string _description) :
-    Dialog::ElementQuery(title,_target,_description)
+    cin >> temp[i];
+  }
+  Matrix M;
+  M.set(0,0, temp[0]);
+  M.set(0,1, temp[1]);
+  M.set(0,2, temp[2]);
+  M.set(1,0, temp[1]);
+  M.set(1,1, temp[3]);
+  M.set(1,2, temp[4]);
+  M.set(2,0, temp[2]);
+  M.set(2,1, temp[4]);
+  M.set(2,2, temp[5]);
+  tmp.setM(M);
+  return true;
+}
+
+TextDialog::ElementTextQuery::ElementTextQuery(std::string title, std::string _description) :
+    Dialog::ElementQuery(title,_description)
 {}
 
@@ -320,5 +574,5 @@
   bool badInput=false;
   bool aborted = false;
-  element * tmp = NULL;
+  const element * temp = NULL;
   do{
     badInput = false;
@@ -333,10 +587,8 @@
       }
       else{
-        tmp = World::getInstance().getPeriode()->FindElement(Z);
-        if(!tmp){
+        temp = World::getInstance().getPeriode()->FindElement(Z);
+        if(!temp){
           Log() << Verbose(0) << "No element with this atomic number!" << endl;
           badInput = true;
-        } else {
-          elements.push_back(tmp);
         }
       }
@@ -357,10 +609,8 @@
       }
       else{
-        tmp = World::getInstance().getPeriode()->FindElement(shorthand.c_str());
-        if(!tmp){
+        temp = World::getInstance().getPeriode()->FindElement(shorthand.c_str());
+        if(!temp){
           Log() << Verbose(0) << "No element with this shorthand!" << endl;
           badInput = true;
-        } else {
-          elements.push_back(tmp);
         }
       }
@@ -377,2 +627,53 @@
   return !aborted;
 }
+
+TextDialog::ElementsTextQuery::ElementsTextQuery(std::string title, std::string _description) :
+    Dialog::ElementsQuery(title,_description)
+{}
+
+TextDialog::ElementsTextQuery::~ElementsTextQuery()
+{}
+
+bool TextDialog::ElementsTextQuery::handle() {
+  std::string shorthand;
+  int Z=-1;
+  Log() << Verbose(0) << getTitle();
+  std::string line;
+  getline(cin,line);
+  // dissect by " "
+  string::iterator olditer = line.begin();
+  for(string::iterator iter = line.begin(); iter != line.end(); ++iter) {
+    if (*iter == ' ') {
+      std::istringstream stream(string(iter, olditer));
+      stream >> shorthand;
+      try {
+        Z = lexical_cast<int>(shorthand);
+        temp = World::getInstance().getPeriode()->FindElement(Z);
+      } catch (bad_lexical_cast) {
+        temp = World::getInstance().getPeriode()->FindElement(shorthand.c_str());
+      };
+      if(!temp && Z!=-1){
+        Log() << Verbose(0) << "Invalid Element" << shorthand << endl;
+        break;
+      }
+      tmp.push_back(temp);
+      olditer = iter;
+    }
+  }
+  if (olditer != line.begin()) { // insert last part also
+    std::istringstream stream(string(olditer, line.end()));
+    stream >> shorthand;
+    try {
+      Z = lexical_cast<int>(shorthand);
+      temp = World::getInstance().getPeriode()->FindElement(Z);
+    } catch (bad_lexical_cast) {
+      temp = World::getInstance().getPeriode()->FindElement(shorthand.c_str());
+    };
+    if(!temp && Z!=-1) {
+      Log() << Verbose(0) << "Invalid Element" << shorthand << endl;
+      tmp.push_back(temp);
+    }
+  }
+
+  return (Z!=-1);
+}
Index: src/UIElements/TextUI/TextDialog.hpp
===================================================================
--- src/UIElements/TextUI/TextDialog.hpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/UIElements/TextUI/TextDialog.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -25,14 +25,20 @@
 
   virtual void queryEmpty(const char *, std::string = "");
-  virtual void queryBoolean(const char *, bool *, std::string = "");
-  virtual void queryInt(const char *, int *, std::string = "");
-  virtual void queryString(const char*, std::string *, std::string = "");
-  virtual void queryStrings(const char*, std::vector<std::string> *, std::string = "");
-  virtual void queryDouble(const char*, double*, std::string = "");
-  virtual void queryAtom(const char*,atom**,std::string = "");
-  virtual void queryMolecule(const char*,molecule**,std::string = "");
-  virtual void queryVector(const char*,Vector *,const double * const,bool, std::string = "");
-  virtual void queryBox(const char*,double ** const, std::string = "");
-  virtual void queryElement(const char*, std::vector<element *> *, std::string = "");
+  virtual void queryBoolean(const char *, std::string = "");
+  virtual void queryInt(const char *, std::string = "");
+  virtual void queryInts(const char *, std::string = "");
+  virtual void queryString(const char*, std::string = "");
+  virtual void queryStrings(const char*, std::string = "");
+  virtual void queryDouble(const char*, std::string = "");
+  virtual void queryDoubles(const char*, std::string = "");
+  virtual void queryAtom(const char*,std::string = "");
+  virtual void queryAtoms(const char*,std::string = "");
+  virtual void queryMolecule(const char*,std::string = "");
+  virtual void queryMolecules(const char*,std::string = "");
+  virtual void queryVector(const char*,bool, std::string = "");
+  virtual void queryVectors(const char*,bool, std::string = "");
+  virtual void queryBox(const char*, std::string = "");
+  virtual void queryElement(const char*, std::string = "");
+  virtual void queryElements(const char*, std::string = "");
 
 protected:
@@ -47,5 +53,5 @@
   class BooleanTextQuery : public Dialog::BooleanQuery {
   public:
-    BooleanTextQuery(std::string title, bool *_target, std::string _description = NULL);
+    BooleanTextQuery(std::string title, std::string _description = NULL);
     virtual ~BooleanTextQuery();
     virtual bool handle();
@@ -54,6 +60,13 @@
   class IntTextQuery : public Dialog::IntQuery {
   public:
-    IntTextQuery(std::string title, int *_target, std::string _description = NULL);
+    IntTextQuery(std::string title, std::string _description = NULL);
     virtual ~IntTextQuery();
+    virtual bool handle();
+  };
+
+  class IntsTextQuery : public Dialog::IntsQuery {
+  public:
+    IntsTextQuery(std::string title, std::string _description = NULL);
+    virtual ~IntsTextQuery();
     virtual bool handle();
   };
@@ -61,6 +74,13 @@
   class DoubleTextQuery : public Dialog::DoubleQuery {
   public:
-    DoubleTextQuery(std::string title, double *_target, std::string _description = NULL);
+    DoubleTextQuery(std::string title, std::string _description = NULL);
     virtual ~DoubleTextQuery();
+    virtual bool handle();
+  };
+
+  class DoublesTextQuery : public Dialog::DoublesQuery {
+  public:
+    DoublesTextQuery(std::string title, std::string _description = NULL);
+    virtual ~DoublesTextQuery();
     virtual bool handle();
   };
@@ -68,5 +88,5 @@
   class StringTextQuery : public Dialog::StringQuery {
   public:
-    StringTextQuery(std::string title, std::string *_target, std::string _description = NULL);
+    StringTextQuery(std::string title, std::string _description = NULL);
     virtual ~StringTextQuery();
     virtual bool handle();
@@ -75,5 +95,5 @@
   class StringsTextQuery : public Dialog::StringsQuery {
   public:
-    StringsTextQuery(std::string title, std::vector<std::string> *_target, std::string _description = NULL);
+    StringsTextQuery(std::string title, std::string _description = NULL);
     virtual ~StringsTextQuery();
     virtual bool handle();
@@ -82,6 +102,13 @@
   class AtomTextQuery : public Dialog::AtomQuery {
   public:
-    AtomTextQuery(std::string title, atom **_target, std::string _description = NULL);
+    AtomTextQuery(std::string title, std::string _description = NULL);
     virtual ~AtomTextQuery();
+    virtual bool handle();
+  };
+
+  class AtomsTextQuery : public Dialog::AtomsQuery {
+  public:
+    AtomsTextQuery(std::string title, std::string _description = NULL);
+    virtual ~AtomsTextQuery();
     virtual bool handle();
   };
@@ -89,6 +116,13 @@
   class MoleculeTextQuery : public Dialog::MoleculeQuery {
   public:
-    MoleculeTextQuery(std::string title, molecule **_target, std::string _description = NULL);
+    MoleculeTextQuery(std::string title, std::string _description = NULL);
     virtual ~MoleculeTextQuery();
+    virtual bool handle();
+  };
+
+  class MoleculesTextQuery : public Dialog::MoleculesQuery {
+  public:
+    MoleculesTextQuery(std::string title, std::string _description = NULL);
+    virtual ~MoleculesTextQuery();
     virtual bool handle();
   };
@@ -96,6 +130,13 @@
   class VectorTextQuery : public Dialog::VectorQuery {
   public:
-    VectorTextQuery(std::string title,Vector *_target,const double *const _cellSize,bool _check, std::string _description = NULL);
+    VectorTextQuery(std::string title,bool _check, std::string _description = NULL);
     virtual ~VectorTextQuery();
+    virtual bool handle();
+  };
+
+  class VectorsTextQuery : public Dialog::VectorsQuery {
+  public:
+    VectorsTextQuery(std::string title,bool _check, std::string _description = NULL);
+    virtual ~VectorsTextQuery();
     virtual bool handle();
   };
@@ -103,5 +144,5 @@
   class BoxTextQuery : public Dialog::BoxQuery {
   public:
-    BoxTextQuery(std::string title,double ** const _cellSize, std::string _description = NULL);
+    BoxTextQuery(std::string title, std::string _description = NULL);
     virtual ~BoxTextQuery();
     virtual bool handle();
@@ -110,6 +151,13 @@
   class ElementTextQuery : public Dialog::ElementQuery {
   public:
-    ElementTextQuery(std::string title, std::vector<element *> *_target, std::string _description = NULL);
+    ElementTextQuery(std::string title, std::string _description = NULL);
     virtual ~ElementTextQuery();
+    virtual bool handle();
+  };
+
+  class ElementsTextQuery : public Dialog::ElementsQuery {
+  public:
+    ElementsTextQuery(std::string title, std::string _description = NULL);
+    virtual ~ElementsTextQuery();
     virtual bool handle();
   };
Index: src/UIElements/TextUI/TextStatusIndicator.cpp
===================================================================
--- src/UIElements/TextUI/TextStatusIndicator.cpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/UIElements/TextUI/TextStatusIndicator.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -5,4 +5,9 @@
  *      Author: crueger
  */
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
 
 #include "Helpers/MemDebug.hpp"
Index: src/UIElements/TextUI/TextUIFactory.cpp
===================================================================
--- src/UIElements/TextUI/TextUIFactory.cpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/UIElements/TextUI/TextUIFactory.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -5,4 +5,11 @@
  *      Author: crueger
  */
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "Helpers/MemDebug.hpp"
 
 #include "UIElements/TextUI/TextUIFactory.hpp"
Index: src/UIElements/TextUI/TextWindow.cpp
===================================================================
--- src/UIElements/TextUI/TextWindow.cpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/UIElements/TextUI/TextWindow.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -5,4 +5,9 @@
  *      Author: crueger
  */
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
 
 #include "Helpers/MemDebug.hpp"
@@ -25,9 +30,8 @@
 #include "Views/StreamStringView.hpp"
 #include "Views/MethodStringView.hpp"
-#include "Helpers/MemDebug.hpp"
 
 #include "defs.hpp"
-#include "log.hpp"
-#include "verbose.hpp"
+#include "Helpers/Log.hpp"
+#include "Helpers/Verbose.hpp"
 
 // all needed due to config::SaveAll()
Index: src/UIElements/TextUI/TextWindow.hpp
===================================================================
--- src/UIElements/TextUI/TextWindow.hpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/UIElements/TextUI/TextWindow.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -11,4 +11,5 @@
 #include "MainWindow.hpp"
 
+#include <string>
 #include <set>
 
Index: src/UIElements/UIFactory.cpp
===================================================================
--- src/UIElements/UIFactory.cpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/UIElements/UIFactory.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -5,4 +5,9 @@
  *      Author: crueger
  */
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
 
 #include "Helpers/MemDebug.hpp"
Index: src/UIElements/Views/MethodStringView.cpp
===================================================================
--- src/UIElements/Views/MethodStringView.cpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/UIElements/Views/MethodStringView.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -5,4 +5,9 @@
  *      Author: crueger
  */
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
 
 #include "Helpers/MemDebug.hpp"
@@ -13,6 +18,6 @@
 
 MethodStringView::MethodStringView(boost::function<string()> _displayMethod) :
-StringView(),
-displayMethod(_displayMethod)
+  StringView(),
+  displayMethod(_displayMethod)
 {
   // TODO Auto-generated constructor stub
Index: src/UIElements/Views/QT4/GLMoleculeView.cpp
===================================================================
--- src/UIElements/Views/QT4/GLMoleculeView.cpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/UIElements/Views/QT4/GLMoleculeView.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -6,5 +6,12 @@
  */
 
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
 #include "GLMoleculeView.hpp"
+
+#include "Helpers/MemDebug.hpp"
 
 GLMoleculeView::GLMoleculeView(QWidget *parent) :
Index: src/UIElements/Views/QT4/QTMoleculeView.cpp
===================================================================
--- src/UIElements/Views/QT4/QTMoleculeView.cpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/UIElements/Views/QT4/QTMoleculeView.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -6,9 +6,16 @@
  */
 
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
 #include "Views/QT4/QTMoleculeView.hpp"
 
 #include <iostream>
+
+#include "Helpers/MemDebug.hpp"
+
 #include "molecule.hpp"
-
 
 using namespace std;
Index: src/UIElements/Views/QT4/QTStatusBar.cpp
===================================================================
--- src/UIElements/Views/QT4/QTStatusBar.cpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/UIElements/Views/QT4/QTStatusBar.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -5,4 +5,9 @@
  *      Author: crueger
  */
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
 
 #include <sstream>
@@ -13,6 +18,9 @@
 
 #include "QTStatusBar.hpp"
+
+#include "Helpers/MemDebug.hpp"
+
 #include "World.hpp"
-#include "helpers.hpp"
+#include "Helpers/helpers.hpp"
 #include "Actions/Process.hpp"
 
@@ -21,7 +29,7 @@
   QStatusBar(_parent),
   Observer("QTStatusBar"),
-  parent(_parent),
   atomCount(World::getInstance().numAtoms()),
-  moleculeCount(World::getInstance().numMolecules())
+  moleculeCount(World::getInstance().numMolecules()),
+  parent(_parent)
 {
   World::getInstance().signOn(this);
Index: src/UIElements/Views/QT4/QTWorldView.cpp
===================================================================
--- src/UIElements/Views/QT4/QTWorldView.cpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/UIElements/Views/QT4/QTWorldView.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -6,9 +6,17 @@
  */
 
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
 #include "Views/QT4/QTWorldView.hpp"
 
 #include <iostream>
 
+#include "Helpers/MemDebug.hpp"
+
 #include "atom.hpp"
+#include "Formula.hpp"
 #include "molecule.hpp"
 
@@ -20,5 +28,5 @@
 // these attributes are skiped so far
 const int QTWorldView::COLUMNCOUNT = COLUMNTYPES_MAX;
-const char *QTWorldView::COLUMNNAMES[QTWorldView::COLUMNCOUNT]={"Name","Atoms"/*,"Formula"*/,"Center"/*,"Size"*/};
+const char *QTWorldView::COLUMNNAMES[QTWorldView::COLUMNCOUNT]={"Name","Atoms","Formula"/*,"Size"*/};
 
 QTWorldView::QTWorldView(QWidget * _parent) :
@@ -61,8 +69,5 @@
     const int index = (*iter)->IndexNr;
     QTableWidgetItem *indexWidget = new QTableWidgetItem();
-    // there probably is an easier method to convert ints to QStrings... but i didn't find it
-    stringstream idxsstr;
-    idxsstr << index;
-    indexWidget->setText(QString(idxsstr.str().c_str()));
+    indexWidget->setText(QString::number(index));
     indexWidget->setData(Qt::UserRole,QVariant(index));
     setVerticalHeaderItem(i,indexWidget);
@@ -75,17 +80,13 @@
     const int atomCount = (*iter)->getAtomCount();
     QTableWidgetItem *countWidget= new QTableWidgetItem();
-    stringstream countsstr;
-    countsstr << atomCount;
-    countWidget->setText(QString(countsstr.str().c_str()));
+    countWidget->setText(QString::number(atomCount));
     countWidget->setFlags(Qt::ItemIsSelectable | Qt::ItemIsUserCheckable | Qt::ItemIsEnabled);
     setItem(i,ATOMS,countWidget);
 
-    const Vector center = (*iter)->Center;
-    QTableWidgetItem *centerWidget = new QTableWidgetItem();
-    stringstream centersstr;
-    centersstr << center;
-    centerWidget->setText(QString(centersstr.str().c_str()));
-    setItem(i,CENTER,centerWidget);
-    centerWidget->setFlags(Qt::ItemIsSelectable | Qt::ItemIsUserCheckable | Qt::ItemIsEnabled);
+    const Formula formula = (*iter)->getFormula();
+    QTableWidgetItem *formulaWidget= new QTableWidgetItem();
+    formulaWidget->setText(QString(formula.toString().c_str()));
+    formulaWidget->setFlags(Qt::ItemIsSelectable | Qt::ItemIsUserCheckable | Qt::ItemIsEnabled);
+    setItem(i,ATOMS,formulaWidget);
 
     molSelection[i]=nameWidget->isSelected();
Index: src/UIElements/Views/QT4/QTWorldView.hpp
===================================================================
--- src/UIElements/Views/QT4/QTWorldView.hpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/UIElements/Views/QT4/QTWorldView.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -28,5 +28,5 @@
 
   static const int COLUMNCOUNT;
-  enum {NAME,ATOMS,CENTER,COLUMNTYPES_MAX} COLUMNTYPES;
+  enum {NAME,ATOMS,FORMULA,COLUMNTYPES_MAX} COLUMNTYPES;
   static const char *COLUMNNAMES[];
 
Index: src/UIElements/Views/StreamStringView.cpp
===================================================================
--- src/UIElements/Views/StreamStringView.cpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/UIElements/Views/StreamStringView.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -5,4 +5,9 @@
  *      Author: crueger
  */
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
 
 #include "Helpers/MemDebug.hpp"
@@ -16,6 +21,6 @@
 
 StreamStringView::StreamStringView(boost::function<void(ostream *)> _displayMethod) :
-StringView(),
-displayMethod(_displayMethod)
+  StringView(),
+  displayMethod(_displayMethod)
 {}
 
Index: src/UIElements/Views/StreamStringView.hpp
===================================================================
--- src/UIElements/Views/StreamStringView.hpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/UIElements/Views/StreamStringView.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -10,5 +10,5 @@
 
 #include <boost/function.hpp>
-#include <iostream>
+#include <iosfwd>
 
 #include "Views/StringView.hpp"
Index: src/UIElements/Views/StringView.cpp
===================================================================
--- src/UIElements/Views/StringView.cpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/UIElements/Views/StringView.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -5,4 +5,9 @@
  *      Author: crueger
  */
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
 
 #include "Helpers/MemDebug.hpp"
Index: src/UIElements/Views/View.cpp
===================================================================
--- src/UIElements/Views/View.cpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/UIElements/Views/View.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -5,4 +5,9 @@
  *      Author: crueger
  */
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
 
 #include "Helpers/MemDebug.hpp"
Index: c/VectorSet.cpp
===================================================================
--- src/VectorSet.cpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ 	(revision )
@@ -1,19 +1,0 @@
-/*
- * VectorSet.cpp
- *
- *  Created on: Jun 2, 2010
- *      Author: crueger
- */
-
-#include "VectorSet.hpp"
-
-VectorSet::VectorSet()
-{
-  // TODO Auto-generated constructor stub
-
-}
-
-VectorSet::~VectorSet()
-{
-  // TODO Auto-generated destructor stub
-}
Index: c/VectorSet.hpp
===================================================================
--- src/VectorSet.hpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ 	(revision )
@@ -1,54 +1,0 @@
-/*
- * VectorSet.hpp
- *
- *  Created on: Jun 2, 2010
- *      Author: crueger
- */
-
-#ifndef VECTORSET_HPP_
-#define VECTORSET_HPP_
-
-
-#include <functional>
-#include <algorithm>
-
-/**
- * A simple mixin to give any STL conforming structure fast Vector abilities
- *
- * TODO: make this work for maps
- */
-
-class Vector;
-
-// this tests, whether we actually have a Vector
-template <class V>
-struct is_vector{};
-
-template <>
-struct is_vector<Vector>{
-  typedef void wrong_type;
-};
-
-template <class Set>
-class VectorSet : public Set
-{
-  // when our set carries something besides a vector this will produce an error
-  typedef typename is_vector<typename Set::value_type>::wrong_type check_for_vector;
-public:
-  // typedefs for STL conforming structure
-  typedef typename Set::iterator iterator;
-  typedef typename Set::const_iterator const_iterator;
-
-  VectorSet(){}
-  virtual ~VectorSet(){}
-
-  /**
-   * translate all Vectors within this set by a specified amount
-   */
-  void translate(const Vector &translater){
-    // this is needed to allow template lookup
-    transform(this->begin(),this->end(),this->begin(),bind1st(plus<Vector>(),translater));
-  }
-};
-
-#endif /* VECTORSET_HPP_ */
Index: src/World.cpp
===================================================================
--- src/World.cpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/World.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -6,7 +6,14 @@
  */
 
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
 #include "Helpers/MemDebug.hpp"
 
 #include "World.hpp"
+
+#include <functional>
 
 #include "atom.hpp"
@@ -22,8 +29,15 @@
 #include "Actions/ManipulateAtomsProcess.hpp"
 #include "Helpers/Assert.hpp"
+#include "Box.hpp"
+#include "LinearAlgebra/Matrix.hpp"
+#include "defs.hpp"
 
 #include "Patterns/Singleton_impl.hpp"
+#include "Patterns/ObservedContainer_impl.hpp"
 
 using namespace std;
+
+const unsigned int MAX_POOL_FRAGMENTATION=20;
+const unsigned int MAX_FRAGMENTATION_SKIPS=100;
 
 /******************************* getter and setter ************************/
@@ -42,9 +56,9 @@
 }
 
-vector<atom*> World::getAllAtoms(AtomDescriptor descriptor){
+World::AtomComposite World::getAllAtoms(AtomDescriptor descriptor){
   return descriptor.findAll();
 }
 
-vector<atom*> World::getAllAtoms(){
+World::AtomComposite World::getAllAtoms(){
   return getAllAtoms(AllAtoms());
 }
@@ -74,6 +88,11 @@
 // system
 
-double * World::getDomain() {
-  return cell_size;
+Box& World::getDomain() {
+  return *cell_size;
+}
+
+void World::setDomain(const Matrix &mat){
+  OBSERVE;
+  *cell_size = mat;
 }
 
@@ -81,10 +100,6 @@
 {
   OBSERVE;
-  cell_size[0] = matrix[0];
-  cell_size[1] = matrix[1];
-  cell_size[2] = matrix[2];
-  cell_size[3] = matrix[3];
-  cell_size[4] = matrix[4];
-  cell_size[5] = matrix[5];
+  Matrix M = ReturnFullMatrixforSymmetric(matrix);
+  cell_size->setM(M);
 }
 
@@ -95,4 +110,5 @@
 void World::setDefaultName(std::string name)
 {
+  OBSERVE;
   defaultName = name;
 };
@@ -119,6 +135,7 @@
   molecule *mol = NULL;
   mol = NewMolecule();
-  ASSERT(!molecules.count(currMoleculeId),"currMoleculeId did not specify an unused ID");
-  mol->setId(currMoleculeId++);
+  moleculeId_t id = getNextMoleculeId();
+  ASSERT(!molecules.count(id),"proposed id did not specify an unused ID");
+  mol->setId(id);
   // store the molecule by ID
   molecules[mol->getId()] = mol;
@@ -129,4 +146,5 @@
 void World::destroyMolecule(molecule* mol){
   OBSERVE;
+  ASSERT(mol,"Molecule that was meant to be destroyed did not exist");
   destroyMolecule(mol->getId());
 }
@@ -138,11 +156,11 @@
   DeleteMolecule(mol);
   molecules.erase(id);
-}
-
-double *World::cell_size = NULL;
+  releaseMoleculeId(id);
+}
 
 atom *World::createAtom(){
   OBSERVE;
   atomId_t id = getNextAtomId();
+  ASSERT(!atoms.count(id),"proposed id did not specify an unused ID");
   atom *res = NewAtom(id);
   res->setWorld(this);
@@ -198,4 +216,25 @@
 }
 
+bool World::changeMoleculeId(moleculeId_t oldId, moleculeId_t newId, molecule* target){
+  OBSERVE;
+  // in case this call did not originate from inside the atom, we redirect it,
+  // to also let it know that it has changed
+  if(!target){
+    target = molecules[oldId];
+    ASSERT(target,"Molecule with that ID not found");
+    return target->changeId(newId);
+  }
+  else{
+    if(reserveMoleculeId(newId)){
+      molecules.erase(oldId);
+      molecules.insert(pair<moleculeId_t,molecule*>(newId,target));
+      return true;
+    }
+    else{
+      return false;
+    }
+  }
+}
+
 ManipulateAtomsProcess* World::manipulateAtoms(boost::function<void(atom*)> op,std::string name,AtomDescriptor descr){
   return new ManipulateAtomsProcess(op, descr,name,true);
@@ -221,70 +260,457 @@
 
 atomId_t World::getNextAtomId(){
-  // see if we can reuse some Id
-  if(atomIdPool.empty()){
-    return currAtomId++;
-  }
-  else{
-    // we give out the first ID from the pool
-    atomId_t id = *(atomIdPool.begin());
-    atomIdPool.erase(id);
+  // try to find an Id in the pool;
+  if(!atomIdPool.empty()){
+    atomIdPool_t::iterator iter=atomIdPool.begin();
+    atomId_t id = iter->first;
+    range<atomId_t> newRange = makeRange(id+1,iter->last);
+    // we wont use this iterator anymore, so we don't care about invalidating
+    atomIdPool.erase(iter);
+    if(newRange.first<newRange.last){
+      atomIdPool.insert(newRange);
+    }
     return id;
   }
+  // Nothing in the pool... we are out of luck
+  return currAtomId++;
 }
 
 void World::releaseAtomId(atomId_t id){
-  atomIdPool.insert(id);
-  // defragmentation of the pool
-  set<atomId_t>::reverse_iterator iter;
-  // go through all Ids in the pool that lie immediately below the border
-  while(!atomIdPool.empty() && *(atomIdPool.rbegin())==(currAtomId-1)){
-    atomIdPool.erase(--currAtomId);
-  }
+  atomIdPool.insert(makeRange(id,id+1));
+  defragAtomIdPool();
 }
 
 bool World::reserveAtomId(atomId_t id){
   if(id>=currAtomId ){
-    // add all ids between the new one and current border as available
-    for(atomId_t pos=currAtomId; pos<id; ++pos){
-      atomIdPool.insert(pos);
+    range<atomId_t> newRange = makeRange(currAtomId,id);
+    if(newRange.first<newRange.last){
+      atomIdPool.insert(newRange);
     }
     currAtomId=id+1;
+    defragAtomIdPool();
     return true;
   }
-  else if(atomIdPool.count(id)){
-    atomIdPool.erase(id);
+  // look for a range that matches the request
+  for(atomIdPool_t::iterator iter=atomIdPool.begin();iter!=atomIdPool.end();++iter){
+    if(iter->isBefore(id)){
+      // we have covered all available ranges... nothing to be found here
+      break;
+    }
+    // no need to check first, since it has to be <=id, since otherwise we would have broken out
+    if(!iter->isBeyond(id)){
+      // we found a matching range... get the id from this range
+
+      // split up this range at the point of id
+      range<atomId_t> bottomRange = makeRange(iter->first,id);
+      range<atomId_t> topRange = makeRange(id+1,iter->last);
+      // remove this range
+      atomIdPool.erase(iter);
+      if(bottomRange.first<bottomRange.last){
+        atomIdPool.insert(bottomRange);
+      }
+      if(topRange.first<topRange.last){
+        atomIdPool.insert(topRange);
+      }
+      defragAtomIdPool();
+      return true;
+    }
+  }
+  // this ID could not be reserved
+  return false;
+}
+
+void World::defragAtomIdPool(){
+  // check if the situation is bad enough to make defragging neccessary
+  if((numAtomDefragSkips<MAX_FRAGMENTATION_SKIPS) &&
+     (atomIdPool.size()<lastAtomPoolSize+MAX_POOL_FRAGMENTATION)){
+    ++numAtomDefragSkips;
+    return;
+  }
+  for(atomIdPool_t::iterator iter = atomIdPool.begin();iter!=atomIdPool.end();){
+    // see if this range is adjacent to the next one
+    atomIdPool_t::iterator next = iter;
+    next++;
+    if(next!=atomIdPool.end() && (next->first==iter->last)){
+      // merge the two ranges
+      range<atomId_t> newRange = makeRange(iter->first,next->last);
+      atomIdPool.erase(iter);
+      atomIdPool.erase(next);
+      pair<atomIdPool_t::iterator,bool> res = atomIdPool.insert(newRange);
+      ASSERT(res.second,"Id-Pool was confused");
+      iter=res.first;
+      continue;
+    }
+    ++iter;
+  }
+  if(!atomIdPool.empty()){
+    // check if the last range is at the border
+    atomIdPool_t::iterator iter = atomIdPool.end();
+    iter--;
+    if(iter->last==currAtomId){
+      currAtomId=iter->first;
+      atomIdPool.erase(iter);
+    }
+  }
+  lastAtomPoolSize=atomIdPool.size();
+  numAtomDefragSkips=0;
+}
+
+// Molecules
+
+moleculeId_t World::getNextMoleculeId(){
+  // try to find an Id in the pool;
+  if(!moleculeIdPool.empty()){
+    moleculeIdPool_t::iterator iter=moleculeIdPool.begin();
+    moleculeId_t id = iter->first;
+    range<moleculeId_t> newRange = makeRange(id+1,iter->last);
+    // we wont use this iterator anymore, so we don't care about invalidating
+    moleculeIdPool.erase(iter);
+    if(newRange.first<newRange.last){
+      moleculeIdPool.insert(newRange);
+    }
+    return id;
+  }
+  // Nothing in the pool... we are out of luck
+  return currMoleculeId++;
+}
+
+void World::releaseMoleculeId(moleculeId_t id){
+  moleculeIdPool.insert(makeRange(id,id+1));
+  defragMoleculeIdPool();
+}
+
+bool World::reserveMoleculeId(moleculeId_t id){
+  if(id>=currMoleculeId ){
+    range<moleculeId_t> newRange = makeRange(currMoleculeId,id);
+    if(newRange.first<newRange.last){
+      moleculeIdPool.insert(newRange);
+    }
+    currMoleculeId=id+1;
+    defragMoleculeIdPool();
     return true;
   }
-  else{
-    // this ID could not be reserved
-    return false;
-  }
-}
+  // look for a range that matches the request
+  for(moleculeIdPool_t::iterator iter=moleculeIdPool.begin();iter!=moleculeIdPool.end();++iter){
+    if(iter->isBefore(id)){
+      // we have coverd all available ranges... nothing to be found here
+      break;
+    }
+    // no need to check first, since it has to be <=id, since otherwise we would have broken out
+    if(!iter->isBeyond(id)){
+      // we found a matching range... get the id from this range
+
+      // split up this range at the point of id
+      range<moleculeId_t> bottomRange = makeRange(iter->first,id);
+      range<moleculeId_t> topRange = makeRange(id+1,iter->last);
+      // remove this range
+      moleculeIdPool.erase(iter);
+      if(bottomRange.first<bottomRange.last){
+        moleculeIdPool.insert(bottomRange);
+      }
+      if(topRange.first<topRange.last){
+        moleculeIdPool.insert(topRange);
+      }
+      defragMoleculeIdPool();
+      return true;
+    }
+  }
+  // this ID could not be reserved
+  return false;
+}
+
+void World::defragMoleculeIdPool(){
+  // check if the situation is bad enough to make defragging neccessary
+  if((numMoleculeDefragSkips<MAX_FRAGMENTATION_SKIPS) &&
+     (moleculeIdPool.size()<lastMoleculePoolSize+MAX_POOL_FRAGMENTATION)){
+    ++numMoleculeDefragSkips;
+    return;
+  }
+  for(moleculeIdPool_t::iterator iter = moleculeIdPool.begin();iter!=moleculeIdPool.end();){
+    // see if this range is adjacent to the next one
+    moleculeIdPool_t::iterator next = iter;
+    next++;
+    if(next!=moleculeIdPool.end() && (next->first==iter->last)){
+      // merge the two ranges
+      range<moleculeId_t> newRange = makeRange(iter->first,next->last);
+      moleculeIdPool.erase(iter);
+      moleculeIdPool.erase(next);
+      pair<moleculeIdPool_t::iterator,bool> res = moleculeIdPool.insert(newRange);
+      ASSERT(res.second,"Id-Pool was confused");
+      iter=res.first;
+      continue;
+    }
+    ++iter;
+  }
+  if(!moleculeIdPool.empty()){
+    // check if the last range is at the border
+    moleculeIdPool_t::iterator iter = moleculeIdPool.end();
+    iter--;
+    if(iter->last==currMoleculeId){
+      currMoleculeId=iter->first;
+      moleculeIdPool.erase(iter);
+    }
+  }
+  lastMoleculePoolSize=moleculeIdPool.size();
+  numMoleculeDefragSkips=0;
+}
+
+/******************************* Iterators ********************************/
+
+// external parts with observers
+
+CONSTRUCT_SELECTIVE_ITERATOR(atom*,World::AtomSet,AtomDescriptor);
+
+World::AtomIterator
+World::getAtomIter(AtomDescriptor descr){
+    return AtomIterator(descr,atoms);
+}
+
+World::AtomIterator
+World::getAtomIter(){
+    return AtomIterator(AllAtoms(),atoms);
+}
+
+World::AtomIterator
+World::atomEnd(){
+  return AtomIterator(AllAtoms(),atoms,atoms.end());
+}
+
+CONSTRUCT_SELECTIVE_ITERATOR(molecule*,World::MoleculeSet,MoleculeDescriptor);
+
+World::MoleculeIterator
+World::getMoleculeIter(MoleculeDescriptor descr){
+    return MoleculeIterator(descr,molecules);
+}
+
+World::MoleculeIterator
+World::getMoleculeIter(){
+    return MoleculeIterator(AllMolecules(),molecules);
+}
+
+World::MoleculeIterator
+World::moleculeEnd(){
+  return MoleculeIterator(AllMolecules(),molecules,molecules.end());
+}
+
+// Internal parts, without observers
+
+// Build the AtomIterator from template
+CONSTRUCT_SELECTIVE_ITERATOR(atom*,World::AtomSet::set_t,AtomDescriptor);
+
+
+World::internal_AtomIterator
+World::getAtomIter_internal(AtomDescriptor descr){
+  return internal_AtomIterator(descr,atoms.getContent());
+}
+
+World::internal_AtomIterator
+World::atomEnd_internal(){
+  return internal_AtomIterator(AllAtoms(),atoms.getContent(),atoms.end_internal());
+}
+
+// build the MoleculeIterator from template
+CONSTRUCT_SELECTIVE_ITERATOR(molecule*,World::MoleculeSet::set_t,MoleculeDescriptor);
+
+World::internal_MoleculeIterator World::getMoleculeIter_internal(MoleculeDescriptor descr){
+  return internal_MoleculeIterator(descr,molecules.getContent());
+}
+
+World::internal_MoleculeIterator World::moleculeEnd_internal(){
+  return internal_MoleculeIterator(AllMolecules(),molecules.getContent(),molecules.end_internal());
+}
+
+/************************** Selection of Atoms and molecules ******************/
+
+// Atoms
+
+void World::clearAtomSelection(){
+  selectedAtoms.clear();
+}
+
+void World::selectAtom(atom *atom){
+  ASSERT(atom,"Invalid pointer in selection of atom");
+  selectedAtoms[atom->getId()]=atom;
+}
+
+void World::selectAtom(atomId_t id){
+  ASSERT(atoms.count(id),"Atom Id selected that was not in the world");
+  selectedAtoms[id]=atoms[id];
+}
+
+void World::selectAllAtoms(AtomDescriptor descr){
+  internal_AtomIterator begin = getAtomIter_internal(descr);
+  internal_AtomIterator end = atomEnd_internal();
+  void (World::*func)(atom*) = &World::selectAtom; // needed for type resolution of overloaded function
+  for_each(begin,end,bind1st(mem_fun(func),this)); // func is select... see above
+}
+
+void World::selectAtomsOfMolecule(molecule *_mol){
+  ASSERT(_mol,"Invalid pointer to molecule in selection of Atoms of Molecule");
+  // need to make it const to get the fast iterators
+  const molecule *mol = _mol;
+  void (World::*func)(atom*) = &World::selectAtom; // needed for type resolution of overloaded function
+  for_each(mol->begin(),mol->end(),bind1st(mem_fun(func),this)); // func is select... see above
+}
+
+void World::selectAtomsOfMolecule(moleculeId_t id){
+  ASSERT(molecules.count(id),"No molecule with the given id upon Selection of atoms from molecule");
+  selectAtomsOfMolecule(molecules[id]);
+}
+
+void World::unselectAtom(atom *atom){
+  ASSERT(atom,"Invalid pointer in unselection of atom");
+  unselectAtom(atom->getId());
+}
+
+void World::unselectAtom(atomId_t id){
+  ASSERT(atoms.count(id),"Atom Id unselected that was not in the world");
+  selectedAtoms.erase(id);
+}
+
+void World::unselectAllAtoms(AtomDescriptor descr){
+  internal_AtomIterator begin = getAtomIter_internal(descr);
+  internal_AtomIterator end = atomEnd_internal();
+  void (World::*func)(atom*) = &World::unselectAtom; // needed for type resolution of overloaded function
+  for_each(begin,end,bind1st(mem_fun(func),this)); // func is unselect... see above
+}
+
+void World::unselectAtomsOfMolecule(molecule *_mol){
+  ASSERT(_mol,"Invalid pointer to molecule in selection of Atoms of Molecule");
+  // need to make it const to get the fast iterators
+  const molecule *mol = _mol;
+  void (World::*func)(atom*) = &World::unselectAtom; // needed for type resolution of overloaded function
+  for_each(mol->begin(),mol->end(),bind1st(mem_fun(func),this)); // func is unsselect... see above
+}
+
+void World::unselectAtomsOfMolecule(moleculeId_t id){
+  ASSERT(molecules.count(id),"No molecule with the given id upon Selection of atoms from molecule");
+  unselectAtomsOfMolecule(molecules[id]);
+}
+
+size_t World::countSelectedAtoms() const {
+  size_t count = 0;
+  for (AtomSet::const_iterator iter = selectedAtoms.begin(); iter != selectedAtoms.end(); ++iter)
+    count++;
+  return count;
+}
+
+bool World::isSelected(atom *atom) const {
+  return selectedAtoms.find(atom->getId()) != selectedAtoms.end();
+}
+
+const std::vector<atom *> World::getSelectedAtoms() const {
+  std::vector<atom *> returnAtoms;
+  returnAtoms.resize(countSelectedAtoms());
+  int count = 0;
+  for (AtomSet::const_iterator iter = selectedAtoms.begin(); iter != selectedAtoms.end(); ++iter)
+    returnAtoms[count++] = iter->second;
+  return returnAtoms;
+}
+
 
 // Molecules
 
-/******************************* Iterators ********************************/
-
-// Build the AtomIterator from template
-CONSTRUCT_SELECTIVE_ITERATOR(atom*,World::AtomSet,AtomDescriptor);
-
-
-World::AtomIterator World::getAtomIter(AtomDescriptor descr){
-  return AtomIterator(descr,atoms);
-}
-
-World::AtomIterator World::atomEnd(){
-  return AtomIterator(AllAtoms(),atoms,atoms.end());
-}
-
-// build the MoleculeIterator from template
-CONSTRUCT_SELECTIVE_ITERATOR(molecule*,World::MoleculeSet,MoleculeDescriptor);
-
-World::MoleculeIterator World::getMoleculeIter(MoleculeDescriptor descr){
-  return MoleculeIterator(descr,molecules);
-}
-
-World::MoleculeIterator World::moleculeEnd(){
-  return MoleculeIterator(AllMolecules(),molecules,molecules.end());
+void World::clearMoleculeSelection(){
+  selectedMolecules.clear();
+}
+
+void World::selectMolecule(molecule *mol){
+  ASSERT(mol,"Invalid pointer to molecule in selection");
+  selectedMolecules[mol->getId()]=mol;
+}
+
+void World::selectMolecule(moleculeId_t id){
+  ASSERT(molecules.count(id),"Molecule Id selected that was not in the world");
+  selectedMolecules[id]=molecules[id];
+}
+
+void World::selectAllMolecules(MoleculeDescriptor descr){
+  internal_MoleculeIterator begin = getMoleculeIter_internal(descr);
+  internal_MoleculeIterator end = moleculeEnd_internal();
+  void (World::*func)(molecule*) = &World::selectMolecule; // needed for type resolution of overloaded function
+  for_each(begin,end,bind1st(mem_fun(func),this)); // func is select... see above
+}
+
+void World::selectMoleculeOfAtom(atom *atom){
+  ASSERT(atom,"Invalid atom pointer in selection of MoleculeOfAtom");
+  molecule *mol=atom->getMolecule();
+  // the atom might not be part of a molecule
+  if(mol){
+    selectMolecule(mol);
+  }
+}
+
+void World::selectMoleculeOfAtom(atomId_t id){
+  ASSERT(atoms.count(id),"No such atom with given ID in selection of Molecules of Atom");\
+  selectMoleculeOfAtom(atoms[id]);
+}
+
+void World::unselectMolecule(molecule *mol){
+  ASSERT(mol,"invalid pointer in unselection of molecule");
+  unselectMolecule(mol->getId());
+}
+
+void World::unselectMolecule(moleculeId_t id){
+  ASSERT(molecules.count(id),"No such molecule with ID in unselection");
+  selectedMolecules.erase(id);
+}
+
+void World::unselectAllMolecules(MoleculeDescriptor descr){
+  internal_MoleculeIterator begin = getMoleculeIter_internal(descr);
+  internal_MoleculeIterator end = moleculeEnd_internal();
+  void (World::*func)(molecule*) = &World::unselectMolecule; // needed for type resolution of overloaded function
+  for_each(begin,end,bind1st(mem_fun(func),this)); // func is unselect... see above
+}
+
+void World::unselectMoleculeOfAtom(atom *atom){
+  ASSERT(atom,"Invalid atom pointer in selection of MoleculeOfAtom");
+  molecule *mol=atom->getMolecule();
+  // the atom might not be part of a molecule
+  if(mol){
+    unselectMolecule(mol);
+  }
+}
+
+void World::unselectMoleculeOfAtom(atomId_t id){
+  ASSERT(atoms.count(id),"No such atom with given ID in selection of Molecules of Atom");\
+  unselectMoleculeOfAtom(atoms[id]);
+}
+
+size_t World::countSelectedMolecules() const {
+  size_t count = 0;
+  for (MoleculeSet::const_iterator iter = selectedMolecules.begin(); iter != selectedMolecules.end(); ++iter)
+    count++;
+  return count;
+}
+
+bool World::isSelected(molecule *mol) const {
+  return selectedMolecules.find(mol->getId()) != selectedMolecules.end();
+}
+
+const std::vector<molecule *> World::getSelectedMolecules() const {
+  std::vector<molecule *> returnMolecules;
+  returnMolecules.resize(countSelectedMolecules());
+  int count = 0;
+  for (MoleculeSet::const_iterator iter = selectedMolecules.begin(); iter != selectedMolecules.end(); ++iter)
+    returnMolecules[count++] = iter->second;
+  return returnMolecules;
+}
+
+/******************* Iterators over Selection *****************************/
+World::AtomSelectionIterator World::beginAtomSelection(){
+  return selectedAtoms.begin();
+}
+
+World::AtomSelectionIterator World::endAtomSelection(){
+  return selectedAtoms.end();
+}
+
+
+World::MoleculeSelectionIterator World::beginMoleculeSelection(){
+  return selectedMolecules.begin();
+}
+
+World::MoleculeSelectionIterator World::endMoleculeSelection(){
+  return selectedMolecules.end();
 }
 
@@ -297,17 +723,20 @@
     Thermostats(new ThermoStatContainer),
     ExitFlag(0),
-    atoms(),
+    atoms(this),
+    selectedAtoms(this),
     currAtomId(0),
-    molecules(),
+    lastAtomPoolSize(0),
+    numAtomDefragSkips(0),
+    molecules(this),
+    selectedMolecules(this),
     currMoleculeId(0),
     molecules_deprecated(new MoleculeListClass(this))
 {
-  cell_size = new double[6];
-  cell_size[0] = 20.;
-  cell_size[1] = 0.;
-  cell_size[2] = 20.;
-  cell_size[3] = 0.;
-  cell_size[4] = 0.;
-  cell_size[5] = 20.;
+  cell_size = new Box;
+  Matrix domain;
+  domain.at(0,0) = 20;
+  domain.at(1,1) = 20;
+  domain.at(2,2) = 20;
+  cell_size->setM(domain);
   defaultName = "none";
   molecules_deprecated->signOn(this);
@@ -317,9 +746,6 @@
 {
   molecules_deprecated->signOff(this);
-  delete[] cell_size;
+  delete cell_size;
   delete molecules_deprecated;
-  delete periode;
-  delete configuration;
-  delete Thermostats;
   MoleculeSet::iterator molIter;
   for(molIter=molecules.begin();molIter!=molecules.end();++molIter){
@@ -332,4 +758,7 @@
   }
   atoms.clear();
+  delete periode;
+  delete configuration;
+  delete Thermostats;
 }
 
@@ -337,4 +766,8 @@
 
 CONSTRUCT_SINGLETON(World)
+
+CONSTRUCT_OBSERVEDCONTAINER(World::AtomSTLSet)
+
+CONSTRUCT_OBSERVEDCONTAINER(World::MoleculeSTLSet)
 
 /******************************* deprecated Legacy Stuff ***********************/
Index: src/World.hpp
===================================================================
--- src/World.hpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/World.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -23,4 +23,7 @@
 #include "Patterns/Cacheable.hpp"
 #include "Patterns/Singleton.hpp"
+#include "Patterns/ObservedContainer.hpp"
+#include "Helpers/Range.hpp"
+#include "AtomSet.hpp"
 
 // include config.h
@@ -34,6 +37,8 @@
 class AtomDescriptor_impl;
 template<typename T> class AtomsCalculation;
+class Box;
 class config;
 class ManipulateAtomsProcess;
+class Matrix;
 class molecule;
 class MoleculeDescriptor;
@@ -43,4 +48,5 @@
 class ThermoStatContainer;
 
+
 /****************************************** forward declarations *****************************/
 
@@ -58,4 +64,7 @@
 friend class MoleculeDescriptor_impl;
 friend class MoleculeDescriptor;
+// coupling with descriptors over selection
+friend class AtomSelectionDescriptor_impl;
+friend class MoleculeSelectionDescriptor_impl;
 
 // Actions, calculations etc associated with the World
@@ -63,8 +72,13 @@
 template<typename> friend class AtomsCalculation;
 public:
+  // some typedefs for the CONSTRUCT_... macros (no "," allows in a single parameter name)
+  typedef std::map<atomId_t,atom*> AtomSTLSet;
+  typedef std::map<moleculeId_t,molecule*> MoleculeSTLSet;
 
   // Types for Atom and Molecule structures
-  typedef std::map<atomId_t,atom*> AtomSet;
-  typedef std::map<moleculeId_t,molecule*> MoleculeSet;
+  typedef ObservedContainer< AtomSTLSet > AtomSet;
+  typedef ObservedContainer< MoleculeSTLSet > MoleculeSet;
+
+  typedef ATOMSET(std::vector) AtomComposite;
 
   /***** getter and setter *****/
@@ -89,6 +103,6 @@
    * returns a vector containing all atoms that match a given descriptor
    */
-  std::vector<atom*> getAllAtoms(AtomDescriptor descriptor);
-  std::vector<atom*> getAllAtoms();
+  AtomComposite getAllAtoms(AtomDescriptor descriptor);
+  AtomComposite getAllAtoms();
 
   /**
@@ -125,5 +139,12 @@
    * get the domain size as a symmetric matrix (6 components)
    */
-  double * getDomain();
+  Box& getDomain();
+
+  /**
+   * Set the domain size from a matrix object
+   *
+   * Matrix needs to be symmetric
+   */
+  void setDomain(const Matrix &mat);
 
   /**
@@ -201,4 +222,12 @@
 
   /**
+   * used when changing an molecule Id.
+   * Unless you are calling this method from inside an moleucle don't fiddle with the third parameter.
+   *
+   * Return value indicates wether the change could be done or not.
+   */
+  bool changeMoleculeId(moleculeId_t oldId, moleculeId_t newId, molecule* target=0);
+
+  /**
    * Produces a process that calls a function on all Atoms matching a given descriptor. The process is not
    * called at this time, so it can be passed around, stored inside menuItems etc.
@@ -207,9 +236,84 @@
   ManipulateAtomsProcess* manipulateAtoms(boost::function<void(atom*)>,std::string);
 
+  /****
+   * Iterators to use internal data structures
+   * All these iterators are observed to track changes.
+   * There is a corresponding protected section with unobserved iterators,
+   * which can be used internally when the extra speed is needed
+   */
+
+  typedef SelectiveIterator<atom*,AtomSet,AtomDescriptor>       AtomIterator;
+
+  /**
+   * returns an iterator over all Atoms matching a given descriptor.
+   * This iterator is observed, so don't keep it around unnecessary to
+   * avoid unintended blocking.
+   */
+  AtomIterator getAtomIter(AtomDescriptor descr);
+  AtomIterator getAtomIter();
+
+  AtomIterator atomEnd();
+
+  typedef SelectiveIterator<molecule*,MoleculeSet,MoleculeDescriptor>   MoleculeIterator;
+
+  /**
+   * returns an iterator over all Molecules matching a given descriptor.
+   * This iterator is observed, so don't keep it around unnecessary to
+   * avoid unintended blocking.
+   */
+  MoleculeIterator getMoleculeIter(MoleculeDescriptor descr);
+  MoleculeIterator getMoleculeIter();
+
+  MoleculeIterator moleculeEnd();
+
+  /******** Selections of molecules and Atoms *************/
+  void clearAtomSelection();
+  void selectAtom(atom*);
+  void selectAtom(atomId_t);
+  void selectAllAtoms(AtomDescriptor);
+  void selectAtomsOfMolecule(molecule*);
+  void selectAtomsOfMolecule(moleculeId_t);
+  void unselectAtom(atom*);
+  void unselectAtom(atomId_t);
+  void unselectAllAtoms(AtomDescriptor);
+  void unselectAtomsOfMolecule(molecule*);
+  void unselectAtomsOfMolecule(moleculeId_t);
+  size_t countSelectedAtoms() const;
+  bool isSelected(atom *_atom) const;
+  const std::vector<atom *> getSelectedAtoms() const;
+
+  void clearMoleculeSelection();
+  void selectMolecule(molecule*);
+  void selectMolecule(moleculeId_t);
+  void selectAllMolecules(MoleculeDescriptor);
+  void selectMoleculeOfAtom(atom*);
+  void selectMoleculeOfAtom(atomId_t);
+  void unselectMolecule(molecule*);
+  void unselectMolecule(moleculeId_t);
+  void unselectAllMolecules(MoleculeDescriptor);
+  void unselectMoleculeOfAtom(atom*);
+  void unselectMoleculeOfAtom(atomId_t);
+  size_t countSelectedMolecules() const;
+  bool isSelected(molecule *_mol) const;
+  const std::vector<molecule *> getSelectedMolecules() const;
+
+  /******************** Iterators to selections *****************/
+  typedef AtomSet::iterator AtomSelectionIterator;
+  AtomSelectionIterator beginAtomSelection();
+  AtomSelectionIterator endAtomSelection();
+
+  typedef MoleculeSet::iterator MoleculeSelectionIterator;
+  MoleculeSelectionIterator beginMoleculeSelection();
+  MoleculeSelectionIterator endMoleculeSelection();
+
 protected:
-  /**** Iterators to use internal data structures */
+  /****
+   * Iterators to use internal data structures
+   * All these iterators are unobserved for speed reasons.
+   * There is a corresponding public section to these methods,
+   * which produce observed iterators.*/
 
   // Atoms
-  typedef SelectiveIterator<atom*,AtomSet,AtomDescriptor> AtomIterator;
+  typedef SelectiveIterator<atom*,AtomSet::set_t,AtomDescriptor>        internal_AtomIterator;
 
   /**
@@ -217,5 +321,5 @@
    * used for internal purposes, like AtomProcesses and AtomCalculations.
    */
-  AtomIterator getAtomIter(AtomDescriptor descr);
+  internal_AtomIterator getAtomIter_internal(AtomDescriptor descr);
 
   /**
@@ -225,9 +329,9 @@
    * used for internal purposes, like AtomProcesses and AtomCalculations.
    */
-  AtomIterator atomEnd();
+  internal_AtomIterator atomEnd_internal();
 
   // Molecules
-
-  typedef SelectiveIterator<molecule*,MoleculeSet,MoleculeDescriptor> MoleculeIterator;
+  typedef SelectiveIterator<molecule*,MoleculeSet::set_t,MoleculeDescriptor>   internal_MoleculeIterator;
+
 
   /**
@@ -235,5 +339,5 @@
    * used for internal purposes, like MoleculeProcesses and MoleculeCalculations.
    */
-  MoleculeIterator getMoleculeIter(MoleculeDescriptor descr);
+  internal_MoleculeIterator getMoleculeIter_internal(MoleculeDescriptor descr);
 
   /**
@@ -243,5 +347,5 @@
    * used for internal purposes, like MoleculeProcesses and MoleculeCalculations.
    */
-  MoleculeIterator moleculeEnd();
+  internal_MoleculeIterator moleculeEnd_internal();
 
 
@@ -254,18 +358,44 @@
   void releaseAtomId(atomId_t);
   bool reserveAtomId(atomId_t);
+  void defragAtomIdPool();
+
+  moleculeId_t getNextMoleculeId();
+  void releaseMoleculeId(moleculeId_t);
+  bool reserveMoleculeId(moleculeId_t);
+  void defragMoleculeIdPool();
 
   periodentafel *periode;
   config *configuration;
-  static double *cell_size;
+  Box *cell_size;
   std::string defaultName;
   class ThermoStatContainer *Thermostats;
   int ExitFlag;
-public:
+private:
+
   AtomSet atoms;
-private:
-  std::set<atomId_t> atomIdPool; //<!stores the pool for all available AtomIds below currAtomId
+  AtomSet selectedAtoms;
+  typedef std::set<range<atomId_t> > atomIdPool_t;
+  /**
+   * stores the pool for all available AtomIds below currAtomId
+   *
+   * The pool contains ranges of free ids in the form [bottom,top).
+   */
+  atomIdPool_t atomIdPool;
   atomId_t currAtomId; //!< stores the next available Id for atoms
+  size_t lastAtomPoolSize; //!< size of the pool after last defrag, to skip some defrags
+  unsigned int numAtomDefragSkips;
+
   MoleculeSet molecules;
+  MoleculeSet selectedMolecules;
+  typedef std::set<range<atomId_t> > moleculeIdPool_t;
+  /**
+   * stores the pool for all available AtomIds below currAtomId
+   *
+   * The pool contains ranges of free ids in the form [bottom,top).
+   */
+  moleculeIdPool_t moleculeIdPool;
   moleculeId_t currMoleculeId;
+  size_t lastMoleculePoolSize; //!< size of the pool after last defrag, to skip some defrags
+  unsigned int numMoleculeDefragSkips;
 private:
   /**
Index: src/analysis_bonds.cpp
===================================================================
--- src/analysis_bonds.cpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/analysis_bonds.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -6,4 +6,9 @@
  */
 
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
 #include "Helpers/MemDebug.hpp"
 
@@ -12,6 +17,7 @@
 #include "bond.hpp"
 #include "element.hpp"
-#include "info.hpp"
-#include "log.hpp"
+#include "Helpers/Info.hpp"
+#include "Helpers/Verbose.hpp"
+#include "Helpers/Log.hpp"
 #include "molecule.hpp"
 
@@ -59,7 +65,7 @@
   int AtomNo = 0;
   for (molecule::const_iterator iter = mol->begin(); iter != mol->end(); ++iter) {
-    if ((*iter)->type == type1)
+    if ((*iter)->getType() == type1)
       for (BondList::const_iterator BondRunner = (*iter)->ListOfBonds.begin(); BondRunner != (*iter)->ListOfBonds.end(); BondRunner++)
-        if ((*BondRunner)->GetOtherAtom((*iter))->type == type2) {
+        if ((*BondRunner)->GetOtherAtom((*iter))->getType() == type2) {
           const double distance = (*BondRunner)->GetDistanceSquared();
           if (Min > distance)
@@ -86,11 +92,11 @@
  * \return angle between \a *first and \a *second, both relative to origin at \a *origin.
  */
-double CalculateAngle(Vector *first, Vector *central, Vector *second)
+double CalculateAngle(const Vector &first, const Vector &central, const Vector &second)
 {
   Vector OHBond;
   Vector OOBond;
 
-  OHBond = (*first) - (*central);
-  OOBond = (*second) - (*central);
+  OHBond = first - central;
+  OOBond = second - central;
   const double angle = OHBond.Angle(OOBond);
   return angle;
@@ -109,5 +115,5 @@
 
   // check angle
-  if (CalculateAngle(&Hydrogen->x, &Oxygen->x, &OtherOxygen->x) < M_PI*(30./180.)) {
+  if (CalculateAngle(Hydrogen->getPosition(), Oxygen->getPosition(), OtherOxygen->getPosition()) < M_PI*(30./180.)) {
     return true;
   } else {
@@ -137,7 +143,7 @@
         molecule::iterator Runner = (*MolRunner)->begin();
         for(;Runner!=(*MolRunner)->end();++Runner){
-          if (((*Walker)->type->Z  == 8) && ((*Runner)->type->Z  == 8)) {
+          if (((*Walker)->getType()->Z  == 8) && ((*Runner)->getType()->Z  == 8)) {
             // check distance
-            const double distance = (*Runner)->x.DistanceSquared((*Walker)->x);
+            const double distance = (*Runner)->DistanceSquared(*(*Walker));
             if ((distance > MYEPSILON) && (distance < HBRIDGEDISTANCE*HBRIDGEDISTANCE)) { // distance >0 means  different atoms
               // on other atom(Runner) we check for bond to interface element and
@@ -151,12 +157,12 @@
                 atom * const OtherAtom = (*BondRunner)->GetOtherAtom(*Runner);
                 // if hydrogen, check angle to be greater(!) than 30 degrees
-                if (OtherAtom->type->Z == 1) {
-                  const double angle = CalculateAngle(&OtherAtom->x, &(*Runner)->x, &(*Walker)->x);
+                if (OtherAtom->getType()->Z == 1) {
+                  const double angle = CalculateAngle(OtherAtom->getPosition(), (*Runner)->getPosition(), (*Walker)->getPosition());
                   OtherHydrogenFlag = OtherHydrogenFlag && (angle > M_PI*(30./180.) + MYEPSILON);
                   Otherangle += angle;
                   OtherHydrogens++;
                 }
-                InterfaceFlag = InterfaceFlag || (OtherAtom->type == InterfaceElement);
-                Interface2Flag = Interface2Flag || (OtherAtom->type == Interface2Element);
+                InterfaceFlag = InterfaceFlag || (OtherAtom->getType() == InterfaceElement);
+                Interface2Flag = Interface2Flag || (OtherAtom->getType() == Interface2Element);
               }
               DoLog(1) && (Log() << Verbose(1) << "Otherangle is " << Otherangle << " for " << OtherHydrogens << " hydrogens." << endl);
@@ -176,8 +182,8 @@
                 for (BondList::const_iterator BondRunner = (*Walker)->ListOfBonds.begin(); BondRunner != (*Walker)->ListOfBonds.end(); BondRunner++) {
                   atom * const OtherAtom = (*BondRunner)->GetOtherAtom(*Walker);
-                  if (OtherAtom->type->Z == 1) {
+                  if (OtherAtom->getType()->Z == 1) {
                     // check angle
                     if (CheckHydrogenBridgeBondAngle(*Walker, OtherAtom, *Runner)) {
-                      DoLog(1) && (Log() << Verbose(1) << (*Walker)->getName() << ", " << OtherAtom->getName() << " and " << (*Runner)->getName() << " has a hydrogen bridge bond with distance " << sqrt(distance) << " and angle " << CalculateAngle(&OtherAtom->x, &(*Walker)->x, &(*Runner)->x)*(180./M_PI) << "." << endl);
+                      DoLog(1) && (Log() << Verbose(1) << (*Walker)->getName() << ", " << OtherAtom->getName() << " and " << (*Runner)->getName() << " has a hydrogen bridge bond with distance " << sqrt(distance) << " and angle " << CalculateAngle(OtherAtom->getPosition(), (*Walker)->getPosition(), (*Runner)->getPosition())*(180./M_PI) << "." << endl);
                       count++;
                       break;
@@ -209,10 +215,10 @@
     for(;Walker!=(*MolWalker)->end();++Walker){
       atom * theAtom = *Walker;
-      if ((theAtom->type == first) || (theAtom->type == second)) {  // first element matches
+      if ((theAtom->getType() == first) || (theAtom->getType() == second)) {  // first element matches
         for (BondList::const_iterator BondRunner = theAtom->ListOfBonds.begin(); BondRunner != theAtom->ListOfBonds.end(); BondRunner++) {
           atom * const OtherAtom = (*BondRunner)->GetOtherAtom(theAtom);
-          if (((OtherAtom->type == first) || (OtherAtom->type == second)) && (theAtom->nr < OtherAtom->nr)) {
+          if (((OtherAtom->getType() == first) || (OtherAtom->getType() == second)) && (theAtom->nr < OtherAtom->nr)) {
             count++;
-            DoLog(1) && (Log() << Verbose(1) << first->name << "-" << second->name << " bond found between " << *Walker << " and " << *OtherAtom << "." << endl);
+            DoLog(1) && (Log() << Verbose(1) << *first << "-" << *second << " bond found between " << *Walker << " and " << *OtherAtom << "." << endl);
           }
         }
@@ -245,5 +251,5 @@
     for(;Walker!=(*MolWalker)->end();++Walker){
       atom *theAtom = *Walker;
-      if (theAtom->type == second) {  // first element matches
+      if (theAtom->getType() == second) {  // first element matches
         for (int i=0;i<2;i++)
           MatchFlag[i] = false;
@@ -251,5 +257,5 @@
           atom * const OtherAtom = (*BondRunner)->GetOtherAtom(theAtom);
           for (int i=0;i<2;i++)
-            if ((!MatchFlag[i]) && (OtherAtom->type == ElementArray[i])) {
+            if ((!MatchFlag[i]) && (OtherAtom->getType() == ElementArray[i])) {
               MatchFlag[i] = true;
               break;  // each bonding atom can match at most one element we are looking for
@@ -261,5 +267,5 @@
         if (result) { // check results
           count++;
-          DoLog(1) && (Log() << Verbose(1) << first->name << "-" << second->name << "-" << third->name << " bond found at " << *Walker << "." << endl);
+          DoLog(1) && (Log() << Verbose(1) << *first << "-" << *second << "-" << *third << " bond found at " << *Walker << "." << endl);
         }
       }
Index: src/analysis_bonds.hpp
===================================================================
--- src/analysis_bonds.hpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/analysis_bonds.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -20,5 +20,5 @@
 /*********************************************** defines ***********************************/
 
-#define HBRIDGEDISTANCE 3.5   //!< HBridge distance from PCCP Vol 10. 4802-4813
+const double HBRIDGEDISTANCE=3.5;   //!< HBridge distance from PCCP Vol 10. 4802-4813
 
 /****************************************** forward declarations *****************************/
Index: src/analysis_correlation.cpp
===================================================================
--- src/analysis_correlation.cpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/analysis_correlation.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -6,54 +6,63 @@
  */
 
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
 #include "Helpers/MemDebug.hpp"
 
 #include <iostream>
-
+#include <iomanip>
+
+#include "BoundaryTriangleSet.hpp"
 #include "analysis_correlation.hpp"
 #include "element.hpp"
-#include "info.hpp"
-#include "log.hpp"
+#include "Helpers/Info.hpp"
+#include "Helpers/Log.hpp"
 #include "molecule.hpp"
 #include "tesselation.hpp"
 #include "tesselationhelpers.hpp"
 #include "triangleintersectionlist.hpp"
-#include "vector.hpp"
-#include "verbose.hpp"
+#include "LinearAlgebra/Vector.hpp"
+#include "LinearAlgebra/Matrix.hpp"
+#include "Helpers/Verbose.hpp"
 #include "World.hpp"
+#include "Box.hpp"
 
 
 /** Calculates the pair correlation between given elements.
  * Note given element order is unimportant (i.e. g(Si, O) === g(O, Si))
- * \param *molecules list of molecules structure
+ * \param *molecules vector of molecules
  * \param &elements vector of elements to correlate
  * \return Map of doubles with values the pair of the two atoms.
  */
-PairCorrelationMap *PairCorrelation(MoleculeListClass * const &molecules, const std::vector<element *> &elements)
+PairCorrelationMap *PairCorrelation(std::vector<molecule *> &molecules, const std::vector<const element *> &elements)
 {
   Info FunctionInfo(__func__);
   PairCorrelationMap *outmap = NULL;
   double distance = 0.;
-  double *domain = World::getInstance().getDomain();
-
-  if (molecules->ListOfMolecules.empty()) {
+  Box &domain = World::getInstance().getDomain();
+
+  if (molecules.empty()) {
     DoeLog(1) && (eLog()<< Verbose(1) <<"No molecule given." << endl);
     return outmap;
   }
-  for (MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin(); MolWalker != molecules->ListOfMolecules.end(); MolWalker++)
+  for (std::vector<molecule *>::const_iterator MolWalker = molecules.begin(); MolWalker != molecules.end(); MolWalker++)
     (*MolWalker)->doCountAtoms();
 
   // create all possible pairs of elements
-  set <pair<element *, element *> > PairsOfElements;
+  set <pair<const element *,const element *> > PairsOfElements;
   if (elements.size() >= 2) {
-    for (vector<element *>::const_iterator type1 = elements.begin(); type1 != elements.end(); ++type1)
-      for (vector<element *>::const_iterator type2 = elements.begin(); type2 != elements.end(); ++type2)
+    for (vector<const element *>::const_iterator type1 = elements.begin(); type1 != elements.end(); ++type1)
+      for (vector<const element *>::const_iterator type2 = elements.begin(); type2 != elements.end(); ++type2)
         if (type1 != type2) {
-          PairsOfElements.insert( pair<element *, element*>(*type1,*type2) );
-          DoLog(1) && (Log() << Verbose(1) << "Creating element pair " << (*type1)->symbol << " and " << (*type2)->symbol << "." << endl);
+          PairsOfElements.insert( make_pair(*type1,*type2) );
+          DoLog(1) && (Log() << Verbose(1) << "Creating element pair " << *(*type1) << " and " << *(*type2) << "." << endl);
         }
   } else if (elements.size() == 1) { // one to all are valid
-    element *elemental = *elements.begin();
-    PairsOfElements.insert( pair<element *, element*>(elemental,(element *)NULL) );
-    PairsOfElements.insert( pair<element *, element*>((element *)NULL,elemental) );
+    const element *elemental = *elements.begin();
+    PairsOfElements.insert( pair<const element *,const element*>(elemental,0) );
+    PairsOfElements.insert( pair<const element *,const element*>(0,elemental) );
   } else { // all elements valid
     PairsOfElements.insert( pair<element *, element*>((element *)NULL, (element *)NULL) );
@@ -61,24 +70,19 @@
 
   outmap = new PairCorrelationMap;
-  for (MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin(); MolWalker != molecules->ListOfMolecules.end(); MolWalker++){
-    if ((*MolWalker)->ActiveFlag) {
-      DoeLog(2) && (eLog()<< Verbose(2) << "Current molecule is " << *MolWalker << "." << endl);
-      eLog() << Verbose(2) << "Current molecule is " << *MolWalker << "." << endl;
-      for (molecule::const_iterator iter = (*MolWalker)->begin(); iter != (*MolWalker)->end(); ++iter) {
-        DoLog(3) && (Log() << Verbose(3) << "Current atom is " << **iter << "." << endl);
-        for (MoleculeList::const_iterator MolOtherWalker = MolWalker; MolOtherWalker != molecules->ListOfMolecules.end(); MolOtherWalker++){
-          if ((*MolOtherWalker)->ActiveFlag) {
-            DoLog(2) && (Log() << Verbose(2) << "Current other molecule is " << *MolOtherWalker << "." << endl);
-            for (molecule::const_iterator runner = (*MolOtherWalker)->begin(); runner != (*MolOtherWalker)->end(); ++runner) {
-              DoLog(3) && (Log() << Verbose(3) << "Current otheratom is " << **runner << "." << endl);
-              if ((*iter)->getId() < (*runner)->getId()){
-                for (set <pair<element *, element *> >::iterator PairRunner = PairsOfElements.begin(); PairRunner != PairsOfElements.end(); ++PairRunner)
-                  if ((PairRunner->first == (**iter).type) && (PairRunner->second == (**runner).type)) {
-                    distance = (*iter)->node->PeriodicDistance(*(*runner)->node,  domain);
-                    //Log() << Verbose(1) <<"Inserting " << *(*iter) << " and " << *(*runner) << endl;
-                    outmap->insert ( pair<double, pair <atom *, atom*> > (distance, pair<atom *, atom*> ((*iter), (*runner)) ) );
-                  }
+  for (std::vector<molecule *>::const_iterator MolWalker = molecules.begin(); MolWalker != molecules.end(); MolWalker++){
+    DoLog(2) && (Log()<< Verbose(2) << "Current molecule is " << *MolWalker << "." << endl);
+    for (molecule::const_iterator iter = (*MolWalker)->begin(); iter != (*MolWalker)->end(); ++iter) {
+      DoLog(3) && (Log() << Verbose(3) << "Current atom is " << **iter << "." << endl);
+      for (std::vector<molecule *>::const_iterator MolOtherWalker = MolWalker; MolOtherWalker != molecules.end(); MolOtherWalker++){
+        DoLog(2) && (Log() << Verbose(2) << "Current other molecule is " << *MolOtherWalker << "." << endl);
+        for (molecule::const_iterator runner = (*MolOtherWalker)->begin(); runner != (*MolOtherWalker)->end(); ++runner) {
+          DoLog(3) && (Log() << Verbose(3) << "Current otheratom is " << **runner << "." << endl);
+          if ((*iter)->getId() < (*runner)->getId()){
+            for (set <pair<const element *, const element *> >::iterator PairRunner = PairsOfElements.begin(); PairRunner != PairsOfElements.end(); ++PairRunner)
+              if ((PairRunner->first == (**iter).getType()) && (PairRunner->second == (**runner).getType())) {
+                distance = domain.periodicDistance((*iter)->getPosition(),(*runner)->getPosition());
+                //Log() << Verbose(1) <<"Inserting " << *(*iter) << " and " << *(*runner) << endl;
+                outmap->insert ( pair<double, pair <atom *, atom*> > (distance, pair<atom *, atom*> ((*iter), (*runner)) ) );
               }
-            }
           }
         }
@@ -96,5 +100,5 @@
  * \return Map of doubles with values the pair of the two atoms.
  */
-PairCorrelationMap *PeriodicPairCorrelation(MoleculeListClass * const &molecules, const std::vector<element *> &elements, const int ranges[NDIM] )
+PairCorrelationMap *PeriodicPairCorrelation(std::vector<molecule *> &molecules, const std::vector<const element *> &elements, const int ranges[NDIM] )
 {
   Info FunctionInfo(__func__);
@@ -108,24 +112,24 @@
   Vector periodicOtherX;
 
-  if (molecules->ListOfMolecules.empty()) {
+  if (molecules.empty()) {
     DoeLog(1) && (eLog()<< Verbose(1) <<"No molecule given." << endl);
     return outmap;
   }
-  for (MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin(); MolWalker != molecules->ListOfMolecules.end(); MolWalker++)
+  for (std::vector<molecule *>::const_iterator MolWalker = molecules.begin(); MolWalker != molecules.end(); MolWalker++)
     (*MolWalker)->doCountAtoms();
 
   // create all possible pairs of elements
-  set <pair<element *, element *> > PairsOfElements;
+  set <pair<const element *,const element *> > PairsOfElements;
   if (elements.size() >= 2) {
-    for (vector<element *>::const_iterator type1 = elements.begin(); type1 != elements.end(); ++type1)
-      for (vector<element *>::const_iterator type2 = elements.begin(); type2 != elements.end(); ++type2)
+    for (vector<const element *>::const_iterator type1 = elements.begin(); type1 != elements.end(); ++type1)
+      for (vector<const element *>::const_iterator type2 = elements.begin(); type2 != elements.end(); ++type2)
         if (type1 != type2) {
-          PairsOfElements.insert( pair<element *, element*>(*type1,*type2) );
-          DoLog(1) && (Log() << Verbose(1) << "Creating element pair " << (*type1)->symbol << " and " << (*type2)->symbol << "." << endl);
+          PairsOfElements.insert( make_pair(*type1,*type2) );
+          DoLog(1) && (Log() << Verbose(1) << "Creating element pair " << *(*type1) << " and " << *(*type2) << "." << endl);
         }
   } else if (elements.size() == 1) { // one to all are valid
-    element *elemental = *elements.begin();
-    PairsOfElements.insert( pair<element *, element*>(elemental,(element *)NULL) );
-    PairsOfElements.insert( pair<element *, element*>((element *)NULL,elemental) );
+    const element *elemental = *elements.begin();
+    PairsOfElements.insert( pair<const element *,const element*>(elemental,0) );
+    PairsOfElements.insert( pair<const element *,const element*>(0,elemental) );
   } else { // all elements valid
     PairsOfElements.insert( pair<element *, element*>((element *)NULL, (element *)NULL) );
@@ -133,49 +137,38 @@
 
   outmap = new PairCorrelationMap;
-  for (MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin(); MolWalker != molecules->ListOfMolecules.end(); MolWalker++){
-    if ((*MolWalker)->ActiveFlag) {
-      double * FullMatrix = ReturnFullMatrixforSymmetric(World::getInstance().getDomain());
-      double * FullInverseMatrix = InverseMatrix(FullMatrix);
-      DoeLog(2) && (eLog()<< Verbose(2) << "Current molecule is " << *MolWalker << "." << endl);
-      eLog() << Verbose(2) << "Current molecule is " << *MolWalker << "." << endl;
-      for (molecule::const_iterator iter = (*MolWalker)->begin(); iter != (*MolWalker)->end(); ++iter) {
-        DoLog(3) && (Log() << Verbose(3) << "Current atom is " << **iter << "." << endl);
-        periodicX = *(*iter)->node;
-        periodicX.MatrixMultiplication(FullInverseMatrix);  // x now in [0,1)^3
-        // go through every range in xyz and get distance
-        for (n[0]=-ranges[0]; n[0] <= ranges[0]; n[0]++)
-          for (n[1]=-ranges[1]; n[1] <= ranges[1]; n[1]++)
-            for (n[2]=-ranges[2]; n[2] <= ranges[2]; n[2]++) {
-              checkX = Vector(n[0], n[1], n[2]) + periodicX;
-              checkX.MatrixMultiplication(FullMatrix);
-              for (MoleculeList::const_iterator MolOtherWalker = MolWalker; MolOtherWalker != molecules->ListOfMolecules.end(); MolOtherWalker++){
-                if ((*MolOtherWalker)->ActiveFlag) {
-                  DoLog(2) && (Log() << Verbose(2) << "Current other molecule is " << *MolOtherWalker << "." << endl);
-                  for (molecule::const_iterator runner = (*MolOtherWalker)->begin(); runner != (*MolOtherWalker)->end(); ++runner) {
-                    DoLog(3) && (Log() << Verbose(3) << "Current otheratom is " << **runner << "." << endl);
-                    if ((*iter)->getId() < (*runner)->getId()){
-                      for (set <pair<element *, element *> >::iterator PairRunner = PairsOfElements.begin(); PairRunner != PairsOfElements.end(); ++PairRunner)
-                        if ((PairRunner->first == (**iter).type) && (PairRunner->second == (**runner).type)) {
-                          periodicOtherX = *(*runner)->node;
-                          periodicOtherX.MatrixMultiplication(FullInverseMatrix);  // x now in [0,1)^3
-                          // go through every range in xyz and get distance
-                          for (Othern[0]=-ranges[0]; Othern[0] <= ranges[0]; Othern[0]++)
-                            for (Othern[1]=-ranges[1]; Othern[1] <= ranges[1]; Othern[1]++)
-                              for (Othern[2]=-ranges[2]; Othern[2] <= ranges[2]; Othern[2]++) {
-                                checkOtherX = Vector(Othern[0], Othern[1], Othern[2]) + periodicOtherX;
-                                checkOtherX.MatrixMultiplication(FullMatrix);
-                                distance = checkX.distance(checkOtherX);
-                                //Log() << Verbose(1) <<"Inserting " << *(*iter) << " and " << *(*runner) << endl;
-                                outmap->insert ( pair<double, pair <atom *, atom*> > (distance, pair<atom *, atom*> ((*iter), (*runner)) ) );
-                              }
-                        }
+  for (std::vector<molecule *>::const_iterator MolWalker = molecules.begin(); MolWalker != molecules.end(); MolWalker++){
+    Matrix FullMatrix = World::getInstance().getDomain().getM();
+    Matrix FullInverseMatrix = World::getInstance().getDomain().getMinv();
+    DoLog(2) && (Log()<< Verbose(2) << "Current molecule is " << *MolWalker << "." << endl);
+    for (molecule::const_iterator iter = (*MolWalker)->begin(); iter != (*MolWalker)->end(); ++iter) {
+      DoLog(3) && (Log() << Verbose(3) << "Current atom is " << **iter << "." << endl);
+      periodicX = FullInverseMatrix * ((*iter)->getPosition()); // x now in [0,1)^3
+      // go through every range in xyz and get distance
+      for (n[0]=-ranges[0]; n[0] <= ranges[0]; n[0]++)
+        for (n[1]=-ranges[1]; n[1] <= ranges[1]; n[1]++)
+          for (n[2]=-ranges[2]; n[2] <= ranges[2]; n[2]++) {
+            checkX = FullMatrix * (Vector(n[0], n[1], n[2]) + periodicX);
+            for (std::vector<molecule *>::const_iterator MolOtherWalker = MolWalker; MolOtherWalker != molecules.end(); MolOtherWalker++){
+                DoLog(2) && (Log() << Verbose(2) << "Current other molecule is " << *MolOtherWalker << "." << endl);
+                for (molecule::const_iterator runner = (*MolOtherWalker)->begin(); runner != (*MolOtherWalker)->end(); ++runner) {
+                  DoLog(3) && (Log() << Verbose(3) << "Current otheratom is " << **runner << "." << endl);
+                  if ((*iter)->getId() < (*runner)->getId()){
+                    for (set <pair<const element *,const element *> >::iterator PairRunner = PairsOfElements.begin(); PairRunner != PairsOfElements.end(); ++PairRunner)
+                      if ((PairRunner->first == (**iter).getType()) && (PairRunner->second == (**runner).getType())) {
+                        periodicOtherX = FullInverseMatrix * ((*runner)->getPosition()); // x now in [0,1)^3
+                        // go through every range in xyz and get distance
+                        for (Othern[0]=-ranges[0]; Othern[0] <= ranges[0]; Othern[0]++)
+                          for (Othern[1]=-ranges[1]; Othern[1] <= ranges[1]; Othern[1]++)
+                            for (Othern[2]=-ranges[2]; Othern[2] <= ranges[2]; Othern[2]++) {
+                              checkOtherX = FullMatrix * (Vector(Othern[0], Othern[1], Othern[2]) + periodicOtherX);
+                              distance = checkX.distance(checkOtherX);
+                              //Log() << Verbose(1) <<"Inserting " << *(*iter) << " and " << *(*runner) << endl;
+                              outmap->insert ( pair<double, pair <atom *, atom*> > (distance, pair<atom *, atom*> ((*iter), (*runner)) ) );
+                            }
+                      }
                     }
                   }
                 }
-              }
-            }
       }
-      delete[](FullMatrix);
-      delete[](FullInverseMatrix);
     }
   }
@@ -190,31 +183,30 @@
  * \return Map of dobules with values as pairs of atom and the vector
  */
-CorrelationToPointMap *CorrelationToPoint(MoleculeListClass * const &molecules, const std::vector<element *> &elements, const Vector *point )
+CorrelationToPointMap *CorrelationToPoint(std::vector<molecule *> &molecules, const std::vector<const element *> &elements, const Vector *point )
 {
   Info FunctionInfo(__func__);
   CorrelationToPointMap *outmap = NULL;
   double distance = 0.;
-  double *cell_size = World::getInstance().getDomain();
-
-  if (molecules->ListOfMolecules.empty()) {
+  Box &domain = World::getInstance().getDomain();
+
+  if (molecules.empty()) {
     DoLog(1) && (Log() << Verbose(1) <<"No molecule given." << endl);
     return outmap;
   }
-  for (MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin(); MolWalker != molecules->ListOfMolecules.end(); MolWalker++)
+  for (std::vector<molecule *>::const_iterator MolWalker = molecules.begin(); MolWalker != molecules.end(); MolWalker++)
     (*MolWalker)->doCountAtoms();
   outmap = new CorrelationToPointMap;
-  for (MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin(); MolWalker != molecules->ListOfMolecules.end(); MolWalker++)
-    if ((*MolWalker)->ActiveFlag) {
-      DoLog(2) && (Log() << Verbose(2) << "Current molecule is " << *MolWalker << "." << endl);
-      for (molecule::const_iterator iter = (*MolWalker)->begin(); iter != (*MolWalker)->end(); ++iter) {
-        DoLog(3) && (Log() << Verbose(3) << "Current atom is " << **iter << "." << endl);
-        for (vector<element *>::const_iterator type = elements.begin(); type != elements.end(); ++type)
-          if ((*type == NULL) || ((*iter)->type == *type)) {
-            distance = (*iter)->node->PeriodicDistance(*point, cell_size);
-            DoLog(4) && (Log() << Verbose(4) << "Current distance is " << distance << "." << endl);
-            outmap->insert ( pair<double, pair<atom *, const Vector*> >(distance, pair<atom *, const Vector*> ((*iter), point) ) );
-          }
-      }
-    }
+  for (std::vector<molecule *>::const_iterator MolWalker = molecules.begin(); MolWalker != molecules.end(); MolWalker++) {
+    DoLog(2) && (Log() << Verbose(2) << "Current molecule is " << *MolWalker << "." << endl);
+    for (molecule::const_iterator iter = (*MolWalker)->begin(); iter != (*MolWalker)->end(); ++iter) {
+      DoLog(3) && (Log() << Verbose(3) << "Current atom is " << **iter << "." << endl);
+      for (vector<const element *>::const_iterator type = elements.begin(); type != elements.end(); ++type)
+        if ((*type == NULL) || ((*iter)->getType() == *type)) {
+          distance = domain.periodicDistance((*iter)->getPosition(),*point);
+          DoLog(4) && (Log() << Verbose(4) << "Current distance is " << distance << "." << endl);
+          outmap->insert ( pair<double, pair<atom *, const Vector*> >(distance, pair<atom *, const Vector*> ((*iter), point) ) );
+        }
+    }
+  }
 
   return outmap;
@@ -228,5 +220,5 @@
  * \return Map of dobules with values as pairs of atom and the vector
  */
-CorrelationToPointMap *PeriodicCorrelationToPoint(MoleculeListClass * const &molecules, const std::vector<element *> &elements, const Vector *point, const int ranges[NDIM] )
+CorrelationToPointMap *PeriodicCorrelationToPoint(std::vector<molecule *> &molecules, const std::vector<const element *> &elements, const Vector *point, const int ranges[NDIM] )
 {
   Info FunctionInfo(__func__);
@@ -237,37 +229,32 @@
   Vector checkX;
 
-  if (molecules->ListOfMolecules.empty()) {
+  if (molecules.empty()) {
     DoLog(1) && (Log() << Verbose(1) <<"No molecule given." << endl);
     return outmap;
   }
-  for (MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin(); MolWalker != molecules->ListOfMolecules.end(); MolWalker++)
+  for (std::vector<molecule *>::const_iterator MolWalker = molecules.begin(); MolWalker != molecules.end(); MolWalker++)
     (*MolWalker)->doCountAtoms();
   outmap = new CorrelationToPointMap;
-  for (MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin(); MolWalker != molecules->ListOfMolecules.end(); MolWalker++)
-    if ((*MolWalker)->ActiveFlag) {
-      double * FullMatrix = ReturnFullMatrixforSymmetric(World::getInstance().getDomain());
-      double * FullInverseMatrix = InverseMatrix(FullMatrix);
-      DoLog(2) && (Log() << Verbose(2) << "Current molecule is " << *MolWalker << "." << endl);
-      for (molecule::const_iterator iter = (*MolWalker)->begin(); iter != (*MolWalker)->end(); ++iter) {
-        DoLog(3) && (Log() << Verbose(3) << "Current atom is " << **iter << "." << endl);
-        for (vector<element *>::const_iterator type = elements.begin(); type != elements.end(); ++type)
-          if ((*type == NULL) || ((*iter)->type == *type)) {
-            periodicX = *(*iter)->node;
-            periodicX.MatrixMultiplication(FullInverseMatrix);  // x now in [0,1)^3
-            // go through every range in xyz and get distance
-            for (n[0]=-ranges[0]; n[0] <= ranges[0]; n[0]++)
-              for (n[1]=-ranges[1]; n[1] <= ranges[1]; n[1]++)
-                for (n[2]=-ranges[2]; n[2] <= ranges[2]; n[2]++) {
-                  checkX = Vector(n[0], n[1], n[2]) + periodicX;
-                  checkX.MatrixMultiplication(FullMatrix);
-                  distance = checkX.distance(*point);
-                  DoLog(4) && (Log() << Verbose(4) << "Current distance is " << distance << "." << endl);
-                  outmap->insert ( pair<double, pair<atom *, const Vector*> >(distance, pair<atom *, const Vector*> (*iter, point) ) );
-                }
-          }
-      }
-      delete[](FullMatrix);
-      delete[](FullInverseMatrix);
-    }
+  for (std::vector<molecule *>::const_iterator MolWalker = molecules.begin(); MolWalker != molecules.end(); MolWalker++) {
+    Matrix FullMatrix = World::getInstance().getDomain().getM();
+    Matrix FullInverseMatrix = World::getInstance().getDomain().getMinv();
+    DoLog(2) && (Log() << Verbose(2) << "Current molecule is " << *MolWalker << "." << endl);
+    for (molecule::const_iterator iter = (*MolWalker)->begin(); iter != (*MolWalker)->end(); ++iter) {
+      DoLog(3) && (Log() << Verbose(3) << "Current atom is " << **iter << "." << endl);
+      for (vector<const element *>::const_iterator type = elements.begin(); type != elements.end(); ++type)
+        if ((*type == NULL) || ((*iter)->getType() == *type)) {
+          periodicX = FullInverseMatrix * ((*iter)->getPosition()); // x now in [0,1)^3
+          // go through every range in xyz and get distance
+          for (n[0]=-ranges[0]; n[0] <= ranges[0]; n[0]++)
+            for (n[1]=-ranges[1]; n[1] <= ranges[1]; n[1]++)
+              for (n[2]=-ranges[2]; n[2] <= ranges[2]; n[2]++) {
+                checkX = FullMatrix * (Vector(n[0], n[1], n[2]) + periodicX);
+                distance = checkX.distance(*point);
+                DoLog(4) && (Log() << Verbose(4) << "Current distance is " << distance << "." << endl);
+                outmap->insert ( pair<double, pair<atom *, const Vector*> >(distance, pair<atom *, const Vector*> (*iter, point) ) );
+              }
+        }
+    }
+  }
 
   return outmap;
@@ -281,5 +268,5 @@
  * \return Map of doubles with values as pairs of atom and the BoundaryTriangleSet that's closest
  */
-CorrelationToSurfaceMap *CorrelationToSurface(MoleculeListClass * const &molecules, const std::vector<element *> &elements, const Tesselation * const Surface, const LinkedCell *LC )
+CorrelationToSurfaceMap *CorrelationToSurface(std::vector<molecule *> &molecules, const std::vector<const element *> &elements, const Tesselation * const Surface, const LinkedCell *LC )
 {
   Info FunctionInfo(__func__);
@@ -289,29 +276,26 @@
   Vector centroid;
 
-  if ((Surface == NULL) || (LC == NULL) || (molecules->ListOfMolecules.empty())) {
+  if ((Surface == NULL) || (LC == NULL) || (molecules.empty())) {
     DoeLog(1) && (eLog()<< Verbose(1) <<"No Tesselation, no LinkedCell or no molecule given." << endl);
     return outmap;
   }
-  for (MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin(); MolWalker != molecules->ListOfMolecules.end(); MolWalker++)
+  for (std::vector<molecule *>::const_iterator MolWalker = molecules.begin(); MolWalker != molecules.end(); MolWalker++)
     (*MolWalker)->doCountAtoms();
   outmap = new CorrelationToSurfaceMap;
-  for (MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin(); MolWalker != molecules->ListOfMolecules.end(); MolWalker++)
-    if ((*MolWalker)->ActiveFlag) {
-      DoLog(1) && (Log() << Verbose(1) << "Current molecule is " << (*MolWalker)->name << "." << endl);
-      if ((*MolWalker)->empty())
-        DoLog(1) && (1) && (Log() << Verbose(1) << "\t is empty." << endl);
-      for (molecule::const_iterator iter = (*MolWalker)->begin(); iter != (*MolWalker)->end(); ++iter) {
-        DoLog(1) && (Log() << Verbose(1) << "\tCurrent atom is " << *(*iter) << "." << endl);
-        for (vector<element *>::const_iterator type = elements.begin(); type != elements.end(); ++type)
-          if ((*type == NULL) || ((*iter)->type == *type)) {
-            TriangleIntersectionList Intersections((*iter)->node,Surface,LC);
-            distance = Intersections.GetSmallestDistance();
-            triangle = Intersections.GetClosestTriangle();
-            outmap->insert ( pair<double, pair<atom *, BoundaryTriangleSet*> >(distance, pair<atom *, BoundaryTriangleSet*> ((*iter), triangle) ) );
-          }
-      }
-    } else {
-      DoLog(1) && (Log() << Verbose(1) << "molecule " << (*MolWalker)->name << " is not active." << endl);
-    }
+  for (std::vector<molecule *>::const_iterator MolWalker = molecules.begin(); MolWalker != molecules.end(); MolWalker++) {
+    DoLog(2) && (Log() << Verbose(2) << "Current molecule is " << (*MolWalker)->name << "." << endl);
+    if ((*MolWalker)->empty())
+      DoLog(2) && (2) && (Log() << Verbose(2) << "\t is empty." << endl);
+    for (molecule::const_iterator iter = (*MolWalker)->begin(); iter != (*MolWalker)->end(); ++iter) {
+      DoLog(3) && (Log() << Verbose(3) << "\tCurrent atom is " << *(*iter) << "." << endl);
+      for (vector<const element *>::const_iterator type = elements.begin(); type != elements.end(); ++type)
+        if ((*type == NULL) || ((*iter)->getType() == *type)) {
+          TriangleIntersectionList Intersections((*iter)->getPosition(),Surface,LC);
+          distance = Intersections.GetSmallestDistance();
+          triangle = Intersections.GetClosestTriangle();
+          outmap->insert ( pair<double, pair<atom *, BoundaryTriangleSet*> >(distance, pair<atom *, BoundaryTriangleSet*> ((*iter), triangle) ) );
+        }
+    }
+  }
 
   return outmap;
@@ -330,5 +314,5 @@
  * \return Map of doubles with values as pairs of atom and the BoundaryTriangleSet that's closest
  */
-CorrelationToSurfaceMap *PeriodicCorrelationToSurface(MoleculeListClass * const &molecules, const std::vector<element *> &elements, const Tesselation * const Surface, const LinkedCell *LC, const int ranges[NDIM] )
+CorrelationToSurfaceMap *PeriodicCorrelationToSurface(std::vector<molecule *> &molecules, const std::vector<const element *> &elements, const Tesselation * const Surface, const LinkedCell *LC, const int ranges[NDIM] )
 {
   Info FunctionInfo(__func__);
@@ -341,47 +325,42 @@
   Vector checkX;
 
-  if ((Surface == NULL) || (LC == NULL) || (molecules->ListOfMolecules.empty())) {
+  if ((Surface == NULL) || (LC == NULL) || (molecules.empty())) {
     DoLog(1) && (Log() << Verbose(1) <<"No Tesselation, no LinkedCell or no molecule given." << endl);
     return outmap;
   }
-  for (MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin(); MolWalker != molecules->ListOfMolecules.end(); MolWalker++)
+  for (std::vector<molecule *>::const_iterator MolWalker = molecules.begin(); MolWalker != molecules.end(); MolWalker++)
     (*MolWalker)->doCountAtoms();
   outmap = new CorrelationToSurfaceMap;
   double ShortestDistance = 0.;
   BoundaryTriangleSet *ShortestTriangle = NULL;
-  for (MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin(); MolWalker != molecules->ListOfMolecules.end(); MolWalker++)
-    if ((*MolWalker)->ActiveFlag) {
-      double * FullMatrix = ReturnFullMatrixforSymmetric(World::getInstance().getDomain());
-      double * FullInverseMatrix = InverseMatrix(FullMatrix);
-      DoLog(2) && (Log() << Verbose(2) << "Current molecule is " << *MolWalker << "." << endl);
-      for (molecule::const_iterator iter = (*MolWalker)->begin(); iter != (*MolWalker)->end(); ++iter) {
-        DoLog(3) && (Log() << Verbose(3) << "Current atom is " << **iter << "." << endl);
-        for (vector<element *>::const_iterator type = elements.begin(); type != elements.end(); ++type)
-          if ((*type == NULL) || ((*iter)->type == *type)) {
-            periodicX = *(*iter)->node;
-            periodicX.MatrixMultiplication(FullInverseMatrix);  // x now in [0,1)^3
-            // go through every range in xyz and get distance
-            ShortestDistance = -1.;
-            for (n[0]=-ranges[0]; n[0] <= ranges[0]; n[0]++)
-              for (n[1]=-ranges[1]; n[1] <= ranges[1]; n[1]++)
-                for (n[2]=-ranges[2]; n[2] <= ranges[2]; n[2]++) {
-                  checkX = Vector(n[0], n[1], n[2]) + periodicX;
-                  checkX.MatrixMultiplication(FullMatrix);
-                  TriangleIntersectionList Intersections(&checkX,Surface,LC);
-                  distance = Intersections.GetSmallestDistance();
-                  triangle = Intersections.GetClosestTriangle();
-                  if ((ShortestDistance == -1.) || (distance < ShortestDistance)) {
-                    ShortestDistance = distance;
-                    ShortestTriangle = triangle;
-                  }
+  for (std::vector<molecule *>::const_iterator MolWalker = molecules.begin(); MolWalker != molecules.end(); MolWalker++) {
+    Matrix FullMatrix = World::getInstance().getDomain().getM();
+    Matrix FullInverseMatrix = World::getInstance().getDomain().getMinv();
+    DoLog(2) && (Log() << Verbose(2) << "Current molecule is " << *MolWalker << "." << endl);
+    for (molecule::const_iterator iter = (*MolWalker)->begin(); iter != (*MolWalker)->end(); ++iter) {
+      DoLog(3) && (Log() << Verbose(3) << "Current atom is " << **iter << "." << endl);
+      for (vector<const element *>::const_iterator type = elements.begin(); type != elements.end(); ++type)
+        if ((*type == NULL) || ((*iter)->getType() == *type)) {
+          periodicX = FullInverseMatrix * ((*iter)->getPosition()); // x now in [0,1)^3
+          // go through every range in xyz and get distance
+          ShortestDistance = -1.;
+          for (n[0]=-ranges[0]; n[0] <= ranges[0]; n[0]++)
+            for (n[1]=-ranges[1]; n[1] <= ranges[1]; n[1]++)
+              for (n[2]=-ranges[2]; n[2] <= ranges[2]; n[2]++) {
+                checkX = FullMatrix * (Vector(n[0], n[1], n[2]) + periodicX);
+                TriangleIntersectionList Intersections(checkX,Surface,LC);
+                distance = Intersections.GetSmallestDistance();
+                triangle = Intersections.GetClosestTriangle();
+                if ((ShortestDistance == -1.) || (distance < ShortestDistance)) {
+                  ShortestDistance = distance;
+                  ShortestTriangle = triangle;
                 }
-            // insert
-            outmap->insert ( pair<double, pair<atom *, BoundaryTriangleSet*> >(ShortestDistance, pair<atom *, BoundaryTriangleSet*> (*iter, ShortestTriangle) ) );
-            //Log() << Verbose(1) << "INFO: Inserting " << Walker << " with distance " << ShortestDistance << " to " << *ShortestTriangle << "." << endl;
-          }
-      }
-      delete[](FullMatrix);
-      delete[](FullInverseMatrix);
-    }
+              }
+          // insert
+          outmap->insert ( pair<double, pair<atom *, BoundaryTriangleSet*> >(ShortestDistance, pair<atom *, BoundaryTriangleSet*> (*iter, ShortestTriangle) ) );
+          //Log() << Verbose(1) << "INFO: Inserting " << Walker << " with distance " << ShortestDistance << " to " << *ShortestTriangle << "." << endl;
+        }
+    }
+  }
 
   return outmap;
@@ -438,5 +417,5 @@
     *file << runner->first;
     for (int i=0;i<NDIM;i++)
-      *file << "\t" << setprecision(8) << (runner->second.first->node->at(i) - runner->second.second->at(i));
+      *file << "\t" << setprecision(8) << (runner->second.first->at(i) - runner->second.second->at(i));
     *file << endl;
   }
@@ -453,6 +432,8 @@
   if (!map->empty())
     for (CorrelationToSurfaceMap::const_iterator runner = map->begin(); runner != map->end(); ++runner) {
-      *file << setprecision(8) << runner->first << "\t" << *(runner->second.first) << "\t" << *(runner->second.second) << endl;
-    }
-};
-
+      *file << setprecision(8) << runner->first << "\t";
+      *file << *(runner->second.first) << "\t";
+      *file << *(runner->second.second) << endl;
+    }
+};
+
Index: src/analysis_correlation.hpp
===================================================================
--- src/analysis_correlation.hpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/analysis_correlation.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -22,8 +22,10 @@
 // STL headers
 #include <map>
+#include <vector>
 
 #include "defs.hpp"
 
 #include "atom.hpp"
+#include "Helpers/Verbose.hpp"
 
 /****************************************** forward declarations *****************************/
@@ -32,5 +34,4 @@
 class element;
 class LinkedCell;
-class MoleculeListClass;
 class Tesselation;
 class Vector;
@@ -45,10 +46,10 @@
 /********************************************** declarations *******************************/
 
-PairCorrelationMap *PairCorrelation(MoleculeListClass * const &molecules, const std::vector<element *> &elements);
-CorrelationToPointMap *CorrelationToPoint(MoleculeListClass * const &molecules, const std::vector<element *> &elements, const Vector *point );
-CorrelationToSurfaceMap *CorrelationToSurface(MoleculeListClass * const &molecules, const std::vector<element *> &elements, const Tesselation * const Surface, const LinkedCell *LC );
-PairCorrelationMap *PeriodicPairCorrelation(MoleculeListClass * const &molecules, const std::vector<element *> &elements, const int ranges[NDIM] );
-CorrelationToPointMap *PeriodicCorrelationToPoint(MoleculeListClass * const &molecules, const std::vector<element *> &elements, const Vector *point, const int ranges[NDIM] );
-CorrelationToSurfaceMap *PeriodicCorrelationToSurface(MoleculeListClass * const &molecules, const std::vector<element *> &elements, const Tesselation * const Surface, const LinkedCell *LC, const int ranges[NDIM] );
+PairCorrelationMap *PairCorrelation(std::vector<molecule *> &molecules, const std::vector<const element *> &elements);
+CorrelationToPointMap *CorrelationToPoint(std::vector<molecule *> &molecules, const std::vector<const element *> &elements, const Vector *point );
+CorrelationToSurfaceMap *CorrelationToSurface(std::vector<molecule *> &molecules, const std::vector<const element *> &elements, const Tesselation * const Surface, const LinkedCell *LC );
+PairCorrelationMap *PeriodicPairCorrelation(std::vector<molecule *> &molecules, const std::vector<const element *> &elements, const int ranges[NDIM] );
+CorrelationToPointMap *PeriodicCorrelationToPoint(std::vector<molecule *> &molecules, const std::vector<const element *> &elements, const Vector *point, const int ranges[NDIM] );
+CorrelationToSurfaceMap *PeriodicCorrelationToSurface(std::vector<molecule *> &molecules, const std::vector<const element *> &elements, const Tesselation * const Surface, const LinkedCell *LC, const int ranges[NDIM] );
 int GetBin ( const double value, const double BinWidth, const double BinStart );
 void OutputCorrelation( ofstream * const file, const BinPairMap * const map );
Index: src/analyzer.cpp
===================================================================
--- src/analyzer.cpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/analyzer.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -8,14 +8,4 @@
 //============================ INCLUDES ===========================
 
-#include "Helpers/MemDebug.hpp"
-
-#include <cstring>
-
-#include "datacreator.hpp"
-#include "helpers.hpp"
-#include "memoryallocator.hpp"
-#include "parser.hpp"
-#include "periodentafel.hpp"
-
 // include config.h
 #ifdef HAVE_CONFIG_H
@@ -23,4 +13,13 @@
 #endif
 
+#include "Helpers/MemDebug.hpp"
+
+#include <cstring>
+
+#include "datacreator.hpp"
+#include "Helpers/helpers.hpp"
+#include "parser.hpp"
+#include "periodentafel.hpp"
+#include "Helpers/Verbose.hpp"
 
 //============================== MAIN =============================
Index: src/atom.cpp
===================================================================
--- src/atom.cpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/atom.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -4,4 +4,9 @@
  *
  */
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
 
 #include "Helpers/MemDebug.hpp"
@@ -12,9 +17,12 @@
 #include "element.hpp"
 #include "lists.hpp"
-#include "memoryallocator.hpp"
 #include "parser.hpp"
-#include "vector.hpp"
+#include "LinearAlgebra/Vector.hpp"
 #include "World.hpp"
 #include "molecule.hpp"
+#include "Shapes/Shape.hpp"
+
+#include <iomanip>
+#include <iostream>
 
 /************************************* Functions for class atom *************************************/
@@ -24,19 +32,20 @@
  */
 atom::atom() :
-  father(this), sort(&nr), mol(0)
-{
-  node = &x;  // TesselPoint::x can only be referenced from here
-};
+  father(this),
+  sort(&nr),
+  mol(0)
+{};
 
 /** Constructor of class atom.
  */
 atom::atom(atom *pointer) :
-    ParticleInfo(pointer),father(pointer), sort(&nr)
-{
-  type = pointer->type;  // copy element of atom
-  x = pointer->x; // copy coordination
-  v = pointer->v; // copy velocity
+    ParticleInfo(pointer),
+    father(pointer),
+    sort(&nr)
+{
+  setType(pointer->getType());  // copy element of atom
+  setPosition(pointer->getPosition()); // copy coordination
+  AtomicVelocity = pointer->AtomicVelocity; // copy velocity
   FixedIon = pointer->FixedIon;
-  node = &x;
   mol = 0;
 };
@@ -46,9 +55,8 @@
   res->father = this;
   res->sort = &res->nr;
-  res->type = type;
-  res->x = this->x;
-  res->v = this->v;
+  res->setType(getType());
+  res->setPosition(this->getPosition());
+  res->AtomicVelocity = this->AtomicVelocity;
   res->FixedIon = FixedIon;
-  res->node = &x;
   res->mol = 0;
   World::getInstance().registerAtom(res);
@@ -107,4 +115,8 @@
 };
 
+bool atom::isFather(const atom *ptr){
+  return ptr==father;
+}
+
 /** Checks whether atom is within the given box.
  * \param offset offset to box origin
@@ -112,7 +124,7 @@
  * \return true - is inside, false - is not
  */
-bool atom::IsInParallelepiped(const Vector offset, const double *parallelepiped) const
-{
-  return (node->IsInParallelepiped(offset, parallelepiped));
+bool atom::IsInShape(const Shape& shape) const
+{
+  return shape.isInside(getPosition());
 };
 
@@ -139,8 +151,8 @@
   if (out != NULL) {
     *out << "Ion_Type" << ElementNo << "_" << AtomNo << "\t"  << fixed << setprecision(9) << showpoint;
-    *out << x[0] << "\t" << x[1] << "\t" << x[2];
+    *out << at(0) << "\t" << at(1) << "\t" << at(2);
     *out << "\t" << FixedIon;
-    if (v.Norm() > MYEPSILON)
-      *out << "\t" << scientific << setprecision(6) << v[0] << "\t" << v[1] << "\t" << v[2] << "\t";
+    if (AtomicVelocity.Norm() > MYEPSILON)
+      *out << "\t" << scientific << setprecision(6) << AtomicVelocity[0] << "\t" << AtomicVelocity[1] << "\t" << AtomicVelocity[2] << "\t";
     if (comment != NULL)
       *out << " # " << comment << endl;
@@ -159,13 +171,16 @@
   * \return true - \a *out present, false - \a *out is NULL
  */
-bool atom::OutputArrayIndexed(ostream * const out, const int *ElementNo, int *AtomNo, const char *comment) const
-{
-  AtomNo[type->Z]++;  // increment number
-  if (out != NULL) {
-    *out << "Ion_Type" << ElementNo[type->Z] << "_" << AtomNo[type->Z] << "\t"  << fixed << setprecision(9) << showpoint;
-    *out << x[0] << "\t" << x[1] << "\t" << x[2];
+bool atom::OutputArrayIndexed(ostream * const out,const enumeration<const element*> &elementLookup, int *AtomNo, const char *comment) const
+{
+  AtomNo[getType()->Z]++;  // increment number
+  if (out != NULL) {
+    const element *elemental = getType();
+    cout << "Looking for atom with element " << *elemental << endl;
+    ASSERT(elementLookup.there.find(elemental)!=elementLookup.there.end(),"Type of this atom was not in the formula upon enumeration");
+    *out << "Ion_Type" << elementLookup.there.find(elemental)->second << "_" << AtomNo[elemental->Z] << "\t"  << fixed << setprecision(9) << showpoint;
+    *out << at(0) << "\t" << at(1) << "\t" << at(2);
     *out << "\t" << FixedIon;
-    if (v.Norm() > MYEPSILON)
-      *out << "\t" << scientific << setprecision(6) << v[0] << "\t" << v[1] << "\t" << v[2] << "\t";
+    if (AtomicVelocity.Norm() > MYEPSILON)
+      *out << "\t" << scientific << setprecision(6) << AtomicVelocity[0] << "\t" << AtomicVelocity[1] << "\t" << AtomicVelocity[2] << "\t";
     if (comment != NULL)
       *out << " # " << comment << endl;
@@ -184,5 +199,5 @@
 {
   if (out != NULL) {
-    *out << type->symbol << "\t" << x[0] << "\t" << x[1] << "\t" << x[2] << "\t" << endl;
+    *out << getType()->getSymbol() << "\t" << at(0) << "\t" << at(1) << "\t" << at(2) << "\t" << endl;
     return true;
   } else
@@ -199,7 +214,7 @@
 bool atom::OutputTrajectory(ofstream * const out, const int *ElementNo, int *AtomNo, const int step) const
 {
-  AtomNo[type->Z]++;
-  if (out != NULL) {
-    *out << "Ion_Type" << ElementNo[type->Z] << "_" << AtomNo[type->Z] << "\t"  << fixed << setprecision(9) << showpoint;
+  AtomNo[getType()->Z]++;
+  if (out != NULL) {
+    *out << "Ion_Type" << ElementNo[getType()->Z] << "_" << AtomNo[getType()->Z] << "\t"  << fixed << setprecision(9) << showpoint;
     *out << Trajectory.R.at(step)[0] << "\t" << Trajectory.R.at(step)[1] << "\t" << Trajectory.R.at(step)[2];
     *out << "\t" << FixedIon;
@@ -222,5 +237,5 @@
 {
   if (out != NULL) {
-    *out << type->symbol << "\t";
+    *out << getType()->getSymbol() << "\t";
     *out << Trajectory.R.at(step)[0] << "\t";
     *out << Trajectory.R.at(step)[1] << "\t";
@@ -238,5 +253,7 @@
 void atom::OutputMPQCLine(ostream * const out, const Vector *center, int *AtomNo = NULL) const
 {
-  *out << "\t\t" << type->symbol << " [ " << x[0]-center->at(0) << "\t" << x[1]-center->at(1) << "\t" << x[2]-center->at(2) << " ]" << endl;
+  Vector recentered(getPosition());
+  recentered -= *center;
+  *out << "\t\t" << getType()->getSymbol() << " [ " << recentered[0] << "\t" << recentered[1] << "\t" << recentered[2] << " ]" << endl;
   if (AtomNo != NULL)
     *AtomNo++;
@@ -261,5 +278,5 @@
 double atom::DistanceSquaredToVector(const Vector &origin) const
 {
-  return origin.DistanceSquared(x);
+  return DistanceSquared(origin);
 };
 
@@ -270,5 +287,5 @@
 double atom::DistanceToVector(const Vector &origin) const
 {
-  return origin.distance(x);
+  return distance(origin);
 };
 
@@ -285,4 +302,17 @@
 };
 
+std::ostream & atom::operator << (std::ostream &ost) const
+{
+  ParticleInfo::operator<<(ost);
+  ost << "," << getPosition();
+  return ost;
+}
+
+std::ostream & operator << (std::ostream &ost, const atom &a)
+{
+  a.ParticleInfo::operator<<(ost);
+  ost << "," << a.getPosition();
+  return ost;
+}
 
 bool operator < (atom &a, atom &b)
@@ -319,4 +349,8 @@
 }
 
+/** Makes the atom be contained in the new molecule \a *_mol.
+ * Uses atom::removeFromMolecule() to delist from old molecule.
+ * \param *_mol pointer to new molecule
+ */
 void atom::setMolecule(molecule *_mol){
   // take this atom from the old molecule
@@ -324,8 +358,17 @@
   mol = _mol;
   if(!mol->containsAtom(this)){
-    mol->AddAtom(this);
-  }
-}
-
+    mol->insert(this);
+  }
+}
+
+/** Returns pointer to the molecule which atom belongs to.
+ * \return containing molecule
+ */
+molecule* atom::getMolecule() const {
+  return mol;
+}
+
+/** Erases the atom in atom::mol's list of atoms and sets it to zero.
+ */
 void atom::removeFromMolecule(){
   if(mol){
Index: src/atom.hpp
===================================================================
--- src/atom.hpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/atom.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -18,8 +18,9 @@
 #endif
 
-#include <iostream>
+#include <iosfwd>
 #include <list>
 #include <vector>
 
+#include "Helpers/helpers.hpp"
 #include "atom_atominfo.hpp"
 #include "atom_bondedparticle.hpp"
@@ -27,5 +28,5 @@
 #include "atom_particleinfo.hpp"
 #include "atom_trajectoryparticle.hpp"
-#include "tesselation.hpp"
+#include "TesselPoint.hpp"
 #include "types.hpp"
 
@@ -35,4 +36,5 @@
 class World;
 class molecule;
+class Shape;
 
 /********************************************** declarations *******************************/
@@ -41,5 +43,5 @@
  * Class incorporates position, type
  */
-class atom : public TesselPoint, public TrajectoryParticle, public GraphNode, public BondedParticle, public virtual ParticleInfo, public virtual AtomInfo {
+class atom : public TrajectoryParticle, public GraphNode, public BondedParticle, public TesselPoint {
   friend atom* NewAtom(atomId_t);
   friend void  DeleteAtom(atom*);
@@ -51,5 +53,5 @@
 
   bool OutputIndexed(ofstream * const out, const int ElementNo, const int AtomNo, const char *comment = NULL) const;
-  bool OutputArrayIndexed(ostream * const out, const int *ElementNo, int *AtomNo, const char *comment = NULL) const;
+  bool OutputArrayIndexed(ostream * const out,const enumeration<const element*>&, int *AtomNo, const char *comment = NULL) const;
   bool OutputXYZLine(ofstream *out) const;
   bool OutputTrajectory(ofstream * const out, const int *ElementNo, int *AtomNo, const int step) const;
@@ -60,4 +62,5 @@
 
   void EqualsFather ( const atom *ptr, const atom **res ) const;
+  bool isFather(const atom *ptr);
   void CorrectFather();
   atom *GetTrueFather();
@@ -66,5 +69,5 @@
   double DistanceToVector(const Vector &origin) const;
   double DistanceSquaredToVector(const Vector &origin) const;
-  bool IsInParallelepiped(const Vector offset, const double *parallelepiped) const;
+  bool IsInShape(const Shape&) const;
 
   // getter and setter
@@ -89,5 +92,9 @@
 
    void setMolecule(molecule*);
+   molecule* getMolecule() const;
    void removeFromMolecule();
+
+   // Output operator
+   std::ostream & operator << (std::ostream &ost) const;
 
   protected:
@@ -117,4 +124,9 @@
 
 /**
+ * Global output operator for class atom.
+ */
+std::ostream & operator << (std::ostream &ost, const atom &_atom);
+
+/**
  * internal method used by the world. Do not use if you don't know what you are doing.
  * You might get burned...
Index: src/atom_atominfo.cpp
===================================================================
--- src/atom_atominfo.cpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/atom_atominfo.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -6,13 +6,33 @@
  */
 
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
 #include "Helpers/MemDebug.hpp"
 
 #include "periodentafel.hpp"
 #include "World.hpp"
+#include "element.hpp"
 #include "atom_atominfo.hpp"
 
 /** Constructor of class AtomInfo.
  */
-AtomInfo::AtomInfo() : type(NULL) {};
+AtomInfo::AtomInfo() :
+  AtomicElement(NULL)
+{};
+
+/** Copy constructor of class AtomInfo.
+ */
+AtomInfo::AtomInfo(const AtomInfo &_atom) :
+    AtomicPosition(_atom.AtomicPosition),
+    AtomicElement(_atom.AtomicElement)
+{};
+
+AtomInfo::AtomInfo(const VectorInterface &_v) :
+    AtomicPosition(_v.getPosition()),
+    AtomicElement(NULL)
+{};
 
 /** Destructor of class AtomInfo.
@@ -22,14 +42,155 @@
 };
 
-const element *AtomInfo::getType(){
-  return type;
+const element *AtomInfo::getType() const
+{
+  return AtomicElement;
+}
+
+const double& AtomInfo::operator[](size_t i) const
+{
+  return AtomicPosition[i];
+}
+
+const double& AtomInfo::at(size_t i) const
+{
+  return AtomicPosition.at(i);
+}
+
+void AtomInfo::set(size_t i, const double value)
+{
+  AtomicPosition.at(i) = value;
+}
+
+const Vector& AtomInfo::getPosition() const
+{
+  return AtomicPosition;
 }
 
 void AtomInfo::setType(const element* _type) {
-  type = _type;
+  AtomicElement = _type;
 }
 
-void AtomInfo::setType(int Z) {
+void AtomInfo::setType(const int Z) {
   const element *elem = World::getInstance().getPeriode()->FindElement(Z);
   setType(elem);
 }
+
+void AtomInfo::setPosition(const Vector& _vector)
+{
+  AtomicPosition = _vector;
+  //cout << "AtomInfo::setPosition: " << getType()->symbol << " at " << getPosition() << endl;
+}
+
+const VectorInterface& AtomInfo::operator+=(const Vector& b)
+{
+  AtomicPosition += b;
+  return *this;
+}
+
+const VectorInterface& AtomInfo::operator-=(const Vector& b)
+{
+  AtomicPosition -= b;
+  return *this;
+}
+
+Vector const AtomInfo::operator+(const Vector& b) const
+{
+  Vector a(AtomicPosition);
+  a += b;
+  return a;
+}
+
+Vector const AtomInfo::operator-(const Vector& b) const
+{
+  Vector a(AtomicPosition);
+  a -= b;
+  return a;
+}
+
+double AtomInfo::distance(const Vector &point) const
+{
+  return AtomicPosition.distance(point);
+}
+
+double AtomInfo::DistanceSquared(const Vector &y) const
+{
+  return AtomicPosition.DistanceSquared(y);
+}
+
+double AtomInfo::distance(const VectorInterface &_atom) const
+{
+  return _atom.distance(AtomicPosition);
+}
+
+double AtomInfo::DistanceSquared(const VectorInterface &_atom) const
+{
+  return _atom.DistanceSquared(AtomicPosition);
+}
+
+VectorInterface &AtomInfo::operator=(const Vector& _vector)
+{
+  AtomicPosition = _vector;
+  return *this;
+}
+
+void AtomInfo::ScaleAll(const double *factor)
+{
+  AtomicPosition.ScaleAll(factor);
+}
+
+void AtomInfo::ScaleAll(const Vector &factor)
+{
+  AtomicPosition.ScaleAll(factor);
+}
+
+void AtomInfo::Scale(const double factor)
+{
+  AtomicPosition.Scale(factor);
+}
+
+void AtomInfo::Zero()
+{
+  AtomicPosition.Zero();
+}
+
+void AtomInfo::One(const double one)
+{
+  AtomicPosition.One(one);
+}
+
+void AtomInfo::LinearCombinationOfVectors(const Vector &x1, const Vector &x2, const Vector &x3, const double * const factors)
+{
+  AtomicPosition.LinearCombinationOfVectors(x1,x2,x3,factors);
+}
+
+const AtomInfo& operator*=(AtomInfo& a, const double m)
+{
+  a.Scale(m);
+  return a;
+}
+
+AtomInfo const operator*(const AtomInfo& a, const double m)
+{
+  AtomInfo copy(a);
+  copy *= m;
+  return copy;
+}
+
+AtomInfo const operator*(const double m, const AtomInfo& a)
+{
+  AtomInfo copy(a);
+  copy *= m;
+  return copy;
+}
+
+std::ostream & AtomInfo::operator << (std::ostream &ost) const
+{
+  return (ost << getPosition());
+}
+
+std::ostream & operator << (std::ostream &ost, const AtomInfo &a)
+{
+  ost << a;
+  return ost;
+}
+
Index: src/atom_atominfo.hpp
===================================================================
--- src/atom_atominfo.hpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/atom_atominfo.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -19,28 +19,73 @@
 #endif
 
-#include "vector.hpp"
+#include "LinearAlgebra/Vector.hpp"
+#include "LinearAlgebra/VectorInterface.hpp"
 
 /****************************************** forward declarations *****************************/
 
+class AtomInfo;
 class element;
+class Matrix;
 
 /********************************************** declarations *******************************/
 
-class AtomInfo {
+class AtomInfo : public VectorInterface {
+
 public:
-  Vector x;       //!< coordinate vector of atom, giving last position within cell
-  Vector v;       //!< velocity vector of atom, giving last velocity within cell
-  Vector F;       //!< Force vector of atom, giving last force within cell
-  const element *type;  //!< pointing to element
+  Vector AtomicVelocity;       //!< velocity vector of atom, giving last velocity within cell
+  Vector AtomicForce;       //!< Force vector of atom, giving last force within cell
 
   AtomInfo();
-  ~AtomInfo();
+  AtomInfo(const AtomInfo &_atom);
+  AtomInfo(const VectorInterface &_v);
+  virtual ~AtomInfo();
 
-  const element *getType();
+  const element *getType() const;
   void setType(const element *);
-  void setType(int);
+  void setType(const int);
+
+  ///// manipulation of the atomic position
+
+  // Accessors ussually come in pairs... and sometimes even more than that
+  const double& operator[](size_t i) const;
+  const double& at(size_t i) const;
+  void set(size_t i, const double value);
+  const Vector& getPosition() const;
+
+  // Assignment operator
+  void setPosition(const Vector& _vector);
+  class VectorInterface &operator=(const Vector& _vector);
+
+  // operators for mathematical operations
+  const VectorInterface& operator+=(const Vector& b);
+  const VectorInterface& operator-=(const Vector& b);
+  Vector const operator+(const Vector& b) const;
+  Vector const operator-(const Vector& b) const;
+
+  void Zero();
+  void One(const double one);
+  void LinearCombinationOfVectors(const Vector &x1, const Vector &x2, const Vector &x3, const double * const factors);
+
+  double distance(const Vector &point) const;
+  double DistanceSquared(const Vector &y) const;
+  double distance(const VectorInterface &_atom) const;
+  double DistanceSquared(const VectorInterface &_atom) const;
+
+  void ScaleAll(const double *factor);
+  void ScaleAll(const Vector &factor);
+  void Scale(const double factor);
+
+  std::ostream & operator << (std::ostream &ost) const;
 
 private:
+  Vector AtomicPosition;       //!< coordinate vector of atom, giving last position within cell
+  const element *AtomicElement;  //!< pointing to element
 };
 
+std::ostream & operator << (std::ostream &ost, const AtomInfo &a);
+
+const AtomInfo& operator*=(AtomInfo& a, const double m);
+AtomInfo const operator*(const AtomInfo& a, const double m);
+AtomInfo const operator*(const double m, const AtomInfo& a);
+
 #endif /* ATOM_ATOMINFO_HPP_ */
Index: src/atom_bondedparticle.cpp
===================================================================
--- src/atom_bondedparticle.cpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/atom_bondedparticle.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -6,4 +6,9 @@
  */
 
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
 #include "Helpers/MemDebug.hpp"
 
@@ -13,6 +18,6 @@
 #include "element.hpp"
 #include "lists.hpp"
-#include "log.hpp"
-#include "verbose.hpp"
+#include "Helpers/Log.hpp"
+#include "Helpers/Verbose.hpp"
 
 /** Constructor of class BondedParticle.
@@ -152,10 +157,10 @@
   NoBonds = CountBonds();
   //Log() << Verbose(3) << "Walker " << *this << ": " << (int)this->type->NoValenceOrbitals << " > " << NoBonds << "?" << endl;
-  if ((int)(type->NoValenceOrbitals) > NoBonds) { // we have a mismatch, check all bonding partners for mismatch
+  if ((int)(getType()->NoValenceOrbitals) > NoBonds) { // we have a mismatch, check all bonding partners for mismatch
     for (BondList::const_iterator Runner = ListOfBonds.begin(); Runner != ListOfBonds.end(); (++Runner)) {
       OtherWalker = (*Runner)->GetOtherAtom(this);
       OtherNoBonds = OtherWalker->CountBonds();
       //Log() << Verbose(3) << "OtherWalker " << *OtherWalker << ": " << (int)OtherWalker->type->NoValenceOrbitals << " > " << OtherNoBonds << "?" << endl;
-      if ((int)(OtherWalker->type->NoValenceOrbitals) > OtherNoBonds) { // check if possible candidate
+      if ((int)(OtherWalker->getType()->NoValenceOrbitals) > OtherNoBonds) { // check if possible candidate
         if ((CandidateBond == NULL) || (ListOfBonds.size() > OtherWalker->ListOfBonds.size())) { // pick the one with fewer number of bonds first
           CandidateBond = (*Runner);
@@ -189,2 +194,16 @@
 };
 
+std::ostream & BondedParticle::operator << (std::ostream &ost) const
+{
+  ParticleInfo::operator<<(ost);
+  ost << "," << getPosition();
+  return ost;
+}
+
+std::ostream & operator << (std::ostream &ost, const BondedParticle &a)
+{
+  a.ParticleInfo::operator<<(ost);
+  ost << "," << a.getPosition();
+  return ost;
+}
+
Index: src/atom_bondedparticle.hpp
===================================================================
--- src/atom_bondedparticle.hpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/atom_bondedparticle.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -49,8 +49,11 @@
   void OutputOrder(ofstream *file) const;
 
+  std::ostream & operator << (std::ostream &ost) const;
+
 private:
 
 };
 
+std::ostream & operator << (std::ostream &ost, const BondedParticle &a);
 
 #endif /* ATOM_BONDEDPARTICLE_HPP_ */
Index: src/atom_bondedparticleinfo.cpp
===================================================================
--- src/atom_bondedparticleinfo.cpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/atom_bondedparticleinfo.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -6,4 +6,9 @@
  */
 
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
 #include "Helpers/MemDebug.hpp"
 
@@ -12,5 +17,8 @@
 /** Constructor of class BondedParticleInfo.
  */
-BondedParticleInfo::BondedParticleInfo() : AdaptiveOrder(0), MaxOrder(false) {};
+BondedParticleInfo::BondedParticleInfo() :
+  AdaptiveOrder(0),
+  MaxOrder(false)
+{};
 
 /** Destructor of class BondedParticleInfo.
Index: src/atom_bondedparticleinfo.hpp
===================================================================
--- src/atom_bondedparticleinfo.hpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/atom_bondedparticleinfo.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -36,5 +36,5 @@
 
   BondedParticleInfo();
-  ~BondedParticleInfo();
+  virtual ~BondedParticleInfo();
 
 private:
Index: src/atom_graphnode.cpp
===================================================================
--- src/atom_graphnode.cpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/atom_graphnode.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -6,9 +6,14 @@
  */
 
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
 #include "Helpers/MemDebug.hpp"
 
 #include "atom_graphnode.hpp"
-#include "log.hpp"
-#include "verbose.hpp"
+#include "Helpers/Log.hpp"
+#include "Helpers/Verbose.hpp"
 
 /** Constructor of class GraphNode.
Index: src/atom_graphnodeinfo.cpp
===================================================================
--- src/atom_graphnodeinfo.cpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/atom_graphnodeinfo.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -6,12 +6,23 @@
  */
 
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
 #include "Helpers/MemDebug.hpp"
 
 #include "atom_graphnodeinfo.hpp"
-#include "memoryallocator.hpp"
 
 /** Constructor of class GraphNodeInfo.
  */
-GraphNodeInfo::GraphNodeInfo() : GraphNr(-1), ComponentNr(NULL), LowpointNr(-1), SeparationVertex(false), IsCyclic(false), Ancestor(NULL) {};
+GraphNodeInfo::GraphNodeInfo() :
+  GraphNr(-1),
+  ComponentNr(0),
+  LowpointNr(-1),
+  SeparationVertex(false),
+  IsCyclic(false),
+  Ancestor(0)
+{};
 
 /** Destructor of class GraphNodeInfo.
Index: src/atom_graphnodeinfo.hpp
===================================================================
--- src/atom_graphnodeinfo.hpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/atom_graphnodeinfo.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -37,5 +37,5 @@
 
   GraphNodeInfo();
-  ~GraphNodeInfo();
+  virtual ~GraphNodeInfo();
 private:
 
Index: src/atom_particleinfo.cpp
===================================================================
--- src/atom_particleinfo.cpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/atom_particleinfo.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -6,18 +6,26 @@
  */
 
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
 #include "Helpers/MemDebug.hpp"
 
 #include "atom_particleinfo.hpp"
-#include "memoryallocator.hpp"
+
+#include <iostream>
 
 /** Constructor of ParticleInfo.
  */
-ParticleInfo::ParticleInfo() : nr(-1), name("Unknown") {
-};
+ParticleInfo::ParticleInfo() :
+  nr(-1),
+  name("Unknown")
+{};
 
 ParticleInfo::ParticleInfo(ParticleInfo *pointer) :
-    nr(pointer->nr),
-    name(pointer->name)
-    {}
+  nr(pointer->nr),
+  name(pointer->name)
+{}
 
 
@@ -37,5 +45,5 @@
 ostream & operator << (ostream &ost, const ParticleInfo &a)
 {
-  ost << "[" << a.getName() << "|" << &a << "]";
+  ost << a.getName();
   return ost;
 };
@@ -43,5 +51,5 @@
 ostream & ParticleInfo::operator << (ostream &ost) const
 {
-  ost << "[" << name << "|" << this << "]";
+  ost << getName();
   return ost;
 };
Index: src/atom_particleinfo.hpp
===================================================================
--- src/atom_particleinfo.hpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/atom_particleinfo.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -18,5 +18,6 @@
 #endif
 
-#include <iostream>
+#include <iosfwd>
+#include <string>
 
 /****************************************** forward declarations *****************************/
@@ -31,5 +32,5 @@
   ParticleInfo();
   ParticleInfo(ParticleInfo*);
-  ~ParticleInfo();
+  virtual ~ParticleInfo();
 
   const std::string& getName() const;
Index: src/atom_trajectoryparticle.cpp
===================================================================
--- src/atom_trajectoryparticle.cpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/atom_trajectoryparticle.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -6,4 +6,9 @@
  */
 
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
 #include "Helpers/MemDebug.hpp"
 
@@ -12,9 +17,9 @@
 #include "config.hpp"
 #include "element.hpp"
-#include "info.hpp"
-#include "log.hpp"
+#include "Helpers/Info.hpp"
+#include "Helpers/Log.hpp"
 #include "parser.hpp"
 #include "ThermoStatContainer.hpp"
-#include "verbose.hpp"
+#include "Helpers/Verbose.hpp"
 
 /** Constructor of class TrajectoryParticle.
@@ -38,5 +43,5 @@
 {
   for (int i=NDIM;i--;)
-    *temperature += type->mass * Trajectory.U.at(step)[i]* Trajectory.U.at(step)[i];
+    *temperature += getType()->mass * Trajectory.U.at(step)[i]* Trajectory.U.at(step)[i];
 };
 
@@ -65,5 +70,5 @@
   for(int d=0;d<NDIM;d++) {
     Trajectory.U.at(Step)[d] -= CoGVelocity->at(d);
-    *ActualTemp += 0.5 * type->mass * Trajectory.U.at(Step)[d] * Trajectory.U.at(Step)[d];
+    *ActualTemp += 0.5 * getType()->mass * Trajectory.U.at(Step)[d] * Trajectory.U.at(Step)[d];
   }
 };
@@ -113,10 +118,10 @@
     Trajectory.R.at(NextStep)[d] = Trajectory.R.at(NextStep-1)[d];
     Trajectory.R.at(NextStep)[d] += configuration->Deltat*(Trajectory.U.at(NextStep-1)[d]);     // s(t) = s(0) + v * deltat + 1/2 a * deltat^2
-    Trajectory.R.at(NextStep)[d] += 0.5*configuration->Deltat*configuration->Deltat*(Trajectory.F.at(NextStep)[d]/type->mass);     // F = m * a and s =
+    Trajectory.R.at(NextStep)[d] += 0.5*configuration->Deltat*configuration->Deltat*(Trajectory.F.at(NextStep)[d]/getType()->mass);     // F = m * a and s =
   }
   // Update U
   for (int d=0; d<NDIM; d++) {
     Trajectory.U.at(NextStep)[d] = Trajectory.U.at(NextStep-1)[d];
-    Trajectory.U.at(NextStep)[d] += configuration->Deltat * (Trajectory.F.at(NextStep)[d]+Trajectory.F.at(NextStep-1)[d]/type->mass); // v = F/m * t
+    Trajectory.U.at(NextStep)[d] += configuration->Deltat * (Trajectory.F.at(NextStep)[d]+Trajectory.F.at(NextStep-1)[d]/getType()->mass); // v = F/m * t
   }
   // Update R (and F)
@@ -137,7 +142,7 @@
 void TrajectoryParticle::SumUpKineticEnergy( int Step, double *TotalMass, Vector *TotalVelocity ) const
 {
-  *TotalMass += type->mass;  // sum up total mass
+  *TotalMass += getType()->mass;  // sum up total mass
   for(int d=0;d<NDIM;d++) {
-    TotalVelocity->at(d) += Trajectory.U.at(Step)[d]*type->mass;
+    TotalVelocity->at(d) += Trajectory.U.at(Step)[d]*getType()->mass;
   }
 };
@@ -154,5 +159,5 @@
     for (int d=0; d<NDIM; d++) {
       U[d] *= ScaleTempFactor;
-      *ekin += 0.5*type->mass * U[d]*U[d];
+      *ekin += 0.5*getType()->mass * U[d]*U[d];
     }
 };
@@ -170,5 +175,5 @@
     for (int d=0; d<NDIM; d++) {
       *G += U[d] * F[d];
-      *E += U[d]*U[d]*type->mass;
+      *E += U[d]*U[d]*getType()->mass;
     }
 };
@@ -185,6 +190,6 @@
   if (FixedIon == 0) // even FixedIon moves, only not by other's forces
     for (int d=0; d<NDIM; d++) {
-      U[d] += configuration->Deltat/type->mass * ( (G_over_E) * (U[d]*type->mass) );
-      *ekin += type->mass * U[d]*U[d];
+      U[d] += configuration->Deltat/getType()->mass * ( (G_over_E) * (U[d]*getType()->mass) );
+      *ekin += getType()->mass * U[d]*U[d];
     }
 };
@@ -198,5 +203,5 @@
 void TrajectoryParticle::Thermostat_Langevin(int Step, gsl_rng * r, double *ekin, config *configuration)
 {
-  double sigma  = sqrt(configuration->Thermostats->TargetTemp/type->mass); // sigma = (k_b T)/m (Hartree/atomicmass = atomiclength/atomictime)
+  double sigma  = sqrt(configuration->Thermostats->TargetTemp/getType()->mass); // sigma = (k_b T)/m (Hartree/atomicmass = atomiclength/atomictime)
   Vector &U = Trajectory.U.at(Step);
   if (FixedIon == 0) { // even FixedIon moves, only not by other's forces
@@ -211,5 +216,5 @@
     }
     for (int d=0; d<NDIM; d++)
-      *ekin += 0.5*type->mass * U[d]*U[d];
+      *ekin += 0.5*getType()->mass * U[d]*U[d];
   }
 };
@@ -227,5 +232,5 @@
     for (int d=0; d<NDIM; d++) {
       U[d] *= sqrt(1+(configuration->Deltat/configuration->Thermostats->TempFrequency)*(ScaleTempFactor-1));
-      *ekin += 0.5*type->mass * U[d]*U[d];
+      *ekin += 0.5*getType()->mass * U[d]*U[d];
     }
   }
@@ -241,5 +246,5 @@
   if (FixedIon == 0) { // even FixedIon moves, only not by other's forces
     for (int d=0; d<NDIM; d++) {
-      *delta_alpha += U[d]*U[d]*type->mass;
+      *delta_alpha += U[d]*U[d]*getType()->mass;
     }
   }
@@ -256,7 +261,23 @@
   if (FixedIon == 0) { // even FixedIon moves, only not by other's forces
     for (int d=0; d<NDIM; d++) {
-        U[d] += configuration->Deltat/type->mass * (configuration->Thermostats->alpha * (U[d] * type->mass));
-        *ekin += (0.5*type->mass) * U[d]*U[d];
+        U[d] += configuration->Deltat/getType()->mass * (configuration->Thermostats->alpha * (U[d] * getType()->mass));
+        *ekin += (0.5*getType()->mass) * U[d]*U[d];
       }
   }
 };
+
+
+std::ostream & TrajectoryParticle::operator << (std::ostream &ost) const
+{
+  ParticleInfo::operator<<(ost);
+  ost << "," << getPosition();
+  return ost;
+}
+
+std::ostream & operator << (std::ostream &ost, const TrajectoryParticle &a)
+{
+  a.ParticleInfo::operator<<(ost);
+  ost << "," << a.getPosition();
+  return ost;
+}
+
Index: src/atom_trajectoryparticle.hpp
===================================================================
--- src/atom_trajectoryparticle.hpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/atom_trajectoryparticle.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -20,4 +20,5 @@
 #include <fstream>
 
+#include <gsl/gsl_inline.h>
 #include <gsl/gsl_randist.h>
 
@@ -62,8 +63,10 @@
   void Thermostat_NoseHoover_scale(int Step, double *ekin, config *configuration);
 
+  std::ostream & operator << (std::ostream &ost) const;
+
 private:
-
 };
 
+ostream & operator << (ostream &ost, const TrajectoryParticle &a);
 
 #endif /* ATOM_TRAJECTORYPARTICLE_HPP_ */
Index: src/atom_trajectoryparticleinfo.cpp
===================================================================
--- src/atom_trajectoryparticleinfo.cpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/atom_trajectoryparticleinfo.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -6,4 +6,9 @@
  */
 
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
 #include "Helpers/MemDebug.hpp"
 
@@ -12,5 +17,7 @@
 /** Constructor of class TrajectoryParticleInfo.
  */
-TrajectoryParticleInfo::TrajectoryParticleInfo() : FixedIon(0) {};
+TrajectoryParticleInfo::TrajectoryParticleInfo() :
+  FixedIon(0)
+{};
 
 /** Destructor of class TrajectoryParticleInfo.
Index: src/atom_trajectoryparticleinfo.hpp
===================================================================
--- src/atom_trajectoryparticleinfo.hpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/atom_trajectoryparticleinfo.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -20,6 +20,6 @@
 #include <vector>
 
-#include "vector.hpp"
-#include "VectorSet.hpp"
+#include "LinearAlgebra/Vector.hpp"
+#include "LinearAlgebra/VectorSet.hpp"
 
 /********************************************** declarations *******************************/
@@ -36,5 +36,5 @@
 
   TrajectoryParticleInfo();
-  ~TrajectoryParticleInfo();
+  virtual ~TrajectoryParticleInfo();
 
 private:
Index: src/bond.cpp
===================================================================
--- src/bond.cpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/bond.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -5,6 +5,13 @@
  */
 
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
 #include "Helpers/MemDebug.hpp"
 
+#include "Helpers/Log.hpp"
+#include "Helpers/Verbose.hpp"
 #include "atom.hpp"
 #include "bond.hpp"
@@ -17,9 +24,16 @@
 /** Empty Constructor for class bond.
  */
-bond::bond()
-  : leftatom(NULL), rightatom(NULL), previous(NULL), next(NULL), HydrogenBond(0),
-    BondDegree(0), nr(-1), Cyclic(false), Type(Undetermined), Used(white)
-{
-};
+bond::bond() :
+  leftatom(NULL),
+  rightatom(NULL),
+  previous(NULL),
+  next(NULL),
+  HydrogenBond(0),
+  BondDegree(0),
+  nr(-1),
+  Cyclic(false),
+  Type(Undetermined),
+  Used(white)
+{};
 
 /** Constructor for class bond, taking right and left bond partner
@@ -29,12 +43,20 @@
  * \param number increasing index
  */
-bond::bond(atom *left, atom *right, const int degree, const int number)
-  : leftatom(left), rightatom(right), previous(NULL), next(NULL), HydrogenBond(0),
-    BondDegree(degree), nr(number), Cyclic(false), Type(Undetermined), Used(white)
+bond::bond(atom *left, atom *right, const int degree, const int number) :
+  leftatom(left),
+  rightatom(right),
+  previous(NULL),
+  next(NULL),
+  HydrogenBond(0),
+  BondDegree(degree),
+  nr(number),
+  Cyclic(false),
+  Type(Undetermined),
+  Used(white)
 {
   if ((left != NULL) && (right != NULL)) {
-    if ((left->type != NULL) && (left->type->Z == 1))
+    if ((left->getType() != NULL) && (left->getType()->Z == 1))
       HydrogenBond++;
-    if ((right->type != NULL) && (right->type->Z == 1))
+    if ((right->getType() != NULL) && (right->getType()->Z == 1))
       HydrogenBond++;
   }
@@ -125,5 +147,5 @@
 double bond::GetDistance() const
 {
-  return (leftatom->node->distance(*rightatom->node));
+  return (leftatom->distance(*rightatom));
 };
 
@@ -133,4 +155,4 @@
 double bond::GetDistanceSquared() const
 {
-  return (leftatom->node->DistanceSquared(*rightatom->node));
+  return (leftatom->DistanceSquared(*rightatom));
 };
Index: src/bondgraph.cpp
===================================================================
--- src/bondgraph.cpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/bondgraph.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -5,4 +5,9 @@
  *      Author: heber
  */
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
 
 #include "Helpers/MemDebug.hpp"
@@ -14,17 +19,22 @@
 #include "bondgraph.hpp"
 #include "element.hpp"
-#include "info.hpp"
-#include "log.hpp"
+#include "Helpers/Info.hpp"
+#include "Helpers/Verbose.hpp"
+#include "Helpers/Log.hpp"
 #include "molecule.hpp"
 #include "parser.hpp"
 #include "periodentafel.hpp"
-#include "vector.hpp"
+#include "LinearAlgebra/Vector.hpp"
+
+const double BondGraph::BondThreshold = 0.4;   //!< CSD threshold in bond check which is the width of the interval whose center is the sum of the covalent radii
 
 /** Constructor of class BondGraph.
  * This classes contains typical bond lengths and thus may be used to construct a bond graph for a given molecule.
  */
-BondGraph::BondGraph(bool IsA) : BondLengthMatrix(NULL), max_distance(0), IsAngstroem(IsA)
-{
-};
+BondGraph::BondGraph(bool IsA) :
+    BondLengthMatrix(NULL),
+    max_distance(0),
+    IsAngstroem(IsA)
+{};
 
 /** Destructor of class BondGraph.
@@ -127,6 +137,6 @@
 
   for (molecule::const_iterator iter = mol->begin(); iter != mol->end(); ++iter) {
-    if ((*iter)->type->CovalentRadius > max_distance)
-      max_distance = (*iter)->type->CovalentRadius;
+    if ((*iter)->getType()->CovalentRadius > max_distance)
+      max_distance = (*iter)->getType()->CovalentRadius;
   }
   max_distance *= 2.;
@@ -144,8 +154,8 @@
 void BondGraph::CovalentMinMaxDistance(BondedParticle * const Walker, BondedParticle * const OtherWalker, double &MinDistance, double &MaxDistance, bool IsAngstroem)
 {
-  MinDistance = OtherWalker->type->CovalentRadius + Walker->type->CovalentRadius;
+  MinDistance = OtherWalker->getType()->CovalentRadius + Walker->getType()->CovalentRadius;
   MinDistance *= (IsAngstroem) ? 1. : 1. / AtomicLengthToAngstroem;
-  MaxDistance = MinDistance + BONDTHRESHOLD;
-  MinDistance -= BONDTHRESHOLD;
+  MaxDistance = MinDistance + BondThreshold;
+  MinDistance -= BondThreshold;
 };
 
@@ -165,8 +175,8 @@
     CovalentMinMaxDistance(Walker, OtherWalker, MinDistance, MaxDistance, IsAngstroem);
   } else {
-    MinDistance = GetBondLength(Walker->type->Z-1, OtherWalker->type->Z-1);
+    MinDistance = GetBondLength(Walker->getType()->Z-1, OtherWalker->getType()->Z-1);
     MinDistance *= (IsAngstroem) ? 1. : 1. / AtomicLengthToAngstroem;
-    MaxDistance = MinDistance + BONDTHRESHOLD;
-    MinDistance -= BONDTHRESHOLD;
+    MaxDistance = MinDistance + BondThreshold;
+    MinDistance -= BondThreshold;
   }
 };
Index: src/bondgraph.hpp
===================================================================
--- src/bondgraph.hpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/bondgraph.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -18,9 +18,6 @@
 #endif
 
-#include <iostream>
+#include <iosfwd>
 
-/*********************************************** defines ***********************************/
-
-#define BONDTHRESHOLD 0.4   //!< CSD threshold in bond check which is the width of the interval whose center is the sum of the covalent radii
 
 /****************************************** forward declarations *****************************/
@@ -48,4 +45,6 @@
 
 private:
+  static const double BondThreshold;
+
   MatrixContainer *BondLengthMatrix;
   double max_distance;
Index: src/boundary.cpp
===================================================================
--- src/boundary.cpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/boundary.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -4,6 +4,17 @@
  */
 
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
 #include "Helpers/MemDebug.hpp"
 
+#include "Actions/MoleculeAction/RotateToPrincipalAxisSystemAction.hpp"
+#include "BoundaryPointSet.hpp"
+#include "BoundaryLineSet.hpp"
+#include "BoundaryTriangleSet.hpp"
+#include "CandidateForTesselation.hpp"
+//#include "TesselPoint.hpp"
 #include "World.hpp"
 #include "atom.hpp"
@@ -12,14 +23,19 @@
 #include "config.hpp"
 #include "element.hpp"
-#include "helpers.hpp"
-#include "info.hpp"
+#include "Helpers/helpers.hpp"
+#include "Helpers/Info.hpp"
 #include "linkedcell.hpp"
-#include "log.hpp"
-#include "memoryallocator.hpp"
+#include "Helpers/Verbose.hpp"
+#include "Helpers/Log.hpp"
 #include "molecule.hpp"
 #include "tesselation.hpp"
 #include "tesselationhelpers.hpp"
 #include "World.hpp"
-#include "Plane.hpp"
+#include "LinearAlgebra/Plane.hpp"
+#include "LinearAlgebra/Matrix.hpp"
+#include "Box.hpp"
+
+#include <iostream>
+#include <iomanip>
 
 #include<gsl/gsl_poly.h>
@@ -81,5 +97,5 @@
               if (Neighbour == BoundaryPoints[axis].end()) // make it wrap around
                 Neighbour = BoundaryPoints[axis].begin();
-              DistanceVector = runner->second.second->x - Neighbour->second.second->x;
+              DistanceVector = (runner->second.second->getPosition()) - (Neighbour->second.second->getPosition());
               do { // seek for neighbour pair where it flips
                   OldComponent = DistanceVector[Othercomponent];
@@ -87,5 +103,5 @@
                   if (Neighbour == BoundaryPoints[axis].end()) // make it wrap around
                     Neighbour = BoundaryPoints[axis].begin();
-                  DistanceVector = runner->second.second->x - Neighbour->second.second->x;
+                  DistanceVector = (runner->second.second->getPosition()) - (Neighbour->second.second->getPosition());
                   //Log() << Verbose(2) << "OldComponent is " << OldComponent << ", new one is " << DistanceVector.x[Othercomponent] << "." << endl;
                 } while ((runner != Neighbour) && (fabs(OldComponent / fabs(
@@ -99,5 +115,5 @@
                   //Log() << Verbose(1) << "The pair, where the sign of OtherComponent flips, is: " << *(Neighbour->second.second) << " and " << *(OtherNeighbour->second.second) << "." << endl;
                   // now we have found the pair: Neighbour and OtherNeighbour
-                  OtherVector = runner->second.second->x - OtherNeighbour->second.second->x;
+                  OtherVector = (runner->second.second->getPosition()) - (OtherNeighbour->second.second->getPosition());
                   //Log() << Verbose(1) << "Distances to Neighbour and OtherNeighbour are " << DistanceVector.x[component] << " and " << OtherVector.x[component] << "." << endl;
                   //Log() << Verbose(1) << "OtherComponents to Neighbour and OtherNeighbour are " << DistanceVector.x[Othercomponent] << " and " << OtherVector.x[Othercomponent] << "." << endl;
@@ -167,5 +183,5 @@
     // 3b. construct set of all points, transformed into cylindrical system and with left and right neighbours
     for (molecule::const_iterator iter = mol->begin(); iter != mol->end(); ++iter) {
-      ProjectedVector = (*iter)->x - (*MolCenter);
+      ProjectedVector = (*iter)->getPosition() - (*MolCenter);
       ProjectedVector.ProjectOntoPlane(AxisVector);
 
@@ -182,5 +198,5 @@
       }
     DoLog(1) && (Log() << Verbose(1) << "Inserting " << **iter << ": (r, alpha) = (" << radius << "," << angle << "): " << ProjectedVector << endl);
-      BoundaryTestPair = BoundaryPoints[axis].insert(BoundariesPair(angle, DistancePair (radius, (*iter))));
+      BoundaryTestPair = BoundaryPoints[axis].insert(BoundariesPair(angle, TesselPointDistancePair (radius, (*iter))));
       if (!BoundaryTestPair.second) { // same point exists, check first r, then distance of original vectors to center of gravity
         DoLog(2) && (Log() << Verbose(2) << "Encountered two vectors whose projection onto axis " << axis << " is equal: " << endl);
@@ -193,8 +209,7 @@
           DoLog(2) && (Log() << Verbose(2) << "Keeping new vector due to larger projected distance " << ProjectedVectorNorm << "." << endl);
         } else if (fabs(ProjectedVectorNorm - BoundaryTestPair.first->second.first) < MYEPSILON) {
-          helper = (*iter)->x;
-          helper -= *MolCenter;
+          helper = (*iter)->getPosition() - (*MolCenter);
           const double oldhelperNorm = helper.NormSquared();
-          helper = BoundaryTestPair.first->second.second->x - (*MolCenter);
+          helper = BoundaryTestPair.first->second.second->getPosition() - (*MolCenter);
           if (helper.NormSquared() < oldhelperNorm) {
             BoundaryTestPair.first->second.second = (*iter);
@@ -249,17 +264,17 @@
         {
           Vector SideA, SideB, SideC, SideH;
-          SideA = left->second.second->x - (*MolCenter);
+          SideA = left->second.second->getPosition() - (*MolCenter);
           SideA.ProjectOntoPlane(AxisVector);
           //          Log() << Verbose(1) << "SideA: " << SideA << endl;
 
-          SideB = right->second.second->x -(*MolCenter);
+          SideB = right->second.second->getPosition() -(*MolCenter);
           SideB.ProjectOntoPlane(AxisVector);
           //          Log() << Verbose(1) << "SideB: " << SideB << endl;
 
-          SideC = left->second.second->x - right->second.second->x;
+          SideC = left->second.second->getPosition() - right->second.second->getPosition();
           SideC.ProjectOntoPlane(AxisVector);
           //          Log() << Verbose(1) << "SideC: " << SideC << endl;
 
-          SideH = runner->second.second->x -(*MolCenter);
+          SideH = runner->second.second->getPosition() -(*MolCenter);
           SideH.ProjectOntoPlane(AxisVector);
           //          Log() << Verbose(1) << "SideH: " << SideH << endl;
@@ -669,6 +684,7 @@
   double cellvolume = 0.;
 
-  // transform to PAS
-  mol->PrincipalAxisSystem(true);
+  // transform to PAS by Action
+  Vector MainAxis(0.,0.,1.);
+  MoleculeRotateToPrincipalAxisSystem(MainAxis);
 
   IsAngstroem = configuration->GetIsAngstroem();
@@ -694,5 +710,5 @@
   // sum up the atomic masses
   for (molecule::const_iterator iter = mol->begin(); iter != mol->end(); ++iter) {
-      totalmass += (*iter)->type->mass;
+      totalmass += (*iter)->getType()->mass;
   }
   DoLog(0) && (Log() << Verbose(0) << "RESULT: The summed mass is " << setprecision(10) << totalmass << " atomicmassunit." << endl);
@@ -769,7 +785,7 @@
   int N[NDIM];
   int n[NDIM];
-  double *M =  ReturnFullMatrixforSymmetric(World::getInstance().getDomain());
-  double Rotations[NDIM*NDIM];
-  double *MInverse = InverseMatrix(M);
+  const Matrix &M = World::getInstance().getDomain().getM();
+  Matrix Rotations;
+  const Matrix &MInverse = World::getInstance().getDomain().getMinv();
   Vector AtomTranslations;
   Vector FillerTranslations;
@@ -793,5 +809,4 @@
   // Center filler at origin
   filler->CenterEdge(&Inserter);
-  filler->Center.Zero();
   const int FillerCount = filler->getAtomCount();
   DoLog(2) && (Log() << Verbose(2) << "INFO: Filler molecule has the following bonds:" << endl);
@@ -804,6 +819,5 @@
 
   // calculate filler grid in [0,1]^3
-  FillerDistance = Vector(distance[0], distance[1], distance[2]);
-  FillerDistance.InverseMatrixMultiplication(M);
+  FillerDistance = MInverse * Vector(distance[0], distance[1], distance[2]);
   for(int i=0;i<NDIM;i++)
     N[i] = (int) ceil(1./FillerDistance[i]);
@@ -818,6 +832,5 @@
       for (n[2] = 0; n[2] < N[2]; n[2]++) {
         // calculate position of current grid vector in untransformed box
-        CurrentPosition = Vector((double)n[0]/(double)N[0], (double)n[1]/(double)N[1], (double)n[2]/(double)N[2]);
-        CurrentPosition.MatrixMultiplication(M);
+        CurrentPosition = M * Vector((double)n[0]/(double)N[0], (double)n[1]/(double)N[1], (double)n[2]/(double)N[2]);
         // create molecule random translation vector ...
         for (int i=0;i<NDIM;i++)
@@ -840,27 +853,27 @@
             }
 
-            Rotations[0] =   cos(phi[0])            *cos(phi[2]) + (sin(phi[0])*sin(phi[1])*sin(phi[2]));
-            Rotations[3] =   sin(phi[0])            *cos(phi[2]) - (cos(phi[0])*sin(phi[1])*sin(phi[2]));
-            Rotations[6] =               cos(phi[1])*sin(phi[2])                                     ;
-            Rotations[1] = - sin(phi[0])*cos(phi[1])                                                ;
-            Rotations[4] =   cos(phi[0])*cos(phi[1])                                                ;
-            Rotations[7] =               sin(phi[1])                                                ;
-            Rotations[3] = - cos(phi[0])            *sin(phi[2]) + (sin(phi[0])*sin(phi[1])*cos(phi[2]));
-            Rotations[5] = - sin(phi[0])            *sin(phi[2]) - (cos(phi[0])*sin(phi[1])*cos(phi[2]));
-            Rotations[8] =               cos(phi[1])*cos(phi[2])                                     ;
+            Rotations.set(0,0,  cos(phi[0])            *cos(phi[2]) + (sin(phi[0])*sin(phi[1])*sin(phi[2])));
+            Rotations.set(0,1,  sin(phi[0])            *cos(phi[2]) - (cos(phi[0])*sin(phi[1])*sin(phi[2])));
+            Rotations.set(0,2,              cos(phi[1])*sin(phi[2])                                        );
+            Rotations.set(1,0, -sin(phi[0])*cos(phi[1])                                                    );
+            Rotations.set(1,1,  cos(phi[0])*cos(phi[1])                                                    );
+            Rotations.set(1,2,              sin(phi[1])                                                    );
+            Rotations.set(2,0, -cos(phi[0])            *sin(phi[2]) + (sin(phi[0])*sin(phi[1])*cos(phi[2])));
+            Rotations.set(2,1, -sin(phi[0])            *sin(phi[2]) - (cos(phi[0])*sin(phi[1])*cos(phi[2])));
+            Rotations.set(2,2,              cos(phi[1])*cos(phi[2])                                        );
           }
 
           // ... and put at new position
-          Inserter = (*iter)->x;
+          Inserter = (*iter)->getPosition();
           if (DoRandomRotation)
-            Inserter.MatrixMultiplication(Rotations);
+            Inserter *= Rotations;
           Inserter += AtomTranslations + FillerTranslations + CurrentPosition;
 
           // check whether inserter is inside box
-          Inserter.MatrixMultiplication(MInverse);
+          Inserter *= MInverse;
           FillIt = true;
           for (int i=0;i<NDIM;i++)
             FillIt = FillIt && (Inserter[i] >= -MYEPSILON) && ((Inserter[i]-1.) <= MYEPSILON);
-          Inserter.MatrixMultiplication(M);
+          Inserter *= M;
 
           // Check whether point is in- or outside
@@ -877,7 +890,7 @@
             // copy atom ...
             CopyAtoms[(*iter)->nr] = (*iter)->clone();
-            CopyAtoms[(*iter)->nr]->x = Inserter;
+            (*CopyAtoms[(*iter)->nr]).setPosition(Inserter);
             Filling->AddAtom(CopyAtoms[(*iter)->nr]);
-            DoLog(4) && (Log() << Verbose(4) << "Filling atom " << **iter << ", translated to " << AtomTranslations << ", at final position is " << (CopyAtoms[(*iter)->nr]->x) << "." << endl);
+            DoLog(1) && (Log() << Verbose(1) << "Filling atom " << **iter << ", translated to " << AtomTranslations << ", at final position is " << (CopyAtoms[(*iter)->nr]->getPosition()) << "." << endl);
           } else {
             DoLog(1) && (Log() << Verbose(1) << "INFO: Position at " << Inserter << " is inner point, within boundary or outside of MaxDistance." << endl);
@@ -901,6 +914,4 @@
     delete TesselStruct[(*ListRunner)];
   }
-  delete[](M);
-  delete[](MInverse);
 
   return Filling;
Index: src/boundary.hpp
===================================================================
--- src/boundary.hpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/boundary.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -1,6 +1,4 @@
 #ifndef BOUNDARY_HPP_
 #define BOUNDARY_HPP_
-
-using namespace std;
 
 /*********************************************** includes ***********************************/
@@ -12,5 +10,5 @@
 
 #include <fstream>
-#include <iostream>
+#include <iosfwd>
 
 // STL headers
@@ -18,8 +16,8 @@
 
 #include "defs.hpp"
+#include "BoundaryMaps.hpp"
 
 /****************************************** forward declarations *****************************/
 
-class atom;
 class BoundaryPointSet;
 class BoundaryLineSet;
@@ -30,19 +28,12 @@
 class MoleculeListClass;
 class Tesselation;
+class TesselPoint;
 class Vector;
 
 /********************************************** definitions *********************************/
 
-#define DEBUG 1
-#define DoSingleStepOutput 0
-#define SingleStepWidth 10
-
-#define DistancePair pair < double, atom* >
-#define DistanceMap multimap < double, atom* >
-#define DistanceTestPair pair < DistanceMap::iterator, bool>
-
-#define Boundaries map <double, DistancePair >
-#define BoundariesPair pair<double, DistancePair >
-#define BoundariesTestPair pair< Boundaries::iterator, bool>
+enum { DEBUG=1 };
+enum { DoSingleStepOutput=0 };
+enum { SingleStepWidth=10 };
 
 /********************************************** declarations *******************************/
@@ -52,5 +43,4 @@
 void FindConvexBorder(const molecule* const mol, Boundaries *BoundaryPts, Tesselation *&TesselStruct, const LinkedCell *LCList, const char *filename);
 Vector* FindEmbeddingHole(MoleculeListClass *mols, molecule *srcmol);
-void FindNextSuitablePoint(class BoundaryTriangleSet *BaseTriangle, class BoundaryLineSet *BaseLine, atom*& OptCandidate, Vector *OptCandidateCenter, double *ShortestAngle, const double RADIUS, LinkedCell *LC);
 bool FindNonConvexBorder(const molecule* const mol, Tesselation *&TesselStruct, const LinkedCell *&LC, const double RADIUS, const char *tempbasename);
 Boundaries *GetBoundaryPoints(const molecule *mol, Tesselation *&TesselStruct);
Index: src/builder.cpp
===================================================================
--- src/builder.cpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/builder.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -54,4 +54,9 @@
  */
 
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
 #include "Helpers/MemDebug.hpp"
 
@@ -59,6 +64,5 @@
 #include "CommandLineParser.hpp"
 #include "config.hpp"
-#include "log.hpp"
-#include "memoryusageobserver.hpp"
+#include "Helpers/Log.hpp"
 #include "molecule.hpp"
 #include "periodentafel.hpp"
@@ -73,5 +77,5 @@
 #include "UIElements/Dialog.hpp"
 #include "Menu/ActionMenuItem.hpp"
-#include "verbose.hpp"
+#include "Helpers/Verbose.hpp"
 #include "World.hpp"
 
@@ -111,8 +115,14 @@
 }
 
+void dumpMemory(){
+  ofstream ost("molecuilder.memdump");
+  Memory::dumpMemory(ost);
+}
+
 int main(int argc, char **argv)
 {
   // while we are non interactive, we want to abort from asserts
-  //ASSERT_DO(Assert::Abort);
+  ASSERT_DO(Assert::Abort);
+  ASSERT_HOOK(dumpMemory);
   string line;
   char **Arguments = NULL;
@@ -128,7 +138,4 @@
   // need to init the history before any action is created
   ActionHistory::init();
-
-  // In the interactive mode, we can leave the user the choice in case of error
-  ASSERT_DO(Assert::Ask);
 
   // from this moment on, we need to be sure to deeinitialize in the correct order
@@ -156,4 +163,6 @@
       UIFactory::makeUserInterface("CommandLine");
     } else {
+      // In the interactive mode, we can leave the user the choice in case of error
+      ASSERT_DO(Assert::Ask);
       #ifdef USE_GUI_QT
         DoLog(0) && (Log() << Verbose(0) << "Setting UI to QT4." << endl);
Index: src/config.cpp
===================================================================
--- src/config.cpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/config.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -5,4 +5,9 @@
  */
 
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
 #include "Helpers/MemDebug.hpp"
 
@@ -10,4 +15,5 @@
 #include <cstring>
 
+//#include "Actions/FragmentationAction/SubgraphDissectionAction.hpp"
 #include "atom.hpp"
 #include "bond.hpp"
@@ -16,14 +22,16 @@
 #include "ConfigFileBuffer.hpp"
 #include "element.hpp"
-#include "helpers.hpp"
-#include "info.hpp"
+#include "Helpers/helpers.hpp"
+#include "Helpers/Info.hpp"
 #include "lists.hpp"
-#include "log.hpp"
+#include "Helpers/Verbose.hpp"
+#include "Helpers/Log.hpp"
 #include "molecule.hpp"
-#include "memoryallocator.hpp"
 #include "molecule.hpp"
 #include "periodentafel.hpp"
 #include "ThermoStatContainer.hpp"
 #include "World.hpp"
+#include "LinearAlgebra/Matrix.hpp"
+#include "Box.hpp"
 
 /************************************* Functions for class config ***************************/
@@ -31,11 +39,65 @@
 /** Constructor for config file class.
  */
-config::config() : BG(NULL), Thermostats(0), PsiType(0), MaxPsiDouble(0), PsiMaxNoUp(0), PsiMaxNoDown(0), MaxMinStopStep(1), InitMaxMinStopStep(1), ProcPEGamma(8), ProcPEPsi(1),
-    configname(NULL), FastParsing(false), Deltat(0.01), basis(""), databasepath(NULL), DoConstrainedMD(0), MaxOuterStep(0), mainname(NULL), defaultpath(NULL), pseudopotpath(NULL),
-    DoOutVis(0), DoOutMes(1), DoOutNICS(0), DoOutOrbitals(0), DoOutCurrent(0), DoFullCurrent(0), DoPerturbation(0), DoWannier(0), CommonWannier(0), SawtoothStart(0.01),
-    VectorPlane(0), VectorCut(0.), UseAddGramSch(1), Seed(1), OutVisStep(10), OutSrcStep(5), MaxPsiStep(0), EpsWannier(1e-7), MaxMinStep(100), RelEpsTotalEnergy(1e-7),
-    RelEpsKineticEnergy(1e-5), MaxMinGapStopStep(0), MaxInitMinStep(100), InitRelEpsTotalEnergy(1e-5), InitRelEpsKineticEnergy(1e-4), InitMaxMinGapStopStep(0), ECut(128.),
-    MaxLevel(5), RiemannTensor(0), LevRFactor(0), RiemannLevel(0), Lev0Factor(2), RTActualUse(0), AddPsis(0), RCut(20.), StructOpt(0), IsAngstroem(1), RelativeCoord(0),
-    MaxTypes(0) {
+config::config() :
+  BG(NULL),
+  Thermostats(0),
+  PsiType(0),
+  MaxPsiDouble(0),
+  PsiMaxNoUp(0),
+  PsiMaxNoDown(0),
+  MaxMinStopStep(1),
+  InitMaxMinStopStep(1),
+  ProcPEGamma(8),
+  ProcPEPsi(1),
+  configname(NULL),
+  FastParsing(false),
+  Deltat(0.01),
+  basis(""),
+  databasepath(NULL),
+  DoConstrainedMD(0),
+  MaxOuterStep(0),
+  mainname(NULL),
+  defaultpath(NULL),
+  pseudopotpath(NULL),
+  DoOutVis(0),
+  DoOutMes(1),
+  DoOutNICS(0),
+  DoOutOrbitals(0),
+  DoOutCurrent(0),
+  DoFullCurrent(0),
+  DoPerturbation(0),
+  DoWannier(0),
+  CommonWannier(0),
+  SawtoothStart(0.01),
+  VectorPlane(0),
+  VectorCut(0.),
+  UseAddGramSch(1),
+  Seed(1),
+  OutVisStep(10),
+  OutSrcStep(5),
+  MaxPsiStep(0),
+  EpsWannier(1e-7),
+  MaxMinStep(100),
+  RelEpsTotalEnergy(1e-7),
+  RelEpsKineticEnergy(1e-5),
+  MaxMinGapStopStep(0),
+  MaxInitMinStep(100),
+  InitRelEpsTotalEnergy(1e-5),
+  InitRelEpsKineticEnergy(1e-4),
+  InitMaxMinGapStopStep(0),
+  ECut(128.),
+  MaxLevel(5),
+  RiemannTensor(0),
+  LevRFactor(0),
+  RiemannLevel(0),
+  Lev0Factor(2),
+  RTActualUse(0),
+  AddPsis(0),
+  RCut(20.),
+  StructOpt(0),
+  IsAngstroem(1),
+  RelativeCoord(0),
+  MaxTypes(0)
+{
   mainname = new char[MAXSTRINGSIZE];
   defaultpath = new char[MAXSTRINGSIZE];
@@ -437,4 +499,5 @@
     map<int, atom *> LinearList;
     atom *neues = NULL;
+    Vector position;
     if (!FastParsing) {
       // parse in trajectories
@@ -450,13 +513,15 @@
               AtomList[i][j] = neues;
               LinearList[ FileBuffer->LineMapping[FileBuffer->CurrentLine] ] = neues;
-              neues->type = elementhash[i]; // find element type
+              neues->setType(elementhash[i]); // find element type
             } else
               neues = AtomList[i][j];
             status = (status &&
-                    ParseForParameter(verbose,FileBuffer, keyword, 0, 1, 1, double_type, &neues->x[0], 1, (repetition == 0) ? critical : optional) &&
-                    ParseForParameter(verbose,FileBuffer, keyword, 0, 2, 1, double_type, &neues->x[1], 1, (repetition == 0) ? critical : optional) &&
-                    ParseForParameter(verbose,FileBuffer, keyword, 0, 3, 1, double_type, &neues->x[2], 1, (repetition == 0) ? critical : optional) &&
+                    ParseForParameter(verbose,FileBuffer, keyword, 0, 1, 1, double_type, &position[0], 1, (repetition == 0) ? critical : optional) &&
+                    ParseForParameter(verbose,FileBuffer, keyword, 0, 2, 1, double_type, &position[1], 1, (repetition == 0) ? critical : optional) &&
+                    ParseForParameter(verbose,FileBuffer, keyword, 0, 3, 1, double_type, &position[2], 1, (repetition == 0) ? critical : optional) &&
                     ParseForParameter(verbose,FileBuffer, keyword, 0, 4, 1, int_type, &neues->FixedIon, 1, (repetition == 0) ? critical : optional));
-            if (!status) break;
+            if (!status)
+              break;
+            neues ->setPosition(position);
 
             // check size of vectors
@@ -470,15 +535,15 @@
             // put into trajectories list
             for (int d=0;d<NDIM;d++)
-              neues->Trajectory.R.at(repetition)[d] = neues->x[d];
+              neues->Trajectory.R.at(repetition)[d] = neues->at(d);
 
             // parse velocities if present
-            if(!ParseForParameter(verbose,FileBuffer, keyword, 0, 5, 1, double_type, &neues->v[0], 1,optional))
-              neues->v[0] = 0.;
-            if(!ParseForParameter(verbose,FileBuffer, keyword, 0, 6, 1, double_type, &neues->v[1], 1,optional))
-              neues->v[1] = 0.;
-            if(!ParseForParameter(verbose,FileBuffer, keyword, 0, 7, 1, double_type, &neues->v[2], 1,optional))
-              neues->v[2] = 0.;
+            if(!ParseForParameter(verbose,FileBuffer, keyword, 0, 5, 1, double_type, &neues->AtomicVelocity[0], 1,optional))
+              neues->AtomicVelocity[0] = 0.;
+            if(!ParseForParameter(verbose,FileBuffer, keyword, 0, 6, 1, double_type, &neues->AtomicVelocity[1], 1,optional))
+              neues->AtomicVelocity[1] = 0.;
+            if(!ParseForParameter(verbose,FileBuffer, keyword, 0, 7, 1, double_type, &neues->AtomicVelocity[2], 1,optional))
+              neues->AtomicVelocity[2] = 0.;
             for (int d=0;d<NDIM;d++)
-              neues->Trajectory.U.at(repetition)[d] = neues->v[d];
+              neues->Trajectory.U.at(repetition)[d] = neues->AtomicVelocity[d];
 
             // parse forces if present
@@ -529,20 +594,21 @@
             AtomList[i][j] = neues;
             LinearList[ FileBuffer->LineMapping[FileBuffer->CurrentLine] ] = neues;
-            neues->type = elementhash[i]; // find element type
+            neues->setType(elementhash[i]); // find element type
           } else
             neues = AtomList[i][j];
           // then parse for each atom the coordinates as often as present
-          ParseForParameter(verbose,FileBuffer, keyword, 0, 1, 1, double_type, &neues->x[0], repetition,critical);
-          ParseForParameter(verbose,FileBuffer, keyword, 0, 2, 1, double_type, &neues->x[1], repetition,critical);
-          ParseForParameter(verbose,FileBuffer, keyword, 0, 3, 1, double_type, &neues->x[2], repetition,critical);
+          ParseForParameter(verbose,FileBuffer, keyword, 0, 1, 1, double_type, &position[0], repetition,critical);
+          ParseForParameter(verbose,FileBuffer, keyword, 0, 2, 1, double_type, &position[1], repetition,critical);
+          ParseForParameter(verbose,FileBuffer, keyword, 0, 3, 1, double_type, &position[2], repetition,critical);
+          neues->setPosition(position);
           ParseForParameter(verbose,FileBuffer, keyword, 0, 4, 1, int_type, &neues->FixedIon, repetition,critical);
-          if(!ParseForParameter(verbose,FileBuffer, keyword, 0, 5, 1, double_type, &neues->v[0], repetition,optional))
-            neues->v[0] = 0.;
-          if(!ParseForParameter(verbose,FileBuffer, keyword, 0, 6, 1, double_type, &neues->v[1], repetition,optional))
-            neues->v[1] = 0.;
-          if(!ParseForParameter(verbose,FileBuffer, keyword, 0, 7, 1, double_type, &neues->v[2], repetition,optional))
-            neues->v[2] = 0.;
+          if(!ParseForParameter(verbose,FileBuffer, keyword, 0, 5, 1, double_type, &neues->AtomicVelocity[0], repetition,optional))
+            neues->AtomicVelocity[0] = 0.;
+          if(!ParseForParameter(verbose,FileBuffer, keyword, 0, 6, 1, double_type, &neues->AtomicVelocity[1], repetition,optional))
+            neues->AtomicVelocity[1] = 0.;
+          if(!ParseForParameter(verbose,FileBuffer, keyword, 0, 7, 1, double_type, &neues->AtomicVelocity[2], repetition,optional))
+            neues->AtomicVelocity[2] = 0.;
           // here we don't care if forces are present (last in trajectories is always equal to current position)
-          neues->type = elementhash[i]; // find element type
+          neues->setType(elementhash[i]); // find element type
           mol->AddAtom(neues);
         }
@@ -679,5 +745,5 @@
   // Unit cell and magnetic field
   ParseForParameter(verbose,FileBuffer, "BoxLength", 0, 3, 3, lower_trigrid, BoxLength, 1, critical); /* Lattice->RealBasis */
-  double * const cell_size = World::getInstance().getDomain();
+  double * cell_size = new double[6];
   cell_size[0] = BoxLength[0];
   cell_size[1] = BoxLength[3];
@@ -686,4 +752,6 @@
   cell_size[4] = BoxLength[7];
   cell_size[5] = BoxLength[8];
+  World::getInstance().setDomain(cell_size);
+  delete cell_size;
   //if (1) fprintf(stderr,"\n");
 
@@ -789,5 +857,5 @@
   // 4. dissect the molecule into connected subgraphs
   // don't do this here ...
-  //MolList->DissectMoleculeIntoConnectedSubgraphs(mol,this);
+  //FragmentationSubgraphDissection();
   //delete(mol);
 
@@ -883,5 +951,5 @@
 
   ParseForParameter(verbose,file, "BoxLength", 0, 3, 3, lower_trigrid, BoxLength, 1, critical); /* Lattice->RealBasis */
-  double * const cell_size = World::getInstance().getDomain();
+  double * cell_size = new double[6];
   cell_size[0] = BoxLength[0];
   cell_size[1] = BoxLength[3];
@@ -890,4 +958,6 @@
   cell_size[4] = BoxLength[7];
   cell_size[5] = BoxLength[8];
+  World::getInstance().setDomain(cell_size);
+  delete[] cell_size;
   if (1) fprintf(stderr,"\n");
   config::DoPerturbation = 0;
@@ -1003,9 +1073,11 @@
         istringstream input2(zeile);
         atom *neues = World::getInstance().createAtom();
-        input2 >> neues->x[0]; // x
-        input2 >> neues->x[1]; // y
-        input2 >> neues->x[2]; // z
+        double tmp;
+        for (int j=0;j<NDIM;j++) {
+          input2 >> tmp;
+          neues->set(j,tmp);
+        }
         input2 >> l;
-        neues->type = elementhash[No]; // find element type
+        neues->setType(elementhash[No]); // find element type
         mol->AddAtom(neues);
       }
@@ -1025,7 +1097,5 @@
 {
   bool result = true;
-  // bring MaxTypes up to date
-  mol->CountElements();
-  const double * const cell_size = World::getInstance().getDomain();
+  const Matrix &domain = World::getInstance().getDomain().getM();
   ofstream * const output = new ofstream(filename, ios::out);
   if (output != NULL) {
@@ -1098,7 +1168,7 @@
     *output << endl;
     *output << "BoxLength\t\t\t# (Length of a unit cell)" << endl;
-    *output << cell_size[0] << "\t" << endl;
-    *output << cell_size[1] << "\t" << cell_size[2] << "\t" << endl;
-    *output << cell_size[3] << "\t" << cell_size[4] << "\t" << cell_size[5] << "\t" << endl;
+    *output << domain.at(0,0) << "\t" << endl;
+    *output << domain.at(1,0) << "\t" << domain.at(1,1) << "\t" << endl;
+    *output << domain.at(2,0) << "\t" << domain.at(2,1) << "\t" << domain.at(2,2) << "\t" << endl;
     // FIXME
     *output << endl;
@@ -1132,5 +1202,5 @@
     *output << "IsAngstroem\t" << config::IsAngstroem << "\t# 0 - Bohr, 1 - Angstroem" << endl;
     *output << "RelativeCoord\t" << config::RelativeCoord << "\t# whether ion coordinates are relative (1) or absolute (0)" << endl;
-    *output << "MaxTypes\t" << mol->ElementCount <<  "\t# maximum number of different ion types" << endl;
+    *output << "MaxTypes\t" << mol->getElementCount() <<  "\t# maximum number of different ion types" << endl;
     *output << endl;
     result = result && mol->Checkout(output);
@@ -1275,6 +1345,6 @@
     AtomNo = 0;
     for (molecule::const_iterator iter = (*MolRunner)->begin(); iter != (*MolRunner)->end(); ++iter) {
-      sprintf(name, "%2s%2d",(*iter)->type->symbol, elementNo[(*iter)->type->Z]);
-      elementNo[(*iter)->type->Z] = (elementNo[(*iter)->type->Z]+1) % 100;   // confine to two digits
+      sprintf(name, "%2s%2d",(*iter)->getType()->getSymbol().c_str(), elementNo[(*iter)->getType()->Z]);
+      elementNo[(*iter)->getType()->Z] = (elementNo[(*iter)->getType()->Z]+1) % 100;   // confine to two digits
       fprintf(f,
              "ATOM %6u %-4s %4s%c%4u    %8.3f%8.3f%8.3f%6.2f%6.2f      %4s%2s%2s\n",
@@ -1284,11 +1354,11 @@
              'a'+(unsigned char)(AtomNo % 26),           /* letter for chain */
              MolNo,         /* residue sequence number */
-             (*iter)->node->at(0),                 /* position X in Angstroem */
-             (*iter)->node->at(1),                 /* position Y in Angstroem */
-             (*iter)->node->at(2),                 /* position Z in Angstroem */
-             (double)(*iter)->type->Valence,         /* occupancy */
-             (double)(*iter)->type->NoValenceOrbitals,          /* temperature factor */
+             (*iter)->at(0),                 /* position X in Angstroem */
+             (*iter)->at(1),                 /* position Y in Angstroem */
+             (*iter)->at(2),                 /* position Z in Angstroem */
+             (double)(*iter)->getType()->Valence,         /* occupancy */
+             (double)(*iter)->getType()->NoValenceOrbitals,          /* temperature factor */
              "0",            /* segment identifier */
-             (*iter)->type->symbol,    /* element symbol */
+             (*iter)->getType()->getSymbol().c_str(),    /* element symbol */
              "0");           /* charge */
       AtomNo++;
@@ -1328,6 +1398,6 @@
   AtomNo = 0;
   for (molecule::const_iterator iter = mol->begin(); iter != mol->end(); ++iter) {
-    sprintf(name, "%2s%2d",(*iter)->type->symbol, elementNo[(*iter)->type->Z]);
-    elementNo[(*iter)->type->Z] = (elementNo[(*iter)->type->Z]+1) % 100;   // confine to two digits
+    sprintf(name, "%2s%2d",(*iter)->getType()->getSymbol().c_str(), elementNo[(*iter)->getType()->Z]);
+    elementNo[(*iter)->getType()->Z] = (elementNo[(*iter)->getType()->Z]+1) % 100;   // confine to two digits
     fprintf(f,
            "ATOM %6u %-4s %4s%c%4u    %8.3f%8.3f%8.3f%6.2f%6.2f      %4s%2s%2s\n",
@@ -1337,11 +1407,11 @@
            'a'+(unsigned char)(AtomNo % 26),           /* letter for chain */
            0,         /* residue sequence number */
-           (*iter)->node->at(0),                 /* position X in Angstroem */
-           (*iter)->node->at(1),                 /* position Y in Angstroem */
-           (*iter)->node->at(2),                 /* position Z in Angstroem */
-           (double)(*iter)->type->Valence,         /* occupancy */
-           (double)(*iter)->type->NoValenceOrbitals,          /* temperature factor */
+           (*iter)->at(0),                 /* position X in Angstroem */
+           (*iter)->at(1),                 /* position Y in Angstroem */
+           (*iter)->at(2),                 /* position Z in Angstroem */
+           (double)(*iter)->getType()->Valence,         /* occupancy */
+           (double)(*iter)->getType()->NoValenceOrbitals,          /* temperature factor */
            "0",            /* segment identifier */
-           (*iter)->type->symbol,    /* element symbol */
+           (*iter)->getType()->getSymbol().c_str(),    /* element symbol */
            "0");           /* charge */
     AtomNo++;
@@ -1386,7 +1456,7 @@
     *output << mol->name << "\t";
     *output << 0 << "\t";
-    *output << (*iter)->node->at(0) << "\t" << (*iter)->node->at(1) << "\t" << (*iter)->node->at(2) << "\t";
-    *output << static_cast<double>((*iter)->type->Valence) << "\t";
-    *output << (*iter)->type->symbol << "\t";
+    *output << (*iter)->at(0) << "\t" << (*iter)->at(1) << "\t" << (*iter)->at(2) << "\t";
+    *output << static_cast<double>((*iter)->getType()->Valence) << "\t";
+    *output << (*iter)->getType()->getSymbol() << "\t";
     for (BondList::iterator runner = (*iter)->ListOfBonds.begin(); runner != (*iter)->ListOfBonds.end(); runner++)
       *output << (*runner)->GetOtherAtom(*iter)->nr << "\t";
@@ -1458,7 +1528,7 @@
         *output << (*MolWalker)->name << "\t";
         *output << MolCounter+1 << "\t";
-        *output << (*iter)->node->at(0) << "\t" << (*iter)->node->at(1) << "\t" << (*iter)->node->at(2) << "\t";
-        *output << (double)(*iter)->type->Valence << "\t";
-        *output << (*iter)->type->symbol << "\t";
+        *output << (*iter)->at(0) << "\t" << (*iter)->at(1) << "\t" << (*iter)->at(2) << "\t";
+        *output << (double)(*iter)->getType()->Valence << "\t";
+        *output << (*iter)->getType()->getSymbol() << "\t";
         for (BondList::iterator runner = (*iter)->ListOfBonds.begin(); runner != (*iter)->ListOfBonds.end(); runner++)
           *output << LocalNotoGlobalNoMap[ (*runner)->GetOtherAtom((*iter))->getId() ] << "\t";
@@ -1522,11 +1592,7 @@
     for (MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++) {
       src[N++] = (*ListRunner)->IndexNr;
-      (*ListRunner)->Translate(&(*ListRunner)->Center);
     }
     mol = World::getInstance().createMolecule();
     mol->SetNameFromFilename(ConfigFileName);
-    molecules->SimpleMultiMerge(mol, src, N);
-    mol->doCountAtoms();
-    mol->CountElements();
     //mol->CalculateOrbitals(*this);
     delete[](src);
Index: src/datacreator.cpp
===================================================================
--- src/datacreator.cpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/datacreator.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -7,9 +7,17 @@
 //============================ INCLUDES ===========================
 
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
 #include "Helpers/MemDebug.hpp"
 
 #include "datacreator.hpp"
-#include "helpers.hpp"
+#include "Helpers/helpers.hpp"
 #include "parser.hpp"
+#include "Helpers/Verbose.hpp"
+
+#include <iomanip>
 
 //=========================== FUNCTIONS============================
Index: src/datacreator.hpp
===================================================================
--- src/datacreator.hpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/datacreator.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -10,5 +10,5 @@
 using namespace std;
 
-#include <iostream>
+#include <iosfwd>
 
 /****************************************** forward declarations *****************************/
Index: src/defs.cpp
===================================================================
--- src/defs.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
+++ src/defs.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -0,0 +1,65 @@
+/*
+ * defs.cpp
+ *
+ *  Created on: Aug 7, 2010
+ *      Author: heber
+ */
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "Helpers/MemDebug.hpp"
+
+#include "defs.hpp"
+
+const double MYEPSILON=1e-13;   //!< machine epsilon precision
+const double AtomicLengthToAngstroem = 0.52917721; //!< conversion factor from atomic length/bohrradius to angstroem
+const double AtomicEnergyToKelvin = 315774.67;  //!< conversion factor from atomic energy to kelvin via boltzmann factor
+const double KelvinToAtomicTemperature = 3.1668152e-06;    //!< conversion factor for Kelvin to atomic temperature (Hartree over k_B)
+const double KelvinToeV = 8.6173422e-05;                   //!< conversion factor for Kelvin to Ht (k_B * T = energy), thus Boltzmann constant in eV/K
+const double AtomicMassUnitsToeV = 931494088.;        //!< conversion factor for atomic weight in units to mass in eV
+const double AtomicMassUnitsToHt = 34480864.;        //!< conversion factor for atomic weight in units to mass in Ht (protonmass/electronmass * electron_mass_in_Ht
+const double ElectronMass_Ht = 18778.865;            //!< electron mass in Ht
+const double ElectronMass_eV = 510998.903;           //!< electron mass in eV
+const double Units2Electronmass = (AtomicMassUnitsToeV/ElectronMass_eV); //!< atomic mass unit in eV/ electron mass in eV = 1 822.88863
+const double Atomictime2Femtoseconds = 0.024188843;     //!< Atomictime in fs
+
+const char* VERSIONSTRING = "v1.0";
+
+const char* LocalPath="./";
+
+// various standard filenames
+const char *DEFAULTCONFIG = "main_pcp_linux";    //!< default filename of config file
+const char *CONVEXENVELOPE = "ConvexEnvelope.dat";    //!< default filename of convex envelope tecplot data file
+const char *KEYSETFILE = "KeySets.dat";    //!< default filename of BOSSANOVA key sets file
+const char *ADJACENCYFILE = "Adjacency.dat";    //!< default filename of BOSSANOVA adjacancy file
+const char *TEFACTORSFILE = "TE-Factors.dat";    //!< default filename of BOSSANOVA total energy factors file
+const char *FORCESFILE = "Forces-Factors.dat";    //!< default filename of BOSSANOVA force factors file
+const char *HCORRECTIONSUFFIX = "Hcorrection.dat";    //!< default filename of BOSSANOVA H correction file (unwanted saturation interaction)
+const char *FITCONSTANTSUFFIX = "FitConstant.dat";   //!< suffix of default filename of BOSSANOVA fit constants file (unwanted saturation interaction)
+const char *SHIELDINGSUFFIX = "sigma_all.csv";                //!< default filename of BOSSANOVA shieldings file
+const char *SHIELDINGPASSUFFIX = "sigma_all_PAS.csv";                 //!< default filename of BOSSANOVA shieldings PAS file
+const char *ORDERATSITEFILE = "OrderAtSite.dat";    //!< default filename of BOSSANOVA Bond Order at each atom file
+const char *ENERGYPERFRAGMENT = "EnergyPerFragment";    //!< default filename of BOSSANOVA Energy contribution Per Fragment file
+const char *FRAGMENTPREFIX = "BondFragment";    //!< default filename prefix of BOSSANOVA fragment config and directories
+const char *STANDARDCONFIG = "unknown.conf";    //!< default filename of standard config file
+const char *STANDARDELEMENTSDB = "elements.db";    //!< default filename of elements data base with masses, Z, VanDerWaals radii, ...
+const char *STANDARDVALENCEDB = "valence.db";    //!< default filename of valence number per element database
+const char *STANDARDORBITALDB = "orbitals.db";    //!< default filename of orbitals per element database
+const char *STANDARDHBONDDISTANCEDB = "Hbonddistance.db";    //!< default filename of typial bond distance to hydrogen database
+const char *STANDARDHBONDANGLEDB = "Hbondangle.db";    //!< default filename of typial bond angle to hydrogen database
+
+// some values
+const double SOLVENTDENSITY_A = 0.6022142;
+const double SOLVENTDENSITY_a0 = 0.089238936;
+
+
+const int UPDATECOUNT = 10;  //!< update ten sites per BOSSANOVA interval
+
+const int STD_MENU_LENGTH = 60;
+const char STD_MENU_TITLE_SPACER = '=';
+const char STD_SEPERATOR_SPACER = '-';
+
+const char *MOLECUILDER_NAME = "Molecuilder";
Index: src/defs.hpp
===================================================================
--- src/defs.hpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/defs.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -8,21 +8,22 @@
 #define DEFS_HPP_
 
-#define MYEPSILON 1e-13   //!< machine epsilon precision
-#define NDIM  3   //!< number of spatial dimensions
-#define MAX_ELEMENTS 128  //!< maximum number of elements for certain lookup tables 
-#define AtomicLengthToAngstroem  0.52917721 //!< conversion factor from atomic length/bohrradius to angstroem
-#define AtomicEnergyToKelvin 315774.67  //!< conversion factor from atomic energy to kelvin via boltzmann factor
-#define KelvinToAtomicTemperature 3.1668152e-06    //!< conversion factor for Kelvin to atomic temperature (Hartree over k_B)
-#define KelvinToeV 8.6173422e-05                   //!< conversion factor for Kelvin to Ht (k_B * T = energy), thus Boltzmann constant in eV/K
-#define AtomicMassUnitsToeV 931494088.        //!< conversion factor for atomic weight in units to mass in eV
-#define AtomicMassUnitsToHt 34480864.        //!< conversion factor for atomic weight in units to mass in Ht (protonmass/electronmass * electron_mass_in_Ht
-#define ElectronMass_Ht 18778.865            //!< electron mass in Ht
-#define ElectronMass_eV 510998.903           //!< electron mass in eV
-#define Units2Electronmass (AtomicMassUnitsToeV/ElectronMass_eV) //!< atomic mass unit in eV/ electron mass in eV = 1 822.88863
-#define Atomictime2Femtoseconds 0.024188843     //!< Atomictime in fs
+enum { NDIM = 3 };   //!< number of spatial dimensions
+enum { MAX_ELEMENTS = 128}; //!< maximum number of elements for certain lookup tables
 
-#define VERSIONSTRING "v1.0"
+extern "C" const double MYEPSILON;  //!< machine epsilon precision
+extern "C" const double AtomicLengthToAngstroem; //!< conversion factor from atomic length/bohrradius to angstroem
+extern "C" const double AtomicEnergyToKelvin;  //!< conversion factor from atomic energy to kelvin via boltzmann factor
+extern "C" const double KelvinToAtomicTemperature;    //!< conversion factor for Kelvin to atomic temperature (Hartree over k_B)
+extern "C" const double KelvinToeV;                   //!< conversion factor for Kelvin to Ht (k_B * T = energy), thus Boltzmann constant in eV/K
+extern "C" const double AtomicMassUnitsToeV;        //!< conversion factor for atomic weight in units to mass in eV
+extern "C" const double AtomicMassUnitsToHt;        //!< conversion factor for atomic weight in units to mass in Ht (protonmass/electronmass * electron_mass_in_Ht
+extern "C" const double ElectronMass_Ht;            //!< electron mass in Ht
+extern "C" const double ElectronMass_eV;           //!< electron mass in eV
+extern "C" const double Units2Electronmass; //!< atomic mass unit in eV/ electron mass in eV = 1 822.88863
+extern "C" const double Atomictime2Femtoseconds;     //!< Atomictime in fs
 
-#define LocalPath "./"
+extern "C" const char* VERSIONSTRING;
+
+extern "C" const char* LocalPath;
 
 //enum BondOrderScheme { NoScheme, BottomUp, TopDown, ANOVA, Combined }; //!< Fragmentation scheme used in BOSS
@@ -48,39 +49,42 @@
 
 // maximum length of any char array
-#define MAXSTRINGSIZE 255
+enum { MAXSTRINGSIZE = 255 };
 
 // various standard filenames
-#define DEFAULTCONFIG "main_pcp_linux"    //!< default filename of config file
-#define CONVEXENVELOPE "ConvexEnvelope.dat"    //!< default filename of convex envelope tecplot data file
-#define KEYSETFILE "KeySets.dat"    //!< default filename of BOSSANOVA key sets file
-#define ADJACENCYFILE "Adjacency.dat"    //!< default filename of BOSSANOVA adjacancy file
-#define TEFACTORSFILE "TE-Factors.dat"    //!< default filename of BOSSANOVA total energy factors file
-#define FORCESFILE "Forces-Factors.dat"    //!< default filename of BOSSANOVA force factors file
-#define HCORRECTIONSUFFIX "Hcorrection.dat"    //!< default filename of BOSSANOVA H correction file (unwanted saturation interaction)
-#define FITCONSTANTSUFFIX "FitConstant.dat"   //!< suffix of default filename of BOSSANOVA fit constants file (unwanted saturation interaction)
-#define SHIELDINGSUFFIX "sigma_all.csv"                //!< default filename of BOSSANOVA shieldings file
-#define SHIELDINGPASSUFFIX "sigma_all_PAS.csv"                 //!< default filename of BOSSANOVA shieldings PAS file
-#define ORDERATSITEFILE "OrderAtSite.dat"    //!< default filename of BOSSANOVA Bond Order at each atom file
-#define ENERGYPERFRAGMENT "EnergyPerFragment"    //!< default filename of BOSSANOVA Energy contribution Per Fragment file
-#define FRAGMENTPREFIX "BondFragment"    //!< default filename prefix of BOSSANOVA fragment config and directories 
-#define STANDARDCONFIG "unknown.conf"    //!< default filename of standard config file
-#define STANDARDELEMENTSDB "elements.db"    //!< default filename of elements data base with masses, Z, VanDerWaals radii, ...
-#define STANDARDVALENCEDB "valence.db"    //!< default filename of valence number per element database
-#define STANDARDORBITALDB "orbitals.db"    //!< default filename of orbitals per element database
-#define STANDARDHBONDDISTANCEDB "Hbonddistance.db"    //!< default filename of typial bond distance to hydrogen database
-#define STANDARDHBONDANGLEDB "Hbondangle.db"    //!< default filename of typial bond angle to hydrogen database
+extern "C" const char *DEFAULTCONFIG;    //!< default filename of config file
+extern "C" const char *CONVEXENVELOPE;    //!< default filename of convex envelope tecplot data file
+extern "C" const char *KEYSETFILE;    //!< default filename of BOSSANOVA key sets file
+extern "C" const char *ADJACENCYFILE;    //!< default filename of BOSSANOVA adjacancy file
+extern "C" const char *TEFACTORSFILE;    //!< default filename of BOSSANOVA total energy factors file
+extern "C" const char *FORCESFILE;    //!< default filename of BOSSANOVA force factors file
+extern "C" const char *HCORRECTIONSUFFIX;    //!< default filename of BOSSANOVA H correction file (unwanted saturation interaction)
+extern "C" const char *FITCONSTANTSUFFIX;   //!< suffix of default filename of BOSSANOVA fit constants file (unwanted saturation interaction)
+extern "C" const char *SHIELDINGSUFFIX;                //!< default filename of BOSSANOVA shieldings file
+extern "C" const char *SHIELDINGPASSUFFIX;                 //!< default filename of BOSSANOVA shieldings PAS file
+extern "C" const char *ORDERATSITEFILE;    //!< default filename of BOSSANOVA Bond Order at each atom file
+extern "C" const char *ENERGYPERFRAGMENT;    //!< default filename of BOSSANOVA Energy contribution Per Fragment file
+extern "C" const char *FRAGMENTPREFIX;    //!< default filename prefix of BOSSANOVA fragment config and directories
+extern "C" const char *STANDARDCONFIG;    //!< default filename of standard config file
+extern "C" const char *STANDARDELEMENTSDB;    //!< default filename of elements data base with masses, Z, VanDerWaals radii, ...
+extern "C" const char *STANDARDVALENCEDB;    //!< default filename of valence number per element database
+extern "C" const char *STANDARDORBITALDB;    //!< default filename of orbitals per element database
+extern "C" const char *STANDARDHBONDDISTANCEDB;    //!< default filename of typial bond distance to hydrogen database
+extern "C" const char *STANDARDHBONDANGLEDB;    //!< default filename of typial bond angle to hydrogen database
 
 // some values
-#define SOLVENTDENSITY_A 0.6022142
-#define SOLVENTDENSITY_a0 0.089238936
+extern "C" const double SOLVENTDENSITY_A;
+extern "C" const double SOLVENTDENSITY_a0;
 
 
-#define UPDATECOUNT 10  //!< update ten sites per BOSSANOVA interval
+extern "C" const int UPDATECOUNT;  //!< update ten sites per BOSSANOVA interval
 
-#define STD_MENU_LENGTH 60
-#define STD_MENU_TITLE_SPACER '='
-#define STD_SEPERATOR_SPACER '-'
+extern "C" const int STD_MENU_LENGTH;
+extern "C" const char STD_MENU_TITLE_SPACER;
+extern "C" const char STD_SEPERATOR_SPACER;
 
-#define MOLECUILDER_NAME "Molecuilder"
+extern "C" const char *MOLECUILDER_NAME;
+
+const extern unsigned int MAX_POOL_FRAGMENTATION;
+const extern unsigned int MAX_FRAGMENTATION_SKIPS;
 
 #endif /*DEFS_HPP_*/
Index: src/element.cpp
===================================================================
--- src/element.cpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/element.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -4,4 +4,9 @@
  * 
  */
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
 
 #include "Helpers/MemDebug.hpp"
@@ -23,8 +28,4 @@
   VanDerWaalsRadius(0),
 	Z(-1),
-	previous(NULL),
-	next(NULL),
-	sort(NULL),
-	No(-1),
 	Valence(0),
 	NoValenceOrbitals(0)
@@ -32,7 +33,39 @@
 };
 
+element::element(const element &src) :
+  mass(src.mass),
+  CovalentRadius(src.CovalentRadius),
+  VanDerWaalsRadius(src.VanDerWaalsRadius),
+  Z(src.Z),
+  Valence(src.Valence),
+  NoValenceOrbitals(src.NoValenceOrbitals),
+  name(src.name),
+  symbol(src.symbol)
+{
+  period = src.period;
+  group = src.group;
+  block = src.block;
+}
+
 /** Destructor of class element.
  */
 element::~element() {};
+
+element &element::operator=(const element &src){
+  if(this!=&src){
+    mass=src.mass;
+    CovalentRadius=src.CovalentRadius;
+    VanDerWaalsRadius=src.VanDerWaalsRadius;
+    Z=src.Z;
+    Valence=src.Valence;
+    NoValenceOrbitals=src.NoValenceOrbitals;
+    name=src.name;
+    symbol=src.symbol;
+    period = src.period;
+    group = src.group;
+    block = src.block;
+  }
+  return *this;
+}
 
 /** Prints element data to \a *out.
@@ -67,5 +100,22 @@
 }
 
-string element::getSymbol() const{
-  return string(symbol);
+string &element::getSymbol(){
+  return symbol;
 }
+
+const string &element::getSymbol() const{
+  return symbol;
+}
+
+std::string &element::getName(){
+  return name;
+}
+
+const std::string &element::getName() const{
+  return name;
+}
+
+std::ostream &operator<<(std::ostream &ost,const element &elem){
+  ost << elem.getName() << "(" << elem.getNumber() << ")";
+  return ost;
+}
Index: src/element.hpp
===================================================================
--- src/element.hpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/element.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -16,5 +16,5 @@
 #endif
 
-#include <iostream>
+#include <iosfwd>
 #include <string>
 
@@ -33,13 +33,7 @@
     double VanDerWaalsRadius;  //!< can-der-Waals radius
     int Z;          //!< atomic number
-    char name[64];  //!< atom name, i.e. "Hydrogren"
-    char symbol[3]; //!< short form of the atom, i.e. "H"
-    char period[8];    //!< period: n quantum number
-    char group[8];    //!< group: l quantum number
-    char block[8];    //!< block: l quantum number
-    element *previous;  //!< previous item in list
-    element *next;  //!< next element in list
-    int *sort;      //!< sorc criteria
-    int No;         //!< number of element set on periodentafel::Output()
+    std::string period;    //!< period: n quantum number
+    std::string group;    //!< group: l quantum number
+    std::string block;    //!< block: l quantum number
     double Valence;   //!< number of valence electrons for this element
     int NoValenceOrbitals;  //!< number of valence orbitals, used for determining bond degree in molecule::CreateConnectmatrix()
@@ -47,18 +41,27 @@
     double HBondAngle[NDIM];     //!< typical angle for one, two, three bonded hydrogen (in degrees)
 
-  element();
-  ~element();
+    element();
+    element(const element&);
+    ~element();
 
-  // accessor functions
-  atomicNumber_t getNumber() const;
-  std::string getSymbol() const;
+    element &operator=(const element&);
 
-  //> print element entries to screen
-  bool Output(std::ostream * const out) const;
-  bool Checkout(std::ostream * const out, const int No, const int NoOfAtoms) const;
+    // accessor functions
+    atomicNumber_t getNumber() const;
+    std::string &getSymbol();
+    const std::string &getSymbol() const;
+    std::string &getName();
+    const std::string &getName() const;
+
+    //> print element entries to screen
+    bool Output(std::ostream * const out) const;
+    bool Checkout(std::ostream * const out, const int No, const int NoOfAtoms) const;
 
   private:
+    std::string name;  //!< atom name, i.e. "Hydrogren"
+    std::string symbol; //!< short form of the atom, i.e. "H"
 };
 
+std::ostream &operator<<(std::ostream&,const element&);
 
 #endif /* ELEMENT_HPP_ */
Index: src/elements_db.cpp
===================================================================
--- src/elements_db.cpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/elements_db.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -5,4 +5,9 @@
  *      Author: heber
  */
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
 
 #include "Helpers/MemDebug.hpp"
Index: src/ellipsoid.cpp
===================================================================
--- src/ellipsoid.cpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/ellipsoid.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -6,4 +6,9 @@
  */
 
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
 #include "Helpers/MemDebug.hpp"
 
@@ -15,11 +20,13 @@
 #include <set>
 
+#include "BoundaryPointSet.hpp"
 #include "boundary.hpp"
 #include "ellipsoid.hpp"
 #include "linkedcell.hpp"
-#include "log.hpp"
+#include "Helpers/Log.hpp"
 #include "tesselation.hpp"
-#include "vector.hpp"
-#include "verbose.hpp"
+#include "LinearAlgebra/Vector.hpp"
+#include "LinearAlgebra/Matrix.hpp"
+#include "Helpers/Verbose.hpp"
 
 /** Determines squared distance for a given point \a x to surface of ellipsoid.
@@ -34,5 +41,5 @@
   Vector helper, RefPoint;
   double distance = -1.;
-  double Matrix[NDIM*NDIM];
+  Matrix Matrix;
   double InverseLength[3];
   double psi,theta,phi; // euler angles in ZX'Z'' convention
@@ -51,14 +58,14 @@
   theta = EllipsoidAngle[1];
   phi = EllipsoidAngle[2];
-  Matrix[0] = cos(psi)*cos(phi) - sin(psi)*cos(theta)*sin(phi);
-  Matrix[1] = -cos(psi)*sin(phi) - sin(psi)*cos(theta)*cos(phi);
-  Matrix[2] = sin(psi)*sin(theta);
-  Matrix[3] = sin(psi)*cos(phi) + cos(psi)*cos(theta)*sin(phi);
-  Matrix[4] = cos(psi)*cos(theta)*cos(phi) - sin(psi)*sin(phi);
-  Matrix[5] = -cos(psi)*sin(theta);
-  Matrix[6] = sin(theta)*sin(phi);
-  Matrix[7] = sin(theta)*cos(phi);
-  Matrix[8] = cos(theta);
-  helper.MatrixMultiplication(Matrix);
+  Matrix.set(0,0, cos(psi)*cos(phi) - sin(psi)*cos(theta)*sin(phi));
+  Matrix.set(1,0, -cos(psi)*sin(phi) - sin(psi)*cos(theta)*cos(phi));
+  Matrix.set(2,0, sin(psi)*sin(theta));
+  Matrix.set(0,1, sin(psi)*cos(phi) + cos(psi)*cos(theta)*sin(phi));
+  Matrix.set(1,1, cos(psi)*cos(theta)*cos(phi) - sin(psi)*sin(phi));
+  Matrix.set(2,1, -cos(psi)*sin(theta));
+  Matrix.set(0,2, sin(theta)*sin(phi));
+  Matrix.set(1,2, sin(theta)*cos(phi));
+  Matrix.set(2,2, cos(theta));
+  helper *= Matrix;
   helper.ScaleAll(InverseLength);
   //Log() << Verbose(4) << "Transformed RefPoint is at " << helper << "." << endl;
@@ -73,14 +80,14 @@
   phi = -EllipsoidAngle[2];
   helper.ScaleAll(EllipsoidLength);
-  Matrix[0] = cos(psi)*cos(phi) - sin(psi)*cos(theta)*sin(phi);
-  Matrix[1] = -cos(psi)*sin(phi) - sin(psi)*cos(theta)*cos(phi);
-  Matrix[2] = sin(psi)*sin(theta);
-  Matrix[3] = sin(psi)*cos(phi) + cos(psi)*cos(theta)*sin(phi);
-  Matrix[4] = cos(psi)*cos(theta)*cos(phi) - sin(psi)*sin(phi);
-  Matrix[5] = -cos(psi)*sin(theta);
-  Matrix[6] = sin(theta)*sin(phi);
-  Matrix[7] = sin(theta)*cos(phi);
-  Matrix[8] = cos(theta);
-  helper.MatrixMultiplication(Matrix);
+  Matrix.set(0,0, cos(psi)*cos(phi) - sin(psi)*cos(theta)*sin(phi));
+  Matrix.set(1,0, -cos(psi)*sin(phi) - sin(psi)*cos(theta)*cos(phi));
+  Matrix.set(2,0, sin(psi)*sin(theta));
+  Matrix.set(0,1, sin(psi)*cos(phi) + cos(psi)*cos(theta)*sin(phi));
+  Matrix.set(1,1, cos(psi)*cos(theta)*cos(phi) - sin(psi)*sin(phi));
+  Matrix.set(2,1, -cos(psi)*sin(theta));
+  Matrix.set(0,2, sin(theta)*sin(phi));
+  Matrix.set(1,2, sin(theta)*cos(phi));
+  Matrix.set(2,2, cos(theta));
+  helper *= Matrix;
   //Log() << Verbose(4) << "Intersection is at " << helper << "." << endl;
 
@@ -303,6 +310,6 @@
               if ((current != PickedAtomNrs.end()) && (*current == index)) {
                 Candidate = (*Runner);
-                DoLog(2) && (Log() << Verbose(2) << "Current picked node is " << **Runner << " with index " << index << "." << endl);
-                x[PointsPicked++] = *Candidate->node;    // we have one more atom picked
+                DoLog(2) && (Log() << Verbose(2) << "Current picked node is " << (*Runner)->getName() << " with index " << index << "." << endl);
+                x[PointsPicked++] = Candidate->getPosition();    // we have one more atom picked
                 current++;    // next pre-picked atom
               }
@@ -350,5 +357,5 @@
       //Log() << Verbose(3) << "Current node is " << *Runner->second->node << " with " << value << " ... " << threshold << ": ";
       if (value > threshold) {
-        x[PointsPicked] = (*Runner->second->node->node);
+        x[PointsPicked] = (Runner->second->node->getPosition());
         PointsPicked++;
         //Log() << Verbose(0) << "IN." << endl;
@@ -387,5 +394,5 @@
   Center.Zero();
   for (PointMap::iterator Runner = T->PointsOnBoundary.begin(); Runner != T->PointsOnBoundary.end(); Runner++)
-    Center += (*Runner->second->node->node);
+    Center += (Runner->second->node->getPosition());
   Center.Scale(1./T->PointsOnBoundaryCount);
   DoLog(1) && (Log() << Verbose(1) << "Center is at " << Center << "." << endl);
Index: c/errorlogger.cpp
===================================================================
--- src/errorlogger.cpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ 	(revision )
@@ -1,102 +1,0 @@
-/*
- * errorLogger.cpp
- *
- *  Created on: Oct 19, 2009
- *      Author: metzler
- */
-
-#include "Helpers/MemDebug.hpp"
-
-#include <fstream>
-#include "errorlogger.hpp"
-#include "verbose.hpp"
-#include "Patterns/Singleton_impl.hpp"
-
-ofstream null("/dev/null");
-int errorLogger::verbosity = 2;
-ostream* errorLogger::nix = &null;
-
-/**
- * Constructor. Do not use this function. Use getInstance() instead.
- *
- * \return errorLogger instance
- */
-errorLogger::errorLogger()
-{
-  verbosity = 2;
-};
-
-/**
- * Destructor. Better use purgeInstance().
- */
-errorLogger::~errorLogger() {
-  verbosity = 2;
-}
-
-CONSTRUCT_SINGLETON(errorLogger)
-
-/**
- * Sets the verbosity.
- *
- * \param verbosityLevel verbosity
- */
-void errorLogger::setVerbosity(int verbosityLevel) {
-  verbosity = verbosityLevel;
-}
-
-/**
- * Operator for the Binary(arg) call.
- * Constructs temporary a Verbose class object, wherein the Binary is stored.
- * Then << is called, which calls Binary's print which adds the tabs and logs
- * the stream.
- * \param &ost stream to extend
- * \param &m pointer to created Binary object
- * \return &ost
- */
-ostream& operator<<(class errorLogger& l, const Verbose& v)
-{
-  int verbosityLevel = l.verbosity;
-  l.nix->clear();
-  if (v.DoErrorOutput(verbosityLevel)) {
-    switch(v.Verbosity) {
-      case 0:
-        cerr << "CRITICAL: ";
-        break;
-      case 1:
-        cerr << "ERROR: ";
-        break;
-      case 2:
-        cerr << "WARNING: ";
-        break;
-      default:
-        break;
-    }
-    v.print(cerr);
-    return cerr;
-  } else
-    return *l.nix;
-};
-ostream& operator<<(class errorLogger* l, const Verbose& v)
-{
-  int verbosityLevel = l->verbosity;
-  l->nix->clear();
-  if (v.DoErrorOutput(verbosityLevel)) {
-    switch(v.Verbosity) {
-      case 0:
-        cerr << "CRITICAL: ";
-        break;
-      case 1:
-        cerr << "ERROR: ";
-        break;
-      case 2:
-      default:
-        cerr << "WARNING: ";
-        break;
-    }
-    v.print(cerr);
-    return cerr;
-  } else
-    return *l->nix;
-};
-
-
Index: c/errorlogger.hpp
===================================================================
--- src/errorlogger.hpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ 	(revision )
@@ -1,39 +1,0 @@
-/*
- * errorLogger.hpp
- *
- *  Created on: Oct 19, 2009
- *      Author: metzler
- */
-
-#ifndef ERRORLOGGER_HPP_
-#define ERRORLOGGER_HPP_
-
-#include <iostream>
-
-#include "Patterns/Singleton.hpp"
-
-using namespace std;
-
-class Verbose;
-
-class errorLogger : public Singleton<errorLogger>{
-  friend class Singleton<errorLogger>;
-public :
-  static ostream *nix;
-  static int verbosity;
-
-  static bool DoOutput();
-  static void setVerbosity(int verbosityLevel);
-
-protected:
-  /** Do not call this constructor directly, use getInstance() instead. */
-  errorLogger();
-  /** Do not call this destructor directly, use purgeInstance() instead. */
-  ~errorLogger();
-
-};
-
-ostream& operator<<(class errorLogger&l, const Verbose& ost);
-ostream& operator<<(class errorLogger*l, const Verbose& ost);
-
-#endif /* ERRORLOGGER_HPP_ */
Index: src/graph.cpp
===================================================================
--- src/graph.cpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/graph.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -4,4 +4,9 @@
  *
  */
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
 
 #include "Helpers/MemDebug.hpp"
@@ -13,5 +18,6 @@
 #include "config.hpp"
 #include "graph.hpp"
-#include "log.hpp"
+#include "Helpers/Verbose.hpp"
+#include "Helpers/Log.hpp"
 #include "molecule.hpp"
 
Index: src/graph.hpp
===================================================================
--- src/graph.hpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/graph.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -27,5 +27,4 @@
 class molecule;
 
-class Graph;
 class SubGraph;
 class Node;
@@ -34,22 +33,24 @@
 /********************************************** definitions *********************************/
 
-#define NodeMap pair < int, class Node* >
-#define EdgeMap multimap < class Node*, class Edge* >
+typedef std::pair < int, class Node* > NodeMap;
+typedef std::multimap < class Node*, class Edge* > EdgeMap;
 
-#define KeyStack deque<int>
-#define KeySet set<int>
-#define NumberValuePair pair<int, double>
-#define Graph map <KeySet, NumberValuePair, KeyCompare >
-#define GraphPair pair <KeySet, NumberValuePair >
-#define KeySetTestPair pair<KeySet::iterator, bool>
-#define GraphTestPair pair<Graph::iterator, bool>
+typedef std::deque<int> KeyStack;
+typedef std::set<int> KeySet;
+typedef std::pair<int, double> NumberValuePair;
 
-
-/******************************** Some small functions and/or structures **********************************/
-
+// needed for definition of Graph and GraphTestPair
 struct KeyCompare
 {
   bool operator() (const KeySet SubgraphA, const KeySet SubgraphB) const;
 };
+
+typedef std::map <KeySet, NumberValuePair, KeyCompare > Graph;
+typedef std::pair <KeySet, NumberValuePair > GraphPair;
+typedef std::pair<KeySet::iterator, bool> KeySetTestPair;
+typedef std::pair<Graph::iterator, bool> GraphTestPair;
+
+
+/******************************** Some small functions and/or structures **********************************/
 
 //bool operator < (KeySet SubgraphA, KeySet SubgraphB);   //note: this declaration is important, otherwise normal < is used (producing wrong order)
Index: c/gslmatrix.cpp
===================================================================
--- src/gslmatrix.cpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ 	(revision )
@@ -1,248 +1,0 @@
-/*
- * gslmatrix.cpp
- *
- *  Created on: Jan 8, 2010
- *      Author: heber
- */
-
-#include "Helpers/MemDebug.hpp"
-
-using namespace std;
-
-#include "gslmatrix.hpp"
-#include "helpers.hpp"
-#include "Helpers/fast_functions.hpp"
-
-#include <cassert>
-#include <gsl/gsl_linalg.h>
-
-/** Constructor of class GSLMatrix.
- * Allocates GSL structures
- * \param m dimension of matrix
- */
-GSLMatrix::GSLMatrix(size_t m, size_t n) : rows(m), columns(n)
-{
-  matrix = gsl_matrix_calloc(rows, columns);
-};
-
-/** Copy constructor of class GSLMatrix.
- * Allocates GSL structures and copies components from \a *src.
- * \param *src source matrix
- */
-GSLMatrix::GSLMatrix(const GSLMatrix * const src) : rows(src->rows), columns(src->columns)
-{
-  matrix = gsl_matrix_alloc(rows, columns);
-  gsl_matrix_memcpy (matrix, src->matrix);
-};
-
-/** Destructor of class GSLMatrix.
- * Frees GSL structures
- */
-GSLMatrix::~GSLMatrix()
-{
-  gsl_matrix_free(matrix);
-  rows = 0;
-  columns = 0;
-};
-
-/** Assignment operator.
- * \param &rhs right hand side
- * \return object itself
- */
-GSLMatrix& GSLMatrix::operator=(const GSLMatrix& rhs)
-{
-  if (this == &rhs)   // not necessary here, but identity assignment check is generally a good idea
-    return *this;
-  assert(rows == rhs.rows && columns == rhs.columns && "Number of rows and columns do not match!");
-
-  gsl_matrix_memcpy (matrix, rhs.matrix);
-
-  return *this;
-};
-
-/* ============================ Accessing =============================== */
-/** This function sets the matrix from a double array.
- * Creates a matrix view of the array and performs a memcopy.
- * \param *x array of values (no dimension check is performed)
- */
-void GSLMatrix::SetFromDoubleArray(double * x)
-{
-  gsl_matrix_view m = gsl_matrix_view_array (x, rows, columns);
-  gsl_matrix_memcpy (matrix, &m.matrix);
-};
-
-/** This function returns the i-th element of a matrix.
- * If \a m or \a n lies outside the allowed range of 0 to GSLMatrix::dimension-1 then the error handler is invoked and 0 is returned.
- * \param m row index
- * \param n colum index
- * \return (m,n)-th element of matrix
- */
-double GSLMatrix::Get(size_t m, size_t n)
-{
-  return gsl_matrix_get (matrix, m, n);
-};
-
-/** This function sets the value of the \a m -th element of a matrix to \a x.
- *  If \a m or \a n lies outside the allowed range of 0 to GSLMatrix::dimension-1 then the error handler is invoked.
- * \param m row index
- * \param m column index
- * \param x value to set element (m,n) to
- */
-void GSLMatrix::Set(size_t m, size_t n, double x)
-{
-  gsl_matrix_set (matrix, m, n, x);
-};
-
-/** These functions return a pointer to the \a m-th element of a matrix.
- *  If \a m or \a n lies outside the allowed range of 0 to GSLMatrix::dimension-1 then the error handler is invoked and a null pointer is returned.
- * \param m index
- * \return pointer to \a m-th element
- */
-double *GSLMatrix::Pointer(size_t m, size_t n)
-{
-  return gsl_matrix_ptr (matrix, m, n);
-};
-
-/** These functions return a constant pointer to the \a m-th element of a matrix.
- *  If \a m or \a n lies outside the allowed range of 0 to GSLMatrix::dimension-1 then the error handler is invoked and a null pointer is returned.
- * \param m index
- * \return const pointer to \a m-th element
- */
-const double *GSLMatrix::const_Pointer(size_t m, size_t n)
-{
-  return gsl_matrix_const_ptr (matrix, m, n);
-};
-
-/* ========================== Initializing =============================== */
-/** This function sets all the elements of the matrix to the value \a x.
- * \param *x
- */
-void GSLMatrix::SetAll(double x)
-{
-  gsl_matrix_set_all (matrix, x);
-};
-
-/** This function sets all the elements of the matrix to zero.
- */
-void GSLMatrix::SetZero()
-{
-  gsl_matrix_set_zero (matrix);
-};
-
-/** This function sets the elements of the matrix to the corresponding elements of the identity matrix, \f$m(i,j) = \delta(i,j)\f$, i.e. a unit diagonal with all off-diagonal elements zero.
- * This applies to both square and rectangular matrices.
- */
-void GSLMatrix::SetIdentity()
-{
-  gsl_matrix_set_identity (matrix);
-};
-
-/* ====================== Exchanging elements ============================ */
-/** This function exchanges the \a i-th and \a j-th row of the matrix in-place.
- * \param i i-th row to swap with ...
- * \param j ... j-th row to swap against
- */
-bool GSLMatrix::SwapRows(size_t i, size_t j)
-{
-  return (gsl_matrix_swap_rows (matrix, i, j) == GSL_SUCCESS);
-};
-
-/** This function exchanges the \a i-th and \a j-th column of the matrix in-place.
- * \param i i-th column to swap with ...
- * \param j ... j-th column to swap against
- */
-bool GSLMatrix::SwapColumns(size_t i, size_t j)
-{
-  return (gsl_matrix_swap_columns (matrix, i, j) == GSL_SUCCESS);
-};
-
-/** This function exchanges the \a i-th row and \a j-th column of the matrix in-place.
- * The matrix must be square for this operation to be possible.
- * \param i i-th row to swap with ...
- * \param j ... j-th column to swap against
- */
-bool GSLMatrix::SwapRowColumn(size_t i, size_t j)
-{
-  assert (rows == columns && "The matrix must be square for swapping row against column to be possible.");
-  return (gsl_matrix_swap_rowcol (matrix, i, j) == GSL_SUCCESS);
-};
-
-/** This function transposes the matrix.
- * Note that the function is extended to the non-square case, where the matrix is re-allocated and copied.
- */
-bool GSLMatrix::Transpose()
-{
-  if (rows == columns)// if square, use GSL
-    return (gsl_matrix_transpose (matrix) == GSL_SUCCESS);
-  else { // otherwise we have to copy a bit
-    gsl_matrix *dest = gsl_matrix_alloc(columns, rows);
-    for (size_t i=0;i<rows; i++)
-      for (size_t j=0;j<columns;j++) {
-        gsl_matrix_set(dest, j,i, gsl_matrix_get(matrix, i,j) );
-      }
-    gsl_matrix_free(matrix);
-    matrix = dest;
-    flip(rows, columns);
-    return true;
-  }
-};
-
-/* ============================ Properties ============================== */
-/** Checks whether matrix' elements are strictly null.
- * \return true - is null, false - else
- */
-bool GSLMatrix::IsNull()
-{
-  return gsl_matrix_isnull (matrix);
-};
-
-/** Checks whether matrix' elements are strictly positive.
- * \return true - is positive, false - else
- */
-bool GSLMatrix::IsPositive()
-{
-  return gsl_matrix_ispos (matrix);
-};
-
-/** Checks whether matrix' elements are strictly negative.
- * \return true - is negative, false - else
- */
-bool GSLMatrix::IsNegative()
-{
-  return gsl_matrix_isneg (matrix);
-};
-
-/** Checks whether matrix' elements are strictly non-negative.
- * \return true - is non-negative, false - else
- */
-bool GSLMatrix::IsNonNegative()
-{
-  return gsl_matrix_isnonneg (matrix);
-};
-
-/** This function performs a Cholesky decomposition to determine whether matrix is positive definite.
- * We check whether GSL returns GSL_EDOM as error, indicating that decomposition failed due to matrix not being positive-definite.
- * \return true - matrix is positive-definite, false - else
- */
-bool GSLMatrix::IsPositiveDefinite()
-{
-  if (rows != columns)  // only possible for square matrices.
-    return false;
-  else
-    return (gsl_linalg_cholesky_decomp (matrix) != GSL_EDOM);
-};
-
-
-/** Calculates the determinant of the matrix.
- * if matrix is square, uses LU decomposition.
- */
-double GSLMatrix::Determinant()
-{
-  int signum = 0;
-  assert (rows == columns && "Determinant can only be calculated for square matrices.");
-  gsl_permutation *p = gsl_permutation_alloc(rows);
-  gsl_linalg_LU_decomp(matrix, p, &signum);
-  gsl_permutation_free(p);
-  return gsl_linalg_LU_det(matrix, signum); 
-};
-
Index: c/gslmatrix.hpp
===================================================================
--- src/gslmatrix.hpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ 	(revision )
@@ -1,70 +1,0 @@
-/*
- * gslmatrix.hpp
- *
- *  Created on: Jan 8, 2010
- *      Author: heber
- */
-
-#ifndef GSLMATRIX_HPP_
-#define GSLMATRIX_HPP_
-
-using namespace std;
-
-/*********************************************** includes ***********************************/
-
-// include config.h
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <gsl/gsl_matrix.h>
-
-/****************************************** forward declarations *****************************/
-
-class GSLMatrix;
-
-/********************************************** declarations *******************************/
-
-class GSLMatrix {
-  friend class LinearSystemOfEquations;
-
-public:
-  GSLMatrix(size_t m, size_t n);
-  GSLMatrix(const GSLMatrix * const src);
-  ~GSLMatrix();
-
-  // Accessing
-  void SetFromDoubleArray(double * x);
-  double Get(size_t m, size_t n);
-  void Set(size_t m, size_t n, double x);
-  double *Pointer(size_t m, size_t n);
-  const double *const_Pointer(size_t m, size_t n);
-
-  // Initializing
-  void SetAll(double x);
-  void SetZero();
-  void SetIdentity();
-
-  // Exchanging elements
-  bool SwapRows(size_t i, size_t j);
-  bool SwapColumns(size_t i, size_t j);
-  bool SwapRowColumn(size_t i, size_t j);
-  bool Transpose();
-  bool IsNull();
-  bool IsPositive();
-  bool IsNegative();
-  bool IsNonNegative();
-  bool IsPositiveDefinite();
-  double Determinant();
-
-  GSLMatrix& operator=(const GSLMatrix& rhs);
-
-private:
-  gsl_matrix *matrix;
-
-  size_t rows;
-  size_t columns;
-};
-
-
-#endif /* GSLMATRIX_HPP_ */
Index: c/gslvector.cpp
===================================================================
--- src/gslvector.cpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ 	(revision )
@@ -1,305 +1,0 @@
-/*
- * gslvector.cpp
- *
- *  Created on: Jan 8, 2010
- *      Author: heber
- */
-
-#include "Helpers/MemDebug.hpp"
-
-#include <cassert>
-#include <cmath>
-
-#include "gslvector.hpp"
-#include "defs.hpp"
-#include "vector.hpp"
-
-/** Constructor of class GSLVector.
- * Allocates GSL structures
- * \param m dimension of vector
- */
-GSLVector::GSLVector(size_t m) : dimension(m)
-{
-  vector = gsl_vector_calloc(dimension);
-};
-
-/** Copy constructor of class GSLVector.
- * Allocates GSL structures and copies components from \a *src.
- * \param *src source vector
- */
-GSLVector::GSLVector(const GSLVector * const src) : dimension(src->dimension)
-{
-  vector = gsl_vector_alloc(dimension);
-  gsl_vector_memcpy (vector, src->vector);
-};
-
-/** Copy constructor of class GSLVector.
- * Allocates GSL structures and copies components from \a *src.
- * \param *src source vector
- */
-GSLVector::GSLVector(const GSLVector & src) : dimension(src.dimension)
-{
-  vector = gsl_vector_alloc(dimension);
-  gsl_vector_memcpy (vector, src.vector);
-};
-
-/** Destructor of class GSLVector.
- * Frees GSL structures
- */
-GSLVector::~GSLVector()
-{
-  gsl_vector_free(vector);
-};
-
-/* ============================ Accessing =============================== */
-/** This function sets the vector from a double array.
- * Creates a vector view of the array and performs a memcopy.
- * \param *x array of values (no dimension check is performed)
- */
-void GSLVector::SetFromDoubleArray(double * x)
-{
-  gsl_vector_view m = gsl_vector_view_array (x, dimension);
-  gsl_vector_memcpy (vector, &m.vector);
-};
-
-/**
- * This function sets the GSLvector from an ordinary vector.
- *
- * Takes access to the internal gsl_vector and copies it
- */
-void GSLVector::SetFromVector(Vector &v){
-  gsl_vector_memcpy (vector, v.get());
-}
-
-/** This function returns the i-th element of a vector.
- * If \a m lies outside the allowed range of 0 to GSLVector::dimension-1 then the error handler is invoked and 0 is returned.
- * \param m m-th element
- * \return  m-th element of vector
- */
-double GSLVector::Get(size_t m) const
-{
-  return gsl_vector_get (vector, m);
-};
-
-/** This function sets the value of the \a m -th element of a vector to \a x.
- *  If \a m lies outside the allowed range of 0 to GSLVector::dimension-1 then the error handler is invoked.
- * \param m-th element to set
- * \param x value to set to
- */
-void GSLVector::Set(size_t m, double x)
-{
-  gsl_vector_set (vector, m, x);
-};
-
-/** These functions return a pointer to the \a m-th element of a vector.
- *  If \a m lies outside the allowed range of 0 to GSLVector::dimension-1 then the error handler is invoked and a null pointer is returned.
- * \param m m-th element
- * \return pointer to \a m-th element
- */
-double *GSLVector::Pointer(size_t m) const
-{
-  return gsl_vector_ptr (vector, m);
-};
-
-/** These functions return a constant pointer to the \a m-th element of a vector.
- *  If \a m lies outside the allowed range of 0 to GSLVector::dimension-1 then the error handler is invoked and a null pointer is returned.
- * \param m m-th element
- * \return const pointer to \a m-th element
- */
-const double *GSLVector::const_Pointer(size_t m) const
-{
-  return gsl_vector_const_ptr (vector, m);
-};
-
-/** Returns the dimension of the vector.
- * \return dimension of vector
- */
-#ifdef HAVE_INLINE
-inline
-#endif
-size_t GSLVector::GetDimension() const
-{
-  return dimension;
-};
-
-/* ========================== Initializing =============================== */
-/** This function sets all the elements of the vector to the value \a x.
- * \param *x
- */
-void GSLVector::SetAll(double x)
-{
-  gsl_vector_set_all (vector, x);
-};
-
-/** This function sets all the elements of the vector to zero.
- */
-void GSLVector::SetZero()
-{
-  gsl_vector_set_zero (vector);
-};
-
-/** This function makes a basis vector by setting all the elements of the vector to zero except for the i-th element which is set to one.
- * \param i i-th component to set to unity (all other to zero)
- * \return vector set
- */
-int GSLVector::SetBasis(size_t i)
-{
-  return gsl_vector_set_basis (vector, i);
-};
-
-/* ====================== Exchanging elements ============================ */
-/** This function exchanges the \a i-th and \a j-th elements of the vector in-place.
- * \param i i-th element to swap with ...
- * \param j ... j-th element to swap against
- */
-int GSLVector::SwapElements(size_t i, size_t j)
-{
-  return gsl_vector_swap_elements (vector, i, j);
-};
-
-/** This function reverses the order of the elements of the vector.
- */
-int GSLVector::Reverse()
-{
-  return gsl_vector_reverse (vector);
-};
-
-
-/* ========================== Operators =============================== */
-/** Compares GSLVector \a to GSLVector \a b component-wise.
- * \param a base GSLVector
- * \param b GSLVector components to add
- * \return a == b
- */
-bool operator==(const GSLVector& a, const GSLVector& b)
-{
-  bool status = true;
-  assert(a.GetDimension() == b.GetDimension() && "Dimenions of GSLVectors to compare differ");
-  for (size_t i=0;i<a.GetDimension();i++)
-    status = status && (fabs(a.Get(i) - b.Get(i)) < MYEPSILON);
-  return status;
-};
-
-/** Sums GSLVector \a to this lhs component-wise.
- * \param a base GSLVector
- * \param b GSLVector components to add
- * \return lhs + a
- */
-const GSLVector& operator+=(GSLVector& a, const GSLVector& b)
-{
-  assert(a.GetDimension() == b.GetDimension() && "Dimenions of GSLVectors to compare differ");
-  for (size_t i=0;i<a.GetDimension();i++)
-    a.Set(i,a.Get(i)+b.Get(i));
-  return a;
-};
-
-/** Subtracts GSLVector \a from this lhs component-wise.
- * \param a base GSLVector
- * \param b GSLVector components to add
- * \return lhs - a
- */
-const GSLVector& operator-=(GSLVector& a, const GSLVector& b)
-{
-  assert(a.GetDimension() == b.GetDimension() && "Dimenions of GSLVectors to compare differ");
-  for (size_t i=0;i<a.GetDimension();i++)
-    a.Set(i,a.Get(i)-b.Get(i));
-  return a;
-};
-
-/** factor each component of \a a times a double \a m.
- * \param a base GSLVector
- * \param m factor
- * \return lhs.Get(i) * m
- */
-const GSLVector& operator*=(GSLVector& a, const double m)
-{
-  for (size_t i=0;i<a.GetDimension();i++)
-    a.Set(i,a.Get(i)*m);
-  return a;
-};
-
-/** Sums two GSLVectors \a  and \b component-wise.
- * \param a first GSLVector
- * \param b second GSLVector
- * \return a + b
- */
-GSLVector const operator+(const GSLVector& a, const GSLVector& b)
-{
-  GSLVector x(a);
-  for (size_t i=0;i<a.GetDimension();i++)
-    x.Set(i,a.Get(i)+b.Get(i));
-  return x;
-};
-
-/** Subtracts GSLVector \a from \b component-wise.
- * \param a first GSLVector
- * \param b second GSLVector
- * \return a - b
- */
-GSLVector const operator-(const GSLVector& a, const GSLVector& b)
-{
-  assert(a.GetDimension() == b.GetDimension() && "Dimenions of GSLVectors to compare differ");
-  GSLVector x(a);
-  for (size_t i=0;i<a.GetDimension();i++)
-    x.Set(i,a.Get(i)-b.Get(i));
-  return x;
-};
-
-/** Factors given GSLVector \a a times \a m.
- * \param a GSLVector
- * \param m factor
- * \return m * a
- */
-GSLVector const operator*(const GSLVector& a, const double m)
-{
-  GSLVector x(a);
-  for (size_t i=0;i<a.GetDimension();i++)
-    x.Set(i,a.Get(i)*m);
-  return x;
-};
-
-/** Factors given GSLVector \a a times \a m.
- * \param m factor
- * \param a GSLVector
- * \return m * a
- */
-GSLVector const operator*(const double m, const GSLVector& a )
-{
-  GSLVector x(a);
-  for (size_t i=0;i<a.GetDimension();i++)
-    x.Set(i,a.Get(i)*m);
-  return x;
-};
-
-ostream& operator<<(ostream& ost, const GSLVector& m)
-{
-  ost << "(";
-  for (size_t i=0;i<m.GetDimension();i++) {
-    ost << m.Get(i);
-    if (i != 2)
-      ost << ",";
-  }
-  ost << ")";
-  return ost;
-};
-
-/* ====================== Checking State ============================ */
-/** Checks whether vector has all components zero.
- * @return true - vector is zero, false - vector is not
- */
-bool GSLVector::IsZero() const
-{
-  return (fabs(Get(0))+fabs(Get(1))+fabs(Get(2)) < MYEPSILON);
-};
-
-/** Checks whether vector has length of 1.
- * @return true - vector is normalized, false - vector is not
- */
-bool GSLVector::IsOne() const
-{
-  double NormValue = 0.;
-  for (size_t i=dimension;--i;)
-    NormValue += Get(i)*Get(i);
-  return (fabs(NormValue - 1.) < MYEPSILON);
-};
-
Index: c/gslvector.hpp
===================================================================
--- src/gslvector.hpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ 	(revision )
@@ -1,80 +1,0 @@
-/*
- * gslvector.hpp
- *
- *  Created on: Jan 8, 2010
- *      Author: heber
- */
-
-#ifndef GSLVECTOR_HPP_
-#define GSLVECTOR_HPP_
-
-using namespace std;
-
-/*********************************************** includes ***********************************/
-
-// include config.h
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <iostream>
-#include <gsl/gsl_vector.h>
-
-/****************************************** forward declarations *****************************/
-
-class GSLVector;
-class Vector;
-
-/********************************************** declarations *******************************/
-
-class GSLVector {
-  friend class LinearSystemOfEquations;
-
-public:
-  GSLVector(size_t m);
-  GSLVector(const GSLVector * const src);
-  GSLVector(const GSLVector & src);
-  ~GSLVector();
-
-  // Accessing
-  void SetFromDoubleArray(double *x);
-  void SetFromVector(Vector &v);
-  double Get(size_t m) const;
-  void Set(size_t m, double x);
-  double *Pointer(size_t m) const;
-  const double *const_Pointer(size_t m) const;
-  size_t GetDimension() const;
-
-  // Initializing
-  void SetAll(double x);
-  void SetZero();
-  int SetBasis(size_t m);
-
-  // Exchanging elements
-  int SwapElements(size_t i, size_t j);
-  int Reverse();
-
-  // checking state
-  bool IsZero() const;
-  bool IsOne() const;
-
-private:
-  gsl_vector *vector;
-
-  const size_t dimension;
-};
-
-ostream & operator << (ostream& ost, const GSLVector &m);
-bool operator==(const GSLVector& a, const GSLVector& b);
-const GSLVector& operator+=(GSLVector& a, const GSLVector& b);
-const GSLVector& operator-=(GSLVector& a, const GSLVector& b);
-const GSLVector& operator*=(GSLVector& a, const double m);
-GSLVector const operator*(const GSLVector& a, const double m);
-GSLVector const operator*(const double m, const GSLVector& a);
-GSLVector const operator+(const GSLVector& a, const GSLVector& b);
-GSLVector const operator-(const GSLVector& a, const GSLVector& b);
-
-
-
-
-#endif /* GSLVECTOR_HPP_ */
Index: c/helpers.cpp
===================================================================
--- src/helpers.cpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ 	(revision )
@@ -1,188 +1,0 @@
-/** \file helpers.cpp
- *
- * Implementation of some auxiliary functions for memory dis-/allocation and so on
- */
-
-#include "Helpers/MemDebug.hpp"
-
-#include "helpers.hpp"
-#include "Helpers/fast_functions.hpp"
-#include "log.hpp"
-#include "memoryusageobserver.hpp"
-
-/********************************************** helpful functions *********************************/
-
-
-/** Asks for a double value and checks input
- * \param *text question
- */
-double ask_value(const char *text)
-{
-  double test = 0.1439851348959832147598734598273456723948652983045928346598365;
-  do {
-    DoLog(0) && (Log() << Verbose(0) << text);
-    cin >> test;
-  } while (test == 0.1439851348959832147598734598273456723948652983045928346598365);
-  return test;
-};
-
-/** Output of a debug message to stderr.
- * \param *P Problem at hand, points to ParallelSimulationData#me
- * \param output output string
- */
-#ifdef HAVE_DEBUG
-void debug_in(const char *output, const char *file, const int line) {
-  if (output) fprintf(stderr,"DEBUG: in %s at line %i: %s\n", file, line, output);
-}
-#else
-void debug_in(const char *output, const char *file, const int line) {}  // print nothing
-#endif
-
-/** modulo operator for doubles.
- * \param *b pointer to double
- * \param lower_bound lower bound
- * \param upper_bound upper bound
- */
-void bound(double *b, double lower_bound, double upper_bound)
-{
-  double step = (upper_bound - lower_bound);
-  while (*b >= upper_bound)
-    *b -= step;
-  while (*b < lower_bound)
-    *b += step;
-};
-
-/** Counts lines in file.
- * Note we are scanning lines from current position, not from beginning.
- * \param InputFile file to be scanned.
- */
-int CountLinesinFile(ifstream &InputFile)
-{
-  char *buffer = new char[MAXSTRINGSIZE];
-  int lines=0;
-
-  int PositionMarker = InputFile.tellg();  // not needed as Inputfile is copied, given by value, not by ref
-  // count the number of lines, i.e. the number of fragments
-  InputFile.getline(buffer, MAXSTRINGSIZE); // skip comment lines
-  InputFile.getline(buffer, MAXSTRINGSIZE);
-  while(!InputFile.eof()) {
-    InputFile.getline(buffer, MAXSTRINGSIZE);
-    lines++;
-  }
-  InputFile.seekg(PositionMarker, ios::beg);
-  delete[](buffer);
-  return lines;
-};
-
-/** Returns a string with \a i prefixed with 0s to match order of total number of molecules in digits.
- * \param FragmentNumber total number of fragments to determine necessary number of digits
- * \param digits number to create with 0 prefixed
- * \return allocated(!) char array with number in digits, ten base.
- */
-char *FixedDigitNumber(const int FragmentNumber, const int digits)
-{
-  char *returnstring;
-  int number = FragmentNumber;
-  int order = 0;
-  while (number != 0) { // determine number of digits needed
-    number = (int)floor(((double)number / 10.));
-    order++;
-    //Log() << Verbose(0) << "Number is " << number << ", order is " << order << "." << endl;
-  }
-  // allocate string
-  returnstring = new char[order + 2];
-  // terminate  and fill string array from end backward
-  returnstring[order] = '\0';
-  number = digits;
-  for (int i=order;i--;) {
-    returnstring[i] = '0' + (char)(number % 10);
-    number = (int)floor(((double)number / 10.));
-  }
-  //Log() << Verbose(0) << returnstring << endl;
-  return returnstring;
-};
-
-/** Tests whether a given string contains a valid number or not.
- * \param *string
- * \return true - is a number, false - is not a valid number
- */
-bool IsValidNumber( const char *string)
-{
-  int ptr = 0;
-  if ((string[ptr] == '.') || (string[ptr] == '-')) // number may be negative or start with dot
-    ptr++;
-  if ((string[ptr] >= '0') && (string[ptr] <= '9'))
-    return true;
-  return false;
-};
-
-/** Blows the 6-dimensional \a cell_size array up to a full NDIM by NDIM matrix.
- * \param *symm 6-dim array of unique symmetric matrix components
- * \return allocated NDIM*NDIM array with the symmetric matrix
- */
-double * ReturnFullMatrixforSymmetric(const double * const symm)
-{
-  double *matrix = new double[NDIM * NDIM];
-  matrix[0] = symm[0];
-  matrix[1] = symm[1];
-  matrix[2] = symm[3];
-  matrix[3] = symm[1];
-  matrix[4] = symm[2];
-  matrix[5] = symm[4];
-  matrix[6] = symm[3];
-  matrix[7] = symm[4];
-  matrix[8] = symm[5];
-  return matrix;
-};
-
-/** Calculate the inverse of a 3x3 matrix.
- * \param *matrix NDIM_NDIM array
- */
-double * InverseMatrix( const double * const A)
-{
-  double *B = new double[NDIM * NDIM];
-  double detA = RDET3(A);
-  double detAReci;
-
-  for (int i=0;i<NDIM*NDIM;++i)
-    B[i] = 0.;
-  // calculate the inverse B
-  if (fabs(detA) > MYEPSILON) {;  // RDET3(A) yields precisely zero if A irregular
-    detAReci = 1./detA;
-    B[0] =  detAReci*RDET2(A[4],A[5],A[7],A[8]);    // A_11
-    B[1] = -detAReci*RDET2(A[1],A[2],A[7],A[8]);    // A_12
-    B[2] =  detAReci*RDET2(A[1],A[2],A[4],A[5]);    // A_13
-    B[3] = -detAReci*RDET2(A[3],A[5],A[6],A[8]);    // A_21
-    B[4] =  detAReci*RDET2(A[0],A[2],A[6],A[8]);    // A_22
-    B[5] = -detAReci*RDET2(A[0],A[2],A[3],A[5]);    // A_23
-    B[6] =  detAReci*RDET2(A[3],A[4],A[6],A[7]);    // A_31
-    B[7] = -detAReci*RDET2(A[0],A[1],A[6],A[7]);    // A_32
-    B[8] =  detAReci*RDET2(A[0],A[1],A[3],A[4]);    // A_33
-  }
-  return B;
-};
-
-
-
-/** Comparison function for GSL heapsort on distances in two molecules.
- * \param *a
- * \param *b
- * \return <0, \a *a less than \a *b, ==0 if equal, >0 \a *a greater than \a *b
- */
-int CompareDoubles (const void * a, const void * b)
-{
-  if (*(double *)a > *(double *)b)
-    return -1;
-  else if (*(double *)a < *(double *)b)
-    return 1;
-  else
-    return 0;
-};
-
-
-/**
- * Calls exit(255).
- */
-void performCriticalExit() {
-  exit(255);
-}
Index: c/helpers.hpp
===================================================================
--- src/helpers.hpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ 	(revision )
@@ -1,199 +1,0 @@
-/** \file helpers.hpp
- *
- * Declaration of some auxiliary functions for memory dis-/allocation and so on
- */
-
-#ifndef HELPERS_HPP_
-#define HELPERS_HPP_
-
-using namespace std;
-
-/*********************************************** includes ***********************************/
-
-// include config.h
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <fstream>
-
-#include "defs.hpp"
-#include "log.hpp"
-#include "memoryallocator.hpp"
-
-/********************************************** definitions *********************************/
-
-/********************************************** helpful functions *********************************/
-
-// taken out of TREMOLO
-/*@-namechecks@*/
-#ifndef __GNUC__
-# undef __attribute__
-# define __attribute__(x)
-#endif
-/*@=namechecks@*/
-
-/* Behandelt aufgetretene Fehler. error ist der Fehlertyp(enum Errors)
-   void *SpecialData ist ein untypisierter Zeiger auf Spezielle Daten zur Fehlerbehandlung.
-   Man koennte auch noch einen Zeiger auf eine Funktion uebergeben */
-extern void /*@exits@*/ debug(const char *output);
-  //__attribute__ ((__return__));
-#define debug(data) debug_in((data), __FILE__, __LINE__)
-
-extern void /*@exits@*/ debug_in(const char *output,
-    const char *file, const int line);
-  //__attribute__ ((__return__));
-
-double ask_value(const char *text);
-bool check_bounds(double *x, double *cell_size);
-void bound(double *b, double lower_bound, double upper_bound);
-int CountLinesinFile(ifstream &InputFile);
-char *FixedDigitNumber(const int FragmentNumber, const int digits);
-bool IsValidNumber( const char *string);
-int CompareDoubles (const void * a, const void * b);
-double * ReturnFullMatrixforSymmetric(const double * const cell_size);
-double * InverseMatrix(const double * const A);
-void performCriticalExit();
-
-/********************************************** helpful template functions *********************************/
-
-
-/** returns greater of the two values.
- * \param x first value
- * \param y second value
- * \return greater of the two (by operator>())
- */
-template <typename T> T Max(T x, T y)
-{
-  if (x > y)
-    return x;
-  else return y;
-};
-
-/** returns smaller of the two values.
- * \param x first value
- * \param y second value
- * \return smaller of the two (by operator<())
- */
-template <typename T> T Min(T x, T y)
-{
-  if (x < y)
-    return x;
-  else return y;
-};
-
-/** Creates a lookup table for true father's Atom::Nr -> atom ptr.
- * \param *start begin of chain list
- * \paran *end end of chain list
- * \param **Lookuptable pointer to return allocated lookup table (should be NULL on start)
- * \param count optional predetermined size for table (otherwise we set the count to highest true father id)
- * \return true - success, false - failure
- */
-template <typename T> bool CreateFatherLookupTable(T *start, T *end, T **&LookupTable, int count = 0)
-{
-  bool status = true;
-  T *Walker = NULL;
-  int AtomNo;
-
-  if (LookupTable != NULL) {
-    DoeLog(0) && (eLog() << Verbose(0) << "Pointer for Lookup table is not NULL! Aborting ..." <<endl);
-    return false;
-  }
-
-  // count them
-  if (count == 0) {
-    Walker = start;
-    while (Walker->next != end) { // create a lookup table (Atom::nr -> atom) used as a marker table lateron
-      Walker = Walker->next;
-      count = (count < Walker->GetTrueFather()->nr) ? Walker->GetTrueFather()->nr : count;
-    }
-  }
-  if (count <= 0) {
-    DoeLog(1) && (eLog() << Verbose(1) << "Count of lookup list is 0 or less." << endl);
-    return false;
-  }
-
-  // allocate and fill
-  LookupTable = new T*[count];
-  if (LookupTable == NULL) {
-    DoeLog(0) && (eLog()<< Verbose(0) << "LookupTable memory allocation failed!" << endl);
-    performCriticalExit();
-    status = false;
-  } else {
-    Walker = start;
-    while (Walker->next != end) { // create a lookup table (Atom::nr -> atom) used as a marker table lateron
-      Walker = Walker->next;
-      AtomNo = Walker->GetTrueFather()->nr;
-      if ((AtomNo >= 0) && (AtomNo < count)) {
-        //*out << "Setting LookupTable[" << AtomNo << "] to " << *Walker << endl;
-        LookupTable[AtomNo] = Walker;
-      } else {
-        DoeLog(2) && (eLog() << Verbose(2) << "Walker " << *Walker << " exceeded range of nuclear ids [0, " << count << ")." << endl);
-        status = false;
-        break;
-      }
-    }
-  }
-
-  return status;
-};
-
-
-/** Frees a two-dimensional array.
- * \param *ptr pointer to array
- * \param dim first dim of array
- */
-template <typename X> void Free2DArray(X **ptr, int dim)
-{
-  int i;
-  if (ptr != NULL) {
-    for(i=dim;i--;)
-      if (ptr[i] != NULL)
-        free(ptr[i]);
-    free(ptr);
-  }
-};
-
-template <typename T> void Increment(T *value, T *inc)
-{
-  *value += *inc;
-};
-
-template <typename T> void AbsoluteValue(T *value, T *abs)
-{
-  *value = *abs;
-};
-
-template <typename T> void IncrementalAbsoluteValue(T *value, T *abs)
-{
-  *value = *abs;
-  (*abs) += 1;
-};
-
-#define PLURAL_S(v) (((v)==1)?"":"s")
-
-// this is to allow different modes of access for
-// maps and sets
-template<typename Res,typename T>
-struct _take{
-  Res get(T value) const;
-};
-
-// if we have a set,vector etc we can directly access the result
-template<typename Res>
-struct _take<Res,Res>{
-  static inline Res get(Res value){
-    return value;
-  }
-};
-
-// if we have a map we have to access the second part of
-// the pair
-template<typename Res,typename T1>
-struct _take<Res,std::pair<T1,Res> >{
-  static inline Res get(std::pair<T1,Res> value){
-    return value.second;
-  }
-};
-
-#endif /*HELPERS_HPP_*/
Index: c/info.cpp
===================================================================
--- src/info.cpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ 	(revision )
@@ -1,43 +1,0 @@
-/*
- * Info.cpp
- *
- *  Created on: Nov 25, 2009
- *      Author: heber
- */
-
-#include "Helpers/MemDebug.hpp"
-
-#include "info.hpp"
-#include "log.hpp"
-#include "verbose.hpp"
-
-int Info::verbosity = 0;
-
-/**
- * Constructor. Do not use this function. Use getInstance() instead.
- *
- * \return Info instance
- */
-Info::Info(const char *msg)
-{
-  verbosity++;
-  FunctionName = msg;
-  DoLog(0) && (Log() << Verbose(0) << "Begin of " << FunctionName << endl);
-};
-
-/**
- * Destructor. Better use purgeInstance().
- */
-Info::~Info() {
-  DoLog(0) && (Log() << Verbose(0) << "End of " << FunctionName << endl);
-  verbosity--;
-}
-
-/**
- * Sets the verbosity.
- *
- * \param verbosityLevel verbosity
- */
-void Info::setVerbosity(int verbosityLevel) {
-  verbosity = verbosityLevel;
-}
Index: c/info.hpp
===================================================================
--- src/info.hpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ 	(revision )
@@ -1,30 +1,0 @@
-/*
- * Info.hpp
- *
- *  Created on: Nov 25, 2009
- *      Author: heber
- */
-
-#ifndef INFO_HPP_
-#define INFO_HPP_
-
-using namespace std;
-
-/*********************************************** includes ***********************************/
-
-/****************************************** forward declarations *****************************/
-
-/********************************************** definitions *********************************/
-
-class Info {
-public :
-  static int verbosity;
-  const char *FunctionName;
-
-  Info(const char *msg);
-  ~Info();
-  static void setVerbosity(int verbosityLevel);
-
-};
-
-#endif /* INFO_HPP_ */
Index: src/joiner.cpp
===================================================================
--- src/joiner.cpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/joiner.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -8,4 +8,9 @@
 //============================ INCLUDES ===========================
 
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
 #include "Helpers/MemDebug.hpp"
 
@@ -13,8 +18,8 @@
 
 #include "datacreator.hpp"
-#include "helpers.hpp"
-#include "memoryallocator.hpp"
+#include "Helpers/helpers.hpp"
 #include "parser.hpp"
 #include "periodentafel.hpp"
+#include "Helpers/Verbose.hpp"
 
 //============================== MAIN =============================
@@ -209,5 +214,9 @@
   prefix << dir << ForceFragmentSuffix;
   if (!ForceFragments.WriteTotalFragments(argv[1], (prefix.str()).c_str())) return 1;
-  if (!CreateDataFragment(EnergyFragments, KeySet, argv[1], FRAGMENTPREFIX ENERGYPERFRAGMENT, "fragment energy versus the Fragment No", "today", CreateEnergy)) return 1;
+  {
+    std::string fileprefix(FRAGMENTPREFIX);
+    fileprefix += ENERGYPERFRAGMENT;
+    if (!CreateDataFragment(EnergyFragments, KeySet, argv[1], fileprefix.c_str(), "fragment energy versus the Fragment No", "today", CreateEnergy)) return 1;
+  }
   if (!NoHessian) {
     prefix.str(" ");
Index: src/leastsquaremin.cpp
===================================================================
--- src/leastsquaremin.cpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/leastsquaremin.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -6,4 +6,9 @@
  */
 
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
 #include "Helpers/MemDebug.hpp"
 
@@ -11,5 +16,5 @@
 
 #include "leastsquaremin.hpp"
-#include "vector.hpp"
+#include "LinearAlgebra/Vector.hpp"
 
 /** Determines sum of squared distances of \a X to all \a **vectors.
Index: c/linearsystemofequations.cpp
===================================================================
--- src/linearsystemofequations.cpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ 	(revision )
@@ -1,131 +1,0 @@
-/*
- * linearsystemofequations.cpp
- *
- *  Created on: Jan 8, 2010
- *      Author: heber
- */
-
-#include "Helpers/MemDebug.hpp"
-
-#include "defs.hpp"
-#include "gslmatrix.hpp"
-#include "gslvector.hpp"
-#include "linearsystemofequations.hpp"
-#include "logger.hpp"
-#include "vector.hpp"
-
-#include <cassert>
-#include <gsl/gsl_permutation.h>
-
-/** Constructor for class LinearSystemOfEquations.
- * Allocates Vector and Matrix classes.
- * \param m column dimension
- * \param n row dimension
- */
-LinearSystemOfEquations::LinearSystemOfEquations(int m, int n) : rows(m), columns(n), IsSymmetric(false)
-{
-  A = new GSLMatrix(m, n);
-  b = new GSLVector(m);
-  x = new GSLVector(n);
-};
-
-/** Destructor for class LinearSystemOfEquations.
- * Destructs Vector and Matrix classes.
- */
-LinearSystemOfEquations::~LinearSystemOfEquations()
-{
-  delete(A);
-  delete(b);
-  delete(x);
-};
-
-/** Sets whether matrix is to be regarded as symmetric.
- * Note that we do not check whether it really is, just take upper diagonal.
- * \param symmetric true or false
- */
-bool LinearSystemOfEquations::SetSymmetric(bool symmetric)
-{
-  assert (rows == columns && "Rows and columns don't have equal size! Setting symmetric not possible.");
-  return (IsSymmetric = symmetric);
-};
-
-/** Initializes vector b to the components of the given vector.
- * \param *x Vector with equal dimension (no check!)
- */
-void LinearSystemOfEquations::Setb(Vector *x)
-{
-  assert ( columns == NDIM && "Vector class is always three-dimensional, unlike this LEqS!");
-  b->SetFromVector(*x);
-};
-
-/** Initializes vector b to the components of the given vector.
- * \param *x array with equal dimension (no check!)
- */
-void LinearSystemOfEquations::Setb(double *x)
-{
-  b->SetFromDoubleArray(x);
-};
-
-/** Initializes matrix a to the components of the given array.
- * note that sort order should be
- * \param *x array with equal dimension (no check!)
- */
-void LinearSystemOfEquations::SetA(double *x)
-{
-  A->SetFromDoubleArray(x);
-};
-
-/** Returns the solution vector x \f$A \cdot x = b\f$ as an array of doubles.
- * \param *array pointer allocated array for solution on return (no bounds check, dimension must match)
- * \return true - solving possible, false - some error occured.
- */
-bool LinearSystemOfEquations::GetSolutionAsArray(double *&array)
-{
-  bool status = Solve();
-
-  // copy solution
-  for (size_t i=0;i<x->dimension;i++) {
-    array[i] = x->Get(i);
-  }
-  return status;
-};
-
-/** Returns the solution vector x \f$A \cdot x = b\f$ as an array of doubles.
- * \param &x solution vector on return (must be 3-dimensional)
- * \return true - solving possible, false - some error occured.
- */
-bool LinearSystemOfEquations::GetSolutionAsVector(Vector &v)
-{
-  assert(rows == NDIM && "Solution can only be returned as vector if number of columns is NDIM.");
-  bool status = Solve();
-
-  // copy solution
-  for (size_t i=0;i<x->dimension;i++)
-    v[i] = x->Get(i);
-  return status;
-};
-
-/** Solves the given system of \f$A \cdot x = b\f$.
- * Use either LU or Householder decomposition.
- * Solution is stored in LinearSystemOfEquations::x
- * \return true - solving possible, false - some error occured.
- */
-bool LinearSystemOfEquations::Solve()
-{
-  // calculate solution
-  int s;
-  if (IsSymmetric) { // use LU
-    gsl_permutation * p = gsl_permutation_alloc (x->dimension);
-    gsl_linalg_LU_decomp (A->matrix, p, &s);
-    gsl_linalg_LU_solve (A->matrix, p, b->vector, x->vector);
-    gsl_permutation_free (p);
-  } else {  // use Householder
-    //GSLMatrix *backup = new GSLMatrix(rows,columns);
-    //*backup = *A;
-    gsl_linalg_HH_solve (A->matrix, b->vector, x->vector);
-    //*A = *backup;
-    //delete(backup);
-  }
-  return true;
-};
-
Index: c/linearsystemofequations.hpp
===================================================================
--- src/linearsystemofequations.hpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ 	(revision )
@@ -1,56 +1,0 @@
-/*
- * linearsystemofequations.hpp
- *
- *  Created on: Jan 8, 2010
- *      Author: heber
- */
-
-using namespace std;
-
-/*********************************************** includes ***********************************/
-
-// include config.h
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <gsl/gsl_linalg.h>
-
-/****************************************** forward declarations *****************************/
-
-class Vector;
-class GSLMatrix;
-class GSLVector;
-
-/********************************************** declarations *******************************/
-
-/** Solver class for a linear system of equations in the form \f$A \cdot x = b\F$.
- *
- */
-class LinearSystemOfEquations {
-public:
-  LinearSystemOfEquations(int n, int m);
-  ~LinearSystemOfEquations();
-
-  // setting
-  void Setb(Vector *x);
-  void Setb(double *x);
-  void SetA(double *x);
-  bool SetSymmetric(bool symmetric);
-
-  // solving
-  bool GetSolutionAsArray(double *&array);
-  bool GetSolutionAsVector(Vector &v);
-
-  GSLVector *b;
-  GSLVector *x;
-  GSLMatrix *A;
-
-private:
-  bool Solve();
-
-  int rows;
-  int columns;
-
-  bool IsSymmetric;
-};
Index: src/linkedcell.cpp
===================================================================
--- src/linkedcell.cpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/linkedcell.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -5,13 +5,19 @@
  */
 
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
 #include "Helpers/MemDebug.hpp"
 
 #include "atom.hpp"
-#include "helpers.hpp"
+#include "Helpers/helpers.hpp"
 #include "linkedcell.hpp"
-#include "log.hpp"
+#include "Helpers/Verbose.hpp"
+#include "Helpers/Log.hpp"
 #include "molecule.hpp"
 #include "tesselation.hpp"
-#include "vector.hpp"
+#include "LinearAlgebra/Vector.hpp"
 
 // ========================================================= class LinkedCell ===========================================
@@ -20,11 +26,11 @@
 /** Constructor for class LinkedCell.
  */
-LinkedCell::LinkedCell()
-{
-  LC = NULL;
+LinkedCell::LinkedCell() :
+  LC(NULL),
+  RADIUS(0.),
+  index(-1)
+{
   for(int i=0;i<NDIM;i++)
     N[i] = 0;
-  index = -1;
-  RADIUS = 0.;
   max.Zero();
   min.Zero();
@@ -35,13 +41,13 @@
  * \param RADIUS edge length of cells
  */
-LinkedCell::LinkedCell(const PointCloud * const set, const double radius)
+LinkedCell::LinkedCell(const PointCloud * const set, const double radius) :
+  LC(NULL),
+  RADIUS(radius),
+  index(-1)
 {
   TesselPoint *Walker = NULL;
 
-  RADIUS = radius;
-  LC = NULL;
   for(int i=0;i<NDIM;i++)
     N[i] = 0;
-  index = -1;
   max.Zero();
   min.Zero();
@@ -55,6 +61,6 @@
   Walker = set->GetPoint();
   for (int i=0;i<NDIM;i++) {
-    max[i] = Walker->node->at(i);
-    min[i] = Walker->node->at(i);
+    max[i] = Walker->at(i);
+    min[i] = Walker->at(i);
   }
   set->GoToFirst();
@@ -62,8 +68,8 @@
     Walker = set->GetPoint();
     for (int i=0;i<NDIM;i++) {
-      if (max[i] < Walker->node->at(i))
-        max[i] = Walker->node->at(i);
-      if (min[i] > Walker->node->at(i))
-        min[i] = Walker->node->at(i);
+      if (max[i] < Walker->at(i))
+        max[i] = Walker->at(i);
+      if (min[i] > Walker->at(i))
+        min[i] = Walker->at(i);
     }
     set->GoToNext();
@@ -95,5 +101,5 @@
     Walker = set->GetPoint();
     for (int i=0;i<NDIM;i++) {
-      n[i] = static_cast<int>(floor((Walker->node->at(i) - min[i])/RADIUS));
+      n[i] = static_cast<int>(floor((Walker->at(i) - min[i])/RADIUS));
     }
     index = n[0] * N[1] * N[2] + n[1] * N[2] + n[2];
@@ -111,12 +117,12 @@
  * \param RADIUS edge length of cells
  */
-LinkedCell::LinkedCell(LinkedNodes *set, const double radius)
+LinkedCell::LinkedCell(LinkedNodes *set, const double radius) :
+  LC(NULL),
+  RADIUS(radius),
+  index(-1)
 {
   class TesselPoint *Walker = NULL;
-  RADIUS = radius;
-  LC = NULL;
   for(int i=0;i<NDIM;i++)
     N[i] = 0;
-  index = -1;
   max.Zero();
   min.Zero();
@@ -129,14 +135,14 @@
   LinkedNodes::iterator Runner = set->begin();
   for (int i=0;i<NDIM;i++) {
-    max[i] = (*Runner)->node->at(i);
-    min[i] = (*Runner)->node->at(i);
+    max[i] = (*Runner)->at(i);
+    min[i] = (*Runner)->at(i);
   }
   for (LinkedNodes::iterator Runner = set->begin(); Runner != set->end(); Runner++) {
     Walker = *Runner;
     for (int i=0;i<NDIM;i++) {
-      if (max[i] < Walker->node->at(i))
-        max[i] = Walker->node->at(i);
-      if (min[i] > Walker->node->at(i))
-        min[i] = Walker->node->at(i);
+      if (max[i] < Walker->at(i))
+        max[i] = Walker->at(i);
+      if (min[i] > Walker->at(i))
+        min[i] = Walker->at(i);
     }
   }
@@ -166,5 +172,5 @@
     Walker = *Runner;
     for (int i=0;i<NDIM;i++) {
-      n[i] = static_cast<int>(floor((Walker->node->at(i) - min[i])/RADIUS));
+      n[i] = static_cast<int>(floor((Walker->at(i) - min[i])/RADIUS));
     }
     index = n[0] * N[1] * N[2] + n[1] * N[2] + n[2];
@@ -247,8 +253,8 @@
  * \return Vector is inside bounding box - true, else - false
  */
-bool LinkedCell::SetIndexToVector(const Vector * const x) const
+bool LinkedCell::SetIndexToVector(const Vector & x) const
 {
   for (int i=0;i<NDIM;i++)
-    n[i] = (int)floor((x->at(i) - min[i])/RADIUS);
+    n[i] = (int)floor((x.at(i) - min[i])/RADIUS);
 
   return CheckBounds();
@@ -263,5 +269,5 @@
   bool status = false;
   for (int i=0;i<NDIM;i++) {
-    n[i] = static_cast<int>(floor((Walker->node->at(i) - min[i])/RADIUS));
+    n[i] = static_cast<int>(floor((Walker->at(i) - min[i])/RADIUS));
   }
   index = n[0] * N[1] * N[2] + n[1] * N[2] + n[2];
@@ -403,5 +409,5 @@
       Walker = *Runner;
       //Log() << Verbose(1) << "Current neighbour is at " << *Walker->node << "." << endl;
-      if ((center->DistanceSquared(*Walker->node) - radiusSquared) < MYEPSILON) {
+      if ((Walker->DistanceSquared(*center) - radiusSquared) < MYEPSILON) {
         TesselList->push_back(Walker);
       }
Index: src/linkedcell.hpp
===================================================================
--- src/linkedcell.hpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/linkedcell.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -24,5 +24,5 @@
 
 #include "defs.hpp"
-#include "vector.hpp"
+#include "LinearAlgebra/Vector.hpp"
 
 /****************************************** forward declarations *****************************/
@@ -60,5 +60,5 @@
     const LinkedCell::LinkedNodes* GetRelativeToCurrentCell(const int relative[NDIM])const ;
     bool SetIndexToNode(const TesselPoint * const Walker)const ;
-    bool SetIndexToVector(const Vector * const x)const ;
+    bool SetIndexToVector(const Vector &x)const ;
     double SetClosestIndexToOutsideVector(const Vector * const x) const;
     bool CheckBounds()const ;
Index: c/log.cpp
===================================================================
--- src/log.cpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ 	(revision )
@@ -1,60 +1,0 @@
-/*
- * log.cpp
- *
- *  Created on: Oct 19, 2009
- *      Author: metzler
- */
-
-#include "Helpers/MemDebug.hpp"
-
-#include "logger.hpp"
-#include "errorlogger.hpp"
-
-/**
- * Sets verbosity for the error logger and the standard logger.
- *
- * \param int verbosity level
- */
-void setVerbosity(int verbosityLevel) {
-  logger::getInstance().setVerbosity(verbosityLevel);
-}
-
-/**
- * Prints a log entry.
- *
- * \param indentation level of the message to log
- */
-class logger& Log() {
-  return logger::getInstance();
-}
-
-/** Checks verbosity for logger.
- * Is supposed to be used in construct as this:
- * DoLog(2) && (Log() << Verbose(2) << "message." << endl);
- * If DoLog does not return true, the right-hand side is not evaluated and we save some time.
- * \param verbose verbosity level of this message
- * \return true - print, false - don't
- */
-bool DoLog(int verbose) {
-  return (verbose <= logger::getInstance().verbosity);
-}
-
-/** Checks verbosity for errorlogger.
- * Is supposed to be used in construct as this:
- * DoLog(2) && (Log() << Verbose(2) << "message." << endl);
- * If DoLog does not return true, the right-hand side is not evaluated and we save some time.
- * \param verbose verbosity level of this message
- * \return true - print, false - don't
- */
-bool DoeLog(int verbose) {
-  return (verbose <= errorLogger::getInstance().verbosity);
-}
-
-/**
- * Prints an error log entry.
- *
- * \param indentation level of the message to log
- */
-class errorLogger & eLog() {
-  return errorLogger::getInstance();
-}
Index: c/log.hpp
===================================================================
--- src/log.hpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ 	(revision )
@@ -1,20 +1,0 @@
-/*
- * log.hpp
- *
- *  Created on: Oct 19, 2009
- *      Author: metzler
- */
-
-#ifndef LOG_HPP_
-#define LOG_HPP_
-
-#include "errorlogger.hpp"
-#include "logger.hpp"
-
-class logger * Log();
-class errorLogger * eLog();
-void setVerbosity(int verbosityLevel);
-bool DoLog(int verbose);
-bool DoeLog(int verbose);
-
-#endif /* LOG_HPP_ */
Index: c/logger.cpp
===================================================================
--- src/logger.cpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ 	(revision )
@@ -1,77 +1,0 @@
-/*
- * logger.cpp
- *
- *  Created on: Oct 19, 2009
- *      Author: metzler
- */
-
-#include "Helpers/MemDebug.hpp"
-
-#include <fstream>
-#include "logger.hpp"
-#include "verbose.hpp"
-#include "Patterns/Singleton_impl.hpp"
-
-ofstream nullStream("/dev/null");
-
-int logger::verbosity = 2;
-ostream* logger::nix = &nullStream;
-
-/**
- * Constructor. Do not use this function. Use getInstance() instead.
- *
- * \return logger instance
- */
-logger::logger()
-{
-  verbosity = 2;
-};
-
-/**
- * Destructor. Better use purgeInstance().
- */
-logger::~logger() {
-  verbosity = 2;
-}
-
-CONSTRUCT_SINGLETON(logger)
-
-/**
- * Sets the verbosity.
- *
- * \param verbosityLevel verbosity
- */
-void logger::setVerbosity(int verbosityLevel) {
-  verbosity = verbosityLevel;
-}
-
-/**
- * Operator for the Binary(arg) call.
- * Constructs temporary a Verbose class object, wherein the Binary is stored.
- * Then << is called, which calls Binary's print which adds the tabs and logs
- * the stream.
- * \param &ost stream to extend
- * \param &m pointer to created Binary object
- * \return &ost
- */
-ostream& operator<<(class logger& l, const Verbose& v)
-{
-  int verbosityLevel = l.verbosity;
-  l.nix->clear();
-  if (v.DoOutput(verbosityLevel)) {
-    v.print(cout);
-    return cout;
-  } else
-    return *l.nix;
-};
-ostream& operator<<(class logger* l, const Verbose& v)
-{
-  int verbosityLevel = l->verbosity;
-  l->nix->clear();
-  if (v.DoOutput(verbosityLevel)) {
-    v.print(cout);
-    return cout;
-  } else
-    return *l->nix;
-};
-
Index: c/logger.hpp
===================================================================
--- src/logger.hpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ 	(revision )
@@ -1,38 +1,0 @@
-/*
- * logger.hpp
- *
- *  Created on: Oct 19, 2009
- *      Author: metzler
- */
-
-#ifndef LOGGER_HPP_
-#define LOGGER_HPP_
-
-#include <iostream>
-
-#include "Patterns/Singleton.hpp"
-
-using namespace std;
-
-class Verbose;
-
-class logger : public Singleton<logger> {
-  friend class Singleton<logger>;
-public :
-  static ostream *nix;
-  static int verbosity;
-
-  static bool DoOutput();
-  static void setVerbosity(int verbosityLevel);
-
-protected:
-  /** Do not call this constructor directly, use getInstance() instead. */
-  logger();
-  /** Do not call this destructor directly, use purgeInstance() instead. */
-  ~logger();
-};
-
-ostream& operator<<(class logger&l, const Verbose& ost);
-ostream& operator<<(class logger*l, const Verbose& ost);
-
-#endif /* LOGGER_HPP_ */
Index: c/memoryallocator.cpp
===================================================================
--- src/memoryallocator.cpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ 	(revision )
@@ -1,38 +1,0 @@
-/*
- * memoryallocator.cpp
- *
- *  Created on: May 31, 2010
- *      Author: heber
- */
-
-#include "Helpers/MemDebug.hpp"
-
-using namespace std;
-
-#include "memoryallocator.hpp"
-
-/** Allocates a memory range using malloc().
- * Prints the provided error message in case of a failure.
- *
- * \param number of memory slices of type X to allocate
- * \param failure message which is printed if the allocation fails
- * \return pointer to the allocated memory range, will be NULL if a failure occurred
- */
-template <> char* Malloc<char>(size_t size, const char* output)
-{
-  char* buffer = NULL;
-  buffer = (char*) malloc(sizeof(char) * (size + 1));
-  for (size_t i = size; i--;)
-    buffer[i] = (i % 2 == 0) ? 'p': 'c';
-  buffer[size] = '\0';
-
-  if (buffer != NULL) {
-    //MemoryUsageObserver::getInstance()->addMemory(buffer, size);
-  } else {
-    Log() << Verbose(0) << "Malloc for datatype " << typeid(char).name()
-      << " failed - pointer is NULL: " << output << endl;
-  }
-
-  return buffer;
-};
-
Index: c/memoryallocator.hpp
===================================================================
--- src/memoryallocator.hpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ 	(revision )
@@ -1,139 +1,0 @@
-/** \file memoryallocator.hpp
- *
- * This file provides wrappers for C++'s memory allocation functions.
- */
-
-#ifndef MEMORYALLOCATOR_HPP_
-#define MEMORYALLOCATOR_HPP_
-
-using namespace std;
-
-/*********************************************** includes ***********************************/
-
-// include config.h
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <cstdlib>
-#include <iostream>
-#include <iomanip>
-#include <fstream>
-#include <sstream>
-#include <math.h>
-#include <string>
-#include <typeinfo>
-
-#include "defs.hpp"
-#include "log.hpp"
-#include "memoryusageobserver.hpp"
-#include "verbose.hpp"
-
-/********************************************** declarations *******************************/
-
-/** Allocates a memory range using malloc().
- * Prints the provided error message in case of a failure.
- *
- * \param number of memory slices of type X to allocate
- * \param failure message which is printed if the allocation fails
- * \return pointer to the allocated memory range, will be NULL if a failure occurred
- */
-template <typename X> X* Malloc(size_t size, const char* output)
-{
-  X* buffer = NULL;
-  buffer = (X*) malloc(sizeof(X) * size);
-
-  if (buffer != NULL) {
-    MemoryUsageObserver::getInstance()->addMemory(buffer, size);
-  } else {
-    Log() << Verbose(0) << "Malloc for datatype " << typeid(X).name()
-      << " failed - pointer is NULL: " << output << endl;
-  }
-
-  return buffer;
-};
-
-/** \see helpers.cpp for Malloc<char> */
-template <> char* Malloc<char>(size_t size, const char* output);
-
-/* Allocates a memory range using calloc().
- * Prints the provided error message in case of a failure.
- *
- * \param number of memory slices of type X to allocate
- * \param failure message which is printed if the allocation fails
- * \return pointer to the allocated memory range, will be NULL if a failure occurred
-*/
-template <typename X> X* Calloc(size_t size, const char* output)
-{
-  X* buffer = NULL;
-  buffer = (X*) calloc(size, sizeof(X));
-
-  if (buffer != NULL) {
-    MemoryUsageObserver::getInstance()->addMemory(buffer, size);
-  } else {
-    Log() << Verbose(0) << "Calloc for datatype " << typeid(X).name()
-      << " failed - pointer is NULL: " << output << endl;
-  }
-
-  return buffer;
-};
-
-
-/** Reallocates a memory range using realloc(). If the provided pointer to the old
- * memory range is NULL, malloc() is called instead.
- * Prints the provided error message in case of a failure (of either malloc() or realloc()).
- *
- * \param pointer to the old memory range
- * \param number of memory slices of type X to allocate
- * \param failure message which is printed if the allocation fails
- * \return pointer to the reallocated memory range, will be NULL if a failure occurred
- */
-template <typename X> X* ReAlloc(X* OldPointer, size_t size, const char* output)
-{
-  X* buffer = NULL;
-  if (OldPointer == NULL) {
-    buffer = (X*) malloc(sizeof(X) * size);
-  } else {
-    buffer = (X*) realloc(OldPointer, sizeof(X) * size);
-    MemoryUsageObserver::getInstance()->removeMemory(OldPointer);
-  }
-  if (buffer != NULL) {
-    MemoryUsageObserver::getInstance()->addMemory(buffer, size);
-  } else {
-    Log() << Verbose(0) << "ReAlloc for datatype " << typeid(X).name()
-      << " failed - new is NULL: " << output << endl;
-  }
-
-  return buffer;
-};
-
-/** Frees allocated memory range using free(), NULL'ing \a **buffer.
- *
- * \param **buffer to the allocated memory range to free; may be NULL, this function is a no-op then
- * \param *msg optional error message
- */
-template <typename X> void Free(X** buffer, const char *msg = NULL)
-{
-  if ((buffer == NULL) || (*buffer == NULL))
-    return;
-
-  MemoryUsageObserver::getInstance()->removeMemory(*buffer, msg);
-  free(*buffer);
-  *buffer = NULL;
-};
-
-/** Frees allocated memory range using free() for ... * const \a buffer types.
- *
- * \param *buffer to the allocated memory range to free; may be NULL, this function is a no-op then
- * \param *msg optional error message
- */
-template <typename X> void Free(X* const buffer, const char *msg = NULL)
-{
-  if ((buffer == NULL))
-    return;
-
-  MemoryUsageObserver::getInstance()->removeMemory(buffer, msg);
-  free(buffer);
-};
-
-#endif /*MEMORYALLOCATOR_HPP_*/
Index: c/memoryusageobserver.cpp
===================================================================
--- src/memoryusageobserver.cpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ 	(revision )
@@ -1,126 +1,0 @@
-/*
- * \file memoryusageobserver.cpp
- *
- * This class represents a Singleton for observing memory usage.
- */
-
-#include "Helpers/MemDebug.hpp"
-
-#include <cstdlib>
-
-#include "log.hpp"
-#include "memoryusageobserver.hpp"
-#include "verbose.hpp"
-
-MemoryUsageObserver* MemoryUsageObserver::instance = NULL;
-
-/**
- * Constructor. Do not use this function. Use getInstance() instead.
- *
- * \return memory usage observer instance
- */
-MemoryUsageObserver::MemoryUsageObserver() {
-  instance = NULL;
-  maximumSize = 0;
-  totalSize = 0;
-}
-
-/**
- * Destructor. Better use purgeInstance().
- */
-MemoryUsageObserver::~MemoryUsageObserver() {
-  while (!memoryUsers.empty()) {
-    map<void*, size_t>::iterator current = memoryUsers.begin();
-    free(current->first);
-    memoryUsers.erase(current);
-  }
-
-  maximumSize = 0;
-  totalSize = 0;
-}
-
-/**
- * Returns the singleton memory usage observer instance.
- *
- * \return memory usage observer instance
- */
-MemoryUsageObserver* MemoryUsageObserver::getInstance() {
-  if (instance == NULL) {
-    instance = new MemoryUsageObserver;
-  }
-
-  return instance;
-}
-
-/**
- * Purges the current memory usage observer instance.
- */
-void MemoryUsageObserver::purgeInstance() {
-  if (instance != NULL) {
-    delete instance;
-  }
-
-  instance = NULL;
-}
-
-/**
- * Adds memory.
- *
- * \param pointer to the allocated piece of memory
- * \param size of the allocated memory
- */
-void MemoryUsageObserver::addMemory(void* pointer, size_t size) {
-  // Memory might become reseized so we need to check whether the provided pointer is already tracked.
-  map<void*, size_t>::iterator current = memoryUsers.find(pointer);
-  if (current != memoryUsers.end()) {
-    totalSize -= current->second;
-  }
-
-  memoryUsers[pointer] = size;
-  totalSize += size;
-  maximumSize = (totalSize > maximumSize) ? totalSize : maximumSize;
-}
-
-/**
- * Removes tracked memory. Prints a warning if untracked memory is to be released.
- *
- * \param pointer to the allocated piece of memory
- * \param *msg optional error message
- */
-void MemoryUsageObserver::removeMemory(void* pointer, const char *msg) {
-  map<void*, size_t>::iterator current = memoryUsers.find(pointer);
-
-  if (current == memoryUsers.end()) {
-    eLog() << Verbose(2) << "There is non-tracked memory to be freed. Pointer "
-      << pointer << " is not registered by MemoryUsageObserver: ";
-    if (msg != NULL)
-      DoLog(0) && (Log() << Verbose(0) << *msg);
-    DoLog(0) && (Log() << Verbose(0) << endl);
-    return;
-  }
-
-  totalSize -= current->second;
-  memoryUsers.erase(current);
-}
-
-/**
- * Gets the size of currently allocated memory.
- */
-size_t MemoryUsageObserver::getUsedMemorySize() {
-  return totalSize;
-}
-
-/**
- * Gets the maximum size of allocated memory until now.
- */
-size_t MemoryUsageObserver::getMaximumUsedMemory() {
-  return maximumSize;
-}
-
-/**
- * Gets a map with pointers to the currently allocated memory ranges as keys and
- * the allocated size as value.
- */
-map<void*, size_t> MemoryUsageObserver::getPointersToAllocatedMemory() {
-  return memoryUsers;
-}
Index: c/memoryusageobserver.hpp
===================================================================
--- src/memoryusageobserver.hpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ 	(revision )
@@ -1,50 +1,0 @@
-/*
- * \file memoryusageobserver.hpp
- *
- * This class represents a Singleton for observing memory usage.
- */
-#ifndef MEMORYUSAGEOBSERVER_HPP_
-#define MEMORYUSAGEOBSERVER_HPP_
-
-using namespace std;
-
-/*********************************************** includes ***********************************/
-
-// include config.h
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <map>
-#include <iostream>
-#include <iomanip>
-#include <fstream>
-#include <sstream>
-#include <math.h>
-#include <string>
-#include <typeinfo>
-
-/********************************************** declarations *******************************/
-
-class MemoryUsageObserver {
-public:
-  static MemoryUsageObserver* getInstance();
-  static void purgeInstance();
-  void addMemory(void* pointer, size_t size);
-  void removeMemory(void* pointer, const char *msg = NULL);
-  size_t getUsedMemorySize();
-  size_t getMaximumUsedMemory();
-  map<void*, size_t> getPointersToAllocatedMemory();
-
-protected:
-  /** Do not call this constructor directly, use getInstance() instead. */
-  MemoryUsageObserver();
-  /** Do not call this destructor directly, use purgeInstance() instead. */
-  ~MemoryUsageObserver();
-
-private:
-  static MemoryUsageObserver* instance;
-  map<void*, size_t> memoryUsers;
-  size_t totalSize, maximumSize;
-};
-#endif /*MEMORYUSAGEOBSERVER_HPP_*/
Index: src/molecule.cpp
===================================================================
--- src/molecule.cpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/molecule.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -5,8 +5,17 @@
  */
 
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
 #include "Helpers/MemDebug.hpp"
 
 #include <cstring>
 #include <boost/bind.hpp>
+#include <boost/foreach.hpp>
+
+#include <gsl/gsl_inline.h>
+#include <gsl/gsl_heapsort.h>
 
 #include "World.hpp"
@@ -16,17 +25,19 @@
 #include "element.hpp"
 #include "graph.hpp"
-#include "helpers.hpp"
+#include "Helpers/helpers.hpp"
 #include "leastsquaremin.hpp"
 #include "linkedcell.hpp"
 #include "lists.hpp"
-#include "log.hpp"
+#include "Helpers/Log.hpp"
 #include "molecule.hpp"
-#include "memoryallocator.hpp"
+
 #include "periodentafel.hpp"
 #include "stackclass.hpp"
 #include "tesselation.hpp"
-#include "vector.hpp"
+#include "LinearAlgebra/Vector.hpp"
+#include "LinearAlgebra/Matrix.hpp"
 #include "World.hpp"
-#include "Plane.hpp"
+#include "Box.hpp"
+#include "LinearAlgebra/Plane.hpp"
 #include "Exceptions/LinearDependenceException.hpp"
 
@@ -39,13 +50,9 @@
 molecule::molecule(const periodentafel * const teil) :
   Observable("molecule"),
-  elemente(teil),  MDSteps(0),  BondCount(0), ElementCount(0), NoNonHydrogen(0), NoNonBonds(0),
+  elemente(teil),  MDSteps(0),  BondCount(0), NoNonHydrogen(0), NoNonBonds(0),
   NoCyclicBonds(0), BondDistance(0.),  ActiveFlag(false), IndexNr(-1),
-  formula(this,boost::bind(&molecule::calcFormula,this),"formula"),
   AtomCount(this,boost::bind(&molecule::doCountAtoms,this),"AtomCount"), last_atom(0),  InternalPointer(atoms.begin())
 {
 
-  // other stuff
-  for(int i=MAX_ELEMENTS;i--;)
-    ElementsInMolecule[i] = 0;
   strcpy(name,World::getInstance().getDefaultName().c_str());
 };
@@ -83,4 +90,17 @@
 }
 
+bool molecule::changeId(moleculeId_t newId){
+  // first we move ourselves in the world
+  // the world lets us know if that succeeded
+  if(World::getInstance().changeMoleculeId(id,newId,this)){
+    id = newId;
+    return true;
+  }
+  else{
+    return false;
+  }
+}
+
+
 moleculeId_t molecule::getId(){
   return id;
@@ -91,21 +111,22 @@
 }
 
-const std::string molecule::getFormula(){
-  return *formula;
-}
-
-std::string molecule::calcFormula(){
-  std::map<atomicNumber_t,unsigned int> counts;
-  stringstream sstr;
-  periodentafel *periode = World::getInstance().getPeriode();
-  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
-    counts[(*iter)->type->getNumber()]++;
-  }
-  std::map<atomicNumber_t,unsigned int>::reverse_iterator iter;
-  for(iter = counts.rbegin(); iter != counts.rend(); ++iter) {
-    atomicNumber_t Z = (*iter).first;
-    sstr << periode->FindElement(Z)->symbol << (*iter).second;
-  }
-  return sstr.str();
+const Formula &molecule::getFormula(){
+  return formula;
+}
+
+unsigned int molecule::getElementCount(){
+  return formula.getElementCount();
+}
+
+bool molecule::hasElement(const element *element) const{
+  return formula.hasElement(element);
+}
+
+bool molecule::hasElement(atomicNumber_t Z) const{
+  return formula.hasElement(Z);
+}
+
+bool molecule::hasElement(const string &shorthand) const{
+  return formula.hasElement(shorthand);
 }
 
@@ -144,4 +165,5 @@
 molecule::const_iterator molecule::erase( const_iterator loc )
 {
+  OBSERVE;
   molecule::const_iterator iter = loc;
   iter--;
@@ -149,4 +171,5 @@
   atomIds.erase( atom->getId() );
   atoms.remove( atom );
+  formula-=atom->getType();
   atom->removeFromMolecule();
   return iter;
@@ -155,8 +178,10 @@
 molecule::const_iterator molecule::erase( atom * key )
 {
+  OBSERVE;
   molecule::const_iterator iter = find(key);
   if (iter != end()){
     atomIds.erase( key->getId() );
     atoms.remove( key );
+    formula-=key->getType();
     key->removeFromMolecule();
   }
@@ -176,7 +201,9 @@
 pair<molecule::iterator,bool> molecule::insert ( atom * const key )
 {
+  OBSERVE;
   pair<atomIdSet::iterator,bool> res = atomIds.insert(key->getId());
   if (res.second) { // push atom if went well
     atoms.push_back(key);
+    formula+=key->getType();
     return pair<iterator,bool>(molecule::iterator(--end()),res.second);
   } else {
@@ -199,13 +226,10 @@
   if (pointer != NULL) {
     pointer->sort = &pointer->nr;
-    if (pointer->type != NULL) {
-      if (ElementsInMolecule[pointer->type->Z] == 0)
-        ElementCount++;
-      ElementsInMolecule[pointer->type->Z]++; // increase number of elements
-      if (pointer->type->Z != 1)
+    if (pointer->getType() != NULL) {
+      if (pointer->getType()->Z != 1)
         NoNonHydrogen++;
       if(pointer->getName() == "Unknown"){
         stringstream sstr;
-        sstr << pointer->type->symbol << pointer->nr+1;
+        sstr << pointer->getType()->getSymbol() << pointer->nr+1;
         pointer->setName(sstr.str());
       }
@@ -231,5 +255,5 @@
     walker->nr = last_atom++;  // increase number within molecule
     insert(walker);
-    if ((pointer->type != NULL) && (pointer->type->Z != 1))
+    if ((pointer->getType() != NULL) && (pointer->getType()->Z != 1))
       NoNonHydrogen++;
     retval=walker;
@@ -284,11 +308,10 @@
   Vector Orthovector1, Orthovector2;  // temporary vectors in coordination construction
   Vector InBondvector;    // vector in direction of *Bond
-  double *matrix = NULL;
+  const Matrix &matrix =  World::getInstance().getDomain().getM();
   bond *Binder = NULL;
-  double * const cell_size = World::getInstance().getDomain();
 
 //  Log() << Verbose(3) << "Begin of AddHydrogenReplacementAtom." << endl;
   // create vector in direction of bond
-  InBondvector = TopReplacement->x - TopOrigin->x;
+  InBondvector = TopReplacement->getPosition() - TopOrigin->getPosition();
   bondlength = InBondvector.Norm();
 
@@ -302,13 +325,11 @@
     Orthovector1.Zero();
     for (int i=NDIM;i--;) {
-      l = TopReplacement->x[i] - TopOrigin->x[i];
+      l = TopReplacement->at(i) - TopOrigin->at(i);
       if (fabs(l) > BondDistance) { // is component greater than bond distance
         Orthovector1[i] = (l < 0) ? -1. : +1.;
       } // (signs are correct, was tested!)
     }
-    matrix = ReturnFullMatrixforSymmetric(cell_size);
-    Orthovector1.MatrixMultiplication(matrix);
+    Orthovector1 *= matrix;
     InBondvector -= Orthovector1; // subtract just the additional translation
-    delete[](matrix);
     bondlength = InBondvector.Norm();
 //    Log() << Verbose(4) << "Corrected InBondvector is now: ";
@@ -319,6 +340,6 @@
   InBondvector.Normalize();
   // get typical bond length and store as scale factor for later
-  ASSERT(TopOrigin->type != NULL, "AddHydrogenReplacementAtom: element of TopOrigin is not given.");
-  BondRescale = TopOrigin->type->HBondDistance[TopBond->BondDegree-1];
+  ASSERT(TopOrigin->getType() != NULL, "AddHydrogenReplacementAtom: element of TopOrigin is not given.");
+  BondRescale = TopOrigin->getType()->HBondDistance[TopBond->BondDegree-1];
   if (BondRescale == -1) {
     DoeLog(1) && (eLog()<< Verbose(1) << "There is no typical hydrogen bond distance in replacing bond (" << TopOrigin->getName() << "<->" << TopReplacement->getName() << ") of degree " << TopBond->BondDegree << "!" << endl);
@@ -334,8 +355,8 @@
     case 1:
       FirstOtherAtom = World::getInstance().createAtom();    // new atom
-      FirstOtherAtom->type = elemente->FindElement(1);  // element is Hydrogen
-      FirstOtherAtom->v = TopReplacement->v; // copy velocity
+      FirstOtherAtom->setType(1);  // element is Hydrogen
+      FirstOtherAtom->AtomicVelocity = TopReplacement->AtomicVelocity; // copy velocity
       FirstOtherAtom->FixedIon = TopReplacement->FixedIon;
-      if (TopReplacement->type->Z == 1) { // neither rescale nor replace if it's already hydrogen
+      if (TopReplacement->getType()->Z == 1) { // neither rescale nor replace if it's already hydrogen
         FirstOtherAtom->father = TopReplacement;
         BondRescale = bondlength;
@@ -344,6 +365,5 @@
       }
       InBondvector *= BondRescale;   // rescale the distance vector to Hydrogen bond length
-      FirstOtherAtom->x = TopOrigin->x; // set coordination to origin ...
-      FirstOtherAtom->x += InBondvector;  // ... and add distance vector to replacement atom
+      FirstOtherAtom->setPosition(TopOrigin->getPosition() + InBondvector); // set coordination to origin and add distance vector to replacement atom
       AllWentWell = AllWentWell && AddAtom(FirstOtherAtom);
 //      Log() << Verbose(4) << "Added " << *FirstOtherAtom << " at: ";
@@ -378,5 +398,5 @@
         // determine the plane of these two with the *origin
         try {
-          Orthovector1 =Plane(TopOrigin->x, FirstOtherAtom->x, SecondOtherAtom->x).getNormal();
+          Orthovector1 =Plane(TopOrigin->getPosition(), FirstOtherAtom->getPosition(), SecondOtherAtom->getPosition()).getNormal();
         }
         catch(LinearDependenceException &excp){
@@ -399,13 +419,13 @@
       FirstOtherAtom = World::getInstance().createAtom();
       SecondOtherAtom = World::getInstance().createAtom();
-      FirstOtherAtom->type = elemente->FindElement(1);
-      SecondOtherAtom->type = elemente->FindElement(1);
-      FirstOtherAtom->v = TopReplacement->v; // copy velocity
+      FirstOtherAtom->setType(1);
+      SecondOtherAtom->setType(1);
+      FirstOtherAtom->AtomicVelocity = TopReplacement->AtomicVelocity; // copy velocity
       FirstOtherAtom->FixedIon = TopReplacement->FixedIon;
-      SecondOtherAtom->v = TopReplacement->v; // copy velocity
+      SecondOtherAtom->AtomicVelocity = TopReplacement->AtomicVelocity; // copy velocity
       SecondOtherAtom->FixedIon = TopReplacement->FixedIon;
       FirstOtherAtom->father = NULL;  // we are just an added hydrogen with no father
       SecondOtherAtom->father = NULL;  //  we are just an added hydrogen with no father
-      bondangle = TopOrigin->type->HBondAngle[1];
+      bondangle = TopOrigin->getType()->HBondAngle[1];
       if (bondangle == -1) {
         DoeLog(1) && (eLog()<< Verbose(1) << "There is no typical hydrogen bond angle in replacing bond (" << TopOrigin->getName() << "<->" << TopReplacement->getName() << ") of degree " << TopBond->BondDegree << "!" << endl);
@@ -421,17 +441,15 @@
 //      Log() << Verbose(0) << endl;
 //      Log() << Verbose(3) << "Half the bond angle is " << bondangle << ", sin and cos of it: " << sin(bondangle) << ", " << cos(bondangle) << endl;
-      FirstOtherAtom->x.Zero();
-      SecondOtherAtom->x.Zero();
+      FirstOtherAtom->Zero();
+      SecondOtherAtom->Zero();
       for(int i=NDIM;i--;) { // rotate by half the bond angle in both directions (InBondvector is bondangle = 0 direction)
-        FirstOtherAtom->x[i] = InBondvector[i] * cos(bondangle) + Orthovector1[i] * (sin(bondangle));
-        SecondOtherAtom->x[i] = InBondvector[i] * cos(bondangle) + Orthovector1[i] * (-sin(bondangle));
-      }
-      FirstOtherAtom->x *= BondRescale;  // rescale by correct BondDistance
-      SecondOtherAtom->x *= BondRescale;
+        FirstOtherAtom->set(i, InBondvector[i] * cos(bondangle) + Orthovector1[i] * (sin(bondangle)));
+        SecondOtherAtom->set(i, InBondvector[i] * cos(bondangle) + Orthovector1[i] * (-sin(bondangle)));
+      }
+      FirstOtherAtom->Scale(BondRescale);  // rescale by correct BondDistance
+      SecondOtherAtom->Scale(BondRescale);
       //Log() << Verbose(3) << "ReScaleCheck: " << FirstOtherAtom->x.Norm() << " and " << SecondOtherAtom->x.Norm() << "." << endl;
-      for(int i=NDIM;i--;) { // and make relative to origin atom
-        FirstOtherAtom->x[i] += TopOrigin->x[i];
-        SecondOtherAtom->x[i] += TopOrigin->x[i];
-      }
+      *FirstOtherAtom += TopOrigin->getPosition();
+      *SecondOtherAtom += TopOrigin->getPosition();
       // ... and add to molecule
       AllWentWell = AllWentWell && AddAtom(FirstOtherAtom);
@@ -455,12 +473,12 @@
       SecondOtherAtom = World::getInstance().createAtom();
       ThirdOtherAtom = World::getInstance().createAtom();
-      FirstOtherAtom->type = elemente->FindElement(1);
-      SecondOtherAtom->type = elemente->FindElement(1);
-      ThirdOtherAtom->type = elemente->FindElement(1);
-      FirstOtherAtom->v = TopReplacement->v; // copy velocity
+      FirstOtherAtom->setType(1);
+      SecondOtherAtom->setType(1);
+      ThirdOtherAtom->setType(1);
+      FirstOtherAtom->AtomicVelocity = TopReplacement->AtomicVelocity; // copy velocity
       FirstOtherAtom->FixedIon = TopReplacement->FixedIon;
-      SecondOtherAtom->v = TopReplacement->v; // copy velocity
+      SecondOtherAtom->AtomicVelocity = TopReplacement->AtomicVelocity; // copy velocity
       SecondOtherAtom->FixedIon = TopReplacement->FixedIon;
-      ThirdOtherAtom->v = TopReplacement->v; // copy velocity
+      ThirdOtherAtom->AtomicVelocity = TopReplacement->AtomicVelocity; // copy velocity
       ThirdOtherAtom->FixedIon = TopReplacement->FixedIon;
       FirstOtherAtom->father = NULL;  //  we are just an added hydrogen with no father
@@ -485,5 +503,5 @@
 
       // create correct coordination for the three atoms
-      alpha = (TopOrigin->type->HBondAngle[2])/180.*M_PI/2.;  // retrieve triple bond angle from database
+      alpha = (TopOrigin->getType()->HBondAngle[2])/180.*M_PI/2.;  // retrieve triple bond angle from database
       l = BondRescale;        // desired bond length
       b = 2.*l*sin(alpha);    // base length of isosceles triangle
@@ -496,10 +514,10 @@
       factors[1] = f;
       factors[2] = 0.;
-      FirstOtherAtom->x.LinearCombinationOfVectors(InBondvector, Orthovector1, Orthovector2, factors);
+      FirstOtherAtom->LinearCombinationOfVectors(InBondvector, Orthovector1, Orthovector2, factors);
       factors[1] = -0.5*f;
       factors[2] = g;
-      SecondOtherAtom->x.LinearCombinationOfVectors(InBondvector, Orthovector1, Orthovector2, factors);
+      SecondOtherAtom->LinearCombinationOfVectors(InBondvector, Orthovector1, Orthovector2, factors);
       factors[2] = -g;
-      ThirdOtherAtom->x.LinearCombinationOfVectors(InBondvector, Orthovector1, Orthovector2, factors);
+      ThirdOtherAtom->LinearCombinationOfVectors(InBondvector, Orthovector1, Orthovector2, factors);
 
       // rescale each to correct BondDistance
@@ -509,7 +527,7 @@
 
       // and relative to *origin atom
-      FirstOtherAtom->x += TopOrigin->x;
-      SecondOtherAtom->x += TopOrigin->x;
-      ThirdOtherAtom->x += TopOrigin->x;
+      *FirstOtherAtom += TopOrigin->getPosition();
+      *SecondOtherAtom += TopOrigin->getPosition();
+      *ThirdOtherAtom += TopOrigin->getPosition();
 
       // ... and add to molecule
@@ -541,5 +559,4 @@
       break;
   }
-  delete[](matrix);
 
 //  Log() << Verbose(3) << "End of AddHydrogenReplacementAtom." << endl;
@@ -588,8 +605,8 @@
     *item >> x[1];
     *item >> x[2];
-    Walker->type = elemente->FindElement(shorthand);
-    if (Walker->type == NULL) {
+    Walker->setType(elemente->FindElement(shorthand));
+    if (Walker->getType() == NULL) {
       DoeLog(1) && (eLog()<< Verbose(1) << "Could not parse the element at line: '" << line << "', setting to H.");
-      Walker->type = elemente->FindElement(1);
+      Walker->setType(1);
     }
     if (Walker->Trajectory.R.size() <= (unsigned int)MDSteps) {
@@ -598,6 +615,6 @@
       Walker->Trajectory.F.resize(MDSteps+10);
     }
+    Walker->setPosition(Vector(x));
     for(j=NDIM;j--;) {
-      Walker->x[j] = x[j];
       Walker->Trajectory.R.at(MDSteps-1)[j] = x[j];
       Walker->Trajectory.U.at(MDSteps-1)[j] = 0;
@@ -618,22 +635,23 @@
 {
   molecule *copy = World::getInstance().createMolecule();
-  atom *LeftAtom = NULL, *RightAtom = NULL;
 
   // copy all atoms
-  ActOnCopyWithEachAtom ( &molecule::AddCopyAtom, copy );
+  for_each(atoms.begin(),atoms.end(),bind1st(mem_fun(&molecule::AddCopyAtom),copy));
 
   // copy all bonds
-  bond *Binder = NULL;
-  bond *NewBond = NULL;
   for(molecule::iterator AtomRunner = begin(); AtomRunner != end(); ++AtomRunner)
     for(BondList::iterator BondRunner = (*AtomRunner)->ListOfBonds.begin(); !(*AtomRunner)->ListOfBonds.empty(); BondRunner = (*AtomRunner)->ListOfBonds.begin())
       if ((*BondRunner)->leftatom == *AtomRunner) {
-        Binder = (*BondRunner);
+        bond *Binder = (*BondRunner);
 
         // get the pendant atoms of current bond in the copy molecule
-        copy->ActOnAllAtoms( &atom::EqualsFather, (const atom *)Binder->leftatom, (const atom **)&LeftAtom );
-        copy->ActOnAllAtoms( &atom::EqualsFather, (const atom *)Binder->rightatom, (const atom **)&RightAtom );
-
-        NewBond = copy->AddBond(LeftAtom, RightAtom, Binder->BondDegree);
+        atomSet::iterator leftiter=find_if(atoms.begin(),atoms.end(),bind2nd(mem_fun(&atom::isFather),Binder->leftatom));
+        atomSet::iterator rightiter=find_if(atoms.begin(),atoms.end(),bind2nd(mem_fun(&atom::isFather),Binder->rightatom));
+        ASSERT(leftiter!=atoms.end(),"No original left atom for bondcopy found");
+        ASSERT(leftiter!=atoms.end(),"No original right atom for bondcopy found");
+        atom *LeftAtom = *leftiter;
+        atom *RightAtom = *rightiter;
+
+        bond *NewBond = copy->AddBond(LeftAtom, RightAtom, Binder->BondDegree);
         NewBond->Cyclic = Binder->Cyclic;
         if (Binder->Cyclic)
@@ -642,8 +660,7 @@
       }
   // correct fathers
-  ActOnAllAtoms( &atom::CorrectFather );
+  for_each(atoms.begin(),atoms.end(),mem_fun(&atom::CorrectFather));
 
   // copy values
-  copy->CountElements();
   if (hasBondStructure()) {  // if adjaceny list is present
     copy->BondDistance = BondDistance;
@@ -660,8 +677,12 @@
  * @param three vectors forming the matrix that defines the shape of the parallelpiped
  */
-molecule* molecule::CopyMoleculeFromSubRegion(const Vector offset, const double *parallelepiped) const {
+molecule* molecule::CopyMoleculeFromSubRegion(const Shape &region) const {
   molecule *copy = World::getInstance().createMolecule();
 
-  ActOnCopyWithEachAtomIfTrue ( &molecule::AddCopyAtom, copy, &atom::IsInParallelepiped, offset, parallelepiped );
+  BOOST_FOREACH(atom *iter,atoms){
+    if(iter->IsInShape(region)){
+      copy->AddCopyAtom(iter);
+    }
+  }
 
   //TODO: copy->BuildInducedSubgraph(this);
@@ -690,5 +711,5 @@
   atom1->RegisterBond(Binder);
   atom2->RegisterBond(Binder);
-  if ((atom1->type != NULL) && (atom1->type->Z != 1) && (atom2->type != NULL) && (atom2->type->Z != 1))
+  if ((atom1->getType() != NULL) && (atom1->getType()->Z != 1) && (atom2->getType() != NULL) && (atom2->getType()->Z != 1))
     NoNonBonds++;
 
@@ -750,14 +771,11 @@
 void molecule::SetBoxDimension(Vector *dim)
 {
-  double * const cell_size = World::getInstance().getDomain();
-  cell_size[0] = dim->at(0);
-  cell_size[1] = 0.;
-  cell_size[2] = dim->at(1);
-  cell_size[3] = 0.;
-  cell_size[4] = 0.;
-  cell_size[5] = dim->at(2);
-};
-
-/** Removes atom from molecule list and deletes it.
+  Matrix domain;
+  for(int i =0; i<NDIM;++i)
+    domain.at(i,i) = dim->at(i);
+  World::getInstance().setDomain(domain);
+};
+
+/** Removes atom from molecule list and removes all of its bonds.
  * \param *pointer atom to be removed
  * \return true - succeeded, false - atom not found in list
@@ -767,10 +785,4 @@
   ASSERT(pointer, "Null pointer passed to molecule::RemoveAtom().");
   OBSERVE;
-  if (ElementsInMolecule[pointer->type->Z] != 0)  { // this would indicate an error
-    ElementsInMolecule[pointer->type->Z]--;  // decrease number of atom of this element
-  } else
-    DoeLog(1) && (eLog()<< Verbose(1) << "Atom " << pointer->getName() << " is of element " << pointer->type->Z << " but the entry in the table of the molecule is 0!" << endl);
-  if (ElementsInMolecule[pointer->type->Z] == 0)  // was last atom of this element?
-    ElementCount--;
   RemoveBonds(pointer);
   erase(pointer);
@@ -786,10 +798,4 @@
   if (pointer == NULL)
     return false;
-  if (ElementsInMolecule[pointer->type->Z] != 0)  // this would indicate an error
-    ElementsInMolecule[pointer->type->Z]--; // decrease number of atom of this element
-  else
-    DoeLog(1) && (eLog()<< Verbose(1) << "Atom " << pointer->getName() << " is of element " << pointer->type->Z << " but the entry in the table of the molecule is 0!" << endl);
-  if (ElementsInMolecule[pointer->type->Z] == 0)  // was last atom of this element?
-    ElementCount--;
   erase(pointer);
   return true;
@@ -802,5 +808,5 @@
 {
   for (molecule::iterator iter = begin(); !empty(); iter = begin())
-      erase(iter);
+    erase(*iter);
   return empty();
 };
@@ -849,10 +855,8 @@
 bool molecule::CheckBounds(const Vector *x) const
 {
-  double * const cell_size = World::getInstance().getDomain();
+  const Matrix &domain = World::getInstance().getDomain().getM();
   bool result = true;
-  int j =-1;
   for (int i=0;i<NDIM;i++) {
-    j += i+1;
-    result = result && ((x->at(i) >= 0) && (x->at(i) < cell_size[j]));
+    result = result && ((x->at(i) >= 0) && (x->at(i) < domain.at(i,i)));
   }
   //return result;
@@ -863,24 +867,18 @@
  * \param *out output stream
  */
-bool molecule::Output(ofstream * const output)
-{
-  int ElementNo[MAX_ELEMENTS], AtomNo[MAX_ELEMENTS];
-  CountElements();
-
-  for (int i=0;i<MAX_ELEMENTS;++i) {
-    AtomNo[i] = 0;
-    ElementNo[i] = 0;
-  }
+bool molecule::Output(ostream * const output)
+{
   if (output == NULL) {
     return false;
   } else {
+    int AtomNo[MAX_ELEMENTS];
+    memset(AtomNo,0,(MAX_ELEMENTS-1)*sizeof(*AtomNo));
+    enumeration<const element*> elementLookup = formula.enumerateElements();
+    for(map<const element*,unsigned int>::iterator iter=elementLookup.there.begin();
+        iter!=elementLookup.there.end();++iter){
+      cout << "Enumerated element " << *iter->first << " with number " << iter->second << endl;
+    }
     *output << "#Ion_TypeNr._Nr.R[0]    R[1]    R[2]    MoveType (0 MoveIon, 1 FixedIon)" << endl;
-    SetIndexedArrayForEachAtomTo ( ElementNo, &element::Z, &AbsoluteValue, 1);
-    int current=1;
-    for (int i=0;i<MAX_ELEMENTS;++i) {
-      if (ElementNo[i] == 1)
-        ElementNo[i] = current++;
-    }
-    ActOnAllAtoms( &atom::OutputArrayIndexed, (ostream * const) output, (const int *)ElementNo, (int *)AtomNo, (const char *) NULL );
+    for_each(atoms.begin(),atoms.end(),boost::bind(&atom::OutputArrayIndexed,_1,output,elementLookup,AtomNo,(const char*)0));
     return true;
   }
@@ -893,5 +891,4 @@
 {
   int ElementNo[MAX_ELEMENTS], AtomNo[MAX_ELEMENTS];
-  CountElements();
 
   if (output == NULL) {
@@ -926,5 +923,5 @@
 {
   DoLog(2) && (Log() << Verbose(2) << endl << "From Contents of ListOfBonds, all non-hydrogen atoms:" << endl);
-  ActOnAllAtoms (&atom::OutputBondOfAtom );
+  for_each(atoms.begin(),atoms.end(),mem_fun(&atom::OutputBondOfAtom));
   DoLog(0) && (Log() << Verbose(0) << endl);
 };
@@ -935,5 +932,5 @@
 bool molecule::Checkout(ofstream * const output)  const
 {
-  return elemente->Checkout(output, ElementsInMolecule);
+  return formula.checkOut(output);
 };
 
@@ -949,5 +946,5 @@
     for (int step=0;step<MDSteps;step++) {
       *output << getAtomCount() << "\n\tCreated by molecuilder, step " << step << ", on " << ctime(&now);
-      ActOnAllAtoms( &atom::OutputTrajectoryXYZ, output, step );
+      for_each(atoms.begin(),atoms.end(),boost::bind(&atom::OutputTrajectoryXYZ,_1,output,step));
     }
     return true;
@@ -966,5 +963,5 @@
     now = time((time_t *)NULL);   // Get the system time and put it into 'now' as 'calender time'
     *output << getAtomCount() << "\n\tCreated by molecuilder on " << ctime(&now);
-    ActOnAllAtoms( &atom::OutputXYZLine, output );
+    for_each(atoms.begin(),atoms.end(),bind2nd(mem_fun(&atom::OutputXYZLine),output));
     return true;
   } else
@@ -982,8 +979,8 @@
   for (molecule::const_iterator iter = atoms.begin(); iter != atoms.end(); ++iter) {
     (*iter)->nr = i;   // update number in molecule (for easier referencing in FragmentMolecule lateron)
-    if ((*iter)->type->Z != 1) // count non-hydrogen atoms whilst at it
+    if ((*iter)->getType()->Z != 1) // count non-hydrogen atoms whilst at it
       NoNonHydrogen++;
     stringstream sstr;
-    sstr << (*iter)->type->symbol << (*iter)->nr+1;
+    sstr << (*iter)->getType()->getSymbol() << (*iter)->nr+1;
     (*iter)->setName(sstr.str());
     DoLog(3) && (Log() << Verbose(3) << "Naming atom nr. " << (*iter)->nr << " " << (*iter)->getName() << "." << endl);
@@ -991,138 +988,4 @@
   }
   return res;
-};
-
-/** Brings molecule::ElementCount and molecule::ElementsInMolecule up-to-date.
- */
-void molecule::CountElements()
-{
-  for(int i=MAX_ELEMENTS;i--;)
-    ElementsInMolecule[i] = 0;
-  ElementCount = 0;
-
-  SetIndexedArrayForEachAtomTo ( ElementsInMolecule, &element::Z, &Increment, 1);
-
-  for(int i=MAX_ELEMENTS;i--;)
-    ElementCount += (ElementsInMolecule[i] != 0 ? 1 : 0);
-};
-
-/** Determines whether two molecules actually contain the same atoms and coordination.
- * \param *out output stream for debugging
- * \param *OtherMolecule the molecule to compare this one to
- * \param threshold upper limit of difference when comparing the coordination.
- * \return NULL - not equal, otherwise an allocated (molecule::AtomCount) permutation map of the atom numbers (which corresponds to which)
- */
-int * molecule::IsEqualToWithinThreshold(molecule *OtherMolecule, double threshold)
-{
-  int flag;
-  double *Distances = NULL, *OtherDistances = NULL;
-  Vector CenterOfGravity, OtherCenterOfGravity;
-  size_t *PermMap = NULL, *OtherPermMap = NULL;
-  int *PermutationMap = NULL;
-  bool result = true; // status of comparison
-
-  DoLog(3) && (Log() << Verbose(3) << "Begin of IsEqualToWithinThreshold." << endl);
-  /// first count both their atoms and elements and update lists thereby ...
-  //Log() << Verbose(0) << "Counting atoms, updating list" << endl;
-  CountElements();
-  OtherMolecule->CountElements();
-
-  /// ... and compare:
-  /// -# AtomCount
-  if (result) {
-    if (getAtomCount() != OtherMolecule->getAtomCount()) {
-      DoLog(4) && (Log() << Verbose(4) << "AtomCounts don't match: " << getAtomCount() << " == " << OtherMolecule->getAtomCount() << endl);
-      result = false;
-    } else Log() << Verbose(4) << "AtomCounts match: " << getAtomCount() << " == " << OtherMolecule->getAtomCount() << endl;
-  }
-  /// -# ElementCount
-  if (result) {
-    if (ElementCount != OtherMolecule->ElementCount) {
-      DoLog(4) && (Log() << Verbose(4) << "ElementCount don't match: " << ElementCount << " == " << OtherMolecule->ElementCount << endl);
-      result = false;
-    } else Log() << Verbose(4) << "ElementCount match: " << ElementCount << " == " << OtherMolecule->ElementCount << endl;
-  }
-  /// -# ElementsInMolecule
-  if (result) {
-    for (flag=MAX_ELEMENTS;flag--;) {
-      //Log() << Verbose(5) << "Element " <<  flag << ": " << ElementsInMolecule[flag] << " <-> " << OtherMolecule->ElementsInMolecule[flag] << "." << endl;
-      if (ElementsInMolecule[flag] != OtherMolecule->ElementsInMolecule[flag])
-        break;
-    }
-    if (flag < MAX_ELEMENTS) {
-      DoLog(4) && (Log() << Verbose(4) << "ElementsInMolecule don't match." << endl);
-      result = false;
-    } else Log() << Verbose(4) << "ElementsInMolecule match." << endl;
-  }
-  /// then determine and compare center of gravity for each molecule ...
-  if (result) {
-    DoLog(5) && (Log() << Verbose(5) << "Calculating Centers of Gravity" << endl);
-    DeterminePeriodicCenter(CenterOfGravity);
-    OtherMolecule->DeterminePeriodicCenter(OtherCenterOfGravity);
-    DoLog(5) && (Log() << Verbose(5) << "Center of Gravity: " << CenterOfGravity << endl);
-    DoLog(5) && (Log() << Verbose(5) << "Other Center of Gravity: " << OtherCenterOfGravity << endl);
-    if (CenterOfGravity.DistanceSquared(OtherCenterOfGravity) > threshold*threshold) {
-      DoLog(4) && (Log() << Verbose(4) << "Centers of gravity don't match." << endl);
-      result = false;
-    }
-  }
-
-  /// ... then make a list with the euclidian distance to this center for each atom of both molecules
-  if (result) {
-    DoLog(5) && (Log() << Verbose(5) << "Calculating distances" << endl);
-    Distances = new double[getAtomCount()];
-    OtherDistances = new double[getAtomCount()];
-    SetIndexedArrayForEachAtomTo ( Distances, &atom::nr, &atom::DistanceSquaredToVector, (const Vector &)CenterOfGravity);
-    SetIndexedArrayForEachAtomTo ( OtherDistances, &atom::nr, &atom::DistanceSquaredToVector, (const Vector &)CenterOfGravity);
-    for(int i=0;i<getAtomCount();i++) {
-      Distances[i] = 0.;
-      OtherDistances[i] = 0.;
-    }
-
-    /// ... sort each list (using heapsort (o(N log N)) from GSL)
-    DoLog(5) && (Log() << Verbose(5) << "Sorting distances" << endl);
-    PermMap = new size_t[getAtomCount()];
-    OtherPermMap = new size_t[getAtomCount()];
-    for(int i=0;i<getAtomCount();i++) {
-      PermMap[i] = 0;
-      OtherPermMap[i] = 0;
-    }
-    gsl_heapsort_index (PermMap, Distances, getAtomCount(), sizeof(double), CompareDoubles);
-    gsl_heapsort_index (OtherPermMap, OtherDistances, getAtomCount(), sizeof(double), CompareDoubles);
-    PermutationMap = new int[getAtomCount()];
-    for(int i=0;i<getAtomCount();i++)
-      PermutationMap[i] = 0;
-    DoLog(5) && (Log() << Verbose(5) << "Combining Permutation Maps" << endl);
-    for(int i=getAtomCount();i--;)
-      PermutationMap[PermMap[i]] = (int) OtherPermMap[i];
-
-    /// ... and compare them step by step, whether the difference is individually(!) below \a threshold for all
-    DoLog(4) && (Log() << Verbose(4) << "Comparing distances" << endl);
-    flag = 0;
-    for (int i=0;i<getAtomCount();i++) {
-      DoLog(5) && (Log() << Verbose(5) << "Distances squared: |" << Distances[PermMap[i]] << " - " << OtherDistances[OtherPermMap[i]] << "| = " << fabs(Distances[PermMap[i]] - OtherDistances[OtherPermMap[i]]) << " ?<? " <<  threshold << endl);
-      if (fabs(Distances[PermMap[i]] - OtherDistances[OtherPermMap[i]]) > threshold*threshold)
-        flag = 1;
-    }
-
-    // free memory
-    delete[](PermMap);
-    delete[](OtherPermMap);
-    delete[](Distances);
-    delete[](OtherDistances);
-    if (flag) { // if not equal
-      delete[](PermutationMap);
-      result = false;
-    }
-  }
-  /// return pointer to map if all distances were below \a threshold
-  DoLog(3) && (Log() << Verbose(3) << "End of IsEqualToWithinThreshold." << endl);
-  if (result) {
-    DoLog(3) && (Log() << Verbose(3) << "Result: Equal." << endl);
-    return PermutationMap;
-  } else {
-    DoLog(3) && (Log() << Verbose(3) << "Result: Not equal." << endl);
-    return NULL;
-  }
 };
 
Index: src/molecule.hpp
===================================================================
--- src/molecule.hpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/molecule.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -7,16 +7,9 @@
 #define MOLECULES_HPP_
 
-using namespace std;
-
 /*********************************************** includes ***********************************/
 
-// GSL headers
-#include <gsl/gsl_eigen.h>
-#include <gsl/gsl_heapsort.h>
-#include <gsl/gsl_linalg.h>
-#include <gsl/gsl_matrix.h>
-#include <gsl/gsl_multimin.h>
-#include <gsl/gsl_vector.h>
-#include <gsl/gsl_randist.h>
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
 
 //// STL headers
@@ -31,9 +24,10 @@
 #include "types.hpp"
 #include "graph.hpp"
-#include "stackclass.hpp"
-#include "tesselation.hpp"
+#include "PointCloud.hpp"
 #include "Patterns/Observer.hpp"
 #include "Patterns/ObservedIterator.hpp"
 #include "Patterns/Cacheable.hpp"
+#include "Formula.hpp"
+#include "AtomSet.hpp"
 
 #include "Descriptors/MoleculeDescriptor_impl.hpp"
@@ -53,4 +47,6 @@
 class periodentafel;
 class Vector;
+class Shape;
+template <class> class StackClass;
 
 /******************************** Some definitions for easier reading **********************************/
@@ -89,5 +85,5 @@
 
   public:
-    typedef std::list<atom*> atomSet;
+    typedef ATOMSET(std::list) atomSet;
     typedef std::set<atomId_t> atomIdSet;
     typedef ObservedIterator<atomSet> iterator;
@@ -103,6 +99,4 @@
     //int AtomCount;          //!< number of atoms, brought up-to-date by CountAtoms()
     int BondCount;          //!< number of atoms, brought up-to-date by CountBonds()
-    int ElementCount;       //!< how many unique elements are therein
-    int ElementsInMolecule[MAX_ELEMENTS]; //!< list whether element (sorted by atomic number) is alread present or not
     mutable int NoNonHydrogen;  //!< number of non-hydrogen atoms in molecule
     mutable int NoNonBonds;     //!< number of non-hydrogen bonds in molecule
@@ -110,10 +104,10 @@
     double BondDistance;  //!< typical bond distance used in CreateAdjacencyList() and furtheron
     bool ActiveFlag;    //!< in a MoleculeListClass used to discern active from inactive molecules
-    Vector Center;      //!< Center of molecule in a global box
+    //Vector Center;      //!< Center of molecule in a global box
     int IndexNr;        //!< index of molecule in a MoleculeListClass
     char name[MAXSTRINGSIZE];         //!< arbitrary name
 
   private:
-    Cacheable<string> formula;
+    Formula formula;
     Cacheable<int>    AtomCount;
     moleculeId_t id;
@@ -141,6 +135,11 @@
   void setId(moleculeId_t);
   void setName(const std::string);
-  const std::string getFormula();
-  std::string calcFormula();
+  const Formula &getFormula();
+  unsigned int getElementCount();
+  bool hasElement(const element*) const;
+  bool hasElement(atomicNumber_t) const;
+  bool hasElement(const std::string&) const;
+
+  virtual bool changeId(atomId_t newId);
 
   iterator begin();
@@ -166,16 +165,4 @@
   bool IsEmpty() const ;
   bool IsEnd() const ;
-
-  // templates for allowing global manipulation of all vectors
-  template <typename res> void ActOnAllVectors( res (Vector::*f)() ) const;
-  template <typename res> void ActOnAllVectors( res (Vector::*f)() const) const;
-  template <typename res, typename T> void ActOnAllVectors( res (Vector::*f)(T), T t ) const;
-  template <typename res, typename T> void ActOnAllVectors( res (Vector::*f)(T) const, T t ) const;
-  template <typename res, typename T> void ActOnAllVectors( res (Vector::*f)(T&), T &t ) const;
-  template <typename res, typename T> void ActOnAllVectors( res (Vector::*f)(T&) const, T &t ) const;
-  template <typename res, typename T, typename U> void ActOnAllVectors( res (Vector::*f)(T, U), T t, U u ) const;
-  template <typename res, typename T, typename U> void ActOnAllVectors( res (Vector::*f)(T, U) const, T t, U u ) const;
-  template <typename res, typename T, typename U, typename V> void ActOnAllVectors( res (Vector::*f)(T, U, V), T t, U u, V v) const;
-  template <typename res, typename T, typename U, typename V> void ActOnAllVectors( res (Vector::*f)(T, U, V) const, T t, U u, V v) const;
 
   // templates for allowing global manipulation of molecule with each atom as single argument
@@ -260,5 +247,4 @@
 
   /// Count and change present atoms' coordination.
-  void CountElements();
   bool CenterInBox();
   bool BoundInBox();
@@ -273,5 +259,5 @@
   void Scale(const double ** const factor);
   void DeterminePeriodicCenter(Vector &center);
-  Vector * DetermineCenterOfGravity();
+  Vector * DetermineCenterOfGravity() const;
   Vector * DetermineCenterOfAll() const;
   Vector * DetermineCenterOfBox() const;
@@ -281,5 +267,4 @@
   bool VerletForceIntegration(char *file, config &configuration, const size_t offset);
   void Thermostats(config &configuration, double ActualTemp, int Thermostat);
-  void PrincipalAxisSystem(bool DoRotate);
   double VolumeOfConvexEnvelope(bool IsAngstroem);
 
@@ -316,5 +301,5 @@
 
   molecule *CopyMolecule();
-  molecule* CopyMoleculeFromSubRegion(const Vector offset, const double *parallelepiped) const;
+  molecule* CopyMoleculeFromSubRegion(const Shape&) const;
 
   /// Fragment molecule by two different approaches:
@@ -340,9 +325,8 @@
 
   // Recognize doubly appearing molecules in a list of them
-  int * IsEqualToWithinThreshold(molecule *OtherMolecule, double threshold);
   int * GetFatherSonAtomicMap(molecule *OtherMolecule);
 
   // Output routines.
-  bool Output(ofstream * const output);
+  bool Output(std::ostream * const output);
   bool OutputTrajectories(ofstream * const output);
   void OutputListOfBonds() const;
@@ -384,5 +368,4 @@
   void Enumerate(ostream *out);
   void Output(ofstream *out);
-  void DissectMoleculeIntoConnectedSubgraphs(const periodentafel * const periode, config * const configuration);
   int CountAllAtoms() const;
 
@@ -395,13 +378,4 @@
   void parseXYZIntoMolecule();
   void eraseMolecule();
-
-
-  // merging of molecules
-  bool SimpleMerge(molecule *mol, molecule *srcmol);
-  bool SimpleAdd(molecule *mol, molecule *srcmol);
-  bool SimpleMultiMerge(molecule *mol, int *src, int N);
-  bool SimpleMultiAdd(molecule *mol, int *src, int N);
-  bool ScatterMerge(molecule *mol, int *src, int N);
-  bool EmbedMerge(molecule *mol, molecule *srcmol);
 
   private:
Index: src/molecule_dynamics.cpp
===================================================================
--- src/molecule_dynamics.cpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/molecule_dynamics.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -6,4 +6,9 @@
  */
 
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
 #include "Helpers/MemDebug.hpp"
 
@@ -12,11 +17,15 @@
 #include "config.hpp"
 #include "element.hpp"
-#include "info.hpp"
-#include "log.hpp"
-#include "memoryallocator.hpp"
+#include "Helpers/Info.hpp"
+#include "Helpers/Verbose.hpp"
+#include "Helpers/Log.hpp"
 #include "molecule.hpp"
 #include "parser.hpp"
-#include "Plane.hpp"
+#include "LinearAlgebra/Plane.hpp"
 #include "ThermoStatContainer.hpp"
+
+#include <gsl/gsl_matrix.h>
+#include <gsl/gsl_vector.h>
+#include <gsl/gsl_linalg.h>
 
 /************************************* Functions for class molecule *********************************/
@@ -509,5 +518,5 @@
       Sprinter = mol->AddCopyAtom((*iter));
       for (int n=NDIM;n--;) {
-        Sprinter->x[n] = (*iter)->Trajectory.R.at(startstep)[n] + (PermutationMap[(*iter)->nr]->Trajectory.R.at(endstep)[n] - (*iter)->Trajectory.R.at(startstep)[n])*((double)step/(double)MaxSteps);
+        Sprinter->set(n, (*iter)->Trajectory.R.at(startstep)[n] + (PermutationMap[(*iter)->nr]->Trajectory.R.at(endstep)[n] - (*iter)->Trajectory.R.at(startstep)[n])*((double)step/(double)MaxSteps));
         // add to Trajectories
         //Log() << Verbose(3) << step << ">=" << MDSteps-1 << endl;
@@ -555,6 +564,4 @@
   Vector Velocity;
   ForceMatrix Force;
-
-  CountElements();  // make sure ElementsInMolecule is up to date
 
   const int AtomCount = getAtomCount();
Index: src/molecule_fragmentation.cpp
===================================================================
--- src/molecule_fragmentation.cpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/molecule_fragmentation.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -6,4 +6,9 @@
  */
 
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
 #include "Helpers/MemDebug.hpp"
 
@@ -15,11 +20,14 @@
 #include "config.hpp"
 #include "element.hpp"
-#include "helpers.hpp"
+#include "Helpers/helpers.hpp"
 #include "lists.hpp"
-#include "log.hpp"
-#include "memoryallocator.hpp"
+#include "Helpers/Verbose.hpp"
+#include "Helpers/Log.hpp"
 #include "molecule.hpp"
 #include "periodentafel.hpp"
 #include "World.hpp"
+#include "LinearAlgebra/Matrix.hpp"
+#include "Box.hpp"
+#include "stackclass.hpp"
 
 /************************************* Functions for class molecule *********************************/
@@ -448,5 +456,5 @@
       for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     #ifdef ADDHYDROGEN
-        if ((*iter)->type->Z != 1) // skip hydrogen
+        if ((*iter)->getType()->Z != 1) // skip hydrogen
     #endif
         {
@@ -468,5 +476,5 @@
     for(molecule::const_iterator iter = begin(); iter != end(); ++iter) {
   #ifdef ADDHYDROGEN
-      if ((*iter)->type->Z != 1) // skip hydrogen
+      if ((*iter)->getType()->Z != 1) // skip hydrogen
   #endif
       {
@@ -877,5 +885,5 @@
   for (KeySet::iterator runner = Leaf->begin(); runner != Leaf->end(); runner++) {
     Runner = FindAtom((*runner));
-    if (Runner->type->Z != 1) { // skip all those added hydrogens when re-filling snake stack
+    if (Runner->getType()->Z != 1) { // skip all those added hydrogens when re-filling snake stack
       if (ShortestPathList[(*runner)] > SP) {  // remove the oldest one with longest shortest path
         SP = ShortestPathList[(*runner)];
@@ -966,5 +974,5 @@
     ++iter;
 #ifdef ADDHYDROGEN
-    while ((iter != Leaf->end()) && ((*iter)->type->Z == 1)){ // skip added hydrogen
+    while ((iter != Leaf->end()) && ((*iter)->getType()->Z == 1)){ // skip added hydrogen
       iter++;
     }
@@ -1344,5 +1352,5 @@
         if ((RestrictedKeySet.find(OtherWalker->nr) != RestrictedKeySet.end())
   #ifdef ADDHYDROGEN
-         && (OtherWalker->type->Z != 1)
+         && (OtherWalker->getType()->Z != 1)
   #endif
                                                               ) {  // skip hydrogens and restrict to fragment
@@ -1716,6 +1724,5 @@
   atom *Walker = NULL;
   atom *OtherWalker = NULL;
-  double * const cell_size = World::getInstance().getDomain();
-  double *matrix = ReturnFullMatrixforSymmetric(cell_size);
+  Matrix matrix = World::getInstance().getDomain().getM();
   enum Shading *ColorList = NULL;
   double tmp;
@@ -1739,5 +1746,5 @@
         Binder = (*BondRunner);
         for (int i=NDIM;i--;) {
-          tmp = fabs(Binder->leftatom->x[i] - Binder->rightatom->x[i]);
+          tmp = fabs(Binder->leftatom->at(i) - Binder->rightatom->at(i));
           //Log() << Verbose(3) << "Checking " << i << "th distance of " << *Binder->leftatom << " to " << *Binder->rightatom << ": " << tmp << "." << endl;
           if (tmp > BondDistance) {
@@ -1753,9 +1760,9 @@
       // create translation vector from their periodically modified distance
       for (int i=NDIM;i--;) {
-        tmp = Binder->leftatom->x[i] - Binder->rightatom->x[i];
+        tmp = Binder->leftatom->at(i) - Binder->rightatom->at(i);
         if (fabs(tmp) > BondDistance)
           Translationvector[i] = (tmp < 0) ? +1. : -1.;
       }
-      Translationvector.MatrixMultiplication(matrix);
+      Translationvector *= matrix;
       //Log() << Verbose(3) << "Translation vector is ";
       Log() << Verbose(0) << Translationvector <<  endl;
@@ -1768,5 +1775,5 @@
         //Log() << Verbose (3) << "Current Walker is: " << *Walker << "." << endl;
         ColorList[Walker->nr] = black;    // mark as explored
-        Walker->x += Translationvector; // translate
+        *Walker += Translationvector; // translate
         for (BondList::const_iterator Runner = Walker->ListOfBonds.begin(); Runner != Walker->ListOfBonds.end(); (++Runner)) {
           if ((*Runner) != Binder) {
@@ -1788,5 +1795,4 @@
   delete(AtomStack);
   delete[](ColorList);
-  delete[](matrix);
   DoLog(2) && (Log() << Verbose(2) << "End of ScanForPeriodicCorrection." << endl);
 };
Index: src/molecule_geometry.cpp
===================================================================
--- src/molecule_geometry.cpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/molecule_geometry.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -6,5 +6,17 @@
  */
 
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
 #include "Helpers/MemDebug.hpp"
+
+#include "Helpers/helpers.hpp"
+#include "Helpers/Log.hpp"
+#include "Helpers/Verbose.hpp"
+#include "LinearAlgebra/Line.hpp"
+#include "LinearAlgebra/Matrix.hpp"
+#include "LinearAlgebra/Plane.hpp"
 
 #include "atom.hpp"
@@ -12,12 +24,14 @@
 #include "config.hpp"
 #include "element.hpp"
-#include "helpers.hpp"
 #include "leastsquaremin.hpp"
-#include "log.hpp"
-#include "memoryallocator.hpp"
 #include "molecule.hpp"
 #include "World.hpp"
-#include "Plane.hpp"
+
+#include "Box.hpp"
+
 #include <boost/foreach.hpp>
+
+#include <gsl/gsl_eigen.h>
+#include <gsl/gsl_multimin.h>
 
 
@@ -33,15 +47,13 @@
   const Vector *Center = DetermineCenterOfAll();
   const Vector *CenterBox = DetermineCenterOfBox();
-  double * const cell_size = World::getInstance().getDomain();
-  double *M = ReturnFullMatrixforSymmetric(cell_size);
-  double *Minv = InverseMatrix(M);
-
-  // go through all atoms
-  ActOnAllVectors( &Vector::SubtractVector, *Center);
-  ActOnAllVectors( &Vector::SubtractVector, *CenterBox);
-  ActOnAllVectors( &Vector::WrapPeriodically, (const double *)M, (const double *)Minv);
-
-  delete[](M);
-  delete[](Minv);
+  Box &domain = World::getInstance().getDomain();
+
+  // go through all atoms
+  BOOST_FOREACH(atom* iter, atoms){
+    *iter -= *Center;
+    *iter -= *CenterBox;
+  }
+  atoms.transformNodes(boost::bind(&Box::WrapPeriodically,domain,_1));
+
   delete(Center);
   delete(CenterBox);
@@ -56,13 +68,9 @@
 {
   bool status = true;
-  double * const cell_size = World::getInstance().getDomain();
-  double *M = ReturnFullMatrixforSymmetric(cell_size);
-  double *Minv = InverseMatrix(M);
-
-  // go through all atoms
-  ActOnAllVectors( &Vector::WrapPeriodically, (const double *)M, (const double *)Minv);
-
-  delete[](M);
-  delete[](Minv);
+  Box &domain = World::getInstance().getDomain();
+
+  // go through all atoms
+  atoms.transformNodes(boost::bind(&Box::WrapPeriodically,domain,_1));
+
   return status;
 };
@@ -80,12 +88,12 @@
   if (iter != end()) { //list not empty?
     for (int i=NDIM;i--;) {
-      max->at(i) = (*iter)->x[i];
-      min->at(i) = (*iter)->x[i];
+      max->at(i) = (*iter)->at(i);
+      min->at(i) = (*iter)->at(i);
     }
     for (; iter != end(); ++iter) {// continue with second if present
       //(*iter)->Output(1,1,out);
       for (int i=NDIM;i--;) {
-        max->at(i) = (max->at(i) < (*iter)->x[i]) ? (*iter)->x[i] : max->at(i);
-        min->at(i) = (min->at(i) > (*iter)->x[i]) ? (*iter)->x[i] : min->at(i);
+        max->at(i) = (max->at(i) < (*iter)->at(i)) ? (*iter)->at(i) : max->at(i);
+        min->at(i) = (min->at(i) > (*iter)->at(i)) ? (*iter)->at(i) : min->at(i);
       }
     }
@@ -98,5 +106,4 @@
     (*max) += (*min);
     Translate(min);
-    Center.Zero();
   }
   delete(min);
@@ -112,15 +119,14 @@
   int Num = 0;
   molecule::const_iterator iter = begin();  // start at first in list
+  Vector Center;
 
   Center.Zero();
-
   if (iter != end()) {   //list not empty?
     for (; iter != end(); ++iter) {  // continue with second if present
       Num++;
-      Center += (*iter)->x;
+      Center += (*iter)->getPosition();
     }
     Center.Scale(-1./(double)Num); // divide through total number (and sign for direction)
     Translate(&Center);
-    Center.Zero();
   }
 };
@@ -140,5 +146,5 @@
     for (; iter != end(); ++iter) {  // continue with second if present
       Num++;
-      (*a) += (*iter)->x;
+      (*a) += (*iter)->getPosition();
     }
     a->Scale(1./(double)Num); // divide through total mass (and sign for direction)
@@ -153,10 +159,6 @@
 {
   Vector *a = new Vector(0.5,0.5,0.5);
-
-  const double *cell_size = World::getInstance().getDomain();
-  double *M = ReturnFullMatrixforSymmetric(cell_size);
-  a->MatrixMultiplication(M);
-  delete[](M);
-
+  const Matrix &M = World::getInstance().getDomain().getM();
+  (*a) *= M;
   return a;
 };
@@ -166,5 +168,5 @@
  * \return pointer to center of gravity vector
  */
-Vector * molecule::DetermineCenterOfGravity()
+Vector * molecule::DetermineCenterOfGravity() const
 {
   molecule::const_iterator iter = begin();  // start at first in list
@@ -177,6 +179,6 @@
   if (iter != end()) {   //list not empty?
     for (; iter != end(); ++iter) {  // continue with second if present
-      Num += (*iter)->type->mass;
-      tmp = (*iter)->type->mass * (*iter)->x;
+      Num += (*iter)->getType()->mass;
+      tmp = (*iter)->getType()->mass * (*iter)->getPosition();
       (*a) += tmp;
     }
@@ -195,5 +197,10 @@
 void molecule::CenterPeriodic()
 {
-  DeterminePeriodicCenter(Center);
+  Vector NewCenter;
+  DeterminePeriodicCenter(NewCenter);
+  // go through all atoms
+  BOOST_FOREACH(atom* iter, atoms){
+    *iter -= NewCenter;
+  }
 };
 
@@ -205,5 +212,8 @@
 void molecule::CenterAtVector(Vector *newcenter)
 {
-  Center = *newcenter;
+  // go through all atoms
+  BOOST_FOREACH(atom* iter, atoms){
+    *iter -= *newcenter;
+  }
 };
 
@@ -222,5 +232,5 @@
     for (int j=0;j<MDSteps;j++)
       (*iter)->Trajectory.R.at(j).ScaleAll(*factor);
-    (*iter)->x.ScaleAll(*factor);
+    (*iter)->ScaleAll(*factor);
   }
 };
@@ -234,5 +244,5 @@
     for (int j=0;j<MDSteps;j++)
       (*iter)->Trajectory.R.at(j) += (*trans);
-    (*iter)->x += (*trans);
+    *(*iter) += (*trans);
   }
 };
@@ -244,14 +254,12 @@
 void molecule::TranslatePeriodically(const Vector *trans)
 {
-  double * const cell_size = World::getInstance().getDomain();
-  double *M = ReturnFullMatrixforSymmetric(cell_size);
-  double *Minv = InverseMatrix(M);
-
-  // go through all atoms
-  ActOnAllVectors( &Vector::AddVector, *trans);
-  ActOnAllVectors( &Vector::WrapPeriodically, (const double *)M, (const double *)Minv);
-
-  delete[](M);
-  delete[](Minv);
+  Box &domain = World::getInstance().getDomain();
+
+  // go through all atoms
+  BOOST_FOREACH(atom* iter, atoms){
+    *iter += *trans;
+  }
+  atoms.transformNodes(boost::bind(&Box::WrapPeriodically,domain,_1));
+
 };
 
@@ -264,7 +272,5 @@
   OBSERVE;
   Plane p(*n,0);
-  BOOST_FOREACH( atom* iter, atoms ){
-    (*iter->node) = p.mirrorVector(*iter->node);
-  }
+  atoms.transformNodes(boost::bind(&Plane::mirrorVector,p,_1));
 };
 
@@ -274,10 +280,10 @@
 void molecule::DeterminePeriodicCenter(Vector &center)
 {
-  double * const cell_size = World::getInstance().getDomain();
-  double *matrix = ReturnFullMatrixforSymmetric(cell_size);
-  double *inversematrix = InverseMatrix(matrix);
+  const Matrix &matrix = World::getInstance().getDomain().getM();
+  const Matrix &inversematrix = World::getInstance().getDomain().getM();
   double tmp;
   bool flag;
   Vector Testvector, Translationvector;
+  Vector Center;
 
   do {
@@ -286,13 +292,12 @@
     for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
 #ifdef ADDHYDROGEN
-      if ((*iter)->type->Z != 1) {
+      if ((*iter)->getType()->Z != 1) {
 #endif
-        Testvector = (*iter)->x;
-        Testvector.MatrixMultiplication(inversematrix);
+        Testvector = inversematrix * (*iter)->getPosition();
         Translationvector.Zero();
         for (BondList::const_iterator Runner = (*iter)->ListOfBonds.begin(); Runner != (*iter)->ListOfBonds.end(); (++Runner)) {
          if ((*iter)->nr < (*Runner)->GetOtherAtom((*iter))->nr) // otherwise we shift one to, the other fro and gain nothing
             for (int j=0;j<NDIM;j++) {
-              tmp = (*iter)->x[j] - (*Runner)->GetOtherAtom(*iter)->x[j];
+              tmp = (*iter)->at(j) - (*Runner)->GetOtherAtom(*iter)->at(j);
               if ((fabs(tmp)) > BondDistance) {
                 flag = false;
@@ -306,5 +311,5 @@
         }
         Testvector += Translationvector;
-        Testvector.MatrixMultiplication(matrix);
+        Testvector *= matrix;
         Center += Testvector;
         Log() << Verbose(1) << "vector is: " << Testvector << endl;
@@ -312,9 +317,8 @@
         // now also change all hydrogens
         for (BondList::const_iterator Runner = (*iter)->ListOfBonds.begin(); Runner != (*iter)->ListOfBonds.end(); (++Runner)) {
-          if ((*Runner)->GetOtherAtom((*iter))->type->Z == 1) {
-            Testvector = (*Runner)->GetOtherAtom((*iter))->x;
-            Testvector.MatrixMultiplication(inversematrix);
+          if ((*Runner)->GetOtherAtom((*iter))->getType()->Z == 1) {
+            Testvector = inversematrix * (*Runner)->GetOtherAtom((*iter))->getPosition();
             Testvector += Translationvector;
-            Testvector.MatrixMultiplication(matrix);
+            Testvector *= matrix;
             Center += Testvector;
             Log() << Verbose(1) << "Hydrogen vector is: " << Testvector << endl;
@@ -325,104 +329,8 @@
     }
   } while (!flag);
-  delete[](matrix);
-  delete[](inversematrix);
 
   Center.Scale(1./static_cast<double>(getAtomCount()));
-};
-
-/** Transforms/Rotates the given molecule into its principal axis system.
- * \param *out output stream for debugging
- * \param DoRotate whether to rotate (true) or only to determine the PAS.
- * TODO treatment of trajetories missing
- */
-void molecule::PrincipalAxisSystem(bool DoRotate)
-{
-  double InertiaTensor[NDIM*NDIM];
-  Vector *CenterOfGravity = DetermineCenterOfGravity();
-
-  CenterPeriodic();
-
-  // reset inertia tensor
-  for(int i=0;i<NDIM*NDIM;i++)
-    InertiaTensor[i] = 0.;
-
-  // sum up inertia tensor
-  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
-    Vector x = (*iter)->x;
-    //x.SubtractVector(CenterOfGravity);
-    InertiaTensor[0] += (*iter)->type->mass*(x[1]*x[1] + x[2]*x[2]);
-    InertiaTensor[1] += (*iter)->type->mass*(-x[0]*x[1]);
-    InertiaTensor[2] += (*iter)->type->mass*(-x[0]*x[2]);
-    InertiaTensor[3] += (*iter)->type->mass*(-x[1]*x[0]);
-    InertiaTensor[4] += (*iter)->type->mass*(x[0]*x[0] + x[2]*x[2]);
-    InertiaTensor[5] += (*iter)->type->mass*(-x[1]*x[2]);
-    InertiaTensor[6] += (*iter)->type->mass*(-x[2]*x[0]);
-    InertiaTensor[7] += (*iter)->type->mass*(-x[2]*x[1]);
-    InertiaTensor[8] += (*iter)->type->mass*(x[0]*x[0] + x[1]*x[1]);
-  }
-  // print InertiaTensor for debugging
-  DoLog(0) && (Log() << Verbose(0) << "The inertia tensor is:" << endl);
-  for(int i=0;i<NDIM;i++) {
-    for(int j=0;j<NDIM;j++)
-      DoLog(0) && (Log() << Verbose(0) << InertiaTensor[i*NDIM+j] << " ");
-    DoLog(0) && (Log() << Verbose(0) << endl);
-  }
-  DoLog(0) && (Log() << Verbose(0) << endl);
-
-  // diagonalize to determine principal axis system
-  gsl_eigen_symmv_workspace *T = gsl_eigen_symmv_alloc(NDIM);
-  gsl_matrix_view m = gsl_matrix_view_array(InertiaTensor, NDIM, NDIM);
-  gsl_vector *eval = gsl_vector_alloc(NDIM);
-  gsl_matrix *evec = gsl_matrix_alloc(NDIM, NDIM);
-  gsl_eigen_symmv(&m.matrix, eval, evec, T);
-  gsl_eigen_symmv_free(T);
-  gsl_eigen_symmv_sort(eval, evec, GSL_EIGEN_SORT_ABS_DESC);
-
-  for(int i=0;i<NDIM;i++) {
-    DoLog(1) && (Log() << Verbose(1) << "eigenvalue = " << gsl_vector_get(eval, i));
-    DoLog(0) && (Log() << Verbose(0) << ", eigenvector = (" << evec->data[i * evec->tda + 0] << "," << evec->data[i * evec->tda + 1] << "," << evec->data[i * evec->tda + 2] << ")" << endl);
-  }
-
-  // check whether we rotate or not
-  if (DoRotate) {
-    DoLog(1) && (Log() << Verbose(1) << "Transforming molecule into PAS ... ");
-    // the eigenvectors specify the transformation matrix
-    ActOnAllVectors( &Vector::MatrixMultiplication, (const double *) evec->data );
-    DoLog(0) && (Log() << Verbose(0) << "done." << endl);
-
-    // summing anew for debugging (resulting matrix has to be diagonal!)
-    // reset inertia tensor
-    for(int i=0;i<NDIM*NDIM;i++)
-      InertiaTensor[i] = 0.;
-
-    // sum up inertia tensor
-    for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
-      Vector x = (*iter)->x;
-      InertiaTensor[0] += (*iter)->type->mass*(x[1]*x[1] + x[2]*x[2]);
-      InertiaTensor[1] += (*iter)->type->mass*(-x[0]*x[1]);
-      InertiaTensor[2] += (*iter)->type->mass*(-x[0]*x[2]);
-      InertiaTensor[3] += (*iter)->type->mass*(-x[1]*x[0]);
-      InertiaTensor[4] += (*iter)->type->mass*(x[0]*x[0] + x[2]*x[2]);
-      InertiaTensor[5] += (*iter)->type->mass*(-x[1]*x[2]);
-      InertiaTensor[6] += (*iter)->type->mass*(-x[2]*x[0]);
-      InertiaTensor[7] += (*iter)->type->mass*(-x[2]*x[1]);
-      InertiaTensor[8] += (*iter)->type->mass*(x[0]*x[0] + x[1]*x[1]);
-    }
-    // print InertiaTensor for debugging
-    DoLog(0) && (Log() << Verbose(0) << "The inertia tensor is:" << endl);
-    for(int i=0;i<NDIM;i++) {
-      for(int j=0;j<NDIM;j++)
-        DoLog(0) && (Log() << Verbose(0) << InertiaTensor[i*NDIM+j] << " ");
-      DoLog(0) && (Log() << Verbose(0) << endl);
-    }
-    DoLog(0) && (Log() << Verbose(0) << endl);
-  }
-
-  // free everything
-  delete(CenterOfGravity);
-  gsl_vector_free(eval);
-  gsl_matrix_free(evec);
-};
-
+  CenterAtVector(&Center);
+};
 
 /** Align all atoms in such a manner that given vector \a *n is along z axis.
@@ -442,7 +350,7 @@
   DoLog(1) && (Log() << Verbose(1) << "Z-X-angle: " << alpha << " ... ");
   for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
-    tmp = (*iter)->x[0];
-    (*iter)->x[0] =  cos(alpha) * tmp + sin(alpha) * (*iter)->x[2];
-    (*iter)->x[2] = -sin(alpha) * tmp + cos(alpha) * (*iter)->x[2];
+    tmp = (*iter)->at(0);
+    (*iter)->set(0,  cos(alpha) * tmp + sin(alpha) * (*iter)->at(2));
+    (*iter)->set(2, -sin(alpha) * tmp + cos(alpha) * (*iter)->at(2));
     for (int j=0;j<MDSteps;j++) {
       tmp = (*iter)->Trajectory.R.at(j)[0];
@@ -461,7 +369,7 @@
   DoLog(1) && (Log() << Verbose(1) << "Z-Y-angle: " << alpha << " ... ");
   for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
-    tmp = (*iter)->x[1];
-    (*iter)->x[1] =  cos(alpha) * tmp + sin(alpha) * (*iter)->x[2];
-    (*iter)->x[2] = -sin(alpha) * tmp + cos(alpha) * (*iter)->x[2];
+    tmp = (*iter)->at(1);
+    (*iter)->set(1,  cos(alpha) * tmp + sin(alpha) * (*iter)->at(2));
+    (*iter)->set(2, -sin(alpha) * tmp + cos(alpha) * (*iter)->at(2));
     for (int j=0;j<MDSteps;j++) {
       tmp = (*iter)->Trajectory.R.at(j)[1];
@@ -501,6 +409,6 @@
   // go through all atoms
   for (molecule::const_iterator iter = par->mol->begin(); iter != par->mol->end(); ++iter) {
-    if ((*iter)->type == ((struct lsq_params *)params)->type) { // for specific type
-      c = (*iter)->x - a;
+    if ((*iter)->getType() == ((struct lsq_params *)params)->type) { // for specific type
+      c = (*iter)->getPosition() - a;
       t = c.ScalarProduct(b);           // get direction parameter
       d = t*b;       // and create vector
Index: src/molecule_graph.cpp
===================================================================
--- src/molecule_graph.cpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/molecule_graph.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -5,4 +5,9 @@
  *      Author: heber
  */
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
 
 #include "Helpers/MemDebug.hpp"
@@ -14,15 +19,17 @@
 #include "defs.hpp"
 #include "element.hpp"
-#include "helpers.hpp"
-#include "info.hpp"
+#include "Helpers/helpers.hpp"
+#include "Helpers/Info.hpp"
 #include "linkedcell.hpp"
 #include "lists.hpp"
-#include "log.hpp"
-#include "memoryallocator.hpp"
+#include "Helpers/Verbose.hpp"
+#include "Helpers/Log.hpp"
 #include "molecule.hpp"
 #include "World.hpp"
 #include "Helpers/fast_functions.hpp"
 #include "Helpers/Assert.hpp"
-
+#include "LinearAlgebra/Matrix.hpp"
+#include "Box.hpp"
+#include "stackclass.hpp"
 
 struct BFSAccounting
@@ -121,5 +128,5 @@
   LinkedCell *LC = NULL;
   bool free_BG = false;
-  double * const cell_size = World::getInstance().getDomain();
+  Box &domain = World::getInstance().getDomain();
 
   if (BG == NULL) {
@@ -178,5 +185,5 @@
                           //Log() << Verbose(1) << "Checking distance " << OtherWalker->x.PeriodicDistanceSquared(&(Walker->x), cell_size) << " against typical bond length of " << bonddistance*bonddistance << "." << endl;
                           (BG->*minmaxdistance)(Walker, OtherWalker, MinDistance, MaxDistance, IsAngstroem);
-                          const double distance = OtherWalker->x.PeriodicDistanceSquared(Walker->x,cell_size);
+                          const double distance = domain.periodicDistanceSquared(OtherWalker->getPosition(),Walker->getPosition());
                           const bool status = (distance <= MaxDistance * MaxDistance) && (distance >= MinDistance * MinDistance);
 //                          Log() << Verbose(1) << "MinDistance is " << MinDistance << " and MaxDistance is " << MaxDistance << "." << endl;
@@ -579,5 +586,5 @@
     // From OldGraphNr to CurrentGraphNr ranges an disconnected subgraph
     DoLog(0) && (Log() << Verbose(0) << "Disconnected subgraph ranges from " << OldGraphNr << " to " << DFS.CurrentGraphNr << "." << endl);
-    LeafWalker->Leaf->Output((ofstream *)&cout);
+    LeafWalker->Leaf->Output((ofstream *)&(Log() << Verbose(0)));
     DoLog(0) && (Log() << Verbose(0) << endl);
 
@@ -731,5 +738,5 @@
         OtherAtom = (*Runner)->GetOtherAtom(Walker);
 #ifdef ADDHYDROGEN
-        if (OtherAtom->type->Z != 1) {
+        if (OtherAtom->getType()->Z != 1) {
 #endif
         DoLog(2) && (Log() << Verbose(2) << "Current OtherAtom is: " << OtherAtom->getName() << " for bond " << *(*Runner) << "." << endl);
Index: src/molecule_pointcloud.cpp
===================================================================
--- src/molecule_pointcloud.cpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/molecule_pointcloud.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -6,10 +6,14 @@
  */
 
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
 #include "Helpers/MemDebug.hpp"
 
 #include "atom.hpp"
 #include "config.hpp"
-#include "info.hpp"
-#include "memoryallocator.hpp"
+#include "Helpers/Info.hpp"
 #include "molecule.hpp"
 
Index: src/molecule_template.hpp
===================================================================
--- src/molecule_template.hpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/molecule_template.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -19,70 +19,4 @@
 /********************************************** declarations *******************************/
 
-// ================== Acting on all Vectors ========================== //
-
-// zero arguments
-template <typename res> void molecule::ActOnAllVectors( res (Vector::*f)() ) const
-    {
-  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
-    (((*iter)->node)->*f)();
-  }
-};
-template <typename res> void molecule::ActOnAllVectors( res (Vector::*f)() const ) const
-    {
-  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
-    (((*iter)->node)->*f)();
-  }
-};
-// one argument
-template <typename res, typename T> void molecule::ActOnAllVectors( res (Vector::*f)(T), T t ) const
-{
-  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
-    (((*iter)->node)->*f)(t);
-  }
-};
-template <typename res, typename T> void molecule::ActOnAllVectors( res (Vector::*f)(T) const, T t ) const
-{
-  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
-    (((*iter)->node)->*f)(t);
-  }
-};
-template <typename res, typename T> void molecule::ActOnAllVectors( res (Vector::*f)(T&), T &t ) const
-{
-  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
-    (((*iter)->node)->*f)(t);
-  }
-};
-template <typename res, typename T> void molecule::ActOnAllVectors( res (Vector::*f)(T&) const, T &t ) const
-{
-  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
-    (((*iter)->node)->*f)(t);
-  }
-};
-// two arguments
-template <typename res, typename T, typename U> void molecule::ActOnAllVectors( res (Vector::*f)(T, U), T t, U u ) const
-{
-  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
-    (((*iter)->node)->*f)(t, u);
-  }
-};
-template <typename res, typename T, typename U> void molecule::ActOnAllVectors( res (Vector::*f)(T, U) const, T t, U u ) const
-{
-  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
-    (((*iter)->node)->*f)(t, u);
-  }
-};
-// three arguments
-template <typename res, typename T, typename U, typename V> void molecule::ActOnAllVectors( res (Vector::*f)(T, U, V), T t, U u, V v) const
-{
-  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
-    (((*iter)->node)->*f)(t, u, v);
-  }
-};
-template <typename res, typename T, typename U, typename V> void molecule::ActOnAllVectors( res (Vector::*f)(T, U, V) const, T t, U u, V v) const
-{
-  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
-    (((*iter)->node)->*f)(t, u, v);
-  }
-};
 
 // ========================= Summing over each Atoms =================================== //
@@ -370,5 +304,5 @@
   int inc = 1;
   for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
-    (*Setor) (&array[((*iter)->type->*index)], &inc);
+    (*Setor) (&array[((*iter)->getType()->*index)], &inc);
   }
 };
@@ -376,5 +310,5 @@
 {
   for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
-    (*Setor) (&array[((*iter)->type->*index)], &value);
+    (*Setor) (&array[((*iter)->getType()->*index)], &value);
   }
 };
@@ -382,5 +316,5 @@
 {
   for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
-    (*Setor) (&array[((*iter)->type->*index)], value);
+    (*Setor) (&array[((*iter)->getType()->*index)], value);
   }
 };
Index: src/moleculelist.cpp
===================================================================
--- src/moleculelist.cpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/moleculelist.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -5,7 +5,15 @@
  */
 
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
 #include "Helpers/MemDebug.hpp"
 
 #include <cstring>
+
+#include <gsl/gsl_inline.h>
+#include <gsl/gsl_heapsort.h>
 
 #include "World.hpp"
@@ -16,12 +24,16 @@
 #include "config.hpp"
 #include "element.hpp"
-#include "helpers.hpp"
+#include "Helpers/helpers.hpp"
 #include "linkedcell.hpp"
 #include "lists.hpp"
-#include "log.hpp"
+#include "Helpers/Verbose.hpp"
+#include "Helpers/Log.hpp"
 #include "molecule.hpp"
-#include "memoryallocator.hpp"
 #include "periodentafel.hpp"
+#include "tesselation.hpp"
 #include "Helpers/Assert.hpp"
+#include "LinearAlgebra/Matrix.hpp"
+#include "Box.hpp"
+#include "stackclass.hpp"
 
 #include "Helpers/Assert.hpp"
@@ -33,10 +45,7 @@
 MoleculeListClass::MoleculeListClass(World *_world) :
   Observable("MoleculeListClass"),
+  MaxIndex(1),
   world(_world)
-{
-  // empty lists
-  ListOfMolecules.clear();
-  MaxIndex = 1;
-};
+{};
 
 /** Destructor for MoleculeListClass.
@@ -172,7 +181,7 @@
       size=0.;
       for (molecule::const_iterator iter = (*ListRunner)->begin(); iter != (*ListRunner)->end(); ++iter) {
-        counts[(*iter)->type->getNumber()]++;
-        if ((*iter)->x.DistanceSquared(Origin) > size)
-          size = (*iter)->x.DistanceSquared(Origin);
+        counts[(*iter)->getType()->getNumber()]++;
+        if ((*iter)->DistanceSquared(Origin) > size)
+          size = (*iter)->DistanceSquared(Origin);
       }
       // output Index, Name, number of atoms, chemical formula
@@ -185,5 +194,7 @@
       }
       // Center and size
-      (*out) << "\t" << (*ListRunner)->Center << "\t" << sqrt(size) << endl;
+      Vector *Center = (*ListRunner)->DetermineCenterOfAll();
+      (*out) << "\t" << *Center << "\t" << sqrt(size) << endl;
+      delete(Center);
     }
   }
@@ -202,166 +213,4 @@
 };
 
-/** Simple merge of two molecules into one.
- * \param *mol destination molecule
- * \param *srcmol source molecule
- * \return true - merge successful, false - merge failed (probably due to non-existant indices
- */
-bool MoleculeListClass::SimpleMerge(molecule *mol, molecule *srcmol)
-{
-  if (srcmol == NULL)
-    return false;
-
-  // put all molecules of src into mol
-  for (molecule::iterator iter = srcmol->begin(); !srcmol->empty(); iter=srcmol->begin()) {
-    atom * const Walker = *iter;
-    srcmol->UnlinkAtom(Walker);
-    mol->AddAtom(Walker);
-  }
-
-  // remove src
-  ListOfMolecules.remove(srcmol);
-  World::getInstance().destroyMolecule(srcmol);
-  return true;
-};
-
-/** Simple add of one molecules into another.
- * \param *mol destination molecule
- * \param *srcmol source molecule
- * \return true - merge successful, false - merge failed (probably due to non-existant indices
- */
-bool MoleculeListClass::SimpleAdd(molecule *mol, molecule *srcmol)
-{
-  if (srcmol == NULL)
-    return false;
-
-  // put all molecules of src into mol
-  atom *Walker = NULL;
-  for (molecule::iterator iter = srcmol->begin(); iter != srcmol->end(); ++iter) {
-    Walker = mol->AddCopyAtom((*iter));
-    Walker->father = Walker;
-  }
-
-  return true;
-};
-
-/** Simple merge of a given set of molecules into one.
- * \param *mol destination molecule
- * \param *src index of set of source molecule
- * \param N number of source molecules
- * \return true - merge successful, false - some merges failed (probably due to non-existant indices)
- */
-bool MoleculeListClass::SimpleMultiMerge(molecule *mol, int *src, int N)
-{
-  bool status = true;
-  // check presence of all source molecules
-  for (int i=0;i<N;i++) {
-    molecule *srcmol = ReturnIndex(src[i]);
-    status = status && SimpleMerge(mol, srcmol);
-  }
-  insert(mol);
-  return status;
-};
-
-/** Simple add of a given set of molecules into one.
- * \param *mol destination molecule
- * \param *src index of set of source molecule
- * \param N number of source molecules
- * \return true - merge successful, false - some merges failed (probably due to non-existant indices)
- */
-bool MoleculeListClass::SimpleMultiAdd(molecule *mol, int *src, int N)
-{
-  bool status = true;
-  // check presence of all source molecules
-  for (int i=0;i<N;i++) {
-    molecule *srcmol = ReturnIndex(src[i]);
-    status = status && SimpleAdd(mol, srcmol);
-  }
-  return status;
-};
-
-/** Scatter merge of a given set of molecules into one.
- * Scatter merge distributes the molecules in such a manner that they don't overlap.
- * \param *mol destination molecule
- * \param *src index of set of source molecule
- * \param N number of source molecules
- * \return true - merge successful, false - merge failed (probably due to non-existant indices
- * \TODO find scatter center for each src molecule
- */
-bool MoleculeListClass::ScatterMerge(molecule *mol, int *src, int N)
-{
-  // check presence of all source molecules
-  for (int i=0;i<N;i++) {
-    // get pointer to src molecule
-    molecule *srcmol = ReturnIndex(src[i]);
-    if (srcmol == NULL)
-      return false;
-  }
-  // adapt each Center
-  for (int i=0;i<N;i++) {
-    // get pointer to src molecule
-    molecule *srcmol = ReturnIndex(src[i]);
-    //srcmol->Center.Zero();
-    srcmol->Translate(&srcmol->Center);
-  }
-  // perform a simple multi merge
-  SimpleMultiMerge(mol, src, N);
-  return true;
-};
-
-/** Embedding merge of a given set of molecules into one.
- * Embedding merge inserts one molecule into the other.
- * \param *mol destination molecule (fixed one)
- * \param *srcmol source molecule (variable one, where atoms are taken from)
- * \return true - merge successful, false - merge failed (probably due to non-existant indices)
- * \TODO linked cell dimensions for boundary points has to be as big as inner diameter!
- */
-bool MoleculeListClass::EmbedMerge(molecule *mol, molecule *srcmol)
-{
-  LinkedCell *LCList = NULL;
-  Tesselation *TesselStruct = NULL;
-  if ((srcmol == NULL) || (mol == NULL)) {
-    DoeLog(1) && (eLog()<< Verbose(1) << "Either fixed or variable molecule is given as NULL." << endl);
-    return false;
-  }
-
-  // calculate envelope for *mol
-  LCList = new LinkedCell(mol, 8.);
-  FindNonConvexBorder(mol, TesselStruct, (const LinkedCell *&)LCList, 4., NULL);
-  if (TesselStruct == NULL) {
-    DoeLog(1) && (eLog()<< Verbose(1) << "Could not tesselate the fixed molecule." << endl);
-    return false;
-  }
-  delete(LCList);
-  LCList = new LinkedCell(TesselStruct, 8.);  // re-create with boundary points only!
-
-  // prepare index list for bonds
-  atom ** CopyAtoms = new atom*[srcmol->getAtomCount()];
-  for(int i=0;i<srcmol->getAtomCount();i++)
-    CopyAtoms[i] = NULL;
-
-  // for each of the source atoms check whether we are in- or outside and add copy atom
-  int nr=0;
-  for (molecule::const_iterator iter = srcmol->begin(); iter != srcmol->end(); ++iter) {
-    DoLog(2) && (Log() << Verbose(2) << "INFO: Current Walker is " << **iter << "." << endl);
-    if (!TesselStruct->IsInnerPoint((*iter)->x, LCList)) {
-      CopyAtoms[(*iter)->nr] = (*iter)->clone();
-      mol->AddAtom(CopyAtoms[(*iter)->nr]);
-      nr++;
-    } else {
-      // do nothing
-    }
-  }
-  DoLog(1) && (Log() << Verbose(1) << nr << " of " << srcmol->getAtomCount() << " atoms have been merged.");
-
-  // go through all bonds and add as well
-  for(molecule::iterator AtomRunner = srcmol->begin(); AtomRunner != srcmol->end(); ++AtomRunner)
-    for(BondList::iterator BondRunner = (*AtomRunner)->ListOfBonds.begin(); BondRunner != (*AtomRunner)->ListOfBonds.end(); ++BondRunner)
-      if ((*BondRunner)->leftatom == *AtomRunner) {
-        DoLog(3) && (Log() << Verbose(3) << "Adding Bond between " << *CopyAtoms[(*BondRunner)->leftatom->nr] << " and " << *CopyAtoms[(*BondRunner)->rightatom->nr]<< "." << endl);
-        mol->AddBond(CopyAtoms[(*BondRunner)->leftatom->nr], CopyAtoms[(*BondRunner)->rightatom->nr], (*BondRunner)->BondDegree);
-      }
-  delete(LCList);
-  return true;
-};
 
 /** Simple output of the pointers in ListOfMolecules.
@@ -491,13 +340,13 @@
     for (molecule::const_iterator iter = (*ListRunner)->begin(); iter != (*ListRunner)->end(); ++iter) {
       //Log() << Verbose(1) << "(*iter): " << *(*iter) << " with first bond " << *((*iter)->ListOfBonds.begin()) << "." << endl;
-      if (((*iter)->type->Z == 1) && (((*iter)->father == NULL)
-          || ((*iter)->father->type->Z != 1))) { // if it's a hydrogen
+      if (((*iter)->getType()->Z == 1) && (((*iter)->father == NULL)
+          || ((*iter)->father->getType()->Z != 1))) { // if it's a hydrogen
         for (molecule::const_iterator runner = (*ListRunner)->begin(); runner != (*ListRunner)->end(); ++runner) {
           //Log() << Verbose(2) << "Runner: " << *(*runner) << " with first bond " << *((*iter)->ListOfBonds.begin()) << "." << endl;
           // 3. take every other hydrogen that is the not the first and not bound to same bonding partner
           Binder = *((*runner)->ListOfBonds.begin());
-          if (((*runner)->type->Z == 1) && ((*runner)->nr > (*iter)->nr) && (Binder->GetOtherAtom((*runner)) != Binder->GetOtherAtom((*iter)))) { // (hydrogens have only one bonding partner!)
+          if (((*runner)->getType()->Z == 1) && ((*runner)->nr > (*iter)->nr) && (Binder->GetOtherAtom((*runner)) != Binder->GetOtherAtom((*iter)))) { // (hydrogens have only one bonding partner!)
             // 4. evaluate the morse potential for each matrix component and add up
-            distance = (*runner)->x.distance((*iter)->x);
+            distance = (*runner)->distance(*(*iter));
             //Log() << Verbose(0) << "Fragment " << (*ListRunner)->name << ": " << *(*runner) << "<= " << distance << "=>" << *(*iter) << ":" << endl;
             for (int k = 0; k < a; k++) {
@@ -587,7 +436,7 @@
       periodentafel::const_iterator elemIter;
       for(elemIter=periode->begin();elemIter!=periode->end();++elemIter){
-        if ((*ListRunner)->ElementsInMolecule[(*elemIter).first]) { // if this element got atoms
+        if ((*ListRunner)->hasElement((*elemIter).first)) { // if this element got atoms
           for(molecule::iterator atomIter = (*ListRunner)->begin(); atomIter !=(*ListRunner)->end();++atomIter){
-            if ((*atomIter)->type->getNumber() == (*elemIter).first) {
+            if ((*atomIter)->getType()->getNumber() == (*elemIter).first) {
               if (((*atomIter)->GetTrueFather() != NULL) && ((*atomIter)->GetTrueFather() != (*atomIter))) {// if there is a rea
                 //Log() << Verbose(0) << "Walker is " << *Walker << " with true father " << *( Walker->GetTrueFather()) << ", it
@@ -631,10 +480,7 @@
   int FragmentCounter = 0;
   ofstream output;
-  double cell_size_backup[6];
-  double * const cell_size = World::getInstance().getDomain();
-
-  // backup cell_size
-  for (int i=0;i<6;i++)
-    cell_size_backup[i] = cell_size[i];
+  Matrix cell_size = World::getInstance().getDomain().getM();
+  Matrix cell_size_backup = cell_size;
+
   // store the fragments as config and as xyz
   for (MoleculeList::iterator ListRunner = ListOfMolecules.begin(); ListRunner != ListOfMolecules.end(); ListRunner++) {
@@ -674,14 +520,12 @@
     (*ListRunner)->CenterEdge(&BoxDimension);
     (*ListRunner)->SetBoxDimension(&BoxDimension); // update Box of atoms by boundary
-    int j = -1;
     for (int k = 0; k < NDIM; k++) {
-      j += k + 1;
       BoxDimension[k] = 2.5 * (World::getInstance().getConfig()->GetIsAngstroem() ? 1. : 1. / AtomicLengthToAngstroem);
-      cell_size[j] = BoxDimension[k] * 2.;
-    }
+      cell_size.at(k,k) = BoxDimension[k] * 2.;
+    }
+    World::getInstance().setDomain(cell_size);
     (*ListRunner)->Translate(&BoxDimension);
 
     // also calculate necessary orbitals
-    (*ListRunner)->CountElements(); // this is a bugfix, atoms should shoulds actually be added correctly to this fragment
     //(*ListRunner)->CalculateOrbitals(*World::getInstance().getConfig);
 
@@ -725,6 +569,5 @@
 
   // restore cell_size
-  for (int i=0;i<6;i++)
-    cell_size[i] = cell_size_backup[i];
+  World::getInstance().setDomain(cell_size_backup);
 
   return result;
@@ -740,103 +583,4 @@
     count += ((*ListRunner)->ActiveFlag ? 1 : 0);
   return count;
-};
-
-/** Dissects given \a *mol into connected subgraphs and inserts them as new molecules but with old atoms into \a this.
- * \param *out output stream for debugging
- * \param *periode periodentafel
- * \param *configuration config with BondGraph
- */
-void MoleculeListClass::DissectMoleculeIntoConnectedSubgraphs(const periodentafel * const periode, config * const configuration)
-{
-  // 0a. remove all present molecules
-  vector<molecule *> allmolecules = World::getInstance().getAllMolecules();
-  for (vector<molecule *>::iterator MolRunner = allmolecules.begin(); MolRunner != allmolecules.end(); ++MolRunner) {
-    erase(*MolRunner);
-    World::getInstance().destroyMolecule(*MolRunner);
-  }
-  // 0b. remove all bonds and construct a molecule with all atoms
-  molecule *mol = World::getInstance().createMolecule();
-  vector <atom *> allatoms = World::getInstance().getAllAtoms();
-  for(vector<atom *>::iterator AtomRunner = allatoms.begin(); AtomRunner != allatoms.end(); ++AtomRunner) {
-    for(BondList::iterator BondRunner = (*AtomRunner)->ListOfBonds.begin(); !(*AtomRunner)->ListOfBonds.empty(); BondRunner = (*AtomRunner)->ListOfBonds.begin())
-      delete(*BondRunner);
-    mol->AddAtom(*AtomRunner);
-  }
-
-  // 1. dissect the molecule into connected subgraphs
-  if (configuration->BG != NULL) {
-    if (!configuration->BG->ConstructBondGraph(mol)) {
-      World::getInstance().destroyMolecule(mol);
-      DoeLog(1) && (eLog()<< Verbose(1) << "There are no bonds." << endl);
-      return;
-    }
-  } else {
-    DoeLog(1) && (eLog()<< Verbose(1) << "There is no BondGraph class present to create bonds." << endl);
-    return;
-  }
-
-  // 2. scan for connected subgraphs
-  MoleculeLeafClass *Subgraphs = NULL;      // list of subgraphs from DFS analysis
-  class StackClass<bond *> *BackEdgeStack = NULL;
-  Subgraphs = mol->DepthFirstSearchAnalysis(BackEdgeStack);
-  delete(BackEdgeStack);
-  if ((Subgraphs == NULL) || (Subgraphs->next == NULL)) {
-    World::getInstance().destroyMolecule(mol);
-    DoeLog(1) && (eLog()<< Verbose(1) << "There are no atoms." << endl);
-    return;
-  }
-
-  // 3. dissect (the following construct is needed to have the atoms not in the order of the DFS, but in
-  // the original one as parsed in)
-  // TODO: Optimize this, when molecules just contain pointer list of global atoms!
-
-  // 4a. create array of molecules to fill
-  const int MolCount = Subgraphs->next->Count();
-  char number[MAXSTRINGSIZE];
-  molecule **molecules = new molecule *[MolCount];
-  MoleculeLeafClass *MolecularWalker = Subgraphs;
-  for (int i=0;i<MolCount;i++) {
-    MolecularWalker = MolecularWalker->next;
-    molecules[i] = World::getInstance().createMolecule();
-    molecules[i]->ActiveFlag = true;
-    strncpy(molecules[i]->name, mol->name, MAXSTRINGSIZE);
-    if (MolCount > 1) {
-      sprintf(number, "-%d", i+1);
-      strncat(molecules[i]->name, number, MAXSTRINGSIZE - strlen(mol->name) - 1);
-    }
-    DoLog(1) && (Log() << Verbose(1) << "MolName is " << molecules[i]->name << ", id is " << molecules[i]->getId() << endl);
-    for (molecule::iterator iter = MolecularWalker->Leaf->begin(); iter != MolecularWalker->Leaf->end(); ++iter) {
-      DoLog(1) && (Log() << Verbose(1) << **iter << endl);
-    }
-    insert(molecules[i]);
-  }
-
-  // 4b. create and fill map of which atom is associated to which connected molecule (note, counting starts at 1)
-  int FragmentCounter = 0;
-  map<int, atom *> AtomToFragmentMap;
-  MolecularWalker = Subgraphs;
-  while (MolecularWalker->next != NULL) {
-    MolecularWalker = MolecularWalker->next;
-    for (molecule::iterator iter = MolecularWalker->Leaf->begin(); !MolecularWalker->Leaf->empty(); iter = MolecularWalker->Leaf->begin()) {
-      atom * Walker = *iter;
-      DoLog(1) && (Log() << Verbose(1) << "Re-linking " << Walker << "..." << endl);
-      MolecularWalker->Leaf->erase(iter);
-      molecules[FragmentCounter]->AddAtom(Walker);    // counting starts at 1
-    }
-    FragmentCounter++;
-  }
-  World::getInstance().destroyMolecule(mol);
-
-  // 4d. we don't need to redo bonds, as they are connected subgraphs and still maintain their ListOfBonds, but we have to remove them from first..last list
-  // TODO: check whether this is really not needed anymore
-  // 4e. free Leafs
-  MolecularWalker = Subgraphs;
-  while (MolecularWalker->next != NULL) {
-    MolecularWalker = MolecularWalker->next;
-    delete(MolecularWalker->previous);
-  }
-  delete(MolecularWalker);
-  delete[](molecules);
-  DoLog(1) && (Log() << Verbose(1) << "I scanned " << FragmentCounter << " molecules." << endl);
 };
 
@@ -887,10 +631,8 @@
   // center at set box dimensions
   mol->CenterEdge(&center);
-  World::getInstance().getDomain()[0] = center[0];
-  World::getInstance().getDomain()[1] = 0;
-  World::getInstance().getDomain()[2] = center[1];
-  World::getInstance().getDomain()[3] = 0;
-  World::getInstance().getDomain()[4] = 0;
-  World::getInstance().getDomain()[5] = center[2];
+  Matrix domain;
+  for(int i =0;i<NDIM;++i)
+    domain.at(i,i) = center[i];
+  World::getInstance().setDomain(domain);
   insert(mol);
 }
@@ -950,5 +692,7 @@
  */
 //MoleculeLeafClass::MoleculeLeafClass(MoleculeLeafClass *Up = NULL, MoleculeLeafClass *Previous = NULL)
-MoleculeLeafClass::MoleculeLeafClass(MoleculeLeafClass *PreviousLeaf = NULL)
+MoleculeLeafClass::MoleculeLeafClass(MoleculeLeafClass *PreviousLeaf = NULL) :
+  Leaf(NULL),
+  previous(PreviousLeaf)
 {
   //  if (Up != NULL)
@@ -957,6 +701,4 @@
   //  UpLeaf = Up;
   //  DownLeaf = NULL;
-  Leaf = NULL;
-  previous = PreviousLeaf;
   if (previous != NULL) {
     MoleculeLeafClass *Walker = previous->next;
@@ -1087,5 +829,5 @@
         if (AtomMask[Father->nr]) // apply mask
 #ifdef ADDHYDROGEN
-          if ((*iter)->type->Z != 1) // skip hydrogen
+          if ((*iter)->getType()->Z != 1) // skip hydrogen
 #endif
           RootStack[FragmentCounter].push_front((*iter)->nr);
Index: src/parser.cpp
===================================================================
--- src/parser.cpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/parser.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -7,16 +7,16 @@
 // ======================================= INCLUDES ==========================================
 
-#include "Helpers/MemDebug.hpp"
-
-#include <cstring>
-
-#include "helpers.hpp"
-#include "memoryallocator.hpp"
-#include "parser.hpp"
-
 // include config.h
 #ifdef HAVE_CONFIG_H
 #include <config.h>
 #endif
+
+#include "Helpers/MemDebug.hpp"
+
+#include <cstring>
+
+#include "Helpers/helpers.hpp"
+#include "parser.hpp"
+#include "Helpers/Verbose.hpp"
 
 // ======================================= FUNCTIONS ==========================================
@@ -59,6 +59,7 @@
 /** Constructor of MatrixContainer class.
  */
-MatrixContainer::MatrixContainer() {
-  Indices = NULL;
+MatrixContainer::MatrixContainer() :
+  Indices(NULL)
+{
   Header = new char*[1];
   Matrix = new double**[1]; // one more each for the total molecule
@@ -850,8 +851,8 @@
 /** Constructor for class HessianMatrix.
  */
-HessianMatrix::HessianMatrix() : MatrixContainer() 
-{
-   IsSymmetric = true;
-}
+HessianMatrix::HessianMatrix() :
+  MatrixContainer(),
+  IsSymmetric(true)
+{}
 
 /** Sums the hessian entries with each factor and put into last element of \a ***Matrix.
@@ -995,12 +996,12 @@
 /** Constructor of KeySetsContainer class.
  */
-KeySetsContainer::KeySetsContainer() {
-  KeySets = NULL;
-  AtomCounter = NULL;
-  FragmentCounter = 0;
-  Order = 0;
-  FragmentsPerOrder = 0;
-  OrderSet = NULL;
-};
+KeySetsContainer::KeySetsContainer() :
+  KeySets(NULL),
+  AtomCounter(NULL),
+  FragmentCounter(0),
+  Order(0),
+  FragmentsPerOrder(0),
+  OrderSet(NULL)
+{};
 
 /** Destructor of KeySetsContainer class.
Index: src/periodentafel.cpp
===================================================================
--- src/periodentafel.cpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/periodentafel.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -5,7 +5,10 @@
  */
 
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
 #include "Helpers/MemDebug.hpp"
-
-using namespace std;
 
 #include <iomanip>
@@ -17,9 +20,9 @@
 #include "element.hpp"
 #include "elements_db.hpp"
-#include "helpers.hpp"
+#include "Helpers/helpers.hpp"
 #include "lists.hpp"
-#include "log.hpp"
+#include "Helpers/Log.hpp"
 #include "periodentafel.hpp"
-#include "verbose.hpp"
+#include "Helpers/Verbose.hpp"
 
 using namespace std;
@@ -34,5 +37,5 @@
   {
     stringstream input(elementsDB,ios_base::in);
-    bool status = LoadElementsDatabase(&input);
+    bool status = LoadElementsDatabase(input);
     ASSERT(status,  "General element initialization failed");
   }
@@ -72,9 +75,8 @@
  * \return iterator to added element
  */
-periodentafel::iterator periodentafel::AddElement(element * const pointer)
+periodentafel::iterator periodentafel::AddElement(element * pointer)
 {
   atomicNumber_t Z = pointer->getNumber();
   ASSERT(!elements.count(Z), "Element is already present.");
-  pointer->sort = &pointer->Z;
   if (pointer->getNumber() < 1 && pointer->getNumber() >= MAX_ELEMENTS)
     DoeLog(0) && (eLog() << Verbose(0) << "Invalid Z number!\n");
@@ -86,5 +88,5 @@
  * \param *pointer element to be removed
  */
-size_t periodentafel::RemoveElement(element * const pointer)
+size_t periodentafel::RemoveElement(const element * pointer)
 {
   return RemoveElement(pointer->getNumber());
@@ -114,5 +116,5 @@
  * \return pointer to element or NULL if not found
  */
-element * const periodentafel::FindElement(atomicNumber_t Z) const
+const element * periodentafel::FindElement(atomicNumber_t Z) const
 {
   const_iterator res = elements.find(Z);
@@ -125,5 +127,5 @@
  * \return pointer to element
  */
-element * const periodentafel::FindElement(const char * const shorthand) const
+const element * periodentafel::FindElement(const string &shorthand) const
 {
   element *res = 0;
@@ -140,7 +142,7 @@
  * \return desired element or NULL
  */
-element * const periodentafel::AskElement() const
-{
-  element * walker = NULL;
+const element * periodentafel::AskElement() const
+{
+  const element * walker = NULL;
   int Z;
   do {
@@ -155,10 +157,10 @@
  * \return pointer to either present or newly created element
  */
-element * const periodentafel::EnterElement()
+const element * periodentafel::EnterElement()
 {
   atomicNumber_t Z = 0;
   DoLog(0) && (Log() << Verbose(0) << "Atomic number: " << Z << endl);
   cin >> Z;
-  element * const res = FindElement(Z);
+  const element *res = FindElement(Z);
   if (!res) {
     // TODO: make this using the constructor
@@ -169,7 +171,7 @@
     cin >> tmp->mass;
     DoLog(0) && (Log() << Verbose(0) << "Name [max 64 chars]: " << endl);
-    cin >> tmp->name;
+    cin >> tmp->getName();
     DoLog(0) && (Log() << Verbose(0) << "Short form [max 3 chars]: " << endl);
-    cin >> tmp->symbol;
+    cin >> tmp->getSymbol();
     AddElement(tmp);
     return tmp;
@@ -180,17 +182,17 @@
 
 /******************** Access to iterators ****************************/
-periodentafel::const_iterator periodentafel::begin(){
+periodentafel::const_iterator periodentafel::begin() const{
   return elements.begin();
 }
 
-periodentafel::const_iterator periodentafel::end(){
+periodentafel::const_iterator periodentafel::end() const{
   return elements.end();
 }
 
-periodentafel::reverse_iterator periodentafel::rbegin(){
+periodentafel::reverse_iterator periodentafel::rbegin() const{
   return reverse_iterator(elements.end());
 }
 
-periodentafel::reverse_iterator periodentafel::rend(){
+periodentafel::reverse_iterator periodentafel::rend() const{
   return reverse_iterator(elements.begin());
 }
@@ -211,27 +213,4 @@
 };
 
-/** Prints period table to given stream.
- * \param *output output stream
- * \param *checkliste elements table for this molecule
- */
-bool periodentafel::Checkout(ostream * const output, const int * const checkliste) const
-{
-  bool result = true;
-  int No = 1;
-
-  if (output != NULL) {
-    *output << "# Ion type data (PP = PseudoPotential, Z = atomic number)" << endl;
-    *output << "#Ion_TypeNr.\tAmount\tZ\tRGauss\tL_Max(PP)L_Loc(PP)IonMass\t# chemical name, symbol" << endl;
-    for(const_iterator iter=elements.begin(); iter!=elements.end();++iter){
-      if (((*iter).first < MAX_ELEMENTS) && (checkliste[(*iter).first])) {
-        (*iter).second->No = No;
-        result = result && (*iter).second->Checkout(output, No++, checkliste[(*iter).first]);
-      }
-    }
-    return result;
-  } else
-    return false;
-};
-
 /** Loads element list from file.
  * \param *path to to standard file names
@@ -251,5 +230,5 @@
   if (!input.fail())
     DoLog(0) && (Log() << Verbose(0) << "Using " << filename << " as elements database." << endl);
-  status = status && LoadElementsDatabase(&input);
+  status = status && LoadElementsDatabase(input);
   input.close();
   input.clear();
@@ -310,49 +289,41 @@
  * \return true - parsing successful, false - something went wrong
  */
-bool periodentafel::LoadElementsDatabase(istream *input)
+bool periodentafel::LoadElementsDatabase(istream &input)
 {
   bool status = true;
-  int counter = 0;
-  pair< std::map<atomicNumber_t,element*>::iterator, bool > InserterTest;
-  if (!(*input).fail()) {
-    (*input).getline(header1, MAXSTRINGSIZE);
-    (*input).getline(header2, MAXSTRINGSIZE); // skip first two header lines
+  string header1tmp,header2tmp;
+  // first parse into a map, so we can revert to old status in case something goes wront
+  map<atomicNumber_t,element*> parsedElements;
+  if (!input.fail()) {
+    getline(input,header1tmp);
+    getline(input,header2tmp); // skip first two header lines
+    //cout << "First header: " << header1tmp << endl;
+    //cout << "Second header: " << header2tmp << endl;
     DoLog(0) && (Log() << Verbose(0) <<  "Parsed elements:");
-    while (!(*input).eof()) {
+    while (!input.eof()) {
       element *neues = new element;
-      (*input) >> neues->name;
-      //(*input) >> ws;
-      (*input) >> neues->symbol;
-      //(*input) >> ws;
-      (*input) >> neues->period;
-      //(*input) >> ws;
-      (*input) >> neues->group;
-      //(*input) >> ws;
-      (*input) >> neues->block;
-      //(*input) >> ws;
-      (*input) >> neues->Z;
-      //(*input) >> ws;
-      (*input) >> neues->mass;
-      //(*input) >> ws;
-      (*input) >> neues->CovalentRadius;
-      //(*input) >> ws;
-      (*input) >> neues->VanDerWaalsRadius;
-      //(*input) >> ws;
-      (*input) >> ws;
+      input >> neues->getName();;
+      //(*input) >> ws;
+      input >> neues->getSymbol();
+      //(*input) >> ws;
+      input >> neues->period;
+      //(*input) >> ws;
+      input >> neues->group;
+      //(*input) >> ws;
+      input >> neues->block;
+      //(*input) >> ws;
+      input >> neues->Z;
+      //(*input) >> ws;
+      input >> neues->mass;
+      //(*input) >> ws;
+      input >> neues->CovalentRadius;
+      //(*input) >> ws;
+      input >> neues->VanDerWaalsRadius;
+      //(*input) >> ws;
+      input >> ws;
       //neues->Output((ofstream *)&cout);
       if ((neues->getNumber() > 0) && (neues->getNumber() < MAX_ELEMENTS)) {
-        if (elements.count(neues->getNumber())) {// if element already present, remove and delete old one (i.e. replace it)
-          //cout << neues->symbol << " is present already." << endl;
-          element * const Elemental = FindElement(neues->getNumber());
-          ASSERT(Elemental != NULL, "element should be present but is not??");
-          *Elemental = *neues;
-          delete(neues);
-          neues = Elemental;
-        } else {
-          InserterTest = elements.insert(pair <atomicNumber_t,element*> (neues->getNumber(), neues));
-          ASSERT(InserterTest.second, "Could not insert new element into periodentafel on LoadElementsDatabase().");
-        }
-        DoLog(0) && (Log() << Verbose(0) << " " << elements[neues->getNumber()]->symbol);
-        counter++;
+        parsedElements[neues->Z] = neues;
+        DoLog(0) && (Log() << Verbose(0) << " " << *neues);
       } else {
         DoeLog(2) && (eLog() << Verbose(2) << "Detected empty line or invalid element in elements db, discarding." << endl);
@@ -360,4 +331,10 @@
         delete(neues);
       }
+      // when the input is in failed state, we most likely just read garbage
+      if(input.fail()) {
+        DoeLog(2) && (eLog() << Verbose(2) << "Error parsing elements db." << endl);
+        status = false;
+        break;
+      }
     }
     DoLog(0) && (Log() << Verbose(0) << endl);
@@ -367,6 +344,27 @@
   }
 
-  if (counter == 0)
+  if (!parsedElements.size())
     status = false;
+
+  if(status){
+    for(map<atomicNumber_t,element*>::iterator iter=parsedElements.begin();
+                                               iter!=parsedElements.end();
+                                               ++iter){
+      if (elements.count(iter->first)) {
+        // if element already present, replace the old one
+        // pointer to old element might still be in use, so we have to replace into the old element
+        *(elements[iter->first])=*iter->second;
+      }
+      else {
+        // no such element in periodentafel... we can just insert
+        elements[iter->first] = iter->second;
+      }
+    }
+    // all went well.. we now copy the header
+    strncpy(header1,header1tmp.c_str(),MAXSTRINGSIZE);
+    header1[MAXSTRINGSIZE-1]=0;
+    strncpy(header2,header2tmp.c_str(),MAXSTRINGSIZE);
+    header2[MAXSTRINGSIZE-1]=0;
+  }
 
   return status;
Index: src/periodentafel.hpp
===================================================================
--- src/periodentafel.hpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/periodentafel.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -9,7 +9,7 @@
 #endif
 
-#include <iostream>
+#include <iosfwd>
 #include <map>
-#include <iterator>
+#include <string>
 
 #include "unittests/periodentafelTest.hpp"
@@ -43,19 +43,18 @@
   ~periodentafel();
 
-  iterator AddElement(element * const pointer);
-  size_t RemoveElement(element * const pointer);
+  iterator AddElement(element * pointer);
+  size_t RemoveElement(const element * pointer);
   size_t RemoveElement(atomicNumber_t);
   void CleanupPeriodtable();
-  element * const FindElement(atomicNumber_t) const;
-  element * const FindElement(const char * const shorthand) const;
-  element * const AskElement() const;
-  element * const EnterElement();
+  const element * FindElement(atomicNumber_t) const;
+  const element * FindElement(const std::string &shorthand) const;
+  const element * AskElement() const;
+  const element * EnterElement();
 
-  const_iterator begin();
-  const_iterator end();
-  reverse_iterator rbegin();
-  reverse_iterator rend();
+  const_iterator begin() const;
+  const_iterator end() const;
+  reverse_iterator rbegin() const;
+  reverse_iterator rend() const;
   bool Output(std::ostream * const output) const;
-  bool Checkout(std::ostream * const output, const int * const checkliste) const;
   bool LoadPeriodentafel(const char * const path);
   bool StorePeriodentafel(const char * const path) const;
@@ -63,5 +62,5 @@
   private:
 
-  bool LoadElementsDatabase(std::istream *input);
+  bool LoadElementsDatabase(std::istream &input);
   bool LoadValenceDatabase(std::istream *input);
   bool LoadOrbitalsDatabase(std::istream *input);
Index: src/stackclass.hpp
===================================================================
--- src/stackclass.hpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/stackclass.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -11,6 +11,6 @@
 #endif
 
-#include "verbose.hpp"
-#include "memoryallocator.hpp"
+#include "Helpers/Verbose.hpp"
+#include "Helpers/Log.hpp"
 
 /****************************************** forward declarations *****************************/
Index: src/tesselation.cpp
===================================================================
--- src/tesselation.cpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/tesselation.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -6,20 +6,33 @@
  */
 
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
 #include "Helpers/MemDebug.hpp"
 
 #include <fstream>
-
-#include "helpers.hpp"
-#include "info.hpp"
+#include <iomanip>
+
+#include "Helpers/helpers.hpp"
+#include "Helpers/Info.hpp"
+#include "BoundaryPointSet.hpp"
+#include "BoundaryLineSet.hpp"
+#include "BoundaryTriangleSet.hpp"
+#include "BoundaryPolygonSet.hpp"
+#include "TesselPoint.hpp"
+#include "CandidateForTesselation.hpp"
+#include "PointCloud.hpp"
 #include "linkedcell.hpp"
-#include "log.hpp"
+#include "Helpers/Log.hpp"
 #include "tesselation.hpp"
 #include "tesselationhelpers.hpp"
 #include "triangleintersectionlist.hpp"
-#include "vector.hpp"
-#include "Line.hpp"
-#include "vector_ops.hpp"
-#include "verbose.hpp"
-#include "Plane.hpp"
+#include "LinearAlgebra/Vector.hpp"
+#include "LinearAlgebra/Line.hpp"
+#include "LinearAlgebra/vector_ops.hpp"
+#include "Helpers/Verbose.hpp"
+#include "LinearAlgebra/Plane.hpp"
 #include "Exceptions/LinearDependenceException.hpp"
 #include "Helpers/Assert.hpp"
@@ -27,1198 +40,20 @@
 class molecule;
 
-// ======================================== Points on Boundary =================================
-
-/** Constructor of BoundaryPointSet.
- */
-BoundaryPointSet::BoundaryPointSet() :
-  LinesCount(0), value(0.), Nr(-1)
-{
-  Info FunctionInfo(__func__);
-  DoLog(1) && (Log() << Verbose(1) << "Adding noname." << endl);
-}
-;
-
-/** Constructor of BoundaryPointSet with Tesselpoint.
- * \param *Walker TesselPoint this boundary point represents
- */
-BoundaryPointSet::BoundaryPointSet(TesselPoint * const Walker) :
-  LinesCount(0), node(Walker), value(0.), Nr(Walker->nr)
-{
-  Info FunctionInfo(__func__);
-  DoLog(1) && (Log() << Verbose(1) << "Adding Node " << *Walker << endl);
-}
-;
-
-/** Destructor of BoundaryPointSet.
- * Sets node to NULL to avoid removing the original, represented TesselPoint.
- * \note When removing point from a class Tesselation, use RemoveTesselationPoint()
- */
-BoundaryPointSet::~BoundaryPointSet()
-{
-  Info FunctionInfo(__func__);
-  //Log() << Verbose(0) << "Erasing point nr. " << Nr << "." << endl;
-  if (!lines.empty())
-    DoeLog(2) && (eLog() << Verbose(2) << "Memory Leak! I " << *this << " am still connected to some lines." << endl);
-  node = NULL;
-}
-;
-
-/** Add a line to the LineMap of this point.
- * \param *line line to add
- */
-void BoundaryPointSet::AddLine(BoundaryLineSet * const line)
-{
-  Info FunctionInfo(__func__);
-  DoLog(1) && (Log() << Verbose(1) << "Adding " << *this << " to line " << *line << "." << endl);
-  if (line->endpoints[0] == this) {
-    lines.insert(LinePair(line->endpoints[1]->Nr, line));
-  } else {
-    lines.insert(LinePair(line->endpoints[0]->Nr, line));
-  }
-  LinesCount++;
-}
-;
-
-/** output operator for BoundaryPointSet.
- * \param &ost output stream
- * \param &a boundary point
- */
-ostream & operator <<(ostream &ost, const BoundaryPointSet &a)
-{
-  ost << "[" << a.Nr << "|" << a.node->getName() << " at " << *a.node->node << "]";
-  return ost;
-}
-;
-
-// ======================================== Lines on Boundary =================================
-
-/** Constructor of BoundaryLineSet.
- */
-BoundaryLineSet::BoundaryLineSet() :
-  Nr(-1)
-{
-  Info FunctionInfo(__func__);
-  for (int i = 0; i < 2; i++)
-    endpoints[i] = NULL;
-}
-;
-
-/** Constructor of BoundaryLineSet with two endpoints.
- * Adds line automatically to each endpoints' LineMap
- * \param *Point[2] array of two boundary points
- * \param number number of the list
- */
-BoundaryLineSet::BoundaryLineSet(BoundaryPointSet * const Point[2], const int number)
-{
-  Info FunctionInfo(__func__);
-  // set number
-  Nr = number;
-  // set endpoints in ascending order
-  SetEndpointsOrdered(endpoints, Point[0], Point[1]);
-  // add this line to the hash maps of both endpoints
-  Point[0]->AddLine(this); //Taken out, to check whether we can avoid unwanted double adding.
-  Point[1]->AddLine(this); //
-  // set skipped to false
-  skipped = false;
-  // clear triangles list
-  DoLog(0) && (Log() << Verbose(0) << "New Line with endpoints " << *this << "." << endl);
-}
-;
-
-/** Constructor of BoundaryLineSet with two endpoints.
- * Adds line automatically to each endpoints' LineMap
- * \param *Point1 first boundary point
- * \param *Point2 second boundary point
- * \param number number of the list
- */
-BoundaryLineSet::BoundaryLineSet(BoundaryPointSet * const Point1, BoundaryPointSet * const Point2, const int number)
-{
-  Info FunctionInfo(__func__);
-  // set number
-  Nr = number;
-  // set endpoints in ascending order
-  SetEndpointsOrdered(endpoints, Point1, Point2);
-  // add this line to the hash maps of both endpoints
-  Point1->AddLine(this); //Taken out, to check whether we can avoid unwanted double adding.
-  Point2->AddLine(this); //
-  // set skipped to false
-  skipped = false;
-  // clear triangles list
-  DoLog(0) && (Log() << Verbose(0) << "New Line with endpoints " << *this << "." << endl);
-}
-;
-
-/** Destructor for BoundaryLineSet.
- * Removes itself from each endpoints' LineMap, calling RemoveTrianglePoint() when point not connected anymore.
- * \note When removing lines from a class Tesselation, use RemoveTesselationLine()
- */
-BoundaryLineSet::~BoundaryLineSet()
-{
-  Info FunctionInfo(__func__);
-  int Numbers[2];
-
-  // get other endpoint number of finding copies of same line
-  if (endpoints[1] != NULL)
-    Numbers[0] = endpoints[1]->Nr;
-  else
-    Numbers[0] = -1;
-  if (endpoints[0] != NULL)
-    Numbers[1] = endpoints[0]->Nr;
-  else
-    Numbers[1] = -1;
-
-  for (int i = 0; i < 2; i++) {
-    if (endpoints[i] != NULL) {
-      if (Numbers[i] != -1) { // as there may be multiple lines with same endpoints, we have to go through each and find in the endpoint's line list this line set
-        pair<LineMap::iterator, LineMap::iterator> erasor = endpoints[i]->lines.equal_range(Numbers[i]);
-        for (LineMap::iterator Runner = erasor.first; Runner != erasor.second; Runner++)
-          if ((*Runner).second == this) {
-            //Log() << Verbose(0) << "Removing Line Nr. " << Nr << " in boundary point " << *endpoints[i] << "." << endl;
-            endpoints[i]->lines.erase(Runner);
-            break;
-          }
-      } else { // there's just a single line left
-        if (endpoints[i]->lines.erase(Nr)) {
-          //Log() << Verbose(0) << "Removing Line Nr. " << Nr << " in boundary point " << *endpoints[i] << "." << endl;
-        }
-      }
-      if (endpoints[i]->lines.empty()) {
-        //Log() << Verbose(0) << *endpoints[i] << " has no more lines it's attached to, erasing." << endl;
-        if (endpoints[i] != NULL) {
-          delete (endpoints[i]);
-          endpoints[i] = NULL;
-        }
-      }
-    }
-  }
-  if (!triangles.empty())
-    DoeLog(2) && (eLog() << Verbose(2) << "Memory Leak! I " << *this << " am still connected to some triangles." << endl);
-}
-;
-
-/** Add triangle to TriangleMap of this boundary line.
- * \param *triangle to add
- */
-void BoundaryLineSet::AddTriangle(BoundaryTriangleSet * const triangle)
-{
-  Info FunctionInfo(__func__);
-  DoLog(0) && (Log() << Verbose(0) << "Add " << triangle->Nr << " to line " << *this << "." << endl);
-  triangles.insert(TrianglePair(triangle->Nr, triangle));
-}
-;
-
-/** Checks whether we have a common endpoint with given \a *line.
- * \param *line other line to test
- * \return true - common endpoint present, false - not connected
- */
-bool BoundaryLineSet::IsConnectedTo(const BoundaryLineSet * const line) const
-{
-  Info FunctionInfo(__func__);
-  if ((endpoints[0] == line->endpoints[0]) || (endpoints[1] == line->endpoints[0]) || (endpoints[0] == line->endpoints[1]) || (endpoints[1] == line->endpoints[1]))
-    return true;
-  else
-    return false;
-}
-;
-
-/** Checks whether the adjacent triangles of a baseline are convex or not.
- * We sum the two angles of each height vector with respect to the center of the baseline.
- * If greater/equal M_PI than we are convex.
- * \param *out output stream for debugging
- * \return true - triangles are convex, false - concave or less than two triangles connected
- */
-bool BoundaryLineSet::CheckConvexityCriterion() const
-{
-  Info FunctionInfo(__func__);
-  double angle = CalculateConvexity();
-  if (angle > -MYEPSILON) {
-    DoLog(0) && (Log() << Verbose(0) << "ACCEPT: Angle is greater than pi: convex." << endl);
-    return true;
-  } else {
-    DoLog(0) && (Log() << Verbose(0) << "REJECT: Angle is less than pi: concave." << endl);
-    return false;
-  }
-}
-
-
-/** Calculates the angle between two triangles with respect to their normal vector.
- * We sum the two angles of each height vector with respect to the center of the baseline.
- * \return angle > 0 then convex, if < 0 then concave
- */
-double BoundaryLineSet::CalculateConvexity() const
-{
-  Info FunctionInfo(__func__);
-  Vector BaseLineCenter, BaseLineNormal, BaseLine, helper[2], NormalCheck;
-  // get the two triangles
-  if (triangles.size() != 2) {
-    DoeLog(0) && (eLog() << Verbose(0) << "Baseline " << *this << " is connected to less than two triangles, Tesselation incomplete!" << endl);
-    return true;
-  }
-  // check normal vectors
-  // have a normal vector on the base line pointing outwards
-  //Log() << Verbose(0) << "INFO: " << *this << " has vectors at " << *(endpoints[0]->node->node) << " and at " << *(endpoints[1]->node->node) << "." << endl;
-  BaseLineCenter = (1./2.)*((*endpoints[0]->node->node) + (*endpoints[1]->node->node));
-  BaseLine = (*endpoints[0]->node->node) - (*endpoints[1]->node->node);
-
-  //Log() << Verbose(0) << "INFO: Baseline is " << BaseLine << " and its center is at " << BaseLineCenter << "." << endl;
-
-  BaseLineNormal.Zero();
-  NormalCheck.Zero();
-  double sign = -1.;
-  int i = 0;
-  class BoundaryPointSet *node = NULL;
-  for (TriangleMap::const_iterator runner = triangles.begin(); runner != triangles.end(); runner++) {
-    //Log() << Verbose(0) << "INFO: NormalVector of " << *(runner->second) << " is " << runner->second->NormalVector << "." << endl;
-    NormalCheck += runner->second->NormalVector;
-    NormalCheck *= sign;
-    sign = -sign;
-    if (runner->second->NormalVector.NormSquared() > MYEPSILON)
-      BaseLineNormal = runner->second->NormalVector;   // yes, copy second on top of first
-    else {
-      DoeLog(0) && (eLog() << Verbose(0) << "Triangle " << *runner->second << " has zero normal vector!" << endl);
-    }
-    node = runner->second->GetThirdEndpoint(this);
-    if (node != NULL) {
-      //Log() << Verbose(0) << "INFO: Third node for triangle " << *(runner->second) << " is " << *node << " at " << *(node->node->node) << "." << endl;
-      helper[i] = (*node->node->node) - BaseLineCenter;
-      helper[i].MakeNormalTo(BaseLine);  // we want to compare the triangle's heights' angles!
-      //Log() << Verbose(0) << "INFO: Height vector with respect to baseline is " << helper[i] << "." << endl;
-      i++;
-    } else {
-      DoeLog(1) && (eLog() << Verbose(1) << "I cannot find third node in triangle, something's wrong." << endl);
-      return true;
-    }
-  }
-  //Log() << Verbose(0) << "INFO: BaselineNormal is " << BaseLineNormal << "." << endl;
-  if (NormalCheck.NormSquared() < MYEPSILON) {
-    DoLog(0) && (Log() << Verbose(0) << "ACCEPT: Normalvectors of both triangles are the same: convex." << endl);
-    return true;
-  }
-  BaseLineNormal.Scale(-1.);
-  double angle = GetAngle(helper[0], helper[1], BaseLineNormal);
-  return (angle - M_PI);
-}
-
-/** Checks whether point is any of the two endpoints this line contains.
- * \param *point point to test
- * \return true - point is of the line, false - is not
- */
-bool BoundaryLineSet::ContainsBoundaryPoint(const BoundaryPointSet * const point) const
-{
-  Info FunctionInfo(__func__);
-  for (int i = 0; i < 2; i++)
-    if (point == endpoints[i])
-      return true;
-  return false;
-}
-;
-
-/** Returns other endpoint of the line.
- * \param *point other endpoint
- * \return NULL - if endpoint not contained in BoundaryLineSet::lines, or pointer to BoundaryPointSet otherwise
- */
-class BoundaryPointSet *BoundaryLineSet::GetOtherEndpoint(const BoundaryPointSet * const point) const
-{
-  Info FunctionInfo(__func__);
-  if (endpoints[0] == point)
-    return endpoints[1];
-  else if (endpoints[1] == point)
-    return endpoints[0];
-  else
-    return NULL;
-}
-;
-
-/** Returns other triangle of the line.
- * \param *point other endpoint
- * \return NULL - if triangle not contained in BoundaryLineSet::triangles, or pointer to BoundaryTriangleSet otherwise
- */
-class BoundaryTriangleSet *BoundaryLineSet::GetOtherTriangle(const BoundaryTriangleSet * const triangle) const
-{
-  Info FunctionInfo(__func__);
-  if (triangles.size() == 2) {
-    for (TriangleMap::const_iterator TriangleRunner = triangles.begin(); TriangleRunner != triangles.end(); ++TriangleRunner)
-      if (TriangleRunner->second != triangle)
-        return TriangleRunner->second;
-  }
-  return NULL;
-}
-;
-
-/** output operator for BoundaryLineSet.
- * \param &ost output stream
- * \param &a boundary line
- */
-ostream & operator <<(ostream &ost, const BoundaryLineSet &a)
-{
-  ost << "[" << a.Nr << "|" << a.endpoints[0]->node->getName() << " at " << *a.endpoints[0]->node->node << "," << a.endpoints[1]->node->getName() << " at " << *a.endpoints[1]->node->node << "]";
-  return ost;
-}
-;
-
-// ======================================== Triangles on Boundary =================================
-
-/** Constructor for BoundaryTriangleSet.
- */
-BoundaryTriangleSet::BoundaryTriangleSet() :
-  Nr(-1)
-{
-  Info FunctionInfo(__func__);
-  for (int i = 0; i < 3; i++) {
-    endpoints[i] = NULL;
-    lines[i] = NULL;
-  }
-}
-;
-
-/** Constructor for BoundaryTriangleSet with three lines.
- * \param *line[3] lines that make up the triangle
- * \param number number of triangle
- */
-BoundaryTriangleSet::BoundaryTriangleSet(class BoundaryLineSet * const line[3], const int number) :
-  Nr(number)
-{
-  Info FunctionInfo(__func__);
-  // set number
-  // set lines
-  for (int i = 0; i < 3; i++) {
-    lines[i] = line[i];
-    lines[i]->AddTriangle(this);
-  }
-  // get ascending order of endpoints
-  PointMap OrderMap;
-  for (int i = 0; i < 3; i++) {
-    // for all three lines
-    for (int j = 0; j < 2; j++) { // for both endpoints
-      OrderMap.insert(pair<int, class BoundaryPointSet *> (line[i]->endpoints[j]->Nr, line[i]->endpoints[j]));
-      // and we don't care whether insertion fails
-    }
-  }
-  // set endpoints
-  int Counter = 0;
-  DoLog(0) && (Log() << Verbose(0) << "New triangle " << Nr << " with end points: " << endl);
-  for (PointMap::iterator runner = OrderMap.begin(); runner != OrderMap.end(); runner++) {
-    endpoints[Counter] = runner->second;
-    DoLog(0) && (Log() << Verbose(0) << " " << *endpoints[Counter] << endl);
-    Counter++;
-  }
-  ASSERT(Counter >= 3,"We have a triangle with only two distinct endpoints!");
-};
-
-
-/** Destructor of BoundaryTriangleSet.
- * Removes itself from each of its lines' LineMap and removes them if necessary.
- * \note When removing triangles from a class Tesselation, use RemoveTesselationTriangle()
- */
-BoundaryTriangleSet::~BoundaryTriangleSet()
-{
-  Info FunctionInfo(__func__);
-  for (int i = 0; i < 3; i++) {
-    if (lines[i] != NULL) {
-      if (lines[i]->triangles.erase(Nr)) {
-        //Log() << Verbose(0) << "Triangle Nr." << Nr << " erased in line " << *lines[i] << "." << endl;
-      }
-      if (lines[i]->triangles.empty()) {
-        //Log() << Verbose(0) << *lines[i] << " is no more attached to any triangle, erasing." << endl;
-        delete (lines[i]);
-        lines[i] = NULL;
-      }
-    }
-  }
-  //Log() << Verbose(0) << "Erasing triangle Nr." << Nr << " itself." << endl;
-}
-;
-
-/** Calculates the normal vector for this triangle.
- * Is made unique by comparison with \a OtherVector to point in the other direction.
- * \param &OtherVector direction vector to make normal vector unique.
- */
-void BoundaryTriangleSet::GetNormalVector(const Vector &OtherVector)
-{
-  Info FunctionInfo(__func__);
-  // get normal vector
-  NormalVector = Plane(*(endpoints[0]->node->node),
-                       *(endpoints[1]->node->node),
-                       *(endpoints[2]->node->node)).getNormal();
-
-  // make it always point inward (any offset vector onto plane projected onto normal vector suffices)
-  if (NormalVector.ScalarProduct(OtherVector) > 0.)
-    NormalVector.Scale(-1.);
-  DoLog(1) && (Log() << Verbose(1) << "Normal Vector is " << NormalVector << "." << endl);
-}
-;
-
-/** Finds the point on the triangle \a *BTS through which the line defined by \a *MolCenter and \a *x crosses.
- * We call Vector::GetIntersectionWithPlane() to receive the intersection point with the plane
- * Thus we test if it's really on the plane and whether it's inside the triangle on the plane or not.
- * The latter is done as follows: We calculate the cross point of one of the triangle's baseline with the line
- * given by the intersection and the third basepoint. Then, we check whether it's on the baseline (i.e. between
- * the first two basepoints) or not.
- * \param *out output stream for debugging
- * \param *MolCenter offset vector of line
- * \param *x second endpoint of line, minus \a *MolCenter is directional vector of line
- * \param *Intersection intersection on plane on return
- * \return true - \a *Intersection contains intersection on plane defined by triangle, false - zero vector if outside of triangle.
- */
-
-bool BoundaryTriangleSet::GetIntersectionInsideTriangle(const Vector * const MolCenter, const Vector * const x, Vector * const Intersection) const
-{
-  Info FunctionInfo(__func__);
-  Vector CrossPoint;
-  Vector helper;
-
-  try {
-    Line centerLine = makeLineThrough(*MolCenter, *x);
-    *Intersection = Plane(NormalVector, *(endpoints[0]->node->node)).GetIntersection(centerLine);
-
-    DoLog(1) && (Log() << Verbose(1) << "INFO: Triangle is " << *this << "." << endl);
-    DoLog(1) && (Log() << Verbose(1) << "INFO: Line is from " << *MolCenter << " to " << *x << "." << endl);
-    DoLog(1) && (Log() << Verbose(1) << "INFO: Intersection is " << *Intersection << "." << endl);
-
-    if (Intersection->DistanceSquared(*endpoints[0]->node->node) < MYEPSILON) {
-      DoLog(1) && (Log() << Verbose(1) << "Intersection coindices with first endpoint." << endl);
-      return true;
-    }   else if (Intersection->DistanceSquared(*endpoints[1]->node->node) < MYEPSILON) {
-      DoLog(1) && (Log() << Verbose(1) << "Intersection coindices with second endpoint." << endl);
-      return true;
-    }   else if (Intersection->DistanceSquared(*endpoints[2]->node->node) < MYEPSILON) {
-      DoLog(1) && (Log() << Verbose(1) << "Intersection coindices with third endpoint." << endl);
-      return true;
-    }
-    // Calculate cross point between one baseline and the line from the third endpoint to intersection
-    int i = 0;
-    do {
-      Line line1 = makeLineThrough(*(endpoints[i%3]->node->node),*(endpoints[(i+1)%3]->node->node));
-      Line line2 = makeLineThrough(*(endpoints[(i+2)%3]->node->node),*Intersection);
-      CrossPoint = line1.getIntersection(line2);
-      helper = (*endpoints[(i+1)%3]->node->node) - (*endpoints[i%3]->node->node);
-      CrossPoint -= (*endpoints[i%3]->node->node);  // cross point was returned as absolute vector
-      const double s = CrossPoint.ScalarProduct(helper)/helper.NormSquared();
-      DoLog(1) && (Log() << Verbose(1) << "INFO: Factor s is " << s << "." << endl);
-      if ((s < -MYEPSILON) || ((s-1.) > MYEPSILON)) {
-        DoLog(1) && (Log() << Verbose(1) << "INFO: Crosspoint " << CrossPoint << "outside of triangle." << endl);
-        return false;
-      }
-      i++;
-    } while (i < 3);
-    DoLog(1) && (Log() << Verbose(1) << "INFO: Crosspoint " << CrossPoint << " inside of triangle." << endl);
-    return true;
-  }
-  catch (MathException &excp) {
-    Log() << Verbose(1) << excp;
-    DoeLog(1) && (eLog() << Verbose(1) << "Alas! Intersection with plane failed - at least numerically - the intersection is not on the plane!" << endl);
-    return false;
-  }
-}
-;
-
-/** Finds the point on the triangle to the point \a *x.
- * We call Vector::GetIntersectionWithPlane() with \a * and the center of the triangle to receive an intersection point.
- * Then we check the in-plane part (the part projected down onto plane). We check whether it crosses one of the
- * boundary lines. If it does, we return this intersection as closest point, otherwise the projected point down.
- * Thus we test if it's really on the plane and whether it's inside the triangle on the plane or not.
- * The latter is done as follows: We calculate the cross point of one of the triangle's baseline with the line
- * given by the intersection and the third basepoint. Then, we check whether it's on the baseline (i.e. between
- * the first two basepoints) or not.
- * \param *x point
- * \param *ClosestPoint desired closest point inside triangle to \a *x, is absolute vector
- * \return Distance squared between \a *x and closest point inside triangle
- */
-double BoundaryTriangleSet::GetClosestPointInsideTriangle(const Vector * const x, Vector * const ClosestPoint) const
-{
-  Info FunctionInfo(__func__);
-  Vector Direction;
-
-  // 1. get intersection with plane
-  DoLog(1) && (Log() << Verbose(1) << "INFO: Looking for closest point of triangle " << *this << " to " << *x << "." << endl);
-  GetCenter(&Direction);
-  try {
-    Line l = makeLineThrough(*x, Direction);
-    *ClosestPoint = Plane(NormalVector, *(endpoints[0]->node->node)).GetIntersection(l);
-  }
-  catch (MathException &excp) {
-    (*ClosestPoint) = (*x);
-  }
-
-  // 2. Calculate in plane part of line (x, intersection)
-  Vector InPlane = (*x) - (*ClosestPoint); // points from plane intersection to straight-down point
-  InPlane.ProjectOntoPlane(NormalVector);
-  InPlane += *ClosestPoint;
-
-  DoLog(2) && (Log() << Verbose(2) << "INFO: Triangle is " << *this << "." << endl);
-  DoLog(2) && (Log() << Verbose(2) << "INFO: Line is from " << Direction << " to " << *x << "." << endl);
-  DoLog(2) && (Log() << Verbose(2) << "INFO: In-plane part is " << InPlane << "." << endl);
-
-  // Calculate cross point between one baseline and the desired point such that distance is shortest
-  double ShortestDistance = -1.;
-  bool InsideFlag = false;
-  Vector CrossDirection[3];
-  Vector CrossPoint[3];
-  Vector helper;
-  for (int i = 0; i < 3; i++) {
-    // treat direction of line as normal of a (cut)plane and the desired point x as the plane offset, the intersect line with point
-    Direction = (*endpoints[(i+1)%3]->node->node) - (*endpoints[i%3]->node->node);
-    // calculate intersection, line can never be parallel to Direction (is the same vector as PlaneNormal);
-    Line l = makeLineThrough(*(endpoints[i%3]->node->node), *(endpoints[(i+1)%3]->node->node));
-    CrossPoint[i] = Plane(Direction, InPlane).GetIntersection(l);
-    CrossDirection[i] = CrossPoint[i] - InPlane;
-    CrossPoint[i] -= (*endpoints[i%3]->node->node);  // cross point was returned as absolute vector
-    const double s = CrossPoint[i].ScalarProduct(Direction)/Direction.NormSquared();
-    DoLog(2) && (Log() << Verbose(2) << "INFO: Factor s is " << s << "." << endl);
-    if ((s >= -MYEPSILON) && ((s-1.) <= MYEPSILON)) {
-          CrossPoint[i] += (*endpoints[i%3]->node->node);  // make cross point absolute again
-      DoLog(2) && (Log() << Verbose(2) << "INFO: Crosspoint is " << CrossPoint[i] << ", intersecting BoundaryLine between " << *endpoints[i % 3]->node->node << " and " << *endpoints[(i + 1) % 3]->node->node << "." << endl);
-      const double distance = CrossPoint[i].DistanceSquared(*x);
-      if ((ShortestDistance < 0.) || (ShortestDistance > distance)) {
-        ShortestDistance = distance;
-        (*ClosestPoint) = CrossPoint[i];
-      }
-    } else
-      CrossPoint[i].Zero();
-  }
-  InsideFlag = true;
-  for (int i = 0; i < 3; i++) {
-    const double sign = CrossDirection[i].ScalarProduct(CrossDirection[(i + 1) % 3]);
-    const double othersign = CrossDirection[i].ScalarProduct(CrossDirection[(i + 2) % 3]);
-
-    if ((sign > -MYEPSILON) && (othersign > -MYEPSILON)) // have different sign
-      InsideFlag = false;
-  }
-  if (InsideFlag) {
-    (*ClosestPoint) = InPlane;
-    ShortestDistance = InPlane.DistanceSquared(*x);
-  } else { // also check endnodes
-    for (int i = 0; i < 3; i++) {
-      const double distance = x->DistanceSquared(*endpoints[i]->node->node);
-      if ((ShortestDistance < 0.) || (ShortestDistance > distance)) {
-        ShortestDistance = distance;
-        (*ClosestPoint) = (*endpoints[i]->node->node);
-      }
-    }
-  }
-  DoLog(1) && (Log() << Verbose(1) << "INFO: Closest Point is " << *ClosestPoint << " with shortest squared distance is " << ShortestDistance << "." << endl);
-  return ShortestDistance;
-}
-;
-
-/** Checks whether lines is any of the three boundary lines this triangle contains.
- * \param *line line to test
- * \return true - line is of the triangle, false - is not
- */
-bool BoundaryTriangleSet::ContainsBoundaryLine(const BoundaryLineSet * const line) const
-{
-  Info FunctionInfo(__func__);
-  for (int i = 0; i < 3; i++)
-    if (line == lines[i])
-      return true;
-  return false;
-}
-;
-
-/** Checks whether point is any of the three endpoints this triangle contains.
- * \param *point point to test
- * \return true - point is of the triangle, false - is not
- */
-bool BoundaryTriangleSet::ContainsBoundaryPoint(const BoundaryPointSet * const point) const
-{
-  Info FunctionInfo(__func__);
-  for (int i = 0; i < 3; i++)
-    if (point == endpoints[i])
-      return true;
-  return false;
-}
-;
-
-/** Checks whether point is any of the three endpoints this triangle contains.
- * \param *point TesselPoint to test
- * \return true - point is of the triangle, false - is not
- */
-bool BoundaryTriangleSet::ContainsBoundaryPoint(const TesselPoint * const point) const
-{
-  Info FunctionInfo(__func__);
-  for (int i = 0; i < 3; i++)
-    if (point == endpoints[i]->node)
-      return true;
-  return false;
-}
-;
-
-/** Checks whether three given \a *Points coincide with triangle's endpoints.
- * \param *Points[3] pointer to BoundaryPointSet
- * \return true - is the very triangle, false - is not
- */
-bool BoundaryTriangleSet::IsPresentTupel(const BoundaryPointSet * const Points[3]) const
-{
-  Info FunctionInfo(__func__);
-  DoLog(1) && (Log() << Verbose(1) << "INFO: Checking " << Points[0] << "," << Points[1] << "," << Points[2] << " against " << endpoints[0] << "," << endpoints[1] << "," << endpoints[2] << "." << endl);
-  return (((endpoints[0] == Points[0]) || (endpoints[0] == Points[1]) || (endpoints[0] == Points[2])) && ((endpoints[1] == Points[0]) || (endpoints[1] == Points[1]) || (endpoints[1] == Points[2])) && ((endpoints[2] == Points[0]) || (endpoints[2] == Points[1]) || (endpoints[2] == Points[2])
-
-  ));
-}
-;
-
-/** Checks whether three given \a *Points coincide with triangle's endpoints.
- * \param *Points[3] pointer to BoundaryPointSet
- * \return true - is the very triangle, false - is not
- */
-bool BoundaryTriangleSet::IsPresentTupel(const BoundaryTriangleSet * const T) const
-{
-  Info FunctionInfo(__func__);
-  return (((endpoints[0] == T->endpoints[0]) || (endpoints[0] == T->endpoints[1]) || (endpoints[0] == T->endpoints[2])) && ((endpoints[1] == T->endpoints[0]) || (endpoints[1] == T->endpoints[1]) || (endpoints[1] == T->endpoints[2])) && ((endpoints[2] == T->endpoints[0]) || (endpoints[2] == T->endpoints[1]) || (endpoints[2] == T->endpoints[2])
-
-  ));
-}
-;
-
-/** Returns the endpoint which is not contained in the given \a *line.
- * \param *line baseline defining two endpoints
- * \return pointer third endpoint or NULL if line does not belong to triangle.
- */
-class BoundaryPointSet *BoundaryTriangleSet::GetThirdEndpoint(const BoundaryLineSet * const line) const
-{
-  Info FunctionInfo(__func__);
-  // sanity check
-  if (!ContainsBoundaryLine(line))
-    return NULL;
-  for (int i = 0; i < 3; i++)
-    if (!line->ContainsBoundaryPoint(endpoints[i]))
-      return endpoints[i];
-  // actually, that' impossible :)
-  return NULL;
-}
-;
-
-/** Returns the baseline which does not contain the given boundary point \a *point.
- * \param *point endpoint which is neither endpoint of the desired line
- * \return pointer to desired third baseline
- */
-class BoundaryLineSet *BoundaryTriangleSet::GetThirdLine(const BoundaryPointSet * const point) const
-{
-  Info FunctionInfo(__func__);
-  // sanity check
-  if (!ContainsBoundaryPoint(point))
-    return NULL;
-  for (int i = 0; i < 3; i++)
-    if (!lines[i]->ContainsBoundaryPoint(point))
-      return lines[i];
-  // actually, that' impossible :)
-  return NULL;
-}
-;
-
-/** Calculates the center point of the triangle.
- * Is third of the sum of all endpoints.
- * \param *center central point on return.
- */
-void BoundaryTriangleSet::GetCenter(Vector * const center) const
-{
-  Info FunctionInfo(__func__);
-  center->Zero();
-  for (int i = 0; i < 3; i++)
-    (*center) += (*endpoints[i]->node->node);
-  center->Scale(1. / 3.);
-  DoLog(1) && (Log() << Verbose(1) << "INFO: Center is at " << *center << "." << endl);
-}
-
-/**
- * gets the Plane defined by the three triangle Basepoints
- */
-Plane BoundaryTriangleSet::getPlane() const{
-  ASSERT(endpoints[0] && endpoints[1] && endpoints[2], "Triangle not fully defined");
-
-  return Plane(*endpoints[0]->node->node,
-               *endpoints[1]->node->node,
-               *endpoints[2]->node->node);
-}
-
-Vector BoundaryTriangleSet::getEndpoint(int i) const{
-  ASSERT(i>=0 && i<3,"Index of Endpoint out of Range");
-
-  return *endpoints[i]->node->node;
-}
-
-string BoundaryTriangleSet::getEndpointName(int i) const{
-  ASSERT(i>=0 && i<3,"Index of Endpoint out of Range");
-
-  return endpoints[i]->node->getName();
-}
-
-/** output operator for BoundaryTriangleSet.
- * \param &ost output stream
- * \param &a boundary triangle
- */
-ostream &operator <<(ostream &ost, const BoundaryTriangleSet &a)
-{
-  ost << "[" << a.Nr << "|" << a.getEndpointName(0) << "," << a.getEndpointName(1) << "," << a.getEndpointName(2) << "]";
-  //  ost << "[" << a.Nr << "|" << a.endpoints[0]->node->Name << " at " << *a.endpoints[0]->node->node << ","
-  //      << a.endpoints[1]->node->Name << " at " << *a.endpoints[1]->node->node << "," << a.endpoints[2]->node->Name << " at " << *a.endpoints[2]->node->node << "]";
-  return ost;
-}
-;
-
-// ======================================== Polygons on Boundary =================================
-
-/** Constructor for BoundaryPolygonSet.
- */
-BoundaryPolygonSet::BoundaryPolygonSet() :
-  Nr(-1)
-{
-  Info FunctionInfo(__func__);
-}
-;
-
-/** Destructor of BoundaryPolygonSet.
- * Just clears endpoints.
- * \note When removing triangles from a class Tesselation, use RemoveTesselationTriangle()
- */
-BoundaryPolygonSet::~BoundaryPolygonSet()
-{
-  Info FunctionInfo(__func__);
-  endpoints.clear();
-  DoLog(1) && (Log() << Verbose(1) << "Erasing polygon Nr." << Nr << " itself." << endl);
-}
-;
-
-/** Calculates the normal vector for this triangle.
- * Is made unique by comparison with \a OtherVector to point in the other direction.
- * \param &OtherVector direction vector to make normal vector unique.
- * \return allocated vector in normal direction
- */
-Vector * BoundaryPolygonSet::GetNormalVector(const Vector &OtherVector) const
-{
-  Info FunctionInfo(__func__);
-  // get normal vector
-  Vector TemporaryNormal;
-  Vector *TotalNormal = new Vector;
-  PointSet::const_iterator Runner[3];
-  for (int i = 0; i < 3; i++) {
-    Runner[i] = endpoints.begin();
-    for (int j = 0; j < i; j++) { // go as much further
-      Runner[i]++;
-      if (Runner[i] == endpoints.end()) {
-        DoeLog(0) && (eLog() << Verbose(0) << "There are less than three endpoints in the polygon!" << endl);
-        performCriticalExit();
-      }
-    }
-  }
-  TotalNormal->Zero();
-  int counter = 0;
-  for (; Runner[2] != endpoints.end();) {
-    TemporaryNormal = Plane(*((*Runner[0])->node->node),
-                            *((*Runner[1])->node->node),
-                            *((*Runner[2])->node->node)).getNormal();
-    for (int i = 0; i < 3; i++) // increase each of them
-      Runner[i]++;
-    (*TotalNormal) += TemporaryNormal;
-  }
-  TotalNormal->Scale(1. / (double) counter);
-
-  // make it always point inward (any offset vector onto plane projected onto normal vector suffices)
-  if (TotalNormal->ScalarProduct(OtherVector) > 0.)
-    TotalNormal->Scale(-1.);
-  DoLog(1) && (Log() << Verbose(1) << "Normal Vector is " << *TotalNormal << "." << endl);
-
-  return TotalNormal;
-}
-;
-
-/** Calculates the center point of the triangle.
- * Is third of the sum of all endpoints.
- * \param *center central point on return.
- */
-void BoundaryPolygonSet::GetCenter(Vector * const center) const
-{
-  Info FunctionInfo(__func__);
-  center->Zero();
-  int counter = 0;
-  for(PointSet::const_iterator Runner = endpoints.begin(); Runner != endpoints.end(); Runner++) {
-    (*center) += (*(*Runner)->node->node);
-    counter++;
-  }
-  center->Scale(1. / (double) counter);
-  DoLog(1) && (Log() << Verbose(1) << "Center is at " << *center << "." << endl);
-}
-
-/** Checks whether the polygons contains all three endpoints of the triangle.
- * \param *triangle triangle to test
- * \return true - triangle is contained polygon, false - is not
- */
-bool BoundaryPolygonSet::ContainsBoundaryTriangle(const BoundaryTriangleSet * const triangle) const
-{
-  Info FunctionInfo(__func__);
-  return ContainsPresentTupel(triangle->endpoints, 3);
-}
-;
-
-/** Checks whether the polygons contains both endpoints of the line.
- * \param *line line to test
- * \return true - line is of the triangle, false - is not
- */
-bool BoundaryPolygonSet::ContainsBoundaryLine(const BoundaryLineSet * const line) const
-{
-  Info FunctionInfo(__func__);
-  return ContainsPresentTupel(line->endpoints, 2);
-}
-;
-
-/** Checks whether point is any of the three endpoints this triangle contains.
- * \param *point point to test
- * \return true - point is of the triangle, false - is not
- */
-bool BoundaryPolygonSet::ContainsBoundaryPoint(const BoundaryPointSet * const point) const
-{
-  Info FunctionInfo(__func__);
-  for (PointSet::const_iterator Runner = endpoints.begin(); Runner != endpoints.end(); Runner++) {
-    DoLog(0) && (Log() << Verbose(0) << "Checking against " << **Runner << endl);
-    if (point == (*Runner)) {
-      DoLog(0) && (Log() << Verbose(0) << " Contained." << endl);
-      return true;
-    }
-  }
-  DoLog(0) && (Log() << Verbose(0) << " Not contained." << endl);
-  return false;
-}
-;
-
-/** Checks whether point is any of the three endpoints this triangle contains.
- * \param *point TesselPoint to test
- * \return true - point is of the triangle, false - is not
- */
-bool BoundaryPolygonSet::ContainsBoundaryPoint(const TesselPoint * const point) const
-{
-  Info FunctionInfo(__func__);
-  for (PointSet::const_iterator Runner = endpoints.begin(); Runner != endpoints.end(); Runner++)
-    if (point == (*Runner)->node) {
-      DoLog(0) && (Log() << Verbose(0) << " Contained." << endl);
-      return true;
-    }
-  DoLog(0) && (Log() << Verbose(0) << " Not contained." << endl);
-  return false;
-}
-;
-
-/** Checks whether given array of \a *Points coincide with polygons's endpoints.
- * \param **Points pointer to an array of BoundaryPointSet
- * \param dim dimension of array
- * \return true - set of points is contained in polygon, false - is not
- */
-bool BoundaryPolygonSet::ContainsPresentTupel(const BoundaryPointSet * const * Points, const int dim) const
-{
-  Info FunctionInfo(__func__);
-  int counter = 0;
-  DoLog(1) && (Log() << Verbose(1) << "Polygon is " << *this << endl);
-  for (int i = 0; i < dim; i++) {
-    DoLog(1) && (Log() << Verbose(1) << " Testing endpoint " << *Points[i] << endl);
-    if (ContainsBoundaryPoint(Points[i])) {
-      counter++;
-    }
-  }
-
-  if (counter == dim)
-    return true;
-  else
-    return false;
-}
-;
-
-/** Checks whether given PointList coincide with polygons's endpoints.
- * \param &endpoints PointList
- * \return true - set of points is contained in polygon, false - is not
- */
-bool BoundaryPolygonSet::ContainsPresentTupel(const PointSet &endpoints) const
-{
-  Info FunctionInfo(__func__);
-  size_t counter = 0;
-  DoLog(1) && (Log() << Verbose(1) << "Polygon is " << *this << endl);
-  for (PointSet::const_iterator Runner = endpoints.begin(); Runner != endpoints.end(); Runner++) {
-    DoLog(1) && (Log() << Verbose(1) << " Testing endpoint " << **Runner << endl);
-    if (ContainsBoundaryPoint(*Runner))
-      counter++;
-  }
-
-  if (counter == endpoints.size())
-    return true;
-  else
-    return false;
-}
-;
-
-/** Checks whether given set of \a *Points coincide with polygons's endpoints.
- * \param *P pointer to BoundaryPolygonSet
- * \return true - is the very triangle, false - is not
- */
-bool BoundaryPolygonSet::ContainsPresentTupel(const BoundaryPolygonSet * const P) const
-{
-  return ContainsPresentTupel((const PointSet) P->endpoints);
-}
-;
-
-/** Gathers all the endpoints' triangles in a unique set.
- * \return set of all triangles
- */
-TriangleSet * BoundaryPolygonSet::GetAllContainedTrianglesFromEndpoints() const
-{
-  Info FunctionInfo(__func__);
-  pair<TriangleSet::iterator, bool> Tester;
-  TriangleSet *triangles = new TriangleSet;
-
-  for (PointSet::const_iterator Runner = endpoints.begin(); Runner != endpoints.end(); Runner++)
-    for (LineMap::const_iterator Walker = (*Runner)->lines.begin(); Walker != (*Runner)->lines.end(); Walker++)
-      for (TriangleMap::const_iterator Sprinter = (Walker->second)->triangles.begin(); Sprinter != (Walker->second)->triangles.end(); Sprinter++) {
-        //Log() << Verbose(0) << " Testing triangle " << *(Sprinter->second) << endl;
-        if (ContainsBoundaryTriangle(Sprinter->second)) {
-          Tester = triangles->insert(Sprinter->second);
-          if (Tester.second)
-            DoLog(0) && (Log() << Verbose(0) << "Adding triangle " << *(Sprinter->second) << endl);
-        }
-      }
-
-  DoLog(1) && (Log() << Verbose(1) << "The Polygon of " << endpoints.size() << " endpoints has " << triangles->size() << " unique triangles in total." << endl);
-  return triangles;
-}
-;
-
-/** Fills the endpoints of this polygon from the triangles attached to \a *line.
- * \param *line lines with triangles attached
- * \return true - polygon contains endpoints, false - line was NULL
- */
-bool BoundaryPolygonSet::FillPolygonFromTrianglesOfLine(const BoundaryLineSet * const line)
-{
-  Info FunctionInfo(__func__);
-  pair<PointSet::iterator, bool> Tester;
-  if (line == NULL)
-    return false;
-  DoLog(1) && (Log() << Verbose(1) << "Filling polygon from line " << *line << endl);
-  for (TriangleMap::const_iterator Runner = line->triangles.begin(); Runner != line->triangles.end(); Runner++) {
-    for (int i = 0; i < 3; i++) {
-      Tester = endpoints.insert((Runner->second)->endpoints[i]);
-      if (Tester.second)
-        DoLog(1) && (Log() << Verbose(1) << "  Inserting endpoint " << *((Runner->second)->endpoints[i]) << endl);
-    }
-  }
-
-  return true;
-}
-;
-
-/** output operator for BoundaryPolygonSet.
- * \param &ost output stream
- * \param &a boundary polygon
- */
-ostream &operator <<(ostream &ost, const BoundaryPolygonSet &a)
-{
-  ost << "[" << a.Nr << "|";
-  for (PointSet::const_iterator Runner = a.endpoints.begin(); Runner != a.endpoints.end();) {
-    ost << (*Runner)->node->getName();
-    Runner++;
-    if (Runner != a.endpoints.end())
-      ost << ",";
-  }
-  ost << "]";
-  return ost;
-}
-;
-
-// =========================================================== class TESSELPOINT ===========================================
-
-/** Constructor of class TesselPoint.
- */
-TesselPoint::TesselPoint()
-{
-  //Info FunctionInfo(__func__);
-  node = NULL;
-  nr = -1;
-}
-;
-
-/** Destructor for class TesselPoint.
- */
-TesselPoint::~TesselPoint()
-{
-  //Info FunctionInfo(__func__);
-}
-;
-
-/** Prints LCNode to screen.
- */
-ostream & operator <<(ostream &ost, const TesselPoint &a)
-{
-  ost << "[" << a.getName() << "|" << *a.node << "]";
-  return ost;
-}
-;
-
-/** Prints LCNode to screen.
- */
-ostream & TesselPoint::operator <<(ostream &ost)
-{
-  Info FunctionInfo(__func__);
-  ost << "[" << (nr) << "|" << this << "]";
-  return ost;
-}
-;
-
-// =========================================================== class POINTCLOUD ============================================
-
-/** Constructor of class PointCloud.
- */
-PointCloud::PointCloud()
-{
-  //Info FunctionInfo(__func__);
-}
-;
-
-/** Destructor for class PointCloud.
- */
-PointCloud::~PointCloud()
-{
-  //Info FunctionInfo(__func__);
-}
-;
-
-// ============================ CandidateForTesselation =============================
-
-/** Constructor of class CandidateForTesselation.
- */
-CandidateForTesselation::CandidateForTesselation(BoundaryLineSet* line) :
-  BaseLine(line), ThirdPoint(NULL), T(NULL), ShortestAngle(2. * M_PI), OtherShortestAngle(2. * M_PI)
-{
-  Info FunctionInfo(__func__);
-}
-;
-
-/** Constructor of class CandidateForTesselation.
- */
-CandidateForTesselation::CandidateForTesselation(TesselPoint *candidate, BoundaryLineSet* line, BoundaryPointSet* point, Vector OptCandidateCenter, Vector OtherOptCandidateCenter) :
-  BaseLine(line), ThirdPoint(point), T(NULL), ShortestAngle(2. * M_PI), OtherShortestAngle(2. * M_PI)
-{
-	Info FunctionInfo(__func__);
-  OptCenter = OptCandidateCenter;
-  OtherOptCenter = OtherOptCandidateCenter;
-};
-
-
-/** Destructor for class CandidateForTesselation.
- */
-CandidateForTesselation::~CandidateForTesselation()
-{
-}
-;
-
-/** Checks validity of a given sphere of a candidate line.
- * Sphere must touch all candidates and the baseline endpoints and there must be no other atoms inside.
- * \param RADIUS radius of sphere
- * \param *LC LinkedCell structure with other atoms
- * \return true - sphere is valid, false - sphere contains other points
- */
-bool CandidateForTesselation::CheckValidity(const double RADIUS, const LinkedCell *LC) const
-{
-  Info FunctionInfo(__func__);
-
-  const double radiusSquared = RADIUS * RADIUS;
-  list<const Vector *> VectorList;
-  VectorList.push_back(&OptCenter);
-  //VectorList.push_back(&OtherOptCenter);  // don't check the other (wrong) center
-
-  if (!pointlist.empty())
-    DoLog(1) && (Log() << Verbose(1) << "INFO: Checking whether sphere contains candidate list and baseline " << *BaseLine->endpoints[0] << "<->" << *BaseLine->endpoints[1] << " only ..." << endl);
-  else
-    DoLog(1) && (Log() << Verbose(1) << "INFO: Checking whether sphere with no candidates contains baseline " << *BaseLine->endpoints[0] << "<->" << *BaseLine->endpoints[1] << " only ..." << endl);
-  // check baseline for OptCenter and OtherOptCenter being on sphere's surface
-  for (list<const Vector *>::const_iterator VRunner = VectorList.begin(); VRunner != VectorList.end(); ++VRunner) {
-    for (int i = 0; i < 2; i++) {
-      const double distance = fabs((*VRunner)->DistanceSquared(*BaseLine->endpoints[i]->node->node) - radiusSquared);
-      if (distance > HULLEPSILON) {
-        DoeLog(1) && (eLog() << Verbose(1) << "Endpoint " << *BaseLine->endpoints[i] << " is out of sphere at " << *(*VRunner) << " by " << distance << "." << endl);
-        return false;
-      }
-    }
-  }
-
-  // check Candidates for OptCenter and OtherOptCenter being on sphere's surface
-  for (TesselPointList::const_iterator Runner = pointlist.begin(); Runner != pointlist.end(); ++Runner) {
-    const TesselPoint *Walker = *Runner;
-    for (list<const Vector *>::const_iterator VRunner = VectorList.begin(); VRunner != VectorList.end(); ++VRunner) {
-      const double distance = fabs((*VRunner)->DistanceSquared(*Walker->node) - radiusSquared);
-      if (distance > HULLEPSILON) {
-        DoeLog(1) && (eLog() << Verbose(1) << "Candidate " << *Walker << " is out of sphere at " << *(*VRunner) << " by " << distance << "." << endl);
-        return false;
-      } else {
-        DoLog(1) && (Log() << Verbose(1) << "Candidate " << *Walker << " is inside by " << distance << "." << endl);
-      }
-    }
-  }
-
-  DoLog(1) && (Log() << Verbose(1) << "INFO: Checking whether sphere contains no others points ..." << endl);
-  bool flag = true;
-  for (list<const Vector *>::const_iterator VRunner = VectorList.begin(); VRunner != VectorList.end(); ++VRunner) {
-    // get all points inside the sphere
-    TesselPointList *ListofPoints = LC->GetPointsInsideSphere(RADIUS, (*VRunner));
-
-    DoLog(1) && (Log() << Verbose(1) << "The following atoms are inside sphere at " << (*VRunner) << ":" << endl);
-    for (TesselPointList::const_iterator Runner = ListofPoints->begin(); Runner != ListofPoints->end(); ++Runner)
-      DoLog(1) && (Log() << Verbose(1) << "  " << *(*Runner) << " with distance " << (*Runner)->node->distance(*(*VRunner)) << "." << endl);
-
-    // remove baseline's endpoints and candidates
-    for (int i = 0; i < 2; i++) {
-      DoLog(1) && (Log() << Verbose(1) << "INFO: removing baseline tesselpoint " << *BaseLine->endpoints[i]->node << "." << endl);
-      ListofPoints->remove(BaseLine->endpoints[i]->node);
-    }
-    for (TesselPointList::const_iterator Runner = pointlist.begin(); Runner != pointlist.end(); ++Runner) {
-      DoLog(1) && (Log() << Verbose(1) << "INFO: removing candidate tesselpoint " << *(*Runner) << "." << endl);
-      ListofPoints->remove(*Runner);
-    }
-    if (!ListofPoints->empty()) {
-      DoeLog(1) && (eLog() << Verbose(1) << "CheckValidity: There are still " << ListofPoints->size() << " points inside the sphere." << endl);
-      flag = false;
-      DoeLog(1) && (eLog() << Verbose(1) << "External atoms inside of sphere at " << *(*VRunner) << ":" << endl);
-      for (TesselPointList::const_iterator Runner = ListofPoints->begin(); Runner != ListofPoints->end(); ++Runner)
-        DoeLog(1) && (eLog() << Verbose(1) << "  " << *(*Runner) << " at distance " << setprecision(13) << (*Runner)->node->distance(*(*VRunner)) << setprecision(6) << "." << endl);
-
-      // check with animate_sphere.tcl VMD script
-      if (ThirdPoint != NULL) {
-        DoeLog(1) && (eLog() << Verbose(1) << "Check by: animate_sphere 0 " << BaseLine->endpoints[0]->Nr + 1 << " " << BaseLine->endpoints[1]->Nr + 1 << " " << ThirdPoint->Nr + 1 << " " << RADIUS << " " << OldCenter[0] << " " << OldCenter[1] << " " << OldCenter[2] << " " << (*VRunner)->at(0) << " " << (*VRunner)->at(1) << " " << (*VRunner)->at(2) << endl);
-      } else {
-        DoeLog(1) && (eLog() << Verbose(1) << "Check by: ... missing third point ..." << endl);
-        DoeLog(1) && (eLog() << Verbose(1) << "Check by: animate_sphere 0 " << BaseLine->endpoints[0]->Nr + 1 << " " << BaseLine->endpoints[1]->Nr + 1 << " ??? " << RADIUS << " " << OldCenter[0] << " " << OldCenter[1] << " " << OldCenter[2] << " " << (*VRunner)->at(0) << " " << (*VRunner)->at(1) << " " << (*VRunner)->at(2) << endl);
-      }
-    }
-    delete (ListofPoints);
-
-  }
-  return flag;
-}
-;
-
-/** output operator for CandidateForTesselation.
- * \param &ost output stream
- * \param &a boundary line
- */
-ostream & operator <<(ostream &ost, const CandidateForTesselation &a)
-{
-  ost << "[" << a.BaseLine->Nr << "|" << a.BaseLine->endpoints[0]->node->getName() << "," << a.BaseLine->endpoints[1]->node->getName() << "] with ";
-  if (a.pointlist.empty())
-    ost << "no candidate.";
-  else {
-    ost << "candidate";
-    if (a.pointlist.size() != 1)
-      ost << "s ";
-    else
-      ost << " ";
-    for (TesselPointList::const_iterator Runner = a.pointlist.begin(); Runner != a.pointlist.end(); Runner++)
-      ost << *(*Runner) << " ";
-    ost << " at angle " << (a.ShortestAngle) << ".";
-  }
-
-  return ost;
-}
-;
-
-// =========================================================== class TESSELATION ===========================================
+const char *TecplotSuffix=".dat";
+const char *Raster3DSuffix=".r3d";
+const char *VRMLSUffix=".wrl";
+
+const double ParallelEpsilon=1e-3;
+const double Tesselation::HULLEPSILON = 1e-9;
 
 /** Constructor of class Tesselation.
  */
 Tesselation::Tesselation() :
-  PointsOnBoundaryCount(0), LinesOnBoundaryCount(0), TrianglesOnBoundaryCount(0), LastTriangle(NULL), TriangleFilesWritten(0), InternalPointer(PointsOnBoundary.begin())
+  PointsOnBoundaryCount(0),
+  LinesOnBoundaryCount(0),
+  TrianglesOnBoundaryCount(0),
+  LastTriangle(NULL),
+  TriangleFilesWritten(0),
+  InternalPointer(PointsOnBoundary.begin())
 {
   Info FunctionInfo(__func__);
@@ -1253,5 +88,5 @@
   int num = 0;
   for (GoToFirst(); (!IsEnd()); GoToNext()) {
-    (*Center) += (*GetPoint()->node);
+    (*Center) += (GetPoint()->getPosition());
     num++;
   }
@@ -1336,9 +171,9 @@
       C++;
       for (; C != PointsOnBoundary.end(); C++) {
-        tmp = A->second->node->node->DistanceSquared(*B->second->node->node);
+        tmp = A->second->node->DistanceSquared(B->second->node->getPosition());
         distance = tmp * tmp;
-        tmp = A->second->node->node->DistanceSquared(*C->second->node->node);
+        tmp = A->second->node->DistanceSquared(C->second->node->getPosition());
         distance += tmp * tmp;
-        tmp = B->second->node->node->DistanceSquared(*C->second->node->node);
+        tmp = B->second->node->DistanceSquared(C->second->node->getPosition());
         distance += tmp * tmp;
         DistanceMMap.insert(DistanceMultiMapPair(distance, pair<PointMap::iterator, PointMap::iterator> (B, C)));
@@ -1359,7 +194,7 @@
     // 2. next, we have to check whether all points reside on only one side of the triangle
     // 3. construct plane vector
-    PlaneVector = Plane(*A->second->node->node,
-                        *baseline->second.first->second->node->node,
-                        *baseline->second.second->second->node->node).getNormal();
+    PlaneVector = Plane(A->second->node->getPosition(),
+                        baseline->second.first->second->node->getPosition(),
+                        baseline->second.second->second->node->getPosition()).getNormal();
     DoLog(2) && (Log() << Verbose(2) << "Plane vector of candidate triangle is " << PlaneVector << endl);
     // 4. loop over all points
@@ -1371,6 +206,5 @@
         continue;
       // 4a. project onto plane vector
-      TrialVector = (*checker->second->node->node);
-      TrialVector.SubtractVector(*A->second->node->node);
+      TrialVector = (checker->second->node->getPosition() - A->second->node->getPosition());
       distance = TrialVector.ScalarProduct(PlaneVector);
       if (fabs(distance) < 1e-4) // we need to have a small epsilon around 0 which is still ok
@@ -1388,13 +222,13 @@
       }
       // 4d. Check whether the point is inside the triangle (check distance to each node
-      tmp = checker->second->node->node->DistanceSquared(*A->second->node->node);
+      tmp = checker->second->node->DistanceSquared(A->second->node->getPosition());
       int innerpoint = 0;
-      if ((tmp < A->second->node->node->DistanceSquared(*baseline->second.first->second->node->node)) && (tmp < A->second->node->node->DistanceSquared(*baseline->second.second->second->node->node)))
+      if ((tmp < A->second->node->DistanceSquared(baseline->second.first->second->node->getPosition())) && (tmp < A->second->node->DistanceSquared(baseline->second.second->second->node->getPosition())))
         innerpoint++;
-      tmp = checker->second->node->node->DistanceSquared(*baseline->second.first->second->node->node);
-      if ((tmp < baseline->second.first->second->node->node->DistanceSquared(*A->second->node->node)) && (tmp < baseline->second.first->second->node->node->DistanceSquared(*baseline->second.second->second->node->node)))
+      tmp = checker->second->node->DistanceSquared(baseline->second.first->second->node->getPosition());
+      if ((tmp < baseline->second.first->second->node->DistanceSquared(A->second->node->getPosition())) && (tmp < baseline->second.first->second->node->DistanceSquared(baseline->second.second->second->node->getPosition())))
         innerpoint++;
-      tmp = checker->second->node->node->DistanceSquared(*baseline->second.second->second->node->node);
-      if ((tmp < baseline->second.second->second->node->node->DistanceSquared(*baseline->second.first->second->node->node)) && (tmp < baseline->second.second->second->node->node->DistanceSquared(*A->second->node->node)))
+      tmp = checker->second->node->DistanceSquared(baseline->second.second->second->node->getPosition());
+      if ((tmp < baseline->second.second->second->node->DistanceSquared(baseline->second.first->second->node->getPosition())) && (tmp < baseline->second.second->second->node->DistanceSquared(A->second->node->getPosition())))
         innerpoint++;
       // 4e. If so, break 4. loop and continue with next candidate in 1. loop
@@ -1477,7 +311,7 @@
         // prepare some auxiliary vectors
         Vector BaseLineCenter, BaseLine;
-        BaseLineCenter = 0.5 * ((*baseline->second->endpoints[0]->node->node) +
-                                (*baseline->second->endpoints[1]->node->node));
-        BaseLine = (*baseline->second->endpoints[0]->node->node) - (*baseline->second->endpoints[1]->node->node);
+        BaseLineCenter = 0.5 * ((baseline->second->endpoints[0]->node->getPosition()) +
+                                (baseline->second->endpoints[1]->node->getPosition()));
+        BaseLine = (baseline->second->endpoints[0]->node->getPosition()) - (baseline->second->endpoints[1]->node->getPosition());
 
         // offset to center of triangle
@@ -1497,5 +331,5 @@
         // project center vector onto triangle plane (points from intersection plane-NormalVector to plane-CenterVector intersection)
         PropagationVector = Plane(BaseLine, NormalVector,0).getNormal();
-        TempVector = CenterVector - (*baseline->second->endpoints[0]->node->node); // TempVector is vector on triangle plane pointing from one baseline egde towards center!
+        TempVector = CenterVector - (baseline->second->endpoints[0]->node->getPosition()); // TempVector is vector on triangle plane pointing from one baseline egde towards center!
         //Log() << Verbose(0) << "Projection of propagation onto temp: " << PropagationVector.Projection(&TempVector) << "." << endl;
         if (PropagationVector.ScalarProduct(TempVector) > 0) // make sure normal propagation vector points outward from baseline
@@ -1510,5 +344,5 @@
 
             // first check direction, so that triangles don't intersect
-            VirtualNormalVector = (*target->second->node->node) - BaseLineCenter;
+            VirtualNormalVector = (target->second->node->getPosition()) - BaseLineCenter;
             VirtualNormalVector.ProjectOntoPlane(NormalVector);
             TempAngle = VirtualNormalVector.Angle(PropagationVector);
@@ -1539,6 +373,6 @@
 
             // check for linear dependence
-            TempVector = (*baseline->second->endpoints[0]->node->node) - (*target->second->node->node);
-            helper = (*baseline->second->endpoints[1]->node->node) - (*target->second->node->node);
+            TempVector = (baseline->second->endpoints[0]->node->getPosition()) - (target->second->node->getPosition());
+            helper = (baseline->second->endpoints[1]->node->getPosition()) - (target->second->node->getPosition());
             helper.ProjectOntoPlane(TempVector);
             if (fabs(helper.NormSquared()) < MYEPSILON) {
@@ -1549,10 +383,10 @@
             // in case NOT both were found, create virtually this triangle, get its normal vector, calculate angle
             flag = true;
-            VirtualNormalVector = Plane(*(baseline->second->endpoints[0]->node->node),
-                                        *(baseline->second->endpoints[1]->node->node),
-                                        *(target->second->node->node)).getNormal();
-            TempVector = (1./3.) * ((*baseline->second->endpoints[0]->node->node) +
-                                    (*baseline->second->endpoints[1]->node->node) +
-                                    (*target->second->node->node));
+            VirtualNormalVector = Plane((baseline->second->endpoints[0]->node->getPosition()),
+                                        (baseline->second->endpoints[1]->node->getPosition()),
+                                        (target->second->node->getPosition())).getNormal();
+            TempVector = (1./3.) * ((baseline->second->endpoints[0]->node->getPosition()) +
+                                    (baseline->second->endpoints[1]->node->getPosition()) +
+                                    (target->second->node->getPosition()));
             TempVector -= (*Center);
             // make it always point outward
@@ -1568,11 +402,11 @@
             } else if (fabs(SmallestAngle - TempAngle) < MYEPSILON) { // check the angle to propagation, both possible targets are in one plane! (their normals have same angle)
               // hence, check the angles to some normal direction from our base line but in this common plane of both targets...
-              helper = (*target->second->node->node) - BaseLineCenter;
+              helper = (target->second->node->getPosition()) - BaseLineCenter;
               helper.ProjectOntoPlane(BaseLine);
               // ...the one with the smaller angle is the better candidate
-              TempVector = (*target->second->node->node) - BaseLineCenter;
+              TempVector = (target->second->node->getPosition()) - BaseLineCenter;
               TempVector.ProjectOntoPlane(VirtualNormalVector);
               TempAngle = TempVector.Angle(helper);
-              TempVector = (*winner->second->node->node) - BaseLineCenter;
+              TempVector = (winner->second->node->getPosition()) - BaseLineCenter;
               TempVector.ProjectOntoPlane(VirtualNormalVector);
               if (TempAngle < TempVector.Angle(helper)) {
@@ -1613,5 +447,5 @@
             BLS[2] = LineChecker[1]->second;
           BTS = new class BoundaryTriangleSet(BLS, TrianglesOnBoundaryCount);
-          BTS->GetCenter(&helper);
+          BTS->GetCenter(helper);
           helper -= (*Center);
           helper *= -1;
@@ -1661,5 +495,5 @@
     DoLog(0) && (Log() << Verbose(0) << "Current point is " << *Walker << "." << endl);
     // get the next triangle
-    triangles = FindClosestTrianglesToVector(Walker->node, BoundaryPoints);
+    triangles = FindClosestTrianglesToVector(Walker->getPosition(), BoundaryPoints);
     if (triangles != NULL)
       BTS = triangles->front();
@@ -1675,8 +509,8 @@
     DoLog(0) && (Log() << Verbose(0) << "Closest triangle is " << *BTS << "." << endl);
     // get the intersection point
-    if (BTS->GetIntersectionInsideTriangle(Center, Walker->node, &Intersection)) {
+    if (BTS->GetIntersectionInsideTriangle(*Center, Walker->getPosition(), Intersection)) {
       DoLog(0) && (Log() << Verbose(0) << "We have an intersection at " << Intersection << "." << endl);
       // we have the intersection, check whether in- or outside of boundary
-      if ((Center->DistanceSquared(*Walker->node) - Center->DistanceSquared(Intersection)) < -MYEPSILON) {
+      if ((Center->DistanceSquared(Walker->getPosition()) - Center->DistanceSquared(Intersection)) < -MYEPSILON) {
         // inside, next!
         DoLog(0) && (Log() << Verbose(0) << *Walker << " is inside wrt triangle " << *BTS << "." << endl);
@@ -2085,5 +919,5 @@
   DoLog(1) && (Log() << Verbose(1) << "The following atoms are inside sphere at " << CandidateLine.OtherOptCenter << ":" << endl);
   for (TesselPointList::const_iterator Runner = ListofPoints->begin(); Runner != ListofPoints->end(); ++Runner)
-    DoLog(1) && (Log() << Verbose(1) << "  " << *(*Runner) << " with distance " << (*Runner)->node->distance(CandidateLine.OtherOptCenter) << "." << endl);
+    DoLog(1) && (Log() << Verbose(1) << "  " << *(*Runner) << " with distance " << (*Runner)->distance(CandidateLine.OtherOptCenter) << "." << endl);
 
   // remove triangles's endpoints
@@ -2101,5 +935,5 @@
     DoLog(1) && (Log() << Verbose(1) << "External atoms inside of sphere at " << CandidateLine.OtherOptCenter << ":" << endl);
     for (TesselPointList::const_iterator Runner = ListofPoints->begin(); Runner != ListofPoints->end(); ++Runner)
-      DoLog(1) && (Log() << Verbose(1) << "  " << *(*Runner) << " with distance " << (*Runner)->node->distance(CandidateLine.OtherOptCenter) << "." << endl);
+      DoLog(1) && (Log() << Verbose(1) << "  " << *(*Runner) << " with distance " << (*Runner)->distance(CandidateLine.OtherOptCenter) << "." << endl);
   }
   delete (ListofPoints);
@@ -2256,7 +1090,7 @@
         if (List != NULL) {
           for (LinkedCell::LinkedNodes::const_iterator Runner = List->begin(); Runner != List->end(); Runner++) {
-            if ((*Runner)->node->at(map[0]) > maxCoordinate[map[0]]) {
-              DoLog(1) && (Log() << Verbose(1) << "New maximal for axis " << map[0] << " node is " << *(*Runner) << " at " << *(*Runner)->node << "." << endl);
-              maxCoordinate[map[0]] = (*Runner)->node->at(map[0]);
+            if ((*Runner)->at(map[0]) > maxCoordinate[map[0]]) {
+              DoLog(1) && (Log() << Verbose(1) << "New maximal for axis " << map[0] << " node is " << *(*Runner) << " at " << (*Runner)->getPosition() << "." << endl);
+              maxCoordinate[map[0]] = (*Runner)->at(map[0]);
               MaxPoint[map[0]] = (*Runner);
             }
@@ -2294,8 +1128,8 @@
 
     // construct center of circle
-    CircleCenter = 0.5 * ((*BaseLine->endpoints[0]->node->node) + (*BaseLine->endpoints[1]->node->node));
+    CircleCenter = 0.5 * ((BaseLine->endpoints[0]->node->getPosition()) + (BaseLine->endpoints[1]->node->getPosition()));
 
     // construct normal vector of circle
-    CirclePlaneNormal = (*BaseLine->endpoints[0]->node->node) - (*BaseLine->endpoints[1]->node->node);
+    CirclePlaneNormal = (BaseLine->endpoints[0]->node->getPosition()) - (BaseLine->endpoints[1]->node->getPosition());
 
     double radius = CirclePlaneNormal.NormSquared();
@@ -2514,10 +1348,10 @@
 
   // construct center of circle
-  CircleCenter = 0.5 * ((*CandidateLine.BaseLine->endpoints[0]->node->node) +
-                        (*CandidateLine.BaseLine->endpoints[1]->node->node));
+  CircleCenter = 0.5 * ((CandidateLine.BaseLine->endpoints[0]->node->getPosition()) +
+                        (CandidateLine.BaseLine->endpoints[1]->node->getPosition()));
 
   // construct normal vector of circle
-  CirclePlaneNormal = (*CandidateLine.BaseLine->endpoints[0]->node->node) -
-                      (*CandidateLine.BaseLine->endpoints[1]->node->node);
+  CirclePlaneNormal = (CandidateLine.BaseLine->endpoints[0]->node->getPosition()) -
+                      (CandidateLine.BaseLine->endpoints[1]->node->getPosition());
 
   // calculate squared radius of circle
@@ -2535,5 +1369,5 @@
     // construct SearchDirection and an "outward pointer"
     SearchDirection = Plane(RelativeSphereCenter, CirclePlaneNormal,0).getNormal();
-    helper = CircleCenter - (*ThirdPoint->node->node);
+    helper = CircleCenter - (ThirdPoint->node->getPosition());
     if (helper.ScalarProduct(SearchDirection) < -HULLEPSILON)// ohoh, SearchDirection points inwards!
       SearchDirection.Scale(-1.);
@@ -2610,5 +1444,5 @@
   for (TesselPointList::iterator Runner = CandidateLine.pointlist.begin(); Runner != CandidateLine.pointlist.end(); Runner++)
     SetOfNeighbours.insert(*Runner);
-  TesselPointList *connectedClosestPoints = GetCircleOfSetOfPoints(&SetOfNeighbours, TurningPoint, CandidateLine.BaseLine->endpoints[1]->node->node);
+  TesselPointList *connectedClosestPoints = GetCircleOfSetOfPoints(&SetOfNeighbours, TurningPoint, CandidateLine.BaseLine->endpoints[1]->node->getPosition());
 
   DoLog(0) && (Log() << Verbose(0) << "List of Candidates for Turning Point " << *TurningPoint << ":" << endl);
@@ -2711,5 +1545,5 @@
 
   // create normal vector
-  BTS->GetCenter(&Center);
+  BTS->GetCenter(Center);
   Center -= CandidateLine.OptCenter;
   BTS->SphereCenter = CandidateLine.OptCenter;
@@ -2790,5 +1624,5 @@
 
   // create normal vector
-  BTS->GetCenter(&Center);
+  BTS->GetCenter(Center);
   Center.SubtractVector(*OptCenter);
   BTS->SphereCenter = *OptCenter;
@@ -2836,7 +1670,7 @@
   Vector DistanceToIntersection[2], BaseLine;
   double distance[2];
-  BaseLine = (*Base->endpoints[1]->node->node) - (*Base->endpoints[0]->node->node);
+  BaseLine = (Base->endpoints[1]->node->getPosition()) - (Base->endpoints[0]->node->getPosition());
   for (int i = 0; i < 2; i++) {
-    DistanceToIntersection[i] = (*ClosestPoint) - (*Base->endpoints[i]->node->node);
+    DistanceToIntersection[i] = (*ClosestPoint) - (Base->endpoints[i]->node->getPosition());
     distance[i] = BaseLine.ScalarProduct(DistanceToIntersection[i]);
   }
@@ -2918,5 +1752,5 @@
 
   // calculate volume
-  volume = CalculateVolumeofGeneralTetraeder(*Base->endpoints[1]->node->node, *OtherBase->endpoints[0]->node->node, *OtherBase->endpoints[1]->node->node, *Base->endpoints[0]->node->node);
+  volume = CalculateVolumeofGeneralTetraeder(Base->endpoints[1]->node->getPosition(), OtherBase->endpoints[0]->node->getPosition(), OtherBase->endpoints[1]->node->getPosition(), Base->endpoints[0]->node->getPosition());
 
   // delete the temporary other base line and the closest points
@@ -3124,5 +1958,5 @@
 
               OrthogonalizedOben = Oben;
-              aCandidate = (*a->node) - (*Candidate->node);
+              aCandidate = (a->getPosition()) - (Candidate->getPosition());
               OrthogonalizedOben.ProjectOntoPlane(aCandidate);
               OrthogonalizedOben.Normalize();
@@ -3131,8 +1965,8 @@
               OrthogonalizedOben.Scale(scaleFactor);
 
-              Center = 0.5 * ((*Candidate->node) + (*a->node));
+              Center = 0.5 * ((Candidate->getPosition()) + (a->getPosition()));
               Center += OrthogonalizedOben;
 
-              AngleCheck = Center - (*a->node);
+              AngleCheck = Center - (a->getPosition());
               norm = aCandidate.Norm();
               // second point shall have smallest angle with respect to Oben vector
@@ -3219,10 +2053,10 @@
 
   // construct center of circle
-  CircleCenter = 0.5 * ((*CandidateLine.BaseLine->endpoints[0]->node->node) +
-                        (*CandidateLine.BaseLine->endpoints[1]->node->node));
+  CircleCenter = 0.5 * ((CandidateLine.BaseLine->endpoints[0]->node->getPosition()) +
+                        (CandidateLine.BaseLine->endpoints[1]->node->getPosition()));
 
   // construct normal vector of circle
-  CirclePlaneNormal = (*CandidateLine.BaseLine->endpoints[0]->node->node) -
-                      (*CandidateLine.BaseLine->endpoints[1]->node->node);
+  CirclePlaneNormal = (CandidateLine.BaseLine->endpoints[0]->node->getPosition()) -
+                      (CandidateLine.BaseLine->endpoints[1]->node->getPosition());
 
   RelativeOldSphereCenter = OldSphereCenter - CircleCenter;
@@ -3251,5 +2085,5 @@
 
       // get cell for the starting point
-      if (LC->SetIndexToVector(&CircleCenter)) {
+      if (LC->SetIndexToVector(CircleCenter)) {
         for (int i = 0; i < NDIM; i++) // store indices of this cell
           N[i] = LC->n[i];
@@ -3281,18 +2115,18 @@
 
                   // find center on the plane
-                  GetCenterofCircumcircle(&NewPlaneCenter, *CandidateLine.BaseLine->endpoints[0]->node->node, *CandidateLine.BaseLine->endpoints[1]->node->node, *Candidate->node);
+                  GetCenterofCircumcircle(NewPlaneCenter, CandidateLine.BaseLine->endpoints[0]->node->getPosition(), CandidateLine.BaseLine->endpoints[1]->node->getPosition(), Candidate->getPosition());
                   DoLog(1) && (Log() << Verbose(1) << "INFO: NewPlaneCenter is " << NewPlaneCenter << "." << endl);
 
                   try {
-                    NewNormalVector = Plane(*(CandidateLine.BaseLine->endpoints[0]->node->node),
-                                            *(CandidateLine.BaseLine->endpoints[1]->node->node),
-                                            *(Candidate->node)).getNormal();
+                    NewNormalVector = Plane((CandidateLine.BaseLine->endpoints[0]->node->getPosition()),
+                                            (CandidateLine.BaseLine->endpoints[1]->node->getPosition()),
+                                            (Candidate->getPosition())).getNormal();
                     DoLog(1) && (Log() << Verbose(1) << "INFO: NewNormalVector is " << NewNormalVector << "." << endl);
-                    radius = CandidateLine.BaseLine->endpoints[0]->node->node->DistanceSquared(NewPlaneCenter);
+                    radius = CandidateLine.BaseLine->endpoints[0]->node->DistanceSquared(NewPlaneCenter);
                     DoLog(1) && (Log() << Verbose(1) << "INFO: CircleCenter is at " << CircleCenter << ", CirclePlaneNormal is " << CirclePlaneNormal << " with circle radius " << sqrt(CircleRadius) << "." << endl);
                     DoLog(1) && (Log() << Verbose(1) << "INFO: SearchDirection is " << SearchDirection << "." << endl);
                     DoLog(1) && (Log() << Verbose(1) << "INFO: Radius of CircumCenterCircle is " << radius << "." << endl);
                     if (radius < RADIUS * RADIUS) {
-                      otherradius = CandidateLine.BaseLine->endpoints[1]->node->node->DistanceSquared(NewPlaneCenter);
+                      otherradius = CandidateLine.BaseLine->endpoints[1]->node->DistanceSquared(NewPlaneCenter);
                       if (fabs(radius - otherradius) < HULLEPSILON) {
                         // construct both new centers
@@ -3308,6 +2142,6 @@
                         OtherNewSphereCenter += helper;
                         DoLog(2) && (Log() << Verbose(2) << "INFO: OtherNewSphereCenter is at " << OtherNewSphereCenter << "." << endl);
-                        alpha = GetPathLengthonCircumCircle(CircleCenter, CirclePlaneNormal, CircleRadius, NewSphereCenter, OldSphereCenter, NormalVector, SearchDirection);
-                        Otheralpha = GetPathLengthonCircumCircle(CircleCenter, CirclePlaneNormal, CircleRadius, OtherNewSphereCenter, OldSphereCenter, NormalVector, SearchDirection);
+                        alpha = GetPathLengthonCircumCircle(CircleCenter, CirclePlaneNormal, CircleRadius, NewSphereCenter, OldSphereCenter, NormalVector, SearchDirection, HULLEPSILON);
+                        Otheralpha = GetPathLengthonCircumCircle(CircleCenter, CirclePlaneNormal, CircleRadius, OtherNewSphereCenter, OldSphereCenter, NormalVector, SearchDirection, HULLEPSILON);
                         if ((ThirdPoint != NULL) && (Candidate == ThirdPoint->node)) { // in that case only the other circlecenter is valid
                           if (OldSphereCenter.DistanceSquared(NewSphereCenter) < OldSphereCenter.DistanceSquared(OtherNewSphereCenter))
@@ -3421,5 +2255,5 @@
  * \return map of BoundaryPointSet of closest points sorted by squared distance or NULL.
  */
-DistanceToPointMap * Tesselation::FindClosestBoundaryPointsToVector(const Vector *x, const LinkedCell* LC) const
+DistanceToPointMap * Tesselation::FindClosestBoundaryPointsToVector(const Vector &x, const LinkedCell* LC) const
 {
   Info FunctionInfo(__func__);
@@ -3449,5 +2283,5 @@
             FindPoint = PointsOnBoundary.find((*Runner)->nr);
             if (FindPoint != PointsOnBoundary.end()) {
-              points->insert(DistanceToPointPair(FindPoint->second->node->node->DistanceSquared(*x), FindPoint->second));
+              points->insert(DistanceToPointPair(FindPoint->second->node->DistanceSquared(x), FindPoint->second));
               DoLog(1) && (Log() << Verbose(1) << "INFO: Putting " << *FindPoint->second << " into the list." << endl);
             }
@@ -3473,5 +2307,5 @@
  * \return closest BoundaryLineSet or NULL in degenerate case.
  */
-BoundaryLineSet * Tesselation::FindClosestBoundaryLineToVector(const Vector *x, const LinkedCell* LC) const
+BoundaryLineSet * Tesselation::FindClosestBoundaryLineToVector(const Vector &x, const LinkedCell* LC) const
 {
   Info FunctionInfo(__func__);
@@ -3484,5 +2318,5 @@
 
   // for each point, check its lines, remember closest
-  DoLog(1) && (Log() << Verbose(1) << "Finding closest BoundaryLine to " << *x << " ... " << endl);
+  DoLog(1) && (Log() << Verbose(1) << "Finding closest BoundaryLine to " << x << " ... " << endl);
   BoundaryLineSet *ClosestLine = NULL;
   double MinDistance = -1.;
@@ -3493,16 +2327,16 @@
     for (LineMap::iterator LineRunner = Runner->second->lines.begin(); LineRunner != Runner->second->lines.end(); LineRunner++) {
       // calculate closest point on line to desired point
-      helper = 0.5 * ((*(LineRunner->second)->endpoints[0]->node->node) +
-                      (*(LineRunner->second)->endpoints[1]->node->node));
-      Center = (*x) - helper;
-      BaseLine = (*(LineRunner->second)->endpoints[0]->node->node) -
-                 (*(LineRunner->second)->endpoints[1]->node->node);
+      helper = 0.5 * (((LineRunner->second)->endpoints[0]->node->getPosition()) +
+                      ((LineRunner->second)->endpoints[1]->node->getPosition()));
+      Center = (x) - helper;
+      BaseLine = ((LineRunner->second)->endpoints[0]->node->getPosition()) -
+                 ((LineRunner->second)->endpoints[1]->node->getPosition());
       Center.ProjectOntoPlane(BaseLine);
       const double distance = Center.NormSquared();
       if ((ClosestLine == NULL) || (distance < MinDistance)) {
         // additionally calculate intersection on line (whether it's on the line section or not)
-        helper = (*x) - (*(LineRunner->second)->endpoints[0]->node->node) - Center;
+        helper = (x) - ((LineRunner->second)->endpoints[0]->node->getPosition()) - Center;
         const double lengthA = helper.ScalarProduct(BaseLine);
-        helper = (*x) - (*(LineRunner->second)->endpoints[1]->node->node) - Center;
+        helper = (x) - ((LineRunner->second)->endpoints[1]->node->getPosition()) - Center;
         const double lengthB = helper.ScalarProduct(BaseLine);
         if (lengthB * lengthA < 0) { // if have different sign
@@ -3533,5 +2367,5 @@
  * \return BoundaryTriangleSet of nearest triangle or NULL.
  */
-TriangleList * Tesselation::FindClosestTrianglesToVector(const Vector *x, const LinkedCell* LC) const
+TriangleList * Tesselation::FindClosestTrianglesToVector(const Vector &x, const LinkedCell* LC) const
 {
   Info FunctionInfo(__func__);
@@ -3544,5 +2378,5 @@
 
   // for each point, check its lines, remember closest
-  DoLog(1) && (Log() << Verbose(1) << "Finding closest BoundaryTriangle to " << *x << " ... " << endl);
+  DoLog(1) && (Log() << Verbose(1) << "Finding closest BoundaryTriangle to " << x << " ... " << endl);
   LineSet ClosestLines;
   double MinDistance = 1e+16;
@@ -3554,12 +2388,12 @@
     for (LineMap::iterator LineRunner = Runner->second->lines.begin(); LineRunner != Runner->second->lines.end(); LineRunner++) {
 
-      BaseLine = (*(LineRunner->second)->endpoints[0]->node->node) -
-                 (*(LineRunner->second)->endpoints[1]->node->node);
+      BaseLine = ((LineRunner->second)->endpoints[0]->node->getPosition()) -
+                 ((LineRunner->second)->endpoints[1]->node->getPosition());
       const double lengthBase = BaseLine.NormSquared();
 
-      BaseLineIntersection = (*x) - (*(LineRunner->second)->endpoints[0]->node->node);
+      BaseLineIntersection = (x) - ((LineRunner->second)->endpoints[0]->node->getPosition());
       const double lengthEndA = BaseLineIntersection.NormSquared();
 
-      BaseLineIntersection = (*x) - (*(LineRunner->second)->endpoints[1]->node->node);
+      BaseLineIntersection = (x) - ((LineRunner->second)->endpoints[1]->node->getPosition());
       const double lengthEndB = BaseLineIntersection.NormSquared();
 
@@ -3579,5 +2413,5 @@
       } else { // intersection is closer, calculate
         // calculate closest point on line to desired point
-        BaseLineIntersection = (*x) - (*(LineRunner->second)->endpoints[1]->node->node);
+        BaseLineIntersection = (x) - ((LineRunner->second)->endpoints[1]->node->getPosition());
         Center = BaseLineIntersection;
         Center.ProjectOntoPlane(BaseLine);
@@ -3620,5 +2454,5 @@
  * \return list of BoundaryTriangleSet of nearest triangles or NULL.
  */
-class BoundaryTriangleSet * Tesselation::FindClosestTriangleToVector(const Vector *x, const LinkedCell* LC) const
+class BoundaryTriangleSet * Tesselation::FindClosestTriangleToVector(const Vector &x, const LinkedCell* LC) const
 {
   Info FunctionInfo(__func__);
@@ -3635,6 +2469,6 @@
   double MinAlignment = 2. * M_PI;
   for (TriangleList::iterator Runner = triangles->begin(); Runner != triangles->end(); Runner++) {
-    (*Runner)->GetCenter(&Center);
-    helper = (*x) - Center;
+    (*Runner)->GetCenter(Center);
+    helper = (x) - Center;
     const double Alignment = helper.Angle((*Runner)->NormalVector);
     if (Alignment < MinAlignment) {
@@ -3662,5 +2496,5 @@
 {
   Info FunctionInfo(__func__);
-  TriangleIntersectionList Intersections(&Point, this, LC);
+  TriangleIntersectionList Intersections(Point, this, LC);
 
   return Intersections.IsInside();
@@ -3702,5 +2536,5 @@
   }
 
-  triangle->GetCenter(&Center);
+  triangle->GetCenter(Center);
   DoLog(2) && (Log() << Verbose(2) << "INFO: Central point of the triangle is " << Center << "." << endl);
   DistanceToCenter = Center - Point;
@@ -3713,5 +2547,5 @@
     Center = Point - triangle->NormalVector; // points towards MolCenter
     DoLog(1) && (Log() << Verbose(1) << "INFO: Calling Intersection with " << Center << " and " << DistanceToCenter << "." << endl);
-    if (triangle->GetIntersectionInsideTriangle(&Center, &DistanceToCenter, &Intersection)) {
+    if (triangle->GetIntersectionInsideTriangle(Center, DistanceToCenter, Intersection)) {
       DoLog(1) && (Log() << Verbose(1) << Point << " is inner point: sufficiently close to boundary, " << Intersection << "." << endl);
       return 0.;
@@ -3722,5 +2556,5 @@
   } else {
     // calculate smallest distance
-    distance = triangle->GetClosestPointInsideTriangle(&Point, &Intersection);
+    distance = triangle->GetClosestPointInsideTriangle(Point, Intersection);
     DoLog(1) && (Log() << Verbose(1) << "Closest point on triangle is " << Intersection << "." << endl);
 
@@ -3746,5 +2580,5 @@
 {
   Info FunctionInfo(__func__);
-  TriangleIntersectionList Intersections(&Point, this, LC);
+  TriangleIntersectionList Intersections(Point, this, LC);
 
   return Intersections.GetSmallestDistance();
@@ -3761,5 +2595,5 @@
 {
   Info FunctionInfo(__func__);
-  TriangleIntersectionList Intersections(&Point, this, LC);
+  TriangleIntersectionList Intersections(Point, this, LC);
 
   return Intersections.GetClosestTriangle();
@@ -3838,5 +2672,5 @@
  * @return list of the all points linked to the provided one
  */
-TesselPointList * Tesselation::GetCircleOfConnectedTriangles(TesselPointSet *SetOfNeighbours, const TesselPoint* const Point, const Vector * const Reference) const
+TesselPointList * Tesselation::GetCircleOfConnectedTriangles(TesselPointSet *SetOfNeighbours, const TesselPoint* const Point, const Vector &Reference) const
 {
   Info FunctionInfo(__func__);
@@ -3870,11 +2704,9 @@
 
   // construct one orthogonal vector
-  if (Reference != NULL) {
-    AngleZero = (*Reference) - (*Point->node);
-    AngleZero.ProjectOntoPlane(PlaneNormal);
-  }
-  if ((Reference == NULL) || (AngleZero.NormSquared() < MYEPSILON)) {
-    DoLog(1) && (Log() << Verbose(1) << "Using alternatively " << *(*SetOfNeighbours->begin())->node << " as angle 0 referencer." << endl);
-    AngleZero = (*(*SetOfNeighbours->begin())->node) - (*Point->node);
+  AngleZero = (Reference) - (Point->getPosition());
+  AngleZero.ProjectOntoPlane(PlaneNormal);
+  if ((AngleZero.NormSquared() < MYEPSILON)) {
+    DoLog(1) && (Log() << Verbose(1) << "Using alternatively " << (*SetOfNeighbours->begin())->getPosition() << " as angle 0 referencer." << endl);
+    AngleZero = ((*SetOfNeighbours->begin())->getPosition()) - (Point->getPosition());
     AngleZero.ProjectOntoPlane(PlaneNormal);
     if (AngleZero.NormSquared() < MYEPSILON) {
@@ -3892,5 +2724,5 @@
   // go through all connected points and calculate angle
   for (TesselPointSet::iterator listRunner = SetOfNeighbours->begin(); listRunner != SetOfNeighbours->end(); listRunner++) {
-    helper = (*(*listRunner)->node) - (*Point->node);
+    helper = ((*listRunner)->getPosition()) - (Point->getPosition());
     helper.ProjectOntoPlane(PlaneNormal);
     double angle = GetAngle(helper, AngleZero, OrthogonalVector);
@@ -3914,8 +2746,8 @@
  * @param *SetOfNeighbours all points for which the angle should be calculated
  * @param *Point of which get all connected points
- * @param *Reference Reference vector for zero angle or NULL for no preference
+ * @param *Reference Reference vector for zero angle or (0,0,0) for no preference
  * @return list of the all points linked to the provided one
  */
-TesselPointList * Tesselation::GetCircleOfSetOfPoints(TesselPointSet *SetOfNeighbours, const TesselPoint* const Point, const Vector * const Reference) const
+TesselPointList * Tesselation::GetCircleOfSetOfPoints(TesselPointSet *SetOfNeighbours, const TesselPoint* const Point, const Vector &Reference) const
 {
   Info FunctionInfo(__func__);
@@ -3941,5 +2773,5 @@
   }
 
-  DoLog(1) && (Log() << Verbose(1) << "INFO: Point is " << *Point << " and Reference is " << *Reference << "." << endl);
+  DoLog(1) && (Log() << Verbose(1) << "INFO: Point is " << *Point << " and Reference is " << Reference << "." << endl);
   // calculate central point
   TesselPointSet::const_iterator TesselA = SetOfNeighbours->begin();
@@ -3951,7 +2783,7 @@
   int counter = 0;
   while (TesselC != SetOfNeighbours->end()) {
-    helper = Plane(*((*TesselA)->node),
-                   *((*TesselB)->node),
-                   *((*TesselC)->node)).getNormal();
+    helper = Plane(((*TesselA)->getPosition()),
+                   ((*TesselB)->getPosition()),
+                   ((*TesselC)->getPosition())).getNormal();
     DoLog(0) && (Log() << Verbose(0) << "Making normal vector out of " << *(*TesselA) << ", " << *(*TesselB) << " and " << *(*TesselC) << ":" << helper << endl);
     counter++;
@@ -3973,11 +2805,11 @@
 
   // construct one orthogonal vector
-  if (Reference != NULL) {
-    AngleZero = (*Reference) - (*Point->node);
+  if (!Reference.IsZero()) {
+    AngleZero = (Reference) - (Point->getPosition());
     AngleZero.ProjectOntoPlane(PlaneNormal);
   }
-  if ((Reference == NULL) || (AngleZero.NormSquared() < MYEPSILON )) {
-    DoLog(1) && (Log() << Verbose(1) << "Using alternatively " << *(*SetOfNeighbours->begin())->node << " as angle 0 referencer." << endl);
-    AngleZero = (*(*SetOfNeighbours->begin())->node) - (*Point->node);
+  if ((Reference.IsZero()) || (AngleZero.NormSquared() < MYEPSILON )) {
+    DoLog(1) && (Log() << Verbose(1) << "Using alternatively " << (*SetOfNeighbours->begin())->getPosition() << " as angle 0 referencer." << endl);
+    AngleZero = ((*SetOfNeighbours->begin())->getPosition()) - (Point->getPosition());
     AngleZero.ProjectOntoPlane(PlaneNormal);
     if (AngleZero.NormSquared() < MYEPSILON) {
@@ -3996,5 +2828,5 @@
   pair<map<double, TesselPoint*>::iterator, bool> InserterTest;
   for (TesselPointSet::iterator listRunner = SetOfNeighbours->begin(); listRunner != SetOfNeighbours->end(); listRunner++) {
-    helper = (*(*listRunner)->node) - (*Point->node);
+    helper = ((*listRunner)->getPosition()) - (Point->getPosition());
     helper.ProjectOntoPlane(PlaneNormal);
     double angle = GetAngle(helper, AngleZero, OrthogonalVector);
@@ -4241,5 +3073,5 @@
 
   // copy old location for the volume
-  OldPoint = (*point->node->node);
+  OldPoint = (point->node->getPosition());
 
   // get list of connected points
@@ -4304,5 +3136,5 @@
           StartNode--;
           //Log() << Verbose(3) << "INFO: StartNode is " << **StartNode << "." << endl;
-          Point = (*(*StartNode)->node) - (*(*MiddleNode)->node);
+          Point = ((*StartNode)->getPosition()) - ((*MiddleNode)->getPosition());
           StartNode = MiddleNode;
           StartNode++;
@@ -4310,6 +3142,6 @@
             StartNode = connectedPath->begin();
           //Log() << Verbose(3) << "INFO: EndNode is " << **StartNode << "." << endl;
-          Reference = (*(*StartNode)->node) - (*(*MiddleNode)->node);
-          OrthogonalVector = (*(*MiddleNode)->node) - OldPoint;
+          Reference = ((*StartNode)->getPosition()) - ((*MiddleNode)->getPosition());
+          OrthogonalVector = ((*MiddleNode)->getPosition()) - OldPoint;
           OrthogonalVector.MakeNormalTo(Reference);
           angle = GetAngle(Point, Reference, OrthogonalVector);
@@ -4366,5 +3198,5 @@
         AddTesselationTriangle();
         // calculate volume summand as a general tetraeder
-        volume += CalculateVolumeofGeneralTetraeder(*TPS[0]->node->node, *TPS[1]->node->node, *TPS[2]->node->node, OldPoint);
+        volume += CalculateVolumeofGeneralTetraeder(TPS[0]->node->getPosition(), TPS[1]->node->getPosition(), TPS[2]->node->getPosition(), OldPoint);
         // advance number
         count++;
@@ -4751,5 +3583,5 @@
   // find nearest boundary point
   class TesselPoint *BackupPoint = NULL;
-  class TesselPoint *NearestPoint = FindClosestTesselPoint(point->node, BackupPoint, LC);
+  class TesselPoint *NearestPoint = FindClosestTesselPoint(point->getPosition(), BackupPoint, LC);
   class BoundaryPointSet *NearestBoundaryPoint = NULL;
   PointMap::iterator PointRunner;
@@ -4772,9 +3604,9 @@
   class BoundaryLineSet *BestLine = NULL;
   for (LineMap::iterator Runner = NearestBoundaryPoint->lines.begin(); Runner != NearestBoundaryPoint->lines.end(); Runner++) {
-    BaseLine = (*Runner->second->endpoints[0]->node->node) -
-               (*Runner->second->endpoints[1]->node->node);
-    CenterToPoint = 0.5 * ((*Runner->second->endpoints[0]->node->node) +
-                           (*Runner->second->endpoints[1]->node->node));
-    CenterToPoint -= (*point->node);
+    BaseLine = (Runner->second->endpoints[0]->node->getPosition()) -
+               (Runner->second->endpoints[1]->node->getPosition());
+    CenterToPoint = 0.5 * ((Runner->second->endpoints[0]->node->getPosition()) +
+                           (Runner->second->endpoints[1]->node->getPosition()));
+    CenterToPoint -= (point->getPosition());
     angle = CenterToPoint.Angle(BaseLine);
     if (fabs(angle - M_PI/2.) < fabs(BestAngle - M_PI/2.)) {
Index: src/tesselation.hpp
===================================================================
--- src/tesselation.hpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/tesselation.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -2,5 +2,6 @@
  * tesselation.hpp
  *
- *  The tesselation class is meant to contain the envelope (concave, convex or neither) of a set of Vectors. As we actually mean this stuff for atoms, we have to encapsulate it all a bit.
+ *  The tesselation class is meant to contain the envelope (concave, convex or neither) of a set of Vectors.
+ *  As we actually mean this stuff for atoms, we have to encapsulate it all a bit.
  *
  *  Created on: Aug 3, 2009
@@ -25,7 +26,11 @@
 #include <stack>
 
+#include "BoundaryMaps.hpp"
+#include "PointCloud.hpp"
+#include "TesselPoint.hpp"
 #include "atom_particleinfo.hpp"
-#include "helpers.hpp"
-#include "vector.hpp"
+#include "Helpers/helpers.hpp"
+#include "LinearAlgebra/Vector.hpp"
+
 
 /****************************************** forward declarations *****************************/
@@ -34,7 +39,6 @@
 class BoundaryLineSet;
 class BoundaryTriangleSet;
+class CandidateForTesselation;
 class LinkedCell;
-class TesselPoint;
-class PointCloud;
 class Tesselation;
 class Plane;
@@ -42,238 +46,17 @@
 /********************************************** definitions *********************************/
 
-#define DoTecplotOutput 1
-#define DoRaster3DOutput 1
-#define DoVRMLOutput 0
-#define TecplotSuffix ".dat"
-#define Raster3DSuffix ".r3d"
-#define VRMLSUffix ".wrl"
+enum { DoTecplotOutput=1 };
+enum { DoRaster3DOutput=1 };
+enum { DoVRMLOutput=0 };
 
-#define ParallelEpsilon 1e-3
+extern "C" const char *TecplotSuffix;
+extern "C" const char *Raster3DSuffix;
+extern "C" const char *VRMLSUffix;
+
+extern "C" const double ParallelEpsilon;
 
 // ======================================================= some template functions =========================================
 
-#define IndexToIndex map <int, int>
-
-#define PointMap map < int, class BoundaryPointSet * >
-#define PointSet set < class BoundaryPointSet * >
-#define PointList list < class BoundaryPointSet * >
-#define PointPair pair < int, class BoundaryPointSet * >
-#define PointTestPair pair < PointMap::iterator, bool >
-
-#define CandidateList list <class CandidateForTesselation *>
-#define CandidateMap map <class BoundaryLineSet *, class CandidateForTesselation *>
-
-#define LineMap multimap < int, class BoundaryLineSet * >
-#define LineSet set < class BoundaryLineSet * >
-#define LineList list < class BoundaryLineSet * >
-#define LinePair pair < int, class BoundaryLineSet * >
-#define LineTestPair pair < LineMap::iterator, bool >
-
-#define TriangleMap map < int, class BoundaryTriangleSet * >
-#define TriangleSet set < class BoundaryTriangleSet * >
-#define TriangleList list < class BoundaryTriangleSet * >
-#define TrianglePair pair < int, class BoundaryTriangleSet * >
-#define TriangleTestPair pair < TrianglePair::iterator, bool >
-
-#define PolygonMap map < int, class BoundaryPolygonSet * >
-#define PolygonSet set < class BoundaryPolygonSet * >
-#define PolygonList list < class BoundaryPolygonSet * >
-
-#define DistanceToPointMap multimap <double, class BoundaryPointSet * >
-#define DistanceToPointPair pair <double, class BoundaryPointSet * >
-
-#define DistanceMultiMap multimap <double, pair < PointMap::iterator, PointMap::iterator> >
-#define DistanceMultiMapPair pair <double, pair < PointMap::iterator, PointMap::iterator> >
-
-#define TesselPointList list <TesselPoint *>
-#define TesselPointSet set <TesselPoint *>
-
-#define ListOfTesselPointList list<list <TesselPoint *> *>
-
-enum centers {Opt, OtherOpt};
-
 /********************************************** declarations *******************************/
-
-template <typename T> void SetEndpointsOrdered(T endpoints[2], T endpoint1, T endpoint2)
-{
-  if (endpoint1->Nr < endpoint2->Nr) {
-    endpoints[0] = endpoint1;
-    endpoints[1] = endpoint2;
-  } else {
-    endpoints[0] = endpoint2;
-    endpoints[1] = endpoint1;
-  }
-};
-
-// ======================================================== class BoundaryPointSet =========================================
-
-class BoundaryPointSet {
-  public:
-    BoundaryPointSet();
-    BoundaryPointSet(TesselPoint * const Walker);
-    ~BoundaryPointSet();
-
-    void AddLine(BoundaryLineSet * const line);
-
-    LineMap lines;
-    int LinesCount;
-    TesselPoint *node;
-    double value;
-    int Nr;
-};
-
-ostream & operator << (ostream &ost, const BoundaryPointSet &a);
-
-// ======================================================== class BoundaryLineSet ==========================================
-
-class BoundaryLineSet {
-  public:
-    BoundaryLineSet();
-    BoundaryLineSet(BoundaryPointSet * const Point[2], const int number);
-    BoundaryLineSet(BoundaryPointSet * const Point1, BoundaryPointSet * const Point2, const int number);
-    ~BoundaryLineSet();
-
-    void AddTriangle(BoundaryTriangleSet * const triangle);
-    bool IsConnectedTo(const BoundaryLineSet * const line) const;
-    bool ContainsBoundaryPoint(const BoundaryPointSet * const point) const;
-    bool CheckConvexityCriterion() const;
-    double CalculateConvexity() const;
-    class BoundaryPointSet *GetOtherEndpoint(const BoundaryPointSet * const point) const;
-    class BoundaryTriangleSet *GetOtherTriangle(const BoundaryTriangleSet * const triangle) const;
-
-    class BoundaryPointSet *endpoints[2];
-    TriangleMap triangles;
-    int Nr;
-    bool skipped;
-};
-
-ostream & operator << (ostream &ost, const BoundaryLineSet &a);
-
-// ======================================================== class BoundaryTriangleSet =======================================
-
-class BoundaryTriangleSet {
-  public:
-    BoundaryTriangleSet();
-    BoundaryTriangleSet(class BoundaryLineSet * const line[3], const int number);
-    ~BoundaryTriangleSet();
-
-    void GetNormalVector(const Vector &NormalVector);
-    void GetCenter(Vector * const center) const;
-    bool GetIntersectionInsideTriangle(const Vector * const MolCenter, const Vector * const x, Vector * const Intersection) const;
-    double GetClosestPointInsideTriangle(const Vector * const x, Vector * const ClosestPoint) const;
-    bool ContainsBoundaryLine(const BoundaryLineSet * const line) const;
-    bool ContainsBoundaryPoint(const BoundaryPointSet * const point) const;
-    bool ContainsBoundaryPoint(const TesselPoint * const point) const;
-    class BoundaryPointSet *GetThirdEndpoint(const BoundaryLineSet * const line) const;
-    class BoundaryLineSet *GetThirdLine(const BoundaryPointSet * const point) const;
-    bool IsPresentTupel(const BoundaryPointSet * const Points[3]) const;
-    bool IsPresentTupel(const BoundaryTriangleSet * const T) const;
-
-    Plane getPlane() const;
-    Vector getEndpoint(int) const;
-    std::string getEndpointName(int) const;
-
-    class BoundaryPointSet *endpoints[3];
-    class BoundaryLineSet *lines[3];
-    Vector NormalVector;
-    Vector SphereCenter;
-    int Nr;
-
-  private:
-
-};
-
-ostream & operator << (ostream &ost, const BoundaryTriangleSet &a);
-
-
-// ======================================================== class BoundaryTriangleSet =======================================
-
-/** Set of BoundaryPointSet.
- * This is just meant as a container for a group of endpoints, extending the node, line, triangle concept. However, this has
- * only marginally something to do with the tesselation. Hence, there is no incorporation into the bookkeeping of the Tesselation
- * class (i.e. no allocation, no deletion).
- * \note we assume that the set of endpoints reside (more or less) on a plane.
- */
-class BoundaryPolygonSet {
-  public:
-    BoundaryPolygonSet();
-    ~BoundaryPolygonSet();
-
-    Vector * GetNormalVector(const Vector &NormalVector) const;
-    void GetCenter(Vector *center) const;
-    bool ContainsBoundaryLine(const BoundaryLineSet * const line) const;
-    bool ContainsBoundaryPoint(const BoundaryPointSet * const point) const;
-    bool ContainsBoundaryPoint(const TesselPoint * const point) const;
-    bool ContainsBoundaryTriangle(const BoundaryTriangleSet * const point) const;
-    bool ContainsPresentTupel(const BoundaryPointSet * const * Points, const int dim) const;
-    bool ContainsPresentTupel(const BoundaryPolygonSet * const P) const;
-    bool ContainsPresentTupel(const PointSet &endpoints) const;
-    TriangleSet * GetAllContainedTrianglesFromEndpoints() const;
-    bool FillPolygonFromTrianglesOfLine(const BoundaryLineSet * const line);
-
-    PointSet endpoints;
-    int Nr;
-};
-
-ostream & operator << (ostream &ost, const BoundaryPolygonSet &a);
-
-// =========================================================== class TESSELPOINT ===========================================
-
-/** Is a single point of the set of Vectors, also a super-class to be inherited and and its functions to be implemented.
- */
-class TesselPoint : virtual public ParticleInfo {
-public:
-  TesselPoint();
-  virtual ~TesselPoint();
-
-  Vector *node;   // pointer to position of the dot in space
-
-  virtual ostream & operator << (ostream &ost);
-};
-
-ostream & operator << (ostream &ost, const TesselPoint &a);
-
-// =========================================================== class POINTCLOUD ============================================
-
-/** Super-class for all point clouds structures, also molecules. They have to inherit this structure and implement the virtual function to access the Vectors.
- * This basically encapsulates a list structure.
- */
-class PointCloud {
-public:
-  PointCloud();
-  virtual ~PointCloud();
-
-  virtual const char * const GetName() const { return "unknown"; };
-  virtual Vector *GetCenter() const { return NULL; };
-  virtual TesselPoint *GetPoint() const { return NULL; };
-  virtual int GetMaxId() const { return 0; };
-  virtual void GoToNext() const {};
-  virtual void GoToFirst() const {};
-  virtual bool IsEmpty() const { return true; };
-  virtual bool IsEnd() const { return true; };
-};
-
-// ======================================================== class CandidateForTesselation =========================================
-
-class CandidateForTesselation {
-  public :
-  CandidateForTesselation(BoundaryLineSet* currentBaseLine);
-  CandidateForTesselation(TesselPoint* candidate, BoundaryLineSet* currentBaseLine, BoundaryPointSet *point, Vector OptCandidateCenter, Vector OtherOptCandidateCenter);
-  ~CandidateForTesselation();
-
-  bool CheckValidity(const double RADIUS, const LinkedCell *LC) const;
-
-  TesselPointList pointlist;
-  const BoundaryLineSet * BaseLine;
-  const BoundaryPointSet * ThirdPoint;
-  const BoundaryTriangleSet *T;
-  Vector OldCenter;
-  Vector OptCenter;
-  Vector OtherOptCenter;
-  double ShortestAngle;
-  double OtherShortestAngle;
-};
-
-ostream & operator <<(ostream &ost, const  CandidateForTesselation &a);
 
 // =========================================================== class TESSELATION ===========================================
@@ -289,5 +72,5 @@
     void AddTesselationPoint(TesselPoint* Candidate, const int n);
     void SetTesselationPoint(TesselPoint* Candidate, const int n) const;
-    void AddTesselationLine(const Vector * const OptCenter, const BoundaryPointSet * const candidate, class BoundaryPointSet *a, class BoundaryPointSet *b, const int n);
+    void AddTesselationLine(const Vector * OptCenter, const BoundaryPointSet * const candidate, class BoundaryPointSet *a, class BoundaryPointSet *b, const int n);
     void AddNewTesselationTriangleLine(class BoundaryPointSet *a, class BoundaryPointSet *b, const int n);
     void AddExistingTesselationTriangleLine(class BoundaryLineSet *FindLine, int n);
@@ -330,10 +113,10 @@
     ListOfTesselPointList * GetPathsOfConnectedPoints(const TesselPoint* const Point) const;
     ListOfTesselPointList * GetClosedPathsOfConnectedPoints(const TesselPoint* const Point) const;
-    TesselPointList * GetCircleOfSetOfPoints(TesselPointSet *SetOfNeighbours, const TesselPoint* const Point, const Vector * const Reference = NULL) const;
-    TesselPointList * GetCircleOfConnectedTriangles(TesselPointSet *SetOfNeighbours, const TesselPoint* const Point, const Vector * const Reference) const;
+    TesselPointList * GetCircleOfSetOfPoints(TesselPointSet *SetOfNeighbours, const TesselPoint* const Point, const Vector &Reference) const;
+    TesselPointList * GetCircleOfConnectedTriangles(TesselPointSet *SetOfNeighbours, const TesselPoint* const Point, const Vector &Reference) const;
     class BoundaryPointSet * GetCommonEndpoint(const BoundaryLineSet * line1, const BoundaryLineSet * line2) const;
     TriangleList * FindTriangles(const TesselPoint* const Points[3]) const;
-    TriangleList * FindClosestTrianglesToVector(const Vector *x, const LinkedCell* LC) const;
-    BoundaryTriangleSet * FindClosestTriangleToVector(const Vector *x, const LinkedCell* LC) const;
+    TriangleList * FindClosestTrianglesToVector(const Vector &x, const LinkedCell* LC) const;
+    BoundaryTriangleSet * FindClosestTriangleToVector(const Vector &x, const LinkedCell* LC) const;
     bool IsInnerPoint(const Vector &Point, const LinkedCell* const LC) const;
     double GetDistanceSquaredToTriangle(const Vector &Point, const BoundaryTriangleSet* const triangle) const;
@@ -341,6 +124,6 @@
     BoundaryTriangleSet * GetClosestTriangleOnSurface(const Vector &Point, const LinkedCell* const LC) const;
     bool AddBoundaryPoint(TesselPoint * Walker, const int n);
-    DistanceToPointMap * FindClosestBoundaryPointsToVector(const Vector *x, const LinkedCell* LC) const;
-    BoundaryLineSet * FindClosestBoundaryLineToVector(const Vector *x, const LinkedCell* LC) const;
+    DistanceToPointMap * FindClosestBoundaryPointsToVector(const Vector &x, const LinkedCell* LC) const;
+    BoundaryLineSet * FindClosestBoundaryLineToVector(const Vector &x, const LinkedCell* LC) const;
 
     // print for debugging
@@ -375,4 +158,6 @@
 
   private:
+    static const double HULLEPSILON; //!< TODO: Get rid of HULLEPSILON, points to numerical instabilities
+
     mutable class BoundaryPointSet *TPS[3]; //this is a Storage for pointers to triangle points, this and BPS[2] needed due to AddLine restrictions
 
Index: src/tesselationhelpers.cpp
===================================================================
--- src/tesselationhelpers.cpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/tesselationhelpers.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -6,83 +6,64 @@
  */
 
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
 #include "Helpers/MemDebug.hpp"
 
 #include <fstream>
 
-#include "info.hpp"
+#include "BoundaryLineSet.hpp"
+#include "BoundaryPointSet.hpp"
+#include "BoundaryPolygonSet.hpp"
+#include "BoundaryTriangleSet.hpp"
+#include "CandidateForTesselation.hpp"
+#include "Helpers/Info.hpp"
 #include "linkedcell.hpp"
-#include "linearsystemofequations.hpp"
-#include "log.hpp"
+#include "LinearAlgebra/linearsystemofequations.hpp"
+#include "Helpers/Log.hpp"
 #include "tesselation.hpp"
 #include "tesselationhelpers.hpp"
-#include "vector.hpp"
-#include "Line.hpp"
-#include "vector_ops.hpp"
-#include "verbose.hpp"
-#include "Plane.hpp"
-
-double DetGet(gsl_matrix * const A, const int inPlace)
-{
-	Info FunctionInfo(__func__);
-  /*
-  inPlace = 1 => A is replaced with the LU decomposed copy.
-  inPlace = 0 => A is retained, and a copy is used for LU.
-  */
-
-  double det;
-  int signum;
-  gsl_permutation *p = gsl_permutation_alloc(A->size1);
-  gsl_matrix *tmpA=0;
-
-  if (inPlace)
-  tmpA = A;
-  else {
-  gsl_matrix *tmpA = gsl_matrix_alloc(A->size1, A->size2);
-  gsl_matrix_memcpy(tmpA , A);
-  }
-
-
-  gsl_linalg_LU_decomp(tmpA , p , &signum);
-  det = gsl_linalg_LU_det(tmpA , signum);
-  gsl_permutation_free(p);
-  if (! inPlace)
-  gsl_matrix_free(tmpA);
-
-  return det;
-};
+#include "LinearAlgebra/Vector.hpp"
+#include "LinearAlgebra/Line.hpp"
+#include "LinearAlgebra/vector_ops.hpp"
+#include "Helpers/Verbose.hpp"
+#include "LinearAlgebra/Plane.hpp"
+#include "LinearAlgebra/Matrix.hpp"
 
 void GetSphere(Vector * const center, const Vector &a, const Vector &b, const Vector &c, const double RADIUS)
 {
 	Info FunctionInfo(__func__);
-  gsl_matrix *A = gsl_matrix_calloc(3,3);
+  Matrix mat;
   double m11, m12, m13, m14;
 
   for(int i=0;i<3;i++) {
-    gsl_matrix_set(A, i, 0, a[i]);
-    gsl_matrix_set(A, i, 1, b[i]);
-    gsl_matrix_set(A, i, 2, c[i]);
-  }
-  m11 = DetGet(A, 1);
+    mat.set(i, 0, a[i]);
+    mat.set(i, 1, b[i]);
+    mat.set(i, 2, c[i]);
+  }
+  m11 = mat.determinant();
 
   for(int i=0;i<3;i++) {
-    gsl_matrix_set(A, i, 0, a[i]*a[i] + b[i]*b[i] + c[i]*c[i]);
-    gsl_matrix_set(A, i, 1, b[i]);
-    gsl_matrix_set(A, i, 2, c[i]);
-  }
-  m12 = DetGet(A, 1);
+    mat.set(i, 0, a[i]*a[i] + b[i]*b[i] + c[i]*c[i]);
+    mat.set(i, 1, b[i]);
+    mat.set(i, 2, c[i]);
+  }
+  m12 = mat.determinant();
 
   for(int i=0;i<3;i++) {
-    gsl_matrix_set(A, i, 0, a[i]*a[i] + b[i]*b[i] + c[i]*c[i]);
-    gsl_matrix_set(A, i, 1, a[i]);
-    gsl_matrix_set(A, i, 2, c[i]);
-  }
-  m13 = DetGet(A, 1);
+    mat.set(i, 0, a[i]*a[i] + b[i]*b[i] + c[i]*c[i]);
+    mat.set(i, 1, a[i]);
+    mat.set(i, 2, c[i]);
+  }
+  m13 = mat.determinant();
 
   for(int i=0;i<3;i++) {
-    gsl_matrix_set(A, i, 0, a[i]*a[i] + b[i]*b[i] + c[i]*c[i]);
-    gsl_matrix_set(A, i, 1, a[i]);
-    gsl_matrix_set(A, i, 2, b[i]);
-  }
-  m14 = DetGet(A, 1);
+    mat.set(i, 0, a[i]*a[i] + b[i]*b[i] + c[i]*c[i]);
+    mat.set(i, 1, a[i]);
+    mat.set(i, 2, b[i]);
+  }
+  m14 = mat.determinant();
 
   if (fabs(m11) < MYEPSILON)
@@ -95,6 +76,4 @@
   if (fabs(a.distance(*center) - RADIUS) > MYEPSILON)
     DoeLog(1) && (eLog()<< Verbose(1) << "The given center is further way by " << fabs(a.distance(*center) - RADIUS) << " from a than RADIUS." << endl);
-
-  gsl_matrix_free(A);
 };
 
@@ -175,5 +154,5 @@
  * \param *c third point
  */
-void GetCenterofCircumcircle(Vector * const Center, const Vector &a, const Vector &b, const Vector &c)
+void GetCenterofCircumcircle(Vector &Center, const Vector &a, const Vector &b, const Vector &c)
 {
 	Info FunctionInfo(__func__);
@@ -187,10 +166,11 @@
   helper[2] = SideC.NormSquared()*(SideA.NormSquared()+SideB.NormSquared() - SideC.NormSquared());
 
-  Center->Zero();
-  *Center += helper[0] * a;
-  *Center += helper[1] * b;
-  *Center += helper[2] * c;
-  Center->Scale(1./(helper[0]+helper[1]+helper[2]));
-  Log() << Verbose(1) << "INFO: Center (2nd algo) is at " << *Center << "." << endl;
+  Center.Zero();
+  Center += helper[0] * a;
+  Center += helper[1] * b;
+  Center += helper[2] * c;
+  if (fabs(helper[0]+helper[1]+helper[2]) > MYEPSILON)
+    Center.Scale(1./(helper[0]+helper[1]+helper[2]));
+  Log() << Verbose(1) << "INFO: Center (2nd algo) is at " << Center << "." << endl;
 };
 
@@ -206,7 +186,8 @@
  * \param NormalVector normal vector
  * \param SearchDirection search direction to make angle unique on return.
+ * \param HULLEPSILON machine precision for tesselation points
  * \return Angle between \a NewSphereCenter and \a OldSphereCenter relative to \a CircleCenter, 2.*M_PI if one test fails
  */
-double GetPathLengthonCircumCircle(const Vector &CircleCenter, const Vector &CirclePlaneNormal, const double CircleRadius, const Vector &NewSphereCenter, const Vector &OldSphereCenter, const Vector &NormalVector, const Vector &SearchDirection)
+double GetPathLengthonCircumCircle(const Vector &CircleCenter, const Vector &CirclePlaneNormal, const double CircleRadius, const Vector &NewSphereCenter, const Vector &OldSphereCenter, const Vector &NormalVector, const Vector &SearchDirection, const double HULLEPSILON)
 {
 	Info FunctionInfo(__func__);
@@ -248,137 +229,4 @@
   Vector x3;
   Vector x4;
-};
-
-/**
- * Intersection calculation function.
- *
- * @param x to find the result for
- * @param function parameter
- */
-double MinIntersectDistance(const gsl_vector * x, void *params)
-{
-	Info FunctionInfo(__func__);
-  double retval = 0;
-  struct Intersection *I = (struct Intersection *)params;
-  Vector intersection;
-  for (int i=0;i<NDIM;i++)
-    intersection[i] = gsl_vector_get(x, i);
-
-  Vector SideA = I->x1 -I->x2 ;
-  Vector HeightA = intersection - I->x1;
-  HeightA.ProjectOntoPlane(SideA);
-
-  Vector SideB = I->x3 - I->x4;
-  Vector HeightB = intersection - I->x3;
-  HeightB.ProjectOntoPlane(SideB);
-
-  retval = HeightA.ScalarProduct(HeightA) + HeightB.ScalarProduct(HeightB);
-  //Log() << Verbose(1) << "MinIntersectDistance called, result: " << retval << endl;
-
-  return retval;
-};
-
-
-/**
- * Calculates whether there is an intersection between two lines. The first line
- * always goes through point 1 and point 2 and the second line is given by the
- * connection between point 4 and point 5.
- *
- * @param point 1 of line 1
- * @param point 2 of line 1
- * @param point 1 of line 2
- * @param point 2 of line 2
- *
- * @return true if there is an intersection between the given lines, false otherwise
- */
-bool existsIntersection(const Vector &point1, const Vector &point2, const Vector &point3, const Vector &point4)
-{
-	Info FunctionInfo(__func__);
-  bool result;
-
-  struct Intersection par;
-    par.x1 = point1;
-    par.x2 = point2;
-    par.x3 = point3;
-    par.x4 = point4;
-
-    const gsl_multimin_fminimizer_type *T = gsl_multimin_fminimizer_nmsimplex;
-    gsl_multimin_fminimizer *s = NULL;
-    gsl_vector *ss, *x;
-    gsl_multimin_function minexFunction;
-
-    size_t iter = 0;
-    int status;
-    double size;
-
-    /* Starting point */
-    x = gsl_vector_alloc(NDIM);
-    gsl_vector_set(x, 0, point1[0]);
-    gsl_vector_set(x, 1, point1[1]);
-    gsl_vector_set(x, 2, point1[2]);
-
-    /* Set initial step sizes to 1 */
-    ss = gsl_vector_alloc(NDIM);
-    gsl_vector_set_all(ss, 1.0);
-
-    /* Initialize method and iterate */
-    minexFunction.n = NDIM;
-    minexFunction.f = &MinIntersectDistance;
-    minexFunction.params = (void *)&par;
-
-    s = gsl_multimin_fminimizer_alloc(T, NDIM);
-    gsl_multimin_fminimizer_set(s, &minexFunction, x, ss);
-
-    do {
-        iter++;
-        status = gsl_multimin_fminimizer_iterate(s);
-
-        if (status) {
-          break;
-        }
-
-        size = gsl_multimin_fminimizer_size(s);
-        status = gsl_multimin_test_size(size, 1e-2);
-
-        if (status == GSL_SUCCESS) {
-          DoLog(1) && (Log() << Verbose(1) << "converged to minimum" <<  endl);
-        }
-    } while (status == GSL_CONTINUE && iter < 100);
-
-    // check whether intersection is in between or not
-  Vector intersection;
-  double t1, t2;
-  for (int i = 0; i < NDIM; i++) {
-    intersection[i] = gsl_vector_get(s->x, i);
-  }
-
-  Vector SideA = par.x2 - par.x1;
-  Vector HeightA = intersection - par.x1;
-
-  t1 = HeightA.ScalarProduct(SideA)/SideA.ScalarProduct(SideA);
-
-  Vector SideB = par.x4 - par.x3;
-  Vector HeightB = intersection - par.x3;
-
-  t2 = HeightB.ScalarProduct(SideB)/SideB.ScalarProduct(SideB);
-
-  Log() << Verbose(1) << "Intersection " << intersection << " is at "
-    << t1 << " for (" << point1 << "," << point2 << ") and at "
-    << t2 << " for (" << point3 << "," << point4 << "): ";
-
-  if (((t1 >= 0) && (t1 <= 1)) && ((t2 >= 0) && (t2 <= 1))) {
-    DoLog(1) && (Log() << Verbose(1) << "true intersection." << endl);
-    result = true;
-  } else {
-    DoLog(1) && (Log() << Verbose(1) << "intersection out of region of interest." << endl);
-    result = false;
-  }
-
-  // free minimizer stuff
-    gsl_vector_free(x);
-    gsl_vector_free(ss);
-    gsl_multimin_fminimizer_free(s);
-
-  return result;
 };
 
@@ -552,5 +400,5 @@
  * @return point which is second closest to the provided one
  */
-TesselPoint* FindSecondClosestTesselPoint(const Vector* Point, const LinkedCell* const LC)
+TesselPoint* FindSecondClosestTesselPoint(const Vector& Point, const LinkedCell* const LC)
 {
 	Info FunctionInfo(__func__);
@@ -576,5 +424,5 @@
         if (List != NULL) {
           for (LinkedCell::LinkedNodes::const_iterator Runner = List->begin(); Runner != List->end(); Runner++) {
-            helper = (*Point) - (*(*Runner)->node);
+            helper = (Point) - ((*Runner)->getPosition());
             double currentNorm = helper. Norm();
             if (currentNorm < distance) {
@@ -605,5 +453,5 @@
  * @return point which is closest to the provided one, NULL if none found
  */
-TesselPoint* FindClosestTesselPoint(const Vector* Point, TesselPoint *&SecondPoint, const LinkedCell* const LC)
+TesselPoint* FindClosestTesselPoint(const Vector& Point, TesselPoint *&SecondPoint, const LinkedCell* const LC)
 {
 	Info FunctionInfo(__func__);
@@ -629,5 +477,5 @@
         if (List != NULL) {
           for (LinkedCell::LinkedNodes::const_iterator Runner = List->begin(); Runner != List->end(); Runner++) {
-            helper = (*Point) - (*(*Runner)->node);
+            helper = (Point) - ((*Runner)->getPosition());
             double currentNorm = helper.NormSquared();
             if (currentNorm < distance) {
@@ -667,6 +515,6 @@
 	Info FunctionInfo(__func__);
   // construct the plane of the two baselines (i.e. take both their directional vectors)
-  Vector Baseline = (*Base->endpoints[1]->node->node) - (*Base->endpoints[0]->node->node);
-  Vector OtherBaseline = (*OtherBase->endpoints[1]->node->node) - (*OtherBase->endpoints[0]->node->node);
+  Vector Baseline = (Base->endpoints[1]->node->getPosition()) - (Base->endpoints[0]->node->getPosition());
+  Vector OtherBaseline = (OtherBase->endpoints[1]->node->getPosition()) - (OtherBase->endpoints[0]->node->getPosition());
   Vector Normal = Baseline;
   Normal.VectorProduct(OtherBaseline);
@@ -675,15 +523,15 @@
 
   // project one offset point of OtherBase onto this plane (and add plane offset vector)
-  Vector NewOffset = (*OtherBase->endpoints[0]->node->node) - (*Base->endpoints[0]->node->node);
+  Vector NewOffset = (OtherBase->endpoints[0]->node->getPosition()) - (Base->endpoints[0]->node->getPosition());
   NewOffset.ProjectOntoPlane(Normal);
-  NewOffset += (*Base->endpoints[0]->node->node);
+  NewOffset += (Base->endpoints[0]->node->getPosition());
   Vector NewDirection = NewOffset + OtherBaseline;
 
   // calculate the intersection between this projected baseline and Base
   Vector *Intersection = new Vector;
-  Line line1 = makeLineThrough(*(Base->endpoints[0]->node->node),*(Base->endpoints[1]->node->node));
+  Line line1 = makeLineThrough((Base->endpoints[0]->node->getPosition()),(Base->endpoints[1]->node->getPosition()));
   Line line2 = makeLineThrough(NewOffset, NewDirection);
   *Intersection = line1.getIntersection(line2);
-  Normal = (*Intersection) - (*Base->endpoints[0]->node->node);
+  Normal = (*Intersection) - (Base->endpoints[0]->node->getPosition());
   DoLog(1) && (Log() << Verbose(1) << "Found closest point on " << *Base << " at " << *Intersection << ", factor in line is " << fabs(Normal.ScalarProduct(Baseline)/Baseline.NormSquared()) << "." << endl);
 
@@ -730,5 +578,5 @@
       *vrmlfile << "Sphere {" << endl << "  "; // 2 is sphere type
       for (i=0;i<NDIM;i++)
-        *vrmlfile << Walker->node->at(i)-center->at(i) << " ";
+        *vrmlfile << Walker->at(i)-center->at(i) << " ";
       *vrmlfile << "\t0.1\t1. 1. 1." << endl; // radius 0.05 and white as colour
       cloud->GoToNext();
@@ -740,5 +588,5 @@
       for (i=0;i<3;i++) { // print each node
         for (int j=0;j<NDIM;j++)  // and for each node all NDIM coordinates
-          *vrmlfile << TriangleRunner->second->endpoints[i]->node->node->at(j)-center->at(j) << " ";
+          *vrmlfile << TriangleRunner->second->endpoints[i]->node->at(j)-center->at(j) << " ";
         *vrmlfile << "\t";
       }
@@ -767,7 +615,7 @@
     Vector *center = cloud->GetCenter();
     // make the circumsphere's center absolute again
-    Vector helper = (1./3.) * ((*Tess->LastTriangle->endpoints[0]->node->node) +
-                               (*Tess->LastTriangle->endpoints[1]->node->node) +
-                               (*Tess->LastTriangle->endpoints[2]->node->node));
+    Vector helper = (1./3.) * ((Tess->LastTriangle->endpoints[0]->node->getPosition()) +
+                               (Tess->LastTriangle->endpoints[1]->node->getPosition()) +
+                               (Tess->LastTriangle->endpoints[2]->node->getPosition()));
     helper -= (*center);
     // and add to file plus translucency object
@@ -802,5 +650,5 @@
       *rasterfile << "2" << endl << "  ";  // 2 is sphere type
       for (int j=0;j<NDIM;j++) { // and for each node all NDIM coordinates
-        const double tmp = Walker->node->at(j)-center->at(j);
+        const double tmp = Walker->at(j)-center->at(j);
         *rasterfile << ((fabs(tmp) < MYEPSILON) ? 0 : tmp) << " ";
       }
@@ -815,5 +663,5 @@
       for (i=0;i<3;i++) {  // print each node
         for (int j=0;j<NDIM;j++) { // and for each node all NDIM coordinates
-          const double tmp = TriangleRunner->second->endpoints[i]->node->node->at(j)-center->at(j);
+          const double tmp = TriangleRunner->second->endpoints[i]->node->at(j)-center->at(j);
           *rasterfile << ((fabs(tmp) < MYEPSILON) ? 0 : tmp) << " ";
         }
@@ -869,5 +717,5 @@
       LookupList[Walker->nr] = Counter++;
       for (int i=0;i<NDIM;i++) {
-        const double tmp = Walker->node->at(i);
+        const double tmp = Walker->at(i);
         *tecplot << ((fabs(tmp) < MYEPSILON) ? 0 : tmp) << " ";
       }
@@ -918,5 +766,5 @@
     TriangleSet *triangles = TesselStruct->GetAllTriangles(PointRunner->second);
     for (TriangleSet::iterator TriangleRunner = triangles->begin(); TriangleRunner != triangles->end(); ++TriangleRunner) {
-      totalarea += CalculateAreaofGeneralTriangle(*(*TriangleRunner)->endpoints[0]->node->node, *(*TriangleRunner)->endpoints[1]->node->node, *(*TriangleRunner)->endpoints[2]->node->node);
+      totalarea += CalculateAreaofGeneralTriangle((*TriangleRunner)->endpoints[0]->node->getPosition() , (*TriangleRunner)->endpoints[1]->node->getPosition() , (*TriangleRunner)->endpoints[2]->node->getPosition());
     }
     ConcavityPerLine *= totalarea;
@@ -927,6 +775,6 @@
       line = (*TriangleRunner)->GetThirdLine(PointRunner->second);
       triangle = line->GetOtherTriangle(*TriangleRunner);
-      area = CalculateAreaofGeneralTriangle(*triangle->endpoints[0]->node->node, *triangle->endpoints[1]->node->node, *triangle->endpoints[2]->node->node);
-      area += CalculateAreaofGeneralTriangle(*(*TriangleRunner)->endpoints[0]->node->node, *(*TriangleRunner)->endpoints[1]->node->node, *(*TriangleRunner)->endpoints[2]->node->node);
+      area = CalculateAreaofGeneralTriangle(triangle->endpoints[0]->node->getPosition() , triangle->endpoints[1]->node->getPosition() , triangle->endpoints[2]->node->getPosition());
+      area += CalculateAreaofGeneralTriangle((*TriangleRunner)->endpoints[0]->node->getPosition() , (*TriangleRunner)->endpoints[1]->node->getPosition() , (*TriangleRunner)->endpoints[2]->node->getPosition());
       area *= -line->CalculateConvexity();
       if (area > 0)
@@ -961,5 +809,5 @@
     distance = 0.;
     for (TriangleMap::const_iterator TriangleRunner = Convex->TrianglesOnBoundary.begin(); TriangleRunner != Convex->TrianglesOnBoundary.end(); TriangleRunner++) {
-      const double CurrentDistance = Convex->GetDistanceSquaredToTriangle(*PointRunner->second->node->node, TriangleRunner->second);
+      const double CurrentDistance = Convex->GetDistanceSquaredToTriangle(PointRunner->second->node->getPosition() , TriangleRunner->second);
       if (CurrentDistance < distance)
         distance = CurrentDistance;
Index: src/tesselationhelpers.hpp
===================================================================
--- src/tesselationhelpers.hpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/tesselationhelpers.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -20,12 +20,7 @@
 #endif
 
-#include <gsl/gsl_linalg.h>
-#include <gsl/gsl_matrix.h>
-#include <gsl/gsl_multimin.h>
-#include <gsl/gsl_permutation.h>
-#include <gsl/gsl_vector.h>
+#include <iosfwd>
 
-#include <iostream>
-
+#include "BoundaryMaps.hpp"
 #include "defs.hpp"
 
@@ -35,4 +30,6 @@
 class BoundaryLineSet;
 class BoundaryTriangleSet;
+class BoundaryPolygonSet;
+class CandidateForTesselation;
 class LinkedCell;
 class TesselPoint;
@@ -43,15 +40,10 @@
 /********************************************** definitions *********************************/
 
-#define HULLEPSILON 1e-9 //!< TODO: Get rid of HULLEPSILON, points to numerical instabilities
-
 /********************************************** declarations *******************************/
 
-double DetGet(gsl_matrix * const A, const int inPlace);
-void GetSphere(Vector * const Center, const Vector &a, const Vector &b, const Vector &c, const double RADIUS);
-void GetCenterOfSphere(Vector* const Center, const Vector &a, const Vector &b, const Vector &c, Vector * const NewUmkreismittelpunkt, const Vector* const Direction, const Vector* const AlternativeDirection, const double HalfplaneIndicator, const double AlternativeIndicator, const double alpha, const double beta, const double gamma, const double RADIUS, const double Umkreisradius);
-void GetCenterofCircumcircle(Vector * const Center, const Vector &a, const Vector &b, const Vector &c);
-double GetPathLengthonCircumCircle(const Vector &CircleCenter, const Vector &CirclePlaneNormal, const double CircleRadius, const Vector &NewSphereCenter, const Vector &OldSphereCenter, const Vector &NormalVector, const Vector &SearchDirection);
-double MinIntersectDistance(const gsl_vector * x, void *params);
-bool existsIntersection(const Vector &point1, const Vector &point2, const Vector &point3, const Vector &point4);
+void GetSphere(Vector & Center, const Vector &a, const Vector &b, const Vector &c, const double RADIUS);
+void GetCenterOfSphere(Vector& Center, const Vector &a, const Vector &b, const Vector &c, Vector &NewUmkreismittelpunkt, const Vector &Direction, const Vector* const AlternativeDirection, const double HalfplaneIndicator, const double AlternativeIndicator, const double alpha, const double beta, const double gamma, const double RADIUS, const double Umkreisradius);
+void GetCenterofCircumcircle(Vector & Center, const Vector &a, const Vector &b, const Vector &c);
+double GetPathLengthonCircumCircle(const Vector &CircleCenter, const Vector &CirclePlaneNormal, const double CircleRadius, const Vector &NewSphereCenter, const Vector &OldSphereCenter, const Vector &NormalVector, const Vector &SearchDirection, const double HULLEPSILON);
 double CalculateVolumeofGeneralTetraeder(const Vector &a, const Vector &b, const Vector &c, const Vector &d);
 double CalculateAreaofGeneralTriangle(const Vector &A, const Vector &B, const Vector &C);
@@ -60,6 +52,6 @@
 bool CheckLineCriteriaForDegeneratedTriangle(const BoundaryPointSet * const nodes[3]);
 bool SortCandidates(const CandidateForTesselation* candidate1, const CandidateForTesselation *candidate2);
-TesselPoint* FindClosestTesselPoint(const Vector* Point, TesselPoint *&SecondPoint, const LinkedCell* const LC);
-TesselPoint* FindSecondClosestTesselPoint(const Vector*, const LinkedCell* const LC);
+TesselPoint* FindClosestTesselPoint(const Vector & Point, TesselPoint *&SecondPoint, const LinkedCell* const LC);
+TesselPoint* FindSecondClosestTesselPoint(const Vector &, const LinkedCell* const LC);
 Vector * GetClosestPointBetweenLine(const BoundaryLineSet * const Base, const BoundaryLineSet * const OtherBase);
 
@@ -70,5 +62,5 @@
 void CalculateConcavityPerBoundaryPoint(const Tesselation * const TesselStruct);
 void CalculateConstrictionPerBoundaryPoint(const Tesselation * const TesselStruct, const Tesselation * const Convex);
-double DistanceToTrianglePlane(const Vector *x, const BoundaryTriangleSet * const triangle);
+double DistanceToTrianglePlane(const Vector &x, const BoundaryTriangleSet * const triangle);
 
 bool CheckListOfBaselines(const Tesselation * const TesselStruct);
Index: src/test/ActOnAlltest.hpp
===================================================================
--- src/test/ActOnAlltest.hpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/test/ActOnAlltest.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -12,5 +12,5 @@
 
 #include <list>
-#include "../vector.hpp"
+#include "../LinearAlgebra/Vector.hpp"
 
 #define ListOfVectors list<Vector *>
Index: src/triangleintersectionlist.cpp
===================================================================
--- src/triangleintersectionlist.cpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/triangleintersectionlist.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -9,4 +9,9 @@
  */
 
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
 #include "Helpers/MemDebug.hpp"
 
@@ -15,12 +20,17 @@
 #include "triangleintersectionlist.hpp"
 
-#include "info.hpp"
+#include "Helpers/Info.hpp"
+#include "BoundaryMaps.hpp"
+#include "BoundaryPointSet.hpp"
+#include "BoundaryLineSet.hpp"
+#include "BoundaryTriangleSet.hpp"
 #include "tesselation.hpp"
-#include "vector.hpp"
+#include "LinearAlgebra/Vector.hpp"
+#include "Helpers/Verbose.hpp"
 
 /** Constructor for class TriangleIntersectionList.
  *
  */
-TriangleIntersectionList::TriangleIntersectionList(const Vector *x, const Tesselation *surface, const LinkedCell* LC) :
+TriangleIntersectionList::TriangleIntersectionList(const Vector &x, const Tesselation *surface, const LinkedCell* LC) :
   Point(x),
   Tess(surface),
@@ -69,5 +79,5 @@
   }
   // return reference, if none can be found
-  return *Point;
+  return Point;
 };
 
@@ -98,5 +108,5 @@
   if (runner != IntersectionList.end()) {
     // if we have found one, check Scalarproduct between the vector
-    Vector TestVector = (*Point) - (*(*runner).second);
+    Vector TestVector = (Point) - (*(*runner).second);
     if (fabs(TestVector.NormSquared()) < MYEPSILON) //
       return true;
@@ -137,6 +147,6 @@
     // get intersection with triangle plane
     Intersection = new Vector;
-    (*TriangleRunner)->GetClosestPointInsideTriangle(Point, Intersection);
-    //Log() << Verbose(1) << "Intersection between " << *Point << " and " << **TriangleRunner << " is at " << *Intersection << "." << endl;
+    (*TriangleRunner)->GetClosestPointInsideTriangle(Point, *Intersection);
+    //Log() << Verbose(1) << "Intersection between " << Point << " and " << **TriangleRunner << " is at " << *Intersection << "." << endl;
     IntersectionList.insert( pair<BoundaryTriangleSet *, Vector * > (*TriangleRunner, Intersection) );
   }
@@ -150,5 +160,5 @@
   if (DistanceList.empty())
     for (TriangleVectorMap::const_iterator runner = IntersectionList.begin(); runner != IntersectionList.end(); runner++)
-      DistanceList.insert( pair<double, BoundaryTriangleSet *> (Point->distance(*(*runner).second), (*runner).first) );
+      DistanceList.insert( pair<double, BoundaryTriangleSet *> (Point.distance(*(*runner).second), (*runner).first) );
 
   //for (DistanceTriangleMap::const_iterator runner = DistanceList.begin(); runner != DistanceList.end(); runner++)
Index: src/triangleintersectionlist.hpp
===================================================================
--- src/triangleintersectionlist.hpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/triangleintersectionlist.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -39,5 +39,5 @@
 {
 public:
-  TriangleIntersectionList(const Vector *x, const Tesselation *surface, const LinkedCell* LC);
+  TriangleIntersectionList(const Vector &x, const Tesselation *surface, const LinkedCell* LC);
   ~TriangleIntersectionList();
 
@@ -52,5 +52,5 @@
   void FillDistanceList() const;
 
-  const Vector *Point;
+  const Vector &Point;
   const Tesselation *Tess;
   const LinkedCell *Vicinity;
Index: src/unittests/ActOnAllUnitTest.cpp
===================================================================
--- src/unittests/ActOnAllUnitTest.cpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/unittests/ActOnAllUnitTest.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -5,4 +5,9 @@
  *      Author: FrederikHeber
  */
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
 
 using namespace std;
@@ -14,6 +19,5 @@
 #include "../test/ActOnAlltest.hpp"
 #include "ActOnAllUnitTest.hpp"
-#include "memoryallocator.hpp"
-#include "vector.hpp"
+#include "LinearAlgebra/Vector.hpp"
 
 #ifdef HAVE_TESTRUNNER
Index: src/unittests/ActionSequenceTest.cpp
===================================================================
--- src/unittests/ActionSequenceTest.cpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/unittests/ActionSequenceTest.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -6,4 +6,9 @@
  */
 
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
 #include <cppunit/CompilerOutputter.h>
 #include <cppunit/extensions/TestFactoryRegistry.h>
@@ -17,4 +22,6 @@
 #include "Actions/ActionRegistry.hpp"
 
+#include "DummyUI.hpp"
+
 #ifdef HAVE_TESTRUNNER
 #include "UnitTestMain.hpp"
@@ -33,4 +40,9 @@
   virtual ~canUndoActionStub(){}
 
+  virtual Dialog* fillDialog(Dialog *dialog){
+    ASSERT(dialog,"No Dialog given when filling action dialog");
+    return dialog;
+  }
+
   virtual Action::state_ptr performCall(){
     return Action::success;
@@ -55,4 +67,9 @@
   cannotUndoActionStub() : Action("cannotUndoActionStub",false){}
   virtual ~cannotUndoActionStub(){}
+
+  virtual Dialog* fillDialog(Dialog *dialog){
+    ASSERT(dialog,"No Dialog given when filling action dialog");
+    return dialog;
+  }
 
   virtual Action::state_ptr performCall(){
@@ -82,4 +99,7 @@
   virtual ~wasCalledActionStub(){}
 
+  virtual Dialog* fillDialog(Dialog *dialog){
+    return dialog;
+  }
   virtual Action::state_ptr performCall(){
     called = true;
@@ -108,5 +128,12 @@
 
 void ActionSequenceTest::setUp(){
+  static bool hasDescriptor = false;
   ActionHistory::init();
+  // TODO: find a way to really reset the factory to a clean state in tear-down
+  if(!hasDescriptor){
+    UIFactory::registerFactory(new DummyUIFactory::description());
+    hasDescriptor = true;
+  }
+  UIFactory::makeUserInterface("Dummy");
   // create some necessary stubs used in this test
   positive1 = new canUndoActionStub();
@@ -135,4 +162,5 @@
   ActionHistory::purgeInstance();
   ActionRegistry::purgeInstance();
+  UIFactory::purgeInstance();
 }
 
@@ -220,12 +248,12 @@
 
   CPPUNIT_ASSERT_EQUAL(true,wasCalled1->wasCalled());
-  CPPUNIT_ASSERT_EQUAL(true,wasCalled1->wasCalled());
+  CPPUNIT_ASSERT_EQUAL(true,wasCalled2->wasCalled());
 
   ActionHistory::getInstance().undoLast();
 
   CPPUNIT_ASSERT_EQUAL(false,wasCalled1->wasCalled());
-  CPPUNIT_ASSERT_EQUAL(false,wasCalled1->wasCalled());
-
-}
-
-
+  CPPUNIT_ASSERT_EQUAL(false,wasCalled2->wasCalled());
+
+}
+
+
Index: src/unittests/AnalysisCorrelationToPointUnitTest.cpp
===================================================================
--- src/unittests/AnalysisCorrelationToPointUnitTest.cpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/unittests/AnalysisCorrelationToPointUnitTest.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -5,4 +5,9 @@
  *      Author: heber
  */
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
 
 using namespace std;
@@ -16,4 +21,6 @@
 #include "analysis_correlation.hpp"
 #include "AnalysisCorrelationToPointUnitTest.hpp"
+
+#include "Descriptors/MoleculeDescriptor.hpp"
 
 #include "atom.hpp"
@@ -38,5 +45,4 @@
 
   // init private all pointers to zero
-  TestList = NULL;
   TestMolecule = NULL;
   pointmap = NULL;
@@ -45,5 +51,5 @@
 
   // construct element list
-  std::vector<element *> elements;
+  std::vector<const element *> elements;
   hydrogen = World::getInstance().getPeriode()->FindElement(1);
   CPPUNIT_ASSERT(hydrogen != NULL && "hydrogen element not found");
@@ -52,18 +58,18 @@
   TestMolecule = World::getInstance().createMolecule();
   Walker = World::getInstance().createAtom();
-  Walker->type = hydrogen;
-  *Walker->node = Vector(1., 0., 1. );
+  Walker->setType(hydrogen);
+  Walker->setPosition(Vector(1., 0., 1. ));
   TestMolecule->AddAtom(Walker);
   Walker = World::getInstance().createAtom();
-  Walker->type = hydrogen;
-  *Walker->node = Vector(0., 1., 1. );
+  Walker->setType(hydrogen);
+  Walker->setPosition(Vector(0., 1., 1. ));
   TestMolecule->AddAtom(Walker);
   Walker = World::getInstance().createAtom();
-  Walker->type = hydrogen;
-  *Walker->node = Vector(1., 1., 0. );
+  Walker->setType(hydrogen);
+  Walker->setPosition(Vector(1., 1., 0. ));
   TestMolecule->AddAtom(Walker);
   Walker = World::getInstance().createAtom();
-  Walker->type = hydrogen;
-  *Walker->node = Vector(0., 0., 0. );
+  Walker->setType(hydrogen);
+  Walker->setPosition(Vector(0., 0., 0. ));
   TestMolecule->AddAtom(Walker);
 
@@ -71,6 +77,4 @@
   CPPUNIT_ASSERT_EQUAL( TestMolecule->getAtomCount(), 4 );
 
-  TestList = World::getInstance().getMolecules();
-  TestList->insert(TestMolecule);
   TestMolecule->ActiveFlag = true;
 
@@ -79,5 +83,8 @@
 
   // init maps
-  pointmap = CorrelationToPoint( (MoleculeListClass * const)TestList, elements, (const Vector *)point );
+  World::getInstance().selectAllMolecules(AllMolecules());
+  allMolecules = World::getInstance().getSelectedMolecules();
+  CPPUNIT_ASSERT_EQUAL( (size_t) 1, allMolecules.size());
+  pointmap = CorrelationToPoint( allMolecules, elements, (const Vector *)point );
   binmap = NULL;
 
Index: src/unittests/AnalysisCorrelationToPointUnitTest.hpp
===================================================================
--- src/unittests/AnalysisCorrelationToPointUnitTest.hpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/unittests/AnalysisCorrelationToPointUnitTest.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -35,7 +35,7 @@
 private:
 
-      MoleculeListClass *TestList;
+      std::vector<molecule *> allMolecules;
       molecule *TestMolecule;
-      element *hydrogen;
+      const element *hydrogen;
 
       CorrelationToPointMap *pointmap;
Index: src/unittests/AnalysisCorrelationToSurfaceUnitTest.cpp
===================================================================
--- src/unittests/AnalysisCorrelationToSurfaceUnitTest.cpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/unittests/AnalysisCorrelationToSurfaceUnitTest.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -6,4 +6,9 @@
  */
 
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
 using namespace std;
 
@@ -16,4 +21,6 @@
 #include "analysis_correlation.hpp"
 #include "AnalysisCorrelationToSurfaceUnitTest.hpp"
+
+#include "Descriptors/MoleculeDescriptor.hpp"
 
 #include "atom.hpp"
@@ -42,8 +49,9 @@
   ASSERT_DO(Assert::Throw);
 
+  setVerbosity(5);
+
   atom *Walker = NULL;
 
   // init private all pointers to zero
-  TestList = NULL;
   TestSurfaceMolecule = NULL;
   surfacemap = NULL;
@@ -61,21 +69,21 @@
 
   Walker = World::getInstance().createAtom();
-  Walker->type = hydrogen;
-  *Walker->node = Vector(1., 0., 1. );
-  TestSurfaceMolecule->AddAtom(Walker);
-
-  Walker = World::getInstance().createAtom();
-  Walker->type = hydrogen;
-  *Walker->node = Vector(0., 1., 1. );
-  TestSurfaceMolecule->AddAtom(Walker);
-
-  Walker = World::getInstance().createAtom();
-  Walker->type = hydrogen;
-  *Walker->node = Vector(1., 1., 0. );
-  TestSurfaceMolecule->AddAtom(Walker);
-
-  Walker = World::getInstance().createAtom();
-  Walker->type = hydrogen;
-  *Walker->node = Vector(0., 0., 0. );
+  Walker->setType(hydrogen);
+  Walker->setPosition(Vector(1., 0., 1. ));
+  TestSurfaceMolecule->AddAtom(Walker);
+
+  Walker = World::getInstance().createAtom();
+  Walker->setType(hydrogen);
+  Walker->setPosition(Vector(0., 1., 1. ));
+  TestSurfaceMolecule->AddAtom(Walker);
+
+  Walker = World::getInstance().createAtom();
+  Walker->setType(hydrogen);
+  Walker->setPosition(Vector(1., 1., 0. ));
+  TestSurfaceMolecule->AddAtom(Walker);
+
+  Walker = World::getInstance().createAtom();
+  Walker->setType(hydrogen);
+  Walker->setPosition(Vector(0., 0., 0. ));
   TestSurfaceMolecule->AddAtom(Walker);
 
@@ -83,7 +91,5 @@
   CPPUNIT_ASSERT_EQUAL( TestSurfaceMolecule->getAtomCount(), 4 );
 
-  TestList = World::getInstance().getMolecules();
   TestSurfaceMolecule->ActiveFlag = true;
-  TestList->insert(TestSurfaceMolecule);
 
   // init tesselation and linked cell
@@ -96,26 +102,27 @@
   TestSurfaceMolecule = World::getInstance().createMolecule();
   Walker = World::getInstance().createAtom();
-  Walker->type = carbon;
-  *Walker->node = Vector(4., 0., 4. );
-  TestSurfaceMolecule->AddAtom(Walker);
-
-  Walker = World::getInstance().createAtom();
-  Walker->type = carbon;
-  *Walker->node = Vector(0., 4., 4. );
-  TestSurfaceMolecule->AddAtom(Walker);
-
-  Walker = World::getInstance().createAtom();
-  Walker->type = carbon;
-  *Walker->node = Vector(4., 4., 0. );
+  Walker->setType(carbon);
+  Walker->setPosition(Vector(4., 0., 4. ));
+  TestSurfaceMolecule->AddAtom(Walker);
+
+  Walker = World::getInstance().createAtom();
+  Walker->setType(carbon);
+  Walker->setPosition(Vector(0., 4., 4. ));
+  TestSurfaceMolecule->AddAtom(Walker);
+
+  Walker = World::getInstance().createAtom();
+  Walker->setType(carbon);
+  Walker->setPosition(Vector(4., 4., 0. ));
   TestSurfaceMolecule->AddAtom(Walker);
 
   // add inner atoms
   Walker = World::getInstance().createAtom();
-  Walker->type = carbon;
-  *Walker->node = Vector(0.5, 0.5, 0.5 );
-  TestSurfaceMolecule->AddAtom(Walker);
-
-  TestSurfaceMolecule->ActiveFlag = true;
-  TestList->insert(TestSurfaceMolecule);
+  Walker->setType(carbon);
+  Walker->setPosition(Vector(0.5, 0.5, 0.5 ));
+  TestSurfaceMolecule->AddAtom(Walker);
+
+  World::getInstance().selectAllMolecules(AllMolecules());
+  allMolecules = World::getInstance().getSelectedMolecules();
+  CPPUNIT_ASSERT_EQUAL( (size_t) 2, allMolecules.size());
 
   // init maps
@@ -146,5 +153,5 @@
 {
   CPPUNIT_ASSERT_EQUAL( 4, TestSurfaceMolecule->getAtomCount() );
-  CPPUNIT_ASSERT_EQUAL( (size_t)2, TestList->ListOfMolecules.size() );
+  CPPUNIT_ASSERT_EQUAL( (size_t)2, allMolecules.size() );
   CPPUNIT_ASSERT_EQUAL( (size_t)4, Surface->PointsOnBoundary.size() );
   CPPUNIT_ASSERT_EQUAL( (size_t)6, Surface->LinesOnBoundary.size() );
@@ -156,5 +163,5 @@
   // do the pair correlation
   elements.push_back(hydrogen);
-  surfacemap = CorrelationToSurface( TestList, elements, Surface, LC );
+  surfacemap = CorrelationToSurface( allMolecules, elements, Surface, LC );
 //  OutputCorrelationToSurface ( (ofstream *)&cout, surfacemap );
   CPPUNIT_ASSERT( surfacemap != NULL );
@@ -166,5 +173,5 @@
   BinPairMap::iterator tester;
   elements.push_back(hydrogen);
-  surfacemap = CorrelationToSurface( TestList, elements, Surface, LC );
+  surfacemap = CorrelationToSurface( allMolecules, elements, Surface, LC );
   // put pair correlation into bins and check with no range
 //  OutputCorrelationToSurface ( (ofstream *)&cout, surfacemap );
@@ -182,5 +189,5 @@
   BinPairMap::iterator tester;
   elements.push_back(hydrogen);
-  surfacemap = CorrelationToSurface( TestList, elements, Surface, LC );
+  surfacemap = CorrelationToSurface( allMolecules, elements, Surface, LC );
 //  OutputCorrelationToSurface ( (ofstream *)&cout, surfacemap );
   // ... and check with [0., 2.] range
@@ -201,5 +208,5 @@
   BinPairMap::iterator tester;
   elements.push_back(carbon);
-  surfacemap = CorrelationToSurface( TestList, elements, Surface, LC );
+  surfacemap = CorrelationToSurface( allMolecules, elements, Surface, LC );
 //  OutputCorrelationToSurface ( (ofstream *)&cout, surfacemap );
   // put pair correlation into bins and check with no range
@@ -221,5 +228,5 @@
   BinPairMap::iterator tester;
   elements.push_back(carbon);
-  surfacemap = CorrelationToSurface( TestList, elements, Surface, LC );
+  surfacemap = CorrelationToSurface( allMolecules, elements, Surface, LC );
 //  OutputCorrelationToSurface ( (ofstream *)&cout, surfacemap );
   // ... and check with [0., 2.] range
Index: src/unittests/AnalysisCorrelationToSurfaceUnitTest.hpp
===================================================================
--- src/unittests/AnalysisCorrelationToSurfaceUnitTest.hpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/unittests/AnalysisCorrelationToSurfaceUnitTest.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -43,9 +43,9 @@
 private:
 
-      MoleculeListClass *TestList;
+      std::vector<molecule *> allMolecules;
       molecule *TestSurfaceMolecule;
-      element *hydrogen;
-      element *carbon;
-      std::vector<element *> elements;
+      const element *hydrogen;
+      const element *carbon;
+      std::vector<const element *> elements;
 
       CorrelationToSurfaceMap *surfacemap;
Index: src/unittests/AnalysisPairCorrelationUnitTest.cpp
===================================================================
--- src/unittests/AnalysisPairCorrelationUnitTest.cpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/unittests/AnalysisPairCorrelationUnitTest.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -5,4 +5,9 @@
  *      Author: heber
  */
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
 
 using namespace std;
@@ -16,4 +21,6 @@
 #include "analysis_correlation.hpp"
 #include "AnalysisPairCorrelationUnitTest.hpp"
+
+#include "Descriptors/MoleculeDescriptor.hpp"
 
 #include "World.hpp"
@@ -42,5 +49,4 @@
 
   // init private all pointers to zero
-  TestList = NULL;
   TestMolecule = NULL;
   correlationmap = NULL;
@@ -48,5 +54,5 @@
 
   // construct element list
-  std::vector<element *> elements;
+  std::vector<const element *> elements;
   hydrogen = World::getInstance().getPeriode()->FindElement(1);
   CPPUNIT_ASSERT(hydrogen != NULL && "hydrogen element not found");
@@ -57,18 +63,18 @@
   TestMolecule = World::getInstance().createMolecule();
   Walker = World::getInstance().createAtom();
-  Walker->type = hydrogen;
-  *Walker->node = Vector(1., 0., 1. );
+  Walker->setType(hydrogen);
+  Walker->setPosition(Vector(1., 0., 1. ));
   TestMolecule->AddAtom(Walker);
   Walker = World::getInstance().createAtom();
-  Walker->type = hydrogen;
-  *Walker->node = Vector(0., 1., 1. );
+  Walker->setType(hydrogen);
+  Walker->setPosition(Vector(0., 1., 1. ));
   TestMolecule->AddAtom(Walker);
   Walker = World::getInstance().createAtom();
-  Walker->type = hydrogen;
-  *Walker->node = Vector(1., 1., 0. );
+  Walker->setType(hydrogen);
+  Walker->setPosition(Vector(1., 1., 0. ));
   TestMolecule->AddAtom(Walker);
   Walker = World::getInstance().createAtom();
-  Walker->type = hydrogen;
-  *Walker->node = Vector(0., 0., 0. );
+  Walker->setType(hydrogen);
+  Walker->setPosition(Vector(0., 0., 0. ));
   TestMolecule->AddAtom(Walker);
 
@@ -76,10 +82,9 @@
   CPPUNIT_ASSERT_EQUAL( TestMolecule->getAtomCount(), 4 );
 
-  TestList = World::getInstance().getMolecules();
-  TestMolecule->ActiveFlag = true;
-  TestList->insert(TestMolecule);
-
   // init maps
-  correlationmap = PairCorrelation( TestList, elements);
+  World::getInstance().selectAllMolecules(AllMolecules());
+  allMolecules = World::getInstance().getSelectedMolecules();
+  CPPUNIT_ASSERT_EQUAL( (size_t) 1, allMolecules.size());
+  correlationmap = PairCorrelation( allMolecules, elements);
   binmap = NULL;
 
Index: src/unittests/AnalysisPairCorrelationUnitTest.hpp
===================================================================
--- src/unittests/AnalysisPairCorrelationUnitTest.hpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/unittests/AnalysisPairCorrelationUnitTest.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -35,7 +35,7 @@
 private:
 
-      MoleculeListClass *TestList;
+      std::vector<molecule *> allMolecules;
       molecule *TestMolecule;
-      element *hydrogen;
+      const element *hydrogen;
 
       PairCorrelationMap *correlationmap;
Index: src/unittests/AtomDescriptorTest.cpp
===================================================================
--- src/unittests/AtomDescriptorTest.cpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/unittests/AtomDescriptorTest.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -5,4 +5,9 @@
  *      Author: crueger
  */
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
 
 #include "AtomDescriptorTest.hpp"
Index: src/unittests/AtomDescriptorTest.hpp
===================================================================
--- src/unittests/AtomDescriptorTest.hpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/unittests/AtomDescriptorTest.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -13,5 +13,6 @@
 #include "types.hpp"
 
-#define ATOM_COUNT (10)
+// we prefer enum over define
+enum { ATOM_COUNT = 10 };
 
 class atom;
Index: src/unittests/BaseShapesUnittest.cpp
===================================================================
--- src/unittests/BaseShapesUnittest.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
+++ src/unittests/BaseShapesUnittest.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -0,0 +1,135 @@
+/*
+ * BaseShapesUnittest.cpp
+ *
+ *  Created on: Jun 18, 2010
+ *      Author: crueger
+ */
+
+#include "BaseShapesUnittest.hpp"
+
+#include <cppunit/CompilerOutputter.h>
+#include <cppunit/extensions/TestFactoryRegistry.h>
+#include <cppunit/ui/text/TestRunner.h>
+
+#include <cmath>
+
+#ifdef HAVE_TESTRUNNER
+#include "UnitTestMain.hpp"
+#endif /*HAVE_TESTRUNNER*/
+
+#include "LinearAlgebra/Vector.hpp"
+#include "Shapes/Shape.hpp"
+
+#include "Shapes/BaseShapes.hpp"
+
+// Registers the fixture into the 'registry'
+CPPUNIT_TEST_SUITE_REGISTRATION( BaseShapesUnittest );
+
+void BaseShapesUnittest::setUp()
+{
+  v000 =  0*e1+0*e2+0*e3;
+  v100 =  1*e1+0*e2+0*e3;
+  v200 = -1*e1+0*e2+0*e3;
+  v010 =  0*e1+1*e2+0*e3;
+  v110 =  1*e1+1*e2+0*e3;
+  v210 = -1*e1+1*e2+0*e3;
+  v020 =  0*e1-1*e2+0*e3;
+  v120 =  1*e1-1*e2+0*e3;
+  v220 = -1*e1-1*e2+0*e3;
+  v001 =  0*e1+0*e2+1*e3;
+  v101 =  1*e1+0*e2+1*e3;
+  v201 = -1*e1+0*e2+1*e3;
+  v011 =  0*e1+1*e2+1*e3;
+  v111 =  1*e1+1*e2+1*e3;
+  v211 = -1*e1+1*e2+1*e3;
+  v021 =  0*e1-1*e2+1*e3;
+  v121 =  1*e1-1*e2+1*e3;
+  v221 = -1*e1-1*e2+1*e3;
+  v002 =  0*e1+0*e2-1*e3;
+  v102 =  1*e1+0*e2-1*e3;
+  v202 = -1*e1+0*e2-1*e3;
+  v012 =  0*e1+1*e2-1*e3;
+  v112 =  1*e1+1*e2-1*e3;
+  v212 = -1*e1+1*e2-1*e3;
+  v022 =  0*e1-1*e2-1*e3;
+  v122 =  1*e1-1*e2-1*e3;
+  v222 = -1*e1-1*e2-1*e3;
+}
+
+void BaseShapesUnittest::tearDown()
+{}
+
+
+void BaseShapesUnittest::isInsideTest(){
+  Shape s1 = Sphere();
+
+  CPPUNIT_ASSERT(s1.isInside(v000));
+  CPPUNIT_ASSERT(s1.isInside(v100));
+  CPPUNIT_ASSERT(s1.isInside(v200));
+  CPPUNIT_ASSERT(s1.isInside(v010));
+  CPPUNIT_ASSERT(!s1.isInside(v110));
+  CPPUNIT_ASSERT(!s1.isInside(v210));
+  CPPUNIT_ASSERT(s1.isInside(v020));
+  CPPUNIT_ASSERT(!s1.isInside(v120));
+  CPPUNIT_ASSERT(!s1.isInside(v220));
+  CPPUNIT_ASSERT(s1.isInside(v001));
+  CPPUNIT_ASSERT(!s1.isInside(v101));
+  CPPUNIT_ASSERT(!s1.isInside(v201));
+  CPPUNIT_ASSERT(!s1.isInside(v011));
+  CPPUNIT_ASSERT(!s1.isInside(v111));
+  CPPUNIT_ASSERT(!s1.isInside(v211));
+  CPPUNIT_ASSERT(!s1.isInside(v021));
+  CPPUNIT_ASSERT(!s1.isInside(v121));
+  CPPUNIT_ASSERT(!s1.isInside(v221));
+  CPPUNIT_ASSERT(s1.isInside(v002));
+  CPPUNIT_ASSERT(!s1.isInside(v102));
+  CPPUNIT_ASSERT(!s1.isInside(v202));
+  CPPUNIT_ASSERT(!s1.isInside(v012));
+  CPPUNIT_ASSERT(!s1.isInside(v112));
+  CPPUNIT_ASSERT(!s1.isInside(v212));
+  CPPUNIT_ASSERT(!s1.isInside(v022));
+  CPPUNIT_ASSERT(!s1.isInside(v122));
+  CPPUNIT_ASSERT(!s1.isInside(v222));
+
+  Shape s2 = Cuboid();
+
+  CPPUNIT_ASSERT(s2.isInside(v000));
+  CPPUNIT_ASSERT(s2.isInside(v100));
+  CPPUNIT_ASSERT(!s2.isInside(v200));
+  CPPUNIT_ASSERT(s2.isInside(v010));
+  CPPUNIT_ASSERT(s2.isInside(v110));
+  CPPUNIT_ASSERT(!s2.isInside(v210));
+  CPPUNIT_ASSERT(!s2.isInside(v020));
+  CPPUNIT_ASSERT(!s2.isInside(v120));
+  CPPUNIT_ASSERT(!s2.isInside(v220));
+  CPPUNIT_ASSERT(s2.isInside(v001));
+  CPPUNIT_ASSERT(s2.isInside(v101));
+  CPPUNIT_ASSERT(!s2.isInside(v201));
+  CPPUNIT_ASSERT(s2.isInside(v011));
+  CPPUNIT_ASSERT(s2.isInside(v111));
+  CPPUNIT_ASSERT(!s2.isInside(v211));
+  CPPUNIT_ASSERT(!s2.isInside(v021));
+  CPPUNIT_ASSERT(!s2.isInside(v121));
+  CPPUNIT_ASSERT(!s2.isInside(v221));
+  CPPUNIT_ASSERT(!s2.isInside(v002));
+  CPPUNIT_ASSERT(!s2.isInside(v102));
+  CPPUNIT_ASSERT(!s2.isInside(v202));
+  CPPUNIT_ASSERT(!s2.isInside(v012));
+  CPPUNIT_ASSERT(!s2.isInside(v112));
+  CPPUNIT_ASSERT(!s2.isInside(v212));
+  CPPUNIT_ASSERT(!s2.isInside(v022));
+  CPPUNIT_ASSERT(!s2.isInside(v122));
+  CPPUNIT_ASSERT(!s2.isInside(v222));
+
+}
+
+void BaseShapesUnittest::PointsOnSurfaceTest(){
+  Shape s = Sphere();
+  const size_t N = 200;
+  std::vector<Vector> PointsOnSurface = s.getHomogeneousPointsOnSurface(N);
+  for (std::vector<Vector>::const_iterator iter = PointsOnSurface.begin(); iter != PointsOnSurface.end(); ++iter) {
+    CPPUNIT_ASSERT(fabs(1. - (*iter).NormSquared()) < MYEPSILON);
+  }
+  CPPUNIT_ASSERT_EQUAL(N, PointsOnSurface.size());
+}
+
Index: src/unittests/BaseShapesUnittest.hpp
===================================================================
--- src/unittests/BaseShapesUnittest.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
+++ src/unittests/BaseShapesUnittest.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -0,0 +1,63 @@
+/*
+ * BaseShapesUnittest.hpp
+ *
+ *  Created on: Jun 18, 2010
+ *      Author: crueger
+ */
+
+#ifndef BASESHAPESUNITTEST_HPP_
+#define BASESHAPESUNITTEST_HPP_
+
+#include <cppunit/extensions/HelperMacros.h>
+
+class Vector;
+
+#include "LinearAlgebra/Vector.hpp"
+
+class BaseShapesUnittest : public CppUnit::TestFixture
+{
+  CPPUNIT_TEST_SUITE( BaseShapesUnittest) ;
+  CPPUNIT_TEST ( isInsideTest );
+  CPPUNIT_TEST ( PointsOnSurfaceTest );
+  CPPUNIT_TEST_SUITE_END();
+
+public:
+  void setUp();
+  void tearDown();
+
+  void isInsideTest();
+  void PointsOnSurfaceTest();
+
+  // a lot of vectors.
+  // these define all the edges of a box around -1 +1 on each axis
+  // 0 is 0, 1 is 1 and 2 is -1
+  Vector v000;
+  Vector v100;
+  Vector v200;
+  Vector v010;
+  Vector v110;
+  Vector v210;
+  Vector v020;
+  Vector v120;
+  Vector v220;
+  Vector v001;
+  Vector v101;
+  Vector v201;
+  Vector v011;
+  Vector v111;
+  Vector v211;
+  Vector v021;
+  Vector v121;
+  Vector v221;
+  Vector v002;
+  Vector v102;
+  Vector v202;
+  Vector v012;
+  Vector v112;
+  Vector v212;
+  Vector v022;
+  Vector v122;
+  Vector v222;
+};
+
+#endif /* BASESHAPESUNITTEST_HPP_ */
Index: src/unittests/BoxUnittest.cpp
===================================================================
--- src/unittests/BoxUnittest.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
+++ src/unittests/BoxUnittest.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -0,0 +1,1609 @@
+/*
+ * BoxUnittest.cpp
+ *
+ *  Created on: Jul 30, 2010
+ *      Author: crueger
+ */
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "BoxUnittest.hpp"
+
+#include <cppunit/CompilerOutputter.h>
+#include <cppunit/extensions/TestFactoryRegistry.h>
+#include <cppunit/ui/text/TestRunner.h>
+
+#ifdef HAVE_TESTRUNNER
+#include "UnitTestMain.hpp"
+#endif /*HAVE_TESTRUNNER*/
+
+#include "LinearAlgebra/Vector.hpp"
+#include "LinearAlgebra/Matrix.hpp"
+#include "Box.hpp"
+#include "Helpers/Assert.hpp"
+
+/********************************************** Test classes **************************************/
+
+// Registers the fixture into the 'registry'
+CPPUNIT_TEST_SUITE_REGISTRATION( BoxUnittest );
+
+void BoxUnittest::setUp(){
+  ASSERT_DO(Assert::Throw);
+  unit = new Matrix;
+  unit->one();
+  zero = new Matrix;
+  invertible = new Matrix;
+  invertible->diagonal() = Vector(1,2,3);
+  uninvertible = new Matrix;
+  uninvertible->column(0) = Vector(1,0,1);
+  uninvertible->column(2) = Vector(1,0,1);
+
+  Matrix boxMat;
+  unitBox = new Box;
+  stretchedBox1 = new Box;
+  boxMat.one();
+  boxMat.diagonal() = Vector(1,2,3);
+  stretchedBox1->setM(boxMat);
+
+  stretchedBox2 = new Box;
+  boxMat.one();
+  boxMat.diagonal() = Vector(2,3,1);
+  stretchedBox2->setM(boxMat);
+
+  stretchedBox3 = new Box;
+  boxMat.one();
+  boxMat.diagonal() = Vector(3,1,2);
+  stretchedBox3->setM(boxMat);
+
+  stretchedBox4 = new Box;
+  boxMat.one();
+  boxMat.diagonal() = Vector(2,2,2);
+  stretchedBox4->setM(boxMat);
+
+  tiltedBox1 = new Box;
+  boxMat.one();
+  boxMat.column(0) = Vector(1,0,1);
+  tiltedBox1->setM(boxMat);
+
+  tiltedBox2 = new Box;
+  boxMat.one();
+  boxMat.column(0) = Vector(1,1,1);
+  tiltedBox2->setM(boxMat);
+
+  tiltedBox3 = new Box;
+  boxMat.one();
+  boxMat.column(1) = Vector(0,1,1);
+  tiltedBox3->setM(boxMat);
+
+  tiltedBox4 = new Box;
+  boxMat.one();
+  boxMat.column(0) = Vector(1,1,1);
+  boxMat.column(1) = Vector(0,1,1);
+  tiltedBox4->setM(boxMat);
+
+}
+
+void BoxUnittest::tearDown(){
+  delete unit;
+  delete zero;
+  delete invertible;
+  delete uninvertible;
+
+  delete unitBox;
+  delete stretchedBox1;
+  delete stretchedBox2;
+  delete stretchedBox3;
+  delete stretchedBox4;
+  delete tiltedBox1;
+  delete tiltedBox2;
+  delete tiltedBox3;
+  delete tiltedBox4;
+
+}
+
+void BoxUnittest::setBoxTest(){
+  Box testBox;
+  CPPUNIT_ASSERT_NO_THROW(testBox.setM(*unit));
+  CPPUNIT_ASSERT_NO_THROW(testBox = *unit);
+  CPPUNIT_ASSERT_NO_THROW(testBox.setM(*invertible));
+  CPPUNIT_ASSERT_NO_THROW(testBox = *invertible);
+#ifndef NDEBUG
+  CPPUNIT_ASSERT_THROW(testBox.setM(*zero),Assert::AssertionFailure);
+  CPPUNIT_ASSERT_THROW(testBox = *zero,Assert::AssertionFailure);
+  CPPUNIT_ASSERT_THROW(testBox.setM(*uninvertible),Assert::AssertionFailure);
+  CPPUNIT_ASSERT_THROW(testBox = *uninvertible,Assert::AssertionFailure);
+#endif
+}
+
+void BoxUnittest::translateInOutTest(){
+  Vector testVector;
+  {
+    testVector=Vector(0,0,0);
+    CPPUNIT_ASSERT_EQUAL(unitBox->translateOut(unitBox->translateIn(testVector)),testVector);
+    CPPUNIT_ASSERT_EQUAL(unitBox->translateIn(unitBox->translateOut(testVector)),testVector);
+    CPPUNIT_ASSERT_EQUAL(stretchedBox1->translateOut(stretchedBox1->translateIn(testVector)),testVector);
+    CPPUNIT_ASSERT_EQUAL(stretchedBox1->translateIn(stretchedBox1->translateOut(testVector)),testVector);
+    CPPUNIT_ASSERT_EQUAL(stretchedBox2->translateOut(stretchedBox2->translateIn(testVector)),testVector);
+    CPPUNIT_ASSERT_EQUAL(stretchedBox2->translateIn(stretchedBox2->translateOut(testVector)),testVector);
+    CPPUNIT_ASSERT_EQUAL(stretchedBox3->translateOut(stretchedBox3->translateIn(testVector)),testVector);
+    CPPUNIT_ASSERT_EQUAL(stretchedBox3->translateIn(stretchedBox3->translateOut(testVector)),testVector);
+    CPPUNIT_ASSERT_EQUAL(stretchedBox4->translateOut(stretchedBox4->translateIn(testVector)),testVector);
+    CPPUNIT_ASSERT_EQUAL(stretchedBox4->translateIn(stretchedBox4->translateOut(testVector)),testVector);
+    CPPUNIT_ASSERT_EQUAL(tiltedBox1->translateOut(tiltedBox1->translateIn(testVector)),testVector);
+    CPPUNIT_ASSERT_EQUAL(tiltedBox1->translateIn(tiltedBox1->translateOut(testVector)),testVector);
+    CPPUNIT_ASSERT_EQUAL(tiltedBox2->translateOut(tiltedBox2->translateIn(testVector)),testVector);
+    CPPUNIT_ASSERT_EQUAL(tiltedBox2->translateIn(tiltedBox2->translateOut(testVector)),testVector);
+    CPPUNIT_ASSERT_EQUAL(tiltedBox3->translateOut(tiltedBox3->translateIn(testVector)),testVector);
+    CPPUNIT_ASSERT_EQUAL(tiltedBox3->translateIn(tiltedBox3->translateOut(testVector)),testVector);
+    CPPUNIT_ASSERT_EQUAL(tiltedBox4->translateOut(tiltedBox4->translateIn(testVector)),testVector);
+    CPPUNIT_ASSERT_EQUAL(tiltedBox4->translateIn(tiltedBox4->translateOut(testVector)),testVector);
+  }
+
+  {
+    testVector=Vector(0.5,0.5,0.5);
+    CPPUNIT_ASSERT_EQUAL(unitBox->translateOut(unitBox->translateIn(testVector)),testVector);
+    CPPUNIT_ASSERT_EQUAL(unitBox->translateIn(unitBox->translateOut(testVector)),testVector);
+    CPPUNIT_ASSERT_EQUAL(stretchedBox1->translateOut(stretchedBox1->translateIn(testVector)),testVector);
+    CPPUNIT_ASSERT_EQUAL(stretchedBox1->translateIn(stretchedBox1->translateOut(testVector)),testVector);
+    CPPUNIT_ASSERT_EQUAL(stretchedBox2->translateOut(stretchedBox2->translateIn(testVector)),testVector);
+    CPPUNIT_ASSERT_EQUAL(stretchedBox2->translateIn(stretchedBox2->translateOut(testVector)),testVector);
+    CPPUNIT_ASSERT_EQUAL(stretchedBox3->translateOut(stretchedBox3->translateIn(testVector)),testVector);
+    CPPUNIT_ASSERT_EQUAL(stretchedBox3->translateIn(stretchedBox3->translateOut(testVector)),testVector);
+    CPPUNIT_ASSERT_EQUAL(stretchedBox4->translateOut(stretchedBox4->translateIn(testVector)),testVector);
+    CPPUNIT_ASSERT_EQUAL(stretchedBox4->translateIn(stretchedBox4->translateOut(testVector)),testVector);
+    CPPUNIT_ASSERT_EQUAL(tiltedBox1->translateOut(tiltedBox1->translateIn(testVector)),testVector);
+    CPPUNIT_ASSERT_EQUAL(tiltedBox1->translateIn(tiltedBox1->translateOut(testVector)),testVector);
+    CPPUNIT_ASSERT_EQUAL(tiltedBox2->translateOut(tiltedBox2->translateIn(testVector)),testVector);
+    CPPUNIT_ASSERT_EQUAL(tiltedBox2->translateIn(tiltedBox2->translateOut(testVector)),testVector);
+    CPPUNIT_ASSERT_EQUAL(tiltedBox3->translateOut(tiltedBox3->translateIn(testVector)),testVector);
+    CPPUNIT_ASSERT_EQUAL(tiltedBox3->translateIn(tiltedBox3->translateOut(testVector)),testVector);
+    CPPUNIT_ASSERT_EQUAL(tiltedBox4->translateOut(tiltedBox4->translateIn(testVector)),testVector);
+    CPPUNIT_ASSERT_EQUAL(tiltedBox4->translateIn(tiltedBox4->translateOut(testVector)),testVector);
+  }
+
+  {
+    testVector=Vector(1,1,1);
+    CPPUNIT_ASSERT_EQUAL(unitBox->translateOut(unitBox->translateIn(testVector)),testVector);
+    CPPUNIT_ASSERT_EQUAL(unitBox->translateIn(unitBox->translateOut(testVector)),testVector);
+    CPPUNIT_ASSERT_EQUAL(stretchedBox1->translateOut(stretchedBox1->translateIn(testVector)),testVector);
+    CPPUNIT_ASSERT_EQUAL(stretchedBox1->translateIn(stretchedBox1->translateOut(testVector)),testVector);
+    CPPUNIT_ASSERT_EQUAL(stretchedBox2->translateOut(stretchedBox2->translateIn(testVector)),testVector);
+    CPPUNIT_ASSERT_EQUAL(stretchedBox2->translateIn(stretchedBox2->translateOut(testVector)),testVector);
+    CPPUNIT_ASSERT_EQUAL(stretchedBox3->translateOut(stretchedBox3->translateIn(testVector)),testVector);
+    CPPUNIT_ASSERT_EQUAL(stretchedBox3->translateIn(stretchedBox3->translateOut(testVector)),testVector);
+    CPPUNIT_ASSERT_EQUAL(stretchedBox4->translateOut(stretchedBox4->translateIn(testVector)),testVector);
+    CPPUNIT_ASSERT_EQUAL(stretchedBox4->translateIn(stretchedBox4->translateOut(testVector)),testVector);
+    CPPUNIT_ASSERT_EQUAL(tiltedBox1->translateOut(tiltedBox1->translateIn(testVector)),testVector);
+    CPPUNIT_ASSERT_EQUAL(tiltedBox1->translateIn(tiltedBox1->translateOut(testVector)),testVector);
+    CPPUNIT_ASSERT_EQUAL(tiltedBox2->translateOut(tiltedBox2->translateIn(testVector)),testVector);
+    CPPUNIT_ASSERT_EQUAL(tiltedBox2->translateIn(tiltedBox2->translateOut(testVector)),testVector);
+    CPPUNIT_ASSERT_EQUAL(tiltedBox3->translateOut(tiltedBox3->translateIn(testVector)),testVector);
+    CPPUNIT_ASSERT_EQUAL(tiltedBox3->translateIn(tiltedBox3->translateOut(testVector)),testVector);
+    CPPUNIT_ASSERT_EQUAL(tiltedBox4->translateOut(tiltedBox4->translateIn(testVector)),testVector);
+    CPPUNIT_ASSERT_EQUAL(tiltedBox4->translateIn(tiltedBox4->translateOut(testVector)),testVector);
+  }
+
+  {
+    testVector=Vector(2,1,1);
+    CPPUNIT_ASSERT_EQUAL(unitBox->translateOut(unitBox->translateIn(testVector)),testVector);
+    CPPUNIT_ASSERT_EQUAL(unitBox->translateIn(unitBox->translateOut(testVector)),testVector);
+    CPPUNIT_ASSERT_EQUAL(stretchedBox1->translateOut(stretchedBox1->translateIn(testVector)),testVector);
+    CPPUNIT_ASSERT_EQUAL(stretchedBox1->translateIn(stretchedBox1->translateOut(testVector)),testVector);
+    CPPUNIT_ASSERT_EQUAL(stretchedBox2->translateOut(stretchedBox2->translateIn(testVector)),testVector);
+    CPPUNIT_ASSERT_EQUAL(stretchedBox2->translateIn(stretchedBox2->translateOut(testVector)),testVector);
+    CPPUNIT_ASSERT_EQUAL(stretchedBox3->translateOut(stretchedBox3->translateIn(testVector)),testVector);
+    CPPUNIT_ASSERT_EQUAL(stretchedBox3->translateIn(stretchedBox3->translateOut(testVector)),testVector);
+    CPPUNIT_ASSERT_EQUAL(stretchedBox4->translateOut(stretchedBox4->translateIn(testVector)),testVector);
+    CPPUNIT_ASSERT_EQUAL(stretchedBox4->translateIn(stretchedBox4->translateOut(testVector)),testVector);
+    CPPUNIT_ASSERT_EQUAL(tiltedBox1->translateOut(tiltedBox1->translateIn(testVector)),testVector);
+    CPPUNIT_ASSERT_EQUAL(tiltedBox1->translateIn(tiltedBox1->translateOut(testVector)),testVector);
+    CPPUNIT_ASSERT_EQUAL(tiltedBox2->translateOut(tiltedBox2->translateIn(testVector)),testVector);
+    CPPUNIT_ASSERT_EQUAL(tiltedBox2->translateIn(tiltedBox2->translateOut(testVector)),testVector);
+    CPPUNIT_ASSERT_EQUAL(tiltedBox3->translateOut(tiltedBox3->translateIn(testVector)),testVector);
+    CPPUNIT_ASSERT_EQUAL(tiltedBox3->translateIn(tiltedBox3->translateOut(testVector)),testVector);
+    CPPUNIT_ASSERT_EQUAL(tiltedBox4->translateOut(tiltedBox4->translateIn(testVector)),testVector);
+    CPPUNIT_ASSERT_EQUAL(tiltedBox4->translateIn(tiltedBox4->translateOut(testVector)),testVector);
+  }
+
+  {
+    testVector=Vector(1,2,1);
+    CPPUNIT_ASSERT_EQUAL(unitBox->translateOut(unitBox->translateIn(testVector)),testVector);
+    CPPUNIT_ASSERT_EQUAL(unitBox->translateIn(unitBox->translateOut(testVector)),testVector);
+    CPPUNIT_ASSERT_EQUAL(stretchedBox1->translateOut(stretchedBox1->translateIn(testVector)),testVector);
+    CPPUNIT_ASSERT_EQUAL(stretchedBox1->translateIn(stretchedBox1->translateOut(testVector)),testVector);
+    CPPUNIT_ASSERT_EQUAL(stretchedBox2->translateOut(stretchedBox2->translateIn(testVector)),testVector);
+    CPPUNIT_ASSERT_EQUAL(stretchedBox2->translateIn(stretchedBox2->translateOut(testVector)),testVector);
+    CPPUNIT_ASSERT_EQUAL(stretchedBox3->translateOut(stretchedBox3->translateIn(testVector)),testVector);
+    CPPUNIT_ASSERT_EQUAL(stretchedBox3->translateIn(stretchedBox3->translateOut(testVector)),testVector);
+    CPPUNIT_ASSERT_EQUAL(stretchedBox4->translateOut(stretchedBox4->translateIn(testVector)),testVector);
+    CPPUNIT_ASSERT_EQUAL(stretchedBox4->translateIn(stretchedBox4->translateOut(testVector)),testVector);
+    CPPUNIT_ASSERT_EQUAL(tiltedBox1->translateOut(tiltedBox1->translateIn(testVector)),testVector);
+    CPPUNIT_ASSERT_EQUAL(tiltedBox1->translateIn(tiltedBox1->translateOut(testVector)),testVector);
+    CPPUNIT_ASSERT_EQUAL(tiltedBox2->translateOut(tiltedBox2->translateIn(testVector)),testVector);
+    CPPUNIT_ASSERT_EQUAL(tiltedBox2->translateIn(tiltedBox2->translateOut(testVector)),testVector);
+    CPPUNIT_ASSERT_EQUAL(tiltedBox3->translateOut(tiltedBox3->translateIn(testVector)),testVector);
+    CPPUNIT_ASSERT_EQUAL(tiltedBox3->translateIn(tiltedBox3->translateOut(testVector)),testVector);
+    CPPUNIT_ASSERT_EQUAL(tiltedBox4->translateOut(tiltedBox4->translateIn(testVector)),testVector);
+    CPPUNIT_ASSERT_EQUAL(tiltedBox4->translateIn(tiltedBox4->translateOut(testVector)),testVector);
+  }
+
+  {
+    testVector=Vector(1,1,2);
+    CPPUNIT_ASSERT_EQUAL(unitBox->translateOut(unitBox->translateIn(testVector)),testVector);
+    CPPUNIT_ASSERT_EQUAL(unitBox->translateIn(unitBox->translateOut(testVector)),testVector);
+    CPPUNIT_ASSERT_EQUAL(stretchedBox1->translateOut(stretchedBox1->translateIn(testVector)),testVector);
+    CPPUNIT_ASSERT_EQUAL(stretchedBox1->translateIn(stretchedBox1->translateOut(testVector)),testVector);
+    CPPUNIT_ASSERT_EQUAL(stretchedBox2->translateOut(stretchedBox2->translateIn(testVector)),testVector);
+    CPPUNIT_ASSERT_EQUAL(stretchedBox2->translateIn(stretchedBox2->translateOut(testVector)),testVector);
+    CPPUNIT_ASSERT_EQUAL(stretchedBox3->translateOut(stretchedBox3->translateIn(testVector)),testVector);
+    CPPUNIT_ASSERT_EQUAL(stretchedBox3->translateIn(stretchedBox3->translateOut(testVector)),testVector);
+    CPPUNIT_ASSERT_EQUAL(stretchedBox4->translateOut(stretchedBox4->translateIn(testVector)),testVector);
+    CPPUNIT_ASSERT_EQUAL(stretchedBox4->translateIn(stretchedBox4->translateOut(testVector)),testVector);
+    CPPUNIT_ASSERT_EQUAL(tiltedBox1->translateOut(tiltedBox1->translateIn(testVector)),testVector);
+    CPPUNIT_ASSERT_EQUAL(tiltedBox1->translateIn(tiltedBox1->translateOut(testVector)),testVector);
+    CPPUNIT_ASSERT_EQUAL(tiltedBox2->translateOut(tiltedBox2->translateIn(testVector)),testVector);
+    CPPUNIT_ASSERT_EQUAL(tiltedBox2->translateIn(tiltedBox2->translateOut(testVector)),testVector);
+    CPPUNIT_ASSERT_EQUAL(tiltedBox3->translateOut(tiltedBox3->translateIn(testVector)),testVector);
+    CPPUNIT_ASSERT_EQUAL(tiltedBox3->translateIn(tiltedBox3->translateOut(testVector)),testVector);
+    CPPUNIT_ASSERT_EQUAL(tiltedBox4->translateOut(tiltedBox4->translateIn(testVector)),testVector);
+    CPPUNIT_ASSERT_EQUAL(tiltedBox4->translateIn(tiltedBox4->translateOut(testVector)),testVector);
+  }
+
+  {
+    testVector=Vector(3,1,1);
+    CPPUNIT_ASSERT_EQUAL(unitBox->translateOut(unitBox->translateIn(testVector)),testVector);
+    CPPUNIT_ASSERT_EQUAL(unitBox->translateIn(unitBox->translateOut(testVector)),testVector);
+    CPPUNIT_ASSERT_EQUAL(stretchedBox1->translateOut(stretchedBox1->translateIn(testVector)),testVector);
+    CPPUNIT_ASSERT_EQUAL(stretchedBox1->translateIn(stretchedBox1->translateOut(testVector)),testVector);
+    CPPUNIT_ASSERT_EQUAL(stretchedBox2->translateOut(stretchedBox2->translateIn(testVector)),testVector);
+    CPPUNIT_ASSERT_EQUAL(stretchedBox2->translateIn(stretchedBox2->translateOut(testVector)),testVector);
+    CPPUNIT_ASSERT_EQUAL(stretchedBox3->translateOut(stretchedBox3->translateIn(testVector)),testVector);
+    CPPUNIT_ASSERT_EQUAL(stretchedBox3->translateIn(stretchedBox3->translateOut(testVector)),testVector);
+    CPPUNIT_ASSERT_EQUAL(stretchedBox4->translateOut(stretchedBox4->translateIn(testVector)),testVector);
+    CPPUNIT_ASSERT_EQUAL(stretchedBox4->translateIn(stretchedBox4->translateOut(testVector)),testVector);
+    CPPUNIT_ASSERT_EQUAL(tiltedBox1->translateOut(tiltedBox1->translateIn(testVector)),testVector);
+    CPPUNIT_ASSERT_EQUAL(tiltedBox1->translateIn(tiltedBox1->translateOut(testVector)),testVector);
+    CPPUNIT_ASSERT_EQUAL(tiltedBox2->translateOut(tiltedBox2->translateIn(testVector)),testVector);
+    CPPUNIT_ASSERT_EQUAL(tiltedBox2->translateIn(tiltedBox2->translateOut(testVector)),testVector);
+    CPPUNIT_ASSERT_EQUAL(tiltedBox3->translateOut(tiltedBox3->translateIn(testVector)),testVector);
+    CPPUNIT_ASSERT_EQUAL(tiltedBox3->translateIn(tiltedBox3->translateOut(testVector)),testVector);
+    CPPUNIT_ASSERT_EQUAL(tiltedBox4->translateOut(tiltedBox4->translateIn(testVector)),testVector);
+    CPPUNIT_ASSERT_EQUAL(tiltedBox4->translateIn(tiltedBox4->translateOut(testVector)),testVector);
+  }
+
+  {
+    testVector=Vector(1,3,1);
+    CPPUNIT_ASSERT_EQUAL(unitBox->translateOut(unitBox->translateIn(testVector)),testVector);
+    CPPUNIT_ASSERT_EQUAL(unitBox->translateIn(unitBox->translateOut(testVector)),testVector);
+    CPPUNIT_ASSERT_EQUAL(stretchedBox1->translateOut(stretchedBox1->translateIn(testVector)),testVector);
+    CPPUNIT_ASSERT_EQUAL(stretchedBox1->translateIn(stretchedBox1->translateOut(testVector)),testVector);
+    CPPUNIT_ASSERT_EQUAL(stretchedBox2->translateOut(stretchedBox2->translateIn(testVector)),testVector);
+    CPPUNIT_ASSERT_EQUAL(stretchedBox2->translateIn(stretchedBox2->translateOut(testVector)),testVector);
+    CPPUNIT_ASSERT_EQUAL(stretchedBox3->translateOut(stretchedBox3->translateIn(testVector)),testVector);
+    CPPUNIT_ASSERT_EQUAL(stretchedBox3->translateIn(stretchedBox3->translateOut(testVector)),testVector);
+    CPPUNIT_ASSERT_EQUAL(stretchedBox4->translateOut(stretchedBox4->translateIn(testVector)),testVector);
+    CPPUNIT_ASSERT_EQUAL(stretchedBox4->translateIn(stretchedBox4->translateOut(testVector)),testVector);
+    CPPUNIT_ASSERT_EQUAL(tiltedBox1->translateOut(tiltedBox1->translateIn(testVector)),testVector);
+    CPPUNIT_ASSERT_EQUAL(tiltedBox1->translateIn(tiltedBox1->translateOut(testVector)),testVector);
+    CPPUNIT_ASSERT_EQUAL(tiltedBox2->translateOut(tiltedBox2->translateIn(testVector)),testVector);
+    CPPUNIT_ASSERT_EQUAL(tiltedBox2->translateIn(tiltedBox2->translateOut(testVector)),testVector);
+    CPPUNIT_ASSERT_EQUAL(tiltedBox3->translateOut(tiltedBox3->translateIn(testVector)),testVector);
+    CPPUNIT_ASSERT_EQUAL(tiltedBox3->translateIn(tiltedBox3->translateOut(testVector)),testVector);
+    CPPUNIT_ASSERT_EQUAL(tiltedBox4->translateOut(tiltedBox4->translateIn(testVector)),testVector);
+    CPPUNIT_ASSERT_EQUAL(tiltedBox4->translateIn(tiltedBox4->translateOut(testVector)),testVector);
+  }
+
+  {
+    testVector=Vector(1,1,3);
+    CPPUNIT_ASSERT_EQUAL(unitBox->translateOut(unitBox->translateIn(testVector)),testVector);
+    CPPUNIT_ASSERT_EQUAL(unitBox->translateIn(unitBox->translateOut(testVector)),testVector);
+    CPPUNIT_ASSERT_EQUAL(stretchedBox1->translateOut(stretchedBox1->translateIn(testVector)),testVector);
+    CPPUNIT_ASSERT_EQUAL(stretchedBox1->translateIn(stretchedBox1->translateOut(testVector)),testVector);
+    CPPUNIT_ASSERT_EQUAL(stretchedBox2->translateOut(stretchedBox2->translateIn(testVector)),testVector);
+    CPPUNIT_ASSERT_EQUAL(stretchedBox2->translateIn(stretchedBox2->translateOut(testVector)),testVector);
+    CPPUNIT_ASSERT_EQUAL(stretchedBox3->translateOut(stretchedBox3->translateIn(testVector)),testVector);
+    CPPUNIT_ASSERT_EQUAL(stretchedBox3->translateIn(stretchedBox3->translateOut(testVector)),testVector);
+    CPPUNIT_ASSERT_EQUAL(stretchedBox4->translateOut(stretchedBox4->translateIn(testVector)),testVector);
+    CPPUNIT_ASSERT_EQUAL(stretchedBox4->translateIn(stretchedBox4->translateOut(testVector)),testVector);
+    CPPUNIT_ASSERT_EQUAL(tiltedBox1->translateOut(tiltedBox1->translateIn(testVector)),testVector);
+    CPPUNIT_ASSERT_EQUAL(tiltedBox1->translateIn(tiltedBox1->translateOut(testVector)),testVector);
+    CPPUNIT_ASSERT_EQUAL(tiltedBox2->translateOut(tiltedBox2->translateIn(testVector)),testVector);
+    CPPUNIT_ASSERT_EQUAL(tiltedBox2->translateIn(tiltedBox2->translateOut(testVector)),testVector);
+    CPPUNIT_ASSERT_EQUAL(tiltedBox3->translateOut(tiltedBox3->translateIn(testVector)),testVector);
+    CPPUNIT_ASSERT_EQUAL(tiltedBox3->translateIn(tiltedBox3->translateOut(testVector)),testVector);
+    CPPUNIT_ASSERT_EQUAL(tiltedBox4->translateOut(tiltedBox4->translateIn(testVector)),testVector);
+    CPPUNIT_ASSERT_EQUAL(tiltedBox4->translateIn(tiltedBox4->translateOut(testVector)),testVector);
+  }
+
+  {
+    testVector=Vector(2,2,2);
+    CPPUNIT_ASSERT_EQUAL(unitBox->translateOut(unitBox->translateIn(testVector)),testVector);
+    CPPUNIT_ASSERT_EQUAL(unitBox->translateIn(unitBox->translateOut(testVector)),testVector);
+    CPPUNIT_ASSERT_EQUAL(stretchedBox1->translateOut(stretchedBox1->translateIn(testVector)),testVector);
+    CPPUNIT_ASSERT_EQUAL(stretchedBox1->translateIn(stretchedBox1->translateOut(testVector)),testVector);
+    CPPUNIT_ASSERT_EQUAL(stretchedBox2->translateOut(stretchedBox2->translateIn(testVector)),testVector);
+    CPPUNIT_ASSERT_EQUAL(stretchedBox2->translateIn(stretchedBox2->translateOut(testVector)),testVector);
+    CPPUNIT_ASSERT_EQUAL(stretchedBox3->translateOut(stretchedBox3->translateIn(testVector)),testVector);
+    CPPUNIT_ASSERT_EQUAL(stretchedBox3->translateIn(stretchedBox3->translateOut(testVector)),testVector);
+    CPPUNIT_ASSERT_EQUAL(stretchedBox4->translateOut(stretchedBox4->translateIn(testVector)),testVector);
+    CPPUNIT_ASSERT_EQUAL(stretchedBox4->translateIn(stretchedBox4->translateOut(testVector)),testVector);
+    CPPUNIT_ASSERT_EQUAL(tiltedBox1->translateOut(tiltedBox1->translateIn(testVector)),testVector);
+    CPPUNIT_ASSERT_EQUAL(tiltedBox1->translateIn(tiltedBox1->translateOut(testVector)),testVector);
+    CPPUNIT_ASSERT_EQUAL(tiltedBox2->translateOut(tiltedBox2->translateIn(testVector)),testVector);
+    CPPUNIT_ASSERT_EQUAL(tiltedBox2->translateIn(tiltedBox2->translateOut(testVector)),testVector);
+    CPPUNIT_ASSERT_EQUAL(tiltedBox3->translateOut(tiltedBox3->translateIn(testVector)),testVector);
+    CPPUNIT_ASSERT_EQUAL(tiltedBox3->translateIn(tiltedBox3->translateOut(testVector)),testVector);
+    CPPUNIT_ASSERT_EQUAL(tiltedBox4->translateOut(tiltedBox4->translateIn(testVector)),testVector);
+    CPPUNIT_ASSERT_EQUAL(tiltedBox4->translateIn(tiltedBox4->translateOut(testVector)),testVector);
+  }
+
+}
+
+void BoxUnittest::isInsideTest(){
+  Vector testVector(0,0,0);
+  CPPUNIT_ASSERT( unitBox->isInside(testVector));
+  CPPUNIT_ASSERT( stretchedBox1->isInside(testVector));
+  CPPUNIT_ASSERT( stretchedBox2->isInside(testVector));
+  CPPUNIT_ASSERT( stretchedBox3->isInside(testVector));
+  CPPUNIT_ASSERT( stretchedBox4->isInside(testVector));
+  CPPUNIT_ASSERT( tiltedBox1->isInside(testVector));
+  CPPUNIT_ASSERT( tiltedBox2->isInside(testVector));
+  CPPUNIT_ASSERT( tiltedBox3->isInside(testVector));
+  CPPUNIT_ASSERT( tiltedBox4->isInside(testVector));
+
+
+  testVector = Vector(0.5,0.5,0.5);
+  CPPUNIT_ASSERT( unitBox->isInside(testVector));
+  CPPUNIT_ASSERT( stretchedBox1->isInside(testVector));
+  CPPUNIT_ASSERT( stretchedBox2->isInside(testVector));
+  CPPUNIT_ASSERT( stretchedBox3->isInside(testVector));
+  CPPUNIT_ASSERT( stretchedBox4->isInside(testVector));
+  CPPUNIT_ASSERT( tiltedBox1->isInside(testVector));
+  CPPUNIT_ASSERT( tiltedBox2->isInside(testVector));
+  CPPUNIT_ASSERT( tiltedBox3->isInside(testVector));
+  CPPUNIT_ASSERT( tiltedBox4->isInside(testVector));
+
+  testVector = Vector(1,1,1);
+  CPPUNIT_ASSERT( unitBox->isInside(testVector));
+  CPPUNIT_ASSERT( stretchedBox1->isInside(testVector));
+  CPPUNIT_ASSERT( stretchedBox2->isInside(testVector));
+  CPPUNIT_ASSERT( stretchedBox3->isInside(testVector));
+  CPPUNIT_ASSERT( stretchedBox4->isInside(testVector));
+  CPPUNIT_ASSERT( tiltedBox1->isInside(testVector));
+  CPPUNIT_ASSERT( tiltedBox2->isInside(testVector));
+  CPPUNIT_ASSERT( tiltedBox3->isInside(testVector));
+  CPPUNIT_ASSERT( tiltedBox4->isInside(testVector));
+
+  testVector = Vector(2,1,1);
+  CPPUNIT_ASSERT(!unitBox->isInside(testVector));
+  CPPUNIT_ASSERT(!stretchedBox1->isInside(testVector));
+  CPPUNIT_ASSERT( stretchedBox2->isInside(testVector));
+  CPPUNIT_ASSERT( stretchedBox3->isInside(testVector));
+  CPPUNIT_ASSERT( stretchedBox4->isInside(testVector));
+  CPPUNIT_ASSERT(!tiltedBox1->isInside(testVector));
+  CPPUNIT_ASSERT(!tiltedBox2->isInside(testVector));
+  CPPUNIT_ASSERT(!tiltedBox3->isInside(testVector));
+  CPPUNIT_ASSERT(!tiltedBox4->isInside(testVector));
+
+  testVector = Vector(1,2,1);
+  CPPUNIT_ASSERT(!unitBox->isInside(testVector));
+  CPPUNIT_ASSERT( stretchedBox1->isInside(testVector));
+  CPPUNIT_ASSERT( stretchedBox2->isInside(testVector));
+  CPPUNIT_ASSERT(!stretchedBox3->isInside(testVector));
+  CPPUNIT_ASSERT( stretchedBox4->isInside(testVector));
+  CPPUNIT_ASSERT(!tiltedBox1->isInside(testVector));
+  CPPUNIT_ASSERT( tiltedBox2->isInside(testVector));
+  CPPUNIT_ASSERT(!tiltedBox3->isInside(testVector));
+  CPPUNIT_ASSERT(!tiltedBox4->isInside(testVector));
+
+  testVector = Vector(1,1,2);
+  CPPUNIT_ASSERT(!unitBox->isInside(testVector));
+  CPPUNIT_ASSERT( stretchedBox1->isInside(testVector));
+  CPPUNIT_ASSERT(!stretchedBox2->isInside(testVector));
+  CPPUNIT_ASSERT( stretchedBox3->isInside(testVector));
+  CPPUNIT_ASSERT( stretchedBox4->isInside(testVector));
+  CPPUNIT_ASSERT( tiltedBox1->isInside(testVector));
+  CPPUNIT_ASSERT( tiltedBox2->isInside(testVector));
+  CPPUNIT_ASSERT( tiltedBox3->isInside(testVector));
+  CPPUNIT_ASSERT( tiltedBox4->isInside(testVector));
+
+  testVector = Vector(3,1,1);
+  CPPUNIT_ASSERT(!unitBox->isInside(testVector));
+  CPPUNIT_ASSERT(!stretchedBox1->isInside(testVector));
+  CPPUNIT_ASSERT(!stretchedBox2->isInside(testVector));
+  CPPUNIT_ASSERT( stretchedBox3->isInside(testVector));
+  CPPUNIT_ASSERT(!stretchedBox4->isInside(testVector));
+  CPPUNIT_ASSERT(!tiltedBox1->isInside(testVector));
+  CPPUNIT_ASSERT(!tiltedBox2->isInside(testVector));
+  CPPUNIT_ASSERT(!tiltedBox3->isInside(testVector));
+  CPPUNIT_ASSERT(!tiltedBox4->isInside(testVector));
+
+  testVector = Vector(1,3,1);
+  CPPUNIT_ASSERT(!unitBox->isInside(testVector));
+  CPPUNIT_ASSERT(!stretchedBox1->isInside(testVector));
+  CPPUNIT_ASSERT( stretchedBox2->isInside(testVector));
+  CPPUNIT_ASSERT(!stretchedBox3->isInside(testVector));
+  CPPUNIT_ASSERT(!stretchedBox4->isInside(testVector));
+  CPPUNIT_ASSERT(!tiltedBox1->isInside(testVector));
+  CPPUNIT_ASSERT(!tiltedBox2->isInside(testVector));
+  CPPUNIT_ASSERT(!tiltedBox3->isInside(testVector));
+  CPPUNIT_ASSERT(!tiltedBox4->isInside(testVector));
+
+  testVector = Vector(1,1,3);
+  CPPUNIT_ASSERT(!unitBox->isInside(testVector));
+  CPPUNIT_ASSERT( stretchedBox1->isInside(testVector));
+  CPPUNIT_ASSERT(!stretchedBox2->isInside(testVector));
+  CPPUNIT_ASSERT(!stretchedBox3->isInside(testVector));
+  CPPUNIT_ASSERT(!stretchedBox4->isInside(testVector));
+  CPPUNIT_ASSERT(!tiltedBox1->isInside(testVector));
+  CPPUNIT_ASSERT(!tiltedBox2->isInside(testVector));
+  CPPUNIT_ASSERT(!tiltedBox3->isInside(testVector));
+  CPPUNIT_ASSERT(!tiltedBox4->isInside(testVector));
+
+  testVector = Vector(2,2,2);
+  CPPUNIT_ASSERT(!unitBox->isInside(testVector));
+  CPPUNIT_ASSERT(!stretchedBox1->isInside(testVector));
+  CPPUNIT_ASSERT(!stretchedBox2->isInside(testVector));
+  CPPUNIT_ASSERT(!stretchedBox3->isInside(testVector));
+  CPPUNIT_ASSERT( stretchedBox4->isInside(testVector));
+  CPPUNIT_ASSERT(!tiltedBox1->isInside(testVector));
+  CPPUNIT_ASSERT(!tiltedBox2->isInside(testVector));
+  CPPUNIT_ASSERT(!tiltedBox3->isInside(testVector));
+  CPPUNIT_ASSERT(!tiltedBox4->isInside(testVector));
+
+  testVector = Vector(3,3,3);
+  CPPUNIT_ASSERT(!unitBox->isInside(testVector));
+  CPPUNIT_ASSERT(!stretchedBox1->isInside(testVector));
+  CPPUNIT_ASSERT(!stretchedBox2->isInside(testVector));
+  CPPUNIT_ASSERT(!stretchedBox3->isInside(testVector));
+  CPPUNIT_ASSERT(!stretchedBox4->isInside(testVector));
+  CPPUNIT_ASSERT(!tiltedBox1->isInside(testVector));
+  CPPUNIT_ASSERT(!tiltedBox2->isInside(testVector));
+  CPPUNIT_ASSERT(!tiltedBox3->isInside(testVector));
+  CPPUNIT_ASSERT(!tiltedBox4->isInside(testVector));
+}
+
+bool testWrapExplode(VECTORSET(std::list) &set,Vector &point, Box* box){
+  bool res = true;
+  Vector wrappedPoint = box->WrapPeriodically(point);
+  for(std::list<Vector>::iterator iter = set.begin(); iter!=set.end();++iter){
+    Vector wrapped = box->WrapPeriodically(*iter);
+    bool equals = (wrapped == wrappedPoint);
+    res = res && equals;
+    if(!equals){
+      cout << "Wrapped vector " << wrapped << " produced from vector " << (*iter) << " does not match target " << wrappedPoint << endl;
+    }
+  }
+  return res;
+}
+
+void BoxUnittest::WrapExplodeTest(){
+  Vector testVector(0,0,0);
+  VECTORSET(std::list) res;
+
+  // we only can explode those vectors that are actually inside the box
+  {
+    testVector = Vector(0,0,0);
+    res = unitBox->explode(testVector,1);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,unitBox));
+    res = stretchedBox1->explode(testVector,1);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox1));
+    res = stretchedBox2->explode(testVector,1);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox2));
+    res = stretchedBox3->explode(testVector,1);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox3));
+    res = stretchedBox4->explode(testVector,1);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox4));
+    res = tiltedBox1->explode(testVector,1);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox1));
+    res = tiltedBox2->explode(testVector,1);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox2));
+    res = tiltedBox3->explode(testVector,1);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox3));
+    res = tiltedBox4->explode(testVector,1);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox4));
+  }
+
+  {
+    testVector = Vector(0.5,0.5,0.5);
+    res = unitBox->explode(testVector,1);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,unitBox));
+    res = stretchedBox1->explode(testVector,1);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox1));
+    res = stretchedBox2->explode(testVector,1);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox2));
+    res = stretchedBox3->explode(testVector,1);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox3));
+    res = stretchedBox4->explode(testVector,1);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox4));
+    res = tiltedBox1->explode(testVector,1);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox1));
+    res = tiltedBox2->explode(testVector,1);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox2));
+    res = tiltedBox3->explode(testVector,1);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox3));
+    res = tiltedBox4->explode(testVector,1);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox4));
+  }
+
+  {
+    testVector = Vector(1,1,1);
+    res = unitBox->explode(testVector,1);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,unitBox));
+    res = stretchedBox1->explode(testVector,1);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox1));
+    res = stretchedBox2->explode(testVector,1);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox2));
+    res = stretchedBox3->explode(testVector,1);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox3));
+    res = stretchedBox4->explode(testVector,1);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox4));
+    res = tiltedBox1->explode(testVector,1);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox1));
+    res = tiltedBox2->explode(testVector,1);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox2));
+    res = tiltedBox3->explode(testVector,1);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox3));
+    res = tiltedBox4->explode(testVector,1);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox4));
+  }
+
+  {
+    testVector = Vector(2,1,1);
+    res = stretchedBox2->explode(testVector,1);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox2));
+    res = stretchedBox3->explode(testVector,1);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox3));
+    res = stretchedBox4->explode(testVector,1);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox4));
+  }
+
+  {
+    testVector = Vector(1,2,1);
+    res = stretchedBox1->explode(testVector,1);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox1));
+    res = stretchedBox2->explode(testVector,1);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox2));
+    res = stretchedBox4->explode(testVector,1);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox1));
+    res = tiltedBox2->explode(testVector,1);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox2));
+  }
+
+  {
+    testVector = Vector(1,1,2);
+    res = stretchedBox1->explode(testVector,1);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox1));
+    res = stretchedBox3->explode(testVector,1);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox3));
+    res = stretchedBox4->explode(testVector,1);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox4));
+    res = tiltedBox1->explode(testVector,1);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox1));
+    res = tiltedBox2->explode(testVector,1);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox2));
+    res = tiltedBox3->explode(testVector,1);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox3));
+    res = tiltedBox4->explode(testVector,1);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox4));
+  }
+
+  {
+    testVector = Vector(3,1,1);
+    res = stretchedBox3->explode(testVector,1);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox3));
+  }
+
+  {
+    testVector = Vector(1,3,1);
+    res = stretchedBox2->explode(testVector,1);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox2));
+  }
+
+  {
+    testVector = Vector(1,1,3);
+    res = stretchedBox1->explode(testVector,1);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox1));
+  }
+
+  {
+    testVector = Vector(2,2,2);
+    res = stretchedBox4->explode(testVector,1);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox4));
+  }
+
+  // Higher level explosions
+
+  {
+    testVector = Vector(0,0,0);
+    res = unitBox->explode(testVector,2);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,unitBox));
+    res = stretchedBox1->explode(testVector,2);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox1));
+    res = stretchedBox2->explode(testVector,2);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox2));
+    res = stretchedBox3->explode(testVector,2);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox3));
+    res = stretchedBox4->explode(testVector,2);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox4));
+    res = tiltedBox1->explode(testVector,2);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox1));
+    res = tiltedBox2->explode(testVector,2);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox2));
+    res = tiltedBox3->explode(testVector,2);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox3));
+    res = tiltedBox4->explode(testVector,2);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox4));
+  }
+
+  {
+    testVector = Vector(0.5,0.5,0.5);
+    res = unitBox->explode(testVector,2);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,unitBox));
+    res = stretchedBox1->explode(testVector,2);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox1));
+    res = stretchedBox2->explode(testVector,2);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox2));
+    res = stretchedBox3->explode(testVector,2);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox3));
+    res = stretchedBox4->explode(testVector,2);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox4));
+    res = tiltedBox1->explode(testVector,2);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox1));
+    res = tiltedBox2->explode(testVector,2);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox2));
+    res = tiltedBox3->explode(testVector,2);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox3));
+    res = tiltedBox4->explode(testVector,2);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox4));
+  }
+
+  {
+    testVector = Vector(1,1,1);
+    res = unitBox->explode(testVector,2);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,unitBox));
+    res = stretchedBox1->explode(testVector,2);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox1));
+    res = stretchedBox2->explode(testVector,2);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox2));
+    res = stretchedBox3->explode(testVector,2);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox3));
+    res = stretchedBox4->explode(testVector,2);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox4));
+    res = tiltedBox1->explode(testVector,2);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox1));
+    res = tiltedBox2->explode(testVector,2);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox2));
+    res = tiltedBox3->explode(testVector,2);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox3));
+    res = tiltedBox4->explode(testVector,2);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox4));
+  }
+
+  {
+    testVector = Vector(2,1,1);
+    res = stretchedBox2->explode(testVector,2);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox2));
+    res = stretchedBox3->explode(testVector,2);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox3));
+    res = stretchedBox4->explode(testVector,2);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox4));
+  }
+
+  {
+    testVector = Vector(1,2,1);
+    res = stretchedBox1->explode(testVector,2);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox1));
+    res = stretchedBox2->explode(testVector,2);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox2));
+    res = stretchedBox4->explode(testVector,2);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox1));
+    res = tiltedBox2->explode(testVector,2);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox2));
+  }
+
+  {
+    testVector = Vector(1,1,2);
+    res = stretchedBox1->explode(testVector,2);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox1));
+    res = stretchedBox3->explode(testVector,2);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox3));
+    res = stretchedBox4->explode(testVector,2);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox4));
+    res = tiltedBox1->explode(testVector,2);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox1));
+    res = tiltedBox2->explode(testVector,2);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox2));
+    res = tiltedBox3->explode(testVector,2);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox3));
+    res = tiltedBox4->explode(testVector,2);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox4));
+  }
+
+  {
+    testVector = Vector(3,1,1);
+    res = stretchedBox3->explode(testVector,2);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox3));
+  }
+
+  {
+    testVector = Vector(1,3,1);
+    res = stretchedBox2->explode(testVector,2);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox2));
+  }
+
+  {
+    testVector = Vector(1,1,3);
+    res = stretchedBox1->explode(testVector,2);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox1));
+  }
+
+  {
+    testVector = Vector(2,2,2);
+    res = stretchedBox4->explode(testVector,2);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox4));
+  }
+
+  // one more set of higher level explosions
+
+  {
+    testVector = Vector(0,0,0);
+    res = unitBox->explode(testVector,3);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,unitBox));
+    res = stretchedBox1->explode(testVector,3);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox1));
+    res = stretchedBox2->explode(testVector,3);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox2));
+    res = stretchedBox3->explode(testVector,3);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox3));
+    res = stretchedBox4->explode(testVector,3);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox4));
+    res = tiltedBox1->explode(testVector,3);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox1));
+    res = tiltedBox2->explode(testVector,3);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox2));
+    res = tiltedBox3->explode(testVector,3);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox3));
+    res = tiltedBox4->explode(testVector,3);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox4));
+  }
+
+  {
+    testVector = Vector(0.5,0.5,0.5);
+    res = unitBox->explode(testVector,3);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,unitBox));
+    res = stretchedBox1->explode(testVector,3);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox1));
+    res = stretchedBox2->explode(testVector,3);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox2));
+    res = stretchedBox3->explode(testVector,3);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox3));
+    res = stretchedBox4->explode(testVector,3);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox4));
+    res = tiltedBox1->explode(testVector,3);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox1));
+    res = tiltedBox2->explode(testVector,3);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox2));
+    res = tiltedBox3->explode(testVector,3);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox3));
+    res = tiltedBox4->explode(testVector,3);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox4));
+  }
+
+  {
+    testVector = Vector(1,1,1);
+    res = unitBox->explode(testVector,3);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,unitBox));
+    res = stretchedBox1->explode(testVector,3);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox1));
+    res = stretchedBox2->explode(testVector,3);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox2));
+    res = stretchedBox3->explode(testVector,3);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox3));
+    res = stretchedBox4->explode(testVector,3);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox4));
+    res = tiltedBox1->explode(testVector,3);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox1));
+    res = tiltedBox2->explode(testVector,3);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox2));
+    res = tiltedBox3->explode(testVector,3);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox3));
+    res = tiltedBox4->explode(testVector,3);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox4));
+  }
+
+  {
+    testVector = Vector(2,1,1);
+    res = stretchedBox2->explode(testVector,3);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox2));
+    res = stretchedBox3->explode(testVector,3);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox3));
+    res = stretchedBox4->explode(testVector,3);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox4));
+  }
+
+  {
+    testVector = Vector(1,2,1);
+    res = stretchedBox1->explode(testVector,3);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox1));
+    res = stretchedBox2->explode(testVector,3);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox2));
+    res = stretchedBox4->explode(testVector,3);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox1));
+    res = tiltedBox2->explode(testVector,3);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox2));
+  }
+
+  {
+    testVector = Vector(1,1,2);
+    res = stretchedBox1->explode(testVector,3);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox1));
+    res = stretchedBox3->explode(testVector,3);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox3));
+    res = stretchedBox4->explode(testVector,3);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox4));
+    res = tiltedBox1->explode(testVector,3);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox1));
+    res = tiltedBox2->explode(testVector,3);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox2));
+    res = tiltedBox3->explode(testVector,3);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox3));
+    res = tiltedBox4->explode(testVector,3);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox4));
+  }
+
+  {
+    testVector = Vector(3,1,1);
+    res = stretchedBox3->explode(testVector,3);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox3));
+  }
+
+  {
+    testVector = Vector(1,3,1);
+    res = stretchedBox2->explode(testVector,3);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox2));
+  }
+
+  {
+    testVector = Vector(1,1,3);
+    res = stretchedBox1->explode(testVector,3);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox1));
+  }
+
+  {
+    testVector = Vector(2,2,2);
+    res = stretchedBox4->explode(testVector,3);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox4));
+  }
+}
+
+void BoxUnittest::BoundaryBounceTest(){
+  Vector testVector(0,0,0);
+  VECTORSET(std::list) res;
+
+  unitBox->setCondition(0,Box::Bounce);
+  stretchedBox1->setCondition(0,Box::Bounce);
+  stretchedBox2->setCondition(0,Box::Bounce);
+  stretchedBox3->setCondition(0,Box::Bounce);
+  stretchedBox4->setCondition(0,Box::Bounce);
+  tiltedBox1->setCondition(0,Box::Bounce);
+  tiltedBox2->setCondition(0,Box::Bounce);
+  tiltedBox3->setCondition(0,Box::Bounce);
+  tiltedBox4->setCondition(0,Box::Bounce);
+
+  {
+    testVector = Vector(0,0,0);
+    res = unitBox->explode(testVector,1);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,unitBox));
+    res = stretchedBox1->explode(testVector,1);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox1));
+    res = stretchedBox2->explode(testVector,1);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox2));
+    res = stretchedBox3->explode(testVector,1);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox3));
+    res = stretchedBox4->explode(testVector,1);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox4));
+    res = tiltedBox1->explode(testVector,1);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox1));
+    res = tiltedBox2->explode(testVector,1);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox2));
+    res = tiltedBox3->explode(testVector,1);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox3));
+    res = tiltedBox4->explode(testVector,1);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox4));
+  }
+
+  {
+    testVector = Vector(0.5,0.5,0.5);
+    res = unitBox->explode(testVector,1);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,unitBox));
+    res = stretchedBox1->explode(testVector,1);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox1));
+    res = stretchedBox2->explode(testVector,1);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox2));
+    res = stretchedBox3->explode(testVector,1);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox3));
+    res = stretchedBox4->explode(testVector,1);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox4));
+    res = tiltedBox1->explode(testVector,1);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox1));
+    res = tiltedBox2->explode(testVector,1);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox2));
+    res = tiltedBox3->explode(testVector,1);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox3));
+    res = tiltedBox4->explode(testVector,1);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox4));
+  }
+
+  {
+    testVector = Vector(0,0,0);
+    res = unitBox->explode(testVector,2);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,unitBox));
+    res = stretchedBox1->explode(testVector,2);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox1));
+    res = stretchedBox2->explode(testVector,2);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox2));
+    res = stretchedBox3->explode(testVector,2);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox3));
+    res = stretchedBox4->explode(testVector,2);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox4));
+    res = tiltedBox1->explode(testVector,2);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox1));
+    res = tiltedBox2->explode(testVector,2);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox2));
+    res = tiltedBox3->explode(testVector,2);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox3));
+    res = tiltedBox4->explode(testVector,2);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox4));
+  }
+
+  {
+    testVector = Vector(0.5,0.5,0.5);
+    res = unitBox->explode(testVector,2);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,unitBox));
+    res = stretchedBox1->explode(testVector,2);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox1));
+    res = stretchedBox2->explode(testVector,2);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox2));
+    res = stretchedBox3->explode(testVector,2);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox3));
+    res = stretchedBox4->explode(testVector,2);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox4));
+    res = tiltedBox1->explode(testVector,2);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox1));
+    res = tiltedBox2->explode(testVector,2);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox2));
+    res = tiltedBox3->explode(testVector,2);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox3));
+    res = tiltedBox4->explode(testVector,2);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox4));
+  }
+
+  unitBox->setCondition(1,Box::Bounce);
+  stretchedBox1->setCondition(1,Box::Bounce);
+  stretchedBox2->setCondition(1,Box::Bounce);
+  stretchedBox3->setCondition(1,Box::Bounce);
+  stretchedBox4->setCondition(1,Box::Bounce);
+  tiltedBox1->setCondition(1,Box::Bounce);
+  tiltedBox2->setCondition(1,Box::Bounce);
+  tiltedBox3->setCondition(1,Box::Bounce);
+  tiltedBox4->setCondition(1,Box::Bounce);
+
+  {
+    testVector = Vector(0,0,0);
+    res = unitBox->explode(testVector,1);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,unitBox));
+    res = stretchedBox1->explode(testVector,1);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox1));
+    res = stretchedBox2->explode(testVector,1);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox2));
+    res = stretchedBox3->explode(testVector,1);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox3));
+    res = stretchedBox4->explode(testVector,1);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox4));
+    res = tiltedBox1->explode(testVector,1);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox1));
+    res = tiltedBox2->explode(testVector,1);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox2));
+    res = tiltedBox3->explode(testVector,1);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox3));
+    res = tiltedBox4->explode(testVector,1);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox4));
+  }
+
+  {
+    testVector = Vector(0.5,0.5,0.5);
+    res = unitBox->explode(testVector,1);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,unitBox));
+    res = stretchedBox1->explode(testVector,1);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox1));
+    res = stretchedBox2->explode(testVector,1);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox2));
+    res = stretchedBox3->explode(testVector,1);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox3));
+    res = stretchedBox4->explode(testVector,1);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox4));
+    res = tiltedBox1->explode(testVector,1);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox1));
+    res = tiltedBox2->explode(testVector,1);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox2));
+    res = tiltedBox3->explode(testVector,1);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox3));
+    res = tiltedBox4->explode(testVector,1);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox4));
+  }
+
+  {
+    testVector = Vector(0,0,0);
+    res = unitBox->explode(testVector,2);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,unitBox));
+    res = stretchedBox1->explode(testVector,2);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox1));
+    res = stretchedBox2->explode(testVector,2);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox2));
+    res = stretchedBox3->explode(testVector,2);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox3));
+    res = stretchedBox4->explode(testVector,2);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox4));
+    res = tiltedBox1->explode(testVector,2);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox1));
+    res = tiltedBox2->explode(testVector,2);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox2));
+    res = tiltedBox3->explode(testVector,2);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox3));
+    res = tiltedBox4->explode(testVector,2);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox4));
+  }
+
+  {
+    testVector = Vector(0.5,0.5,0.5);
+    res = unitBox->explode(testVector,2);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,unitBox));
+    res = stretchedBox1->explode(testVector,2);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox1));
+    res = stretchedBox2->explode(testVector,2);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox2));
+    res = stretchedBox3->explode(testVector,2);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox3));
+    res = stretchedBox4->explode(testVector,2);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox4));
+    res = tiltedBox1->explode(testVector,2);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox1));
+    res = tiltedBox2->explode(testVector,2);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox2));
+    res = tiltedBox3->explode(testVector,2);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox3));
+    res = tiltedBox4->explode(testVector,2);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox4));
+  }
+
+  unitBox->setCondition(2,Box::Bounce);
+  stretchedBox1->setCondition(2,Box::Bounce);
+  stretchedBox2->setCondition(2,Box::Bounce);
+  stretchedBox3->setCondition(2,Box::Bounce);
+  stretchedBox4->setCondition(2,Box::Bounce);
+  tiltedBox1->setCondition(2,Box::Bounce);
+  tiltedBox2->setCondition(2,Box::Bounce);
+  tiltedBox3->setCondition(2,Box::Bounce);
+  tiltedBox4->setCondition(2,Box::Bounce);
+
+  {
+    testVector = Vector(0,0,0);
+    res = unitBox->explode(testVector,1);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,unitBox));
+    res = stretchedBox1->explode(testVector,1);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox1));
+    res = stretchedBox2->explode(testVector,1);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox2));
+    res = stretchedBox3->explode(testVector,1);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox3));
+    res = stretchedBox4->explode(testVector,1);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox4));
+    res = tiltedBox1->explode(testVector,1);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox1));
+    res = tiltedBox2->explode(testVector,1);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox2));
+    res = tiltedBox3->explode(testVector,1);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox3));
+    res = tiltedBox4->explode(testVector,1);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox4));
+  }
+
+  {
+    testVector = Vector(0.5,0.5,0.5);
+    res = unitBox->explode(testVector,1);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,unitBox));
+    res = stretchedBox1->explode(testVector,1);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox1));
+    res = stretchedBox2->explode(testVector,1);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox2));
+    res = stretchedBox3->explode(testVector,1);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox3));
+    res = stretchedBox4->explode(testVector,1);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox4));
+    res = tiltedBox1->explode(testVector,1);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox1));
+    res = tiltedBox2->explode(testVector,1);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox2));
+    res = tiltedBox3->explode(testVector,1);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox3));
+    res = tiltedBox4->explode(testVector,1);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox4));
+  }
+
+  {
+    testVector = Vector(0,0,0);
+    res = unitBox->explode(testVector,2);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,unitBox));
+    res = stretchedBox1->explode(testVector,2);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox1));
+    res = stretchedBox2->explode(testVector,2);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox2));
+    res = stretchedBox3->explode(testVector,2);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox3));
+    res = stretchedBox4->explode(testVector,2);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox4));
+    res = tiltedBox1->explode(testVector,2);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox1));
+    res = tiltedBox2->explode(testVector,2);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox2));
+    res = tiltedBox3->explode(testVector,2);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox3));
+    res = tiltedBox4->explode(testVector,2);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox4));
+  }
+
+  {
+    testVector = Vector(0.5,0.5,0.5);
+    res = unitBox->explode(testVector,2);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,unitBox));
+    res = stretchedBox1->explode(testVector,2);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox1));
+    res = stretchedBox2->explode(testVector,2);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox2));
+    res = stretchedBox3->explode(testVector,2);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox3));
+    res = stretchedBox4->explode(testVector,2);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox4));
+    res = tiltedBox1->explode(testVector,2);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox1));
+    res = tiltedBox2->explode(testVector,2);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox2));
+    res = tiltedBox3->explode(testVector,2);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox3));
+    res = tiltedBox4->explode(testVector,2);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox4));
+  }
+}
+
+void BoxUnittest::BoundaryIgnoreTest(){
+  Vector testVector(0,0,0);
+  VECTORSET(std::list) res;
+
+  unitBox->setCondition(0,Box::Ignore);
+  stretchedBox1->setCondition(0,Box::Ignore);
+  stretchedBox2->setCondition(0,Box::Ignore);
+  stretchedBox3->setCondition(0,Box::Ignore);
+  stretchedBox4->setCondition(0,Box::Ignore);
+  tiltedBox1->setCondition(0,Box::Ignore);
+  tiltedBox2->setCondition(0,Box::Ignore);
+  tiltedBox3->setCondition(0,Box::Ignore);
+  tiltedBox4->setCondition(0,Box::Ignore);
+
+  {
+    testVector = Vector(0,0,0);
+    res = unitBox->explode(testVector,1);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,unitBox));
+    res = stretchedBox1->explode(testVector,1);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox1));
+    res = stretchedBox2->explode(testVector,1);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox2));
+    res = stretchedBox3->explode(testVector,1);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox3));
+    res = stretchedBox4->explode(testVector,1);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox4));
+    res = tiltedBox1->explode(testVector,1);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox1));
+    res = tiltedBox2->explode(testVector,1);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox2));
+    res = tiltedBox3->explode(testVector,1);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox3));
+    res = tiltedBox4->explode(testVector,1);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox4));
+  }
+
+  {
+    testVector = Vector(0.5,0.5,0.5);
+    res = unitBox->explode(testVector,1);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,unitBox));
+    res = stretchedBox1->explode(testVector,1);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox1));
+    res = stretchedBox2->explode(testVector,1);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox2));
+    res = stretchedBox3->explode(testVector,1);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox3));
+    res = stretchedBox4->explode(testVector,1);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox4));
+    res = tiltedBox1->explode(testVector,1);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox1));
+    res = tiltedBox2->explode(testVector,1);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox2));
+    res = tiltedBox3->explode(testVector,1);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox3));
+    res = tiltedBox4->explode(testVector,1);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox4));
+  }
+
+  {
+    testVector = Vector(0,0,0);
+    res = unitBox->explode(testVector,2);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,unitBox));
+    res = stretchedBox1->explode(testVector,2);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox1));
+    res = stretchedBox2->explode(testVector,2);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox2));
+    res = stretchedBox3->explode(testVector,2);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox3));
+    res = stretchedBox4->explode(testVector,2);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox4));
+    res = tiltedBox1->explode(testVector,2);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox1));
+    res = tiltedBox2->explode(testVector,2);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox2));
+    res = tiltedBox3->explode(testVector,2);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox3));
+    res = tiltedBox4->explode(testVector,2);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox4));
+  }
+
+  {
+    testVector = Vector(0.5,0.5,0.5);
+    res = unitBox->explode(testVector,2);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,unitBox));
+    res = stretchedBox1->explode(testVector,2);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox1));
+    res = stretchedBox2->explode(testVector,2);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox2));
+    res = stretchedBox3->explode(testVector,2);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox3));
+    res = stretchedBox4->explode(testVector,2);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox4));
+    res = tiltedBox1->explode(testVector,2);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox1));
+    res = tiltedBox2->explode(testVector,2);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox2));
+    res = tiltedBox3->explode(testVector,2);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox3));
+    res = tiltedBox4->explode(testVector,2);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox4));
+  }
+
+  unitBox->setCondition(1,Box::Ignore);
+  stretchedBox1->setCondition(1,Box::Ignore);
+  stretchedBox2->setCondition(1,Box::Ignore);
+  stretchedBox3->setCondition(1,Box::Ignore);
+  stretchedBox4->setCondition(1,Box::Ignore);
+  tiltedBox1->setCondition(1,Box::Ignore);
+  tiltedBox2->setCondition(1,Box::Ignore);
+  tiltedBox3->setCondition(1,Box::Ignore);
+  tiltedBox4->setCondition(1,Box::Ignore);
+
+  {
+    testVector = Vector(0,0,0);
+    res = unitBox->explode(testVector,1);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,unitBox));
+    res = stretchedBox1->explode(testVector,1);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox1));
+    res = stretchedBox2->explode(testVector,1);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox2));
+    res = stretchedBox3->explode(testVector,1);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox3));
+    res = stretchedBox4->explode(testVector,1);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox4));
+    res = tiltedBox1->explode(testVector,1);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox1));
+    res = tiltedBox2->explode(testVector,1);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox2));
+    res = tiltedBox3->explode(testVector,1);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox3));
+    res = tiltedBox4->explode(testVector,1);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox4));
+  }
+
+  {
+    testVector = Vector(0.5,0.5,0.5);
+    res = unitBox->explode(testVector,1);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,unitBox));
+    res = stretchedBox1->explode(testVector,1);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox1));
+    res = stretchedBox2->explode(testVector,1);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox2));
+    res = stretchedBox3->explode(testVector,1);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox3));
+    res = stretchedBox4->explode(testVector,1);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox4));
+    res = tiltedBox1->explode(testVector,1);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox1));
+    res = tiltedBox2->explode(testVector,1);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox2));
+    res = tiltedBox3->explode(testVector,1);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox3));
+    res = tiltedBox4->explode(testVector,1);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox4));
+  }
+
+  {
+    testVector = Vector(0,0,0);
+    res = unitBox->explode(testVector,2);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,unitBox));
+    res = stretchedBox1->explode(testVector,2);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox1));
+    res = stretchedBox2->explode(testVector,2);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox2));
+    res = stretchedBox3->explode(testVector,2);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox3));
+    res = stretchedBox4->explode(testVector,2);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox4));
+    res = tiltedBox1->explode(testVector,2);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox1));
+    res = tiltedBox2->explode(testVector,2);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox2));
+    res = tiltedBox3->explode(testVector,2);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox3));
+    res = tiltedBox4->explode(testVector,2);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox4));
+  }
+
+  {
+    testVector = Vector(0.5,0.5,0.5);
+    res = unitBox->explode(testVector,2);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,unitBox));
+    res = stretchedBox1->explode(testVector,2);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox1));
+    res = stretchedBox2->explode(testVector,2);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox2));
+    res = stretchedBox3->explode(testVector,2);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox3));
+    res = stretchedBox4->explode(testVector,2);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox4));
+    res = tiltedBox1->explode(testVector,2);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox1));
+    res = tiltedBox2->explode(testVector,2);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox2));
+    res = tiltedBox3->explode(testVector,2);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox3));
+    res = tiltedBox4->explode(testVector,2);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox4));
+  }
+
+  unitBox->setCondition(2,Box::Ignore);
+  stretchedBox1->setCondition(2,Box::Ignore);
+  stretchedBox2->setCondition(2,Box::Ignore);
+  stretchedBox3->setCondition(2,Box::Ignore);
+  stretchedBox4->setCondition(2,Box::Ignore);
+  tiltedBox1->setCondition(2,Box::Ignore);
+  tiltedBox2->setCondition(2,Box::Ignore);
+  tiltedBox3->setCondition(2,Box::Ignore);
+  tiltedBox4->setCondition(2,Box::Ignore);
+
+  {
+    testVector = Vector(0,0,0);
+    res = unitBox->explode(testVector,1);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,unitBox));
+    res = stretchedBox1->explode(testVector,1);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox1));
+    res = stretchedBox2->explode(testVector,1);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox2));
+    res = stretchedBox3->explode(testVector,1);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox3));
+    res = stretchedBox4->explode(testVector,1);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox4));
+    res = tiltedBox1->explode(testVector,1);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox1));
+    res = tiltedBox2->explode(testVector,1);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox2));
+    res = tiltedBox3->explode(testVector,1);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox3));
+    res = tiltedBox4->explode(testVector,1);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox4));
+  }
+
+  {
+    testVector = Vector(0.5,0.5,0.5);
+    res = unitBox->explode(testVector,1);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,unitBox));
+    res = stretchedBox1->explode(testVector,1);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox1));
+    res = stretchedBox2->explode(testVector,1);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox2));
+    res = stretchedBox3->explode(testVector,1);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox3));
+    res = stretchedBox4->explode(testVector,1);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox4));
+    res = tiltedBox1->explode(testVector,1);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox1));
+    res = tiltedBox2->explode(testVector,1);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox2));
+    res = tiltedBox3->explode(testVector,1);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox3));
+    res = tiltedBox4->explode(testVector,1);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox4));
+  }
+
+  {
+    testVector = Vector(0,0,0);
+    res = unitBox->explode(testVector,2);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,unitBox));
+    res = stretchedBox1->explode(testVector,2);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox1));
+    res = stretchedBox2->explode(testVector,2);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox2));
+    res = stretchedBox3->explode(testVector,2);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox3));
+    res = stretchedBox4->explode(testVector,2);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox4));
+    res = tiltedBox1->explode(testVector,2);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox1));
+    res = tiltedBox2->explode(testVector,2);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox2));
+    res = tiltedBox3->explode(testVector,2);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox3));
+    res = tiltedBox4->explode(testVector,2);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox4));
+  }
+
+  {
+    testVector = Vector(0.5,0.5,0.5);
+    res = unitBox->explode(testVector,2);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,unitBox));
+    res = stretchedBox1->explode(testVector,2);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox1));
+    res = stretchedBox2->explode(testVector,2);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox2));
+    res = stretchedBox3->explode(testVector,2);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox3));
+    res = stretchedBox4->explode(testVector,2);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox4));
+    res = tiltedBox1->explode(testVector,2);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox1));
+    res = tiltedBox2->explode(testVector,2);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox2));
+    res = tiltedBox3->explode(testVector,2);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox3));
+    res = tiltedBox4->explode(testVector,2);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox4));
+  }
+}
+
+void BoxUnittest::BoundaryMixedTest(){
+  Vector testVector(0,0,0);
+  VECTORSET(std::list) res;
+
+  unitBox->setCondition(0,Box::Bounce);
+  unitBox->setCondition(1,Box::Ignore);
+  unitBox->setCondition(2,Box::Wrap);
+
+  stretchedBox1->setCondition(0,Box::Bounce);
+  stretchedBox1->setCondition(1,Box::Ignore);
+  stretchedBox1->setCondition(2,Box::Wrap);
+
+  stretchedBox2->setCondition(0,Box::Bounce);
+  stretchedBox2->setCondition(1,Box::Ignore);
+  stretchedBox2->setCondition(2,Box::Wrap);
+
+  stretchedBox3->setCondition(0,Box::Bounce);
+  stretchedBox3->setCondition(1,Box::Ignore);
+  stretchedBox3->setCondition(2,Box::Wrap);
+
+  stretchedBox4->setCondition(0,Box::Bounce);
+  stretchedBox4->setCondition(1,Box::Ignore);
+  stretchedBox4->setCondition(2,Box::Wrap);
+
+  tiltedBox1->setCondition(0,Box::Bounce);
+  tiltedBox1->setCondition(1,Box::Ignore);
+  tiltedBox1->setCondition(2,Box::Wrap);
+
+  tiltedBox2->setCondition(0,Box::Bounce);
+  tiltedBox2->setCondition(1,Box::Ignore);
+  tiltedBox2->setCondition(2,Box::Wrap);
+
+  tiltedBox3->setCondition(0,Box::Bounce);
+  tiltedBox3->setCondition(1,Box::Ignore);
+  tiltedBox3->setCondition(2,Box::Wrap);
+
+  tiltedBox4->setCondition(0,Box::Bounce);
+  tiltedBox4->setCondition(1,Box::Ignore);
+  tiltedBox4->setCondition(2,Box::Wrap);
+
+  {
+    testVector = Vector(0,0,0);
+    res = unitBox->explode(testVector,1);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,unitBox));
+    res = stretchedBox1->explode(testVector,1);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox1));
+    res = stretchedBox2->explode(testVector,1);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox2));
+    res = stretchedBox3->explode(testVector,1);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox3));
+    res = stretchedBox4->explode(testVector,1);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox4));
+    res = tiltedBox1->explode(testVector,1);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox1));
+    res = tiltedBox2->explode(testVector,1);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox2));
+    res = tiltedBox3->explode(testVector,1);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox3));
+    res = tiltedBox4->explode(testVector,1);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox4));
+  }
+
+  {
+    testVector = Vector(0.5,0.5,0.5);
+    res = unitBox->explode(testVector,1);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,unitBox));
+    res = stretchedBox1->explode(testVector,1);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox1));
+    res = stretchedBox2->explode(testVector,1);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox2));
+    res = stretchedBox3->explode(testVector,1);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox3));
+    res = stretchedBox4->explode(testVector,1);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox4));
+    res = tiltedBox1->explode(testVector,1);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox1));
+    res = tiltedBox2->explode(testVector,1);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox2));
+    res = tiltedBox3->explode(testVector,1);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox3));
+    res = tiltedBox4->explode(testVector,1);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox4));
+  }
+
+  {
+    testVector = Vector(0,0,0);
+    res = unitBox->explode(testVector,2);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,unitBox));
+    res = stretchedBox1->explode(testVector,2);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox1));
+    res = stretchedBox2->explode(testVector,2);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox2));
+    res = stretchedBox3->explode(testVector,2);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox3));
+    res = stretchedBox4->explode(testVector,2);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox4));
+    res = tiltedBox1->explode(testVector,2);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox1));
+    res = tiltedBox2->explode(testVector,2);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox2));
+    res = tiltedBox3->explode(testVector,2);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox3));
+    res = tiltedBox4->explode(testVector,2);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox4));
+  }
+
+  {
+    testVector = Vector(0.5,0.5,0.5);
+    res = unitBox->explode(testVector,2);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,unitBox));
+    res = stretchedBox1->explode(testVector,2);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox1));
+    res = stretchedBox2->explode(testVector,2);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox2));
+    res = stretchedBox3->explode(testVector,2);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox3));
+    res = stretchedBox4->explode(testVector,2);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox4));
+    res = tiltedBox1->explode(testVector,2);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox1));
+    res = tiltedBox2->explode(testVector,2);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox2));
+    res = tiltedBox3->explode(testVector,2);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox3));
+    res = tiltedBox4->explode(testVector,2);
+    CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox4));
+  }
+
+}
Index: src/unittests/BoxUnittest.hpp
===================================================================
--- src/unittests/BoxUnittest.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
+++ src/unittests/BoxUnittest.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -0,0 +1,56 @@
+/*
+ * BoxUnittest.hpp
+ *
+ *  Created on: Jul 30, 2010
+ *      Author: crueger
+ */
+
+#ifndef BOXUNITTEST_HPP_
+#define BOXUNITTEST_HPP_
+
+#include <cppunit/extensions/HelperMacros.h>
+
+class Matrix;
+class Box;
+
+class BoxUnittest : public CppUnit::TestFixture
+{
+  CPPUNIT_TEST_SUITE( BoxUnittest );
+  CPPUNIT_TEST ( setBoxTest );
+  CPPUNIT_TEST ( translateInOutTest );
+  CPPUNIT_TEST ( isInsideTest );
+  CPPUNIT_TEST ( WrapExplodeTest );
+  CPPUNIT_TEST ( BoundaryBounceTest );
+  CPPUNIT_TEST ( BoundaryIgnoreTest );
+  CPPUNIT_TEST ( BoundaryMixedTest );
+  CPPUNIT_TEST_SUITE_END();
+
+public:
+  void setUp();
+  void tearDown();
+
+  void setBoxTest();
+  void translateInOutTest();
+  void isInsideTest();
+  void WrapExplodeTest();
+  void BoundaryBounceTest();
+  void BoundaryIgnoreTest();
+  void BoundaryMixedTest();
+
+  Matrix *unit;
+  Matrix *zero;
+  Matrix *invertible;
+  Matrix *uninvertible;
+
+  Box *unitBox;
+  Box *stretchedBox1;
+  Box *stretchedBox2;
+  Box *stretchedBox3;
+  Box *stretchedBox4;
+  Box *tiltedBox1;
+  Box *tiltedBox2;
+  Box *tiltedBox3;
+  Box *tiltedBox4;
+};
+
+#endif /* BOXUNITTEST_HPP_ */
Index: src/unittests/CacheableTest.cpp
===================================================================
--- src/unittests/CacheableTest.cpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/unittests/CacheableTest.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -5,4 +5,9 @@
  *      Author: crueger
  */
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
 
 #include "CacheableTest.hpp"
Index: src/unittests/CountBondsUnitTest.cpp
===================================================================
--- src/unittests/CountBondsUnitTest.cpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/unittests/CountBondsUnitTest.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -6,4 +6,8 @@
  */
 
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
 
 using namespace std;
@@ -54,16 +58,16 @@
   Walker = World::getInstance().createAtom();
   CPPUNIT_ASSERT(Walker != NULL && "could not create atom");
-  Walker->type = hydrogen;
-  *Walker->node = Vector(-0.2418, 0.9350, 0. );
+  Walker->setType(hydrogen);
+  Walker->setPosition(Vector(-0.2418, 0.9350, 0. ));
   TestMolecule1->AddAtom(Walker);
   Walker = World::getInstance().createAtom();
   CPPUNIT_ASSERT(Walker != NULL && "could not create atom");
-  Walker->type = hydrogen;
-  *Walker->node = Vector(0.9658, 0., 0. );
+  Walker->setType(hydrogen);
+  Walker->setPosition(Vector(0.9658, 0., 0. ));
   TestMolecule1->AddAtom(Walker);
   Walker = World::getInstance().createAtom();
   CPPUNIT_ASSERT(Walker != NULL && "could not create atom");
-  Walker->type = oxygen;
-  *Walker->node = Vector(0., 0., 0. );
+  Walker->setType(oxygen);
+  Walker->setPosition(Vector(0., 0., 0. ));
   TestMolecule1->AddAtom(Walker);
 
@@ -72,16 +76,16 @@
   Walker = World::getInstance().createAtom();
   CPPUNIT_ASSERT(Walker != NULL && "could not create atom");
-  Walker->type = hydrogen;
-  *Walker->node = Vector(-0.2418, 0.9350, 0. );
+  Walker->setType(hydrogen);
+  Walker->setPosition(Vector(-0.2418, 0.9350, 0. ));
   TestMolecule2->AddAtom(Walker);
   Walker = World::getInstance().createAtom();
   CPPUNIT_ASSERT(Walker != NULL && "could not create atom");
-  Walker->type = hydrogen;
-  *Walker->node = Vector(0.9658, 0., 0. );
+  Walker->setType(hydrogen);
+  Walker->setPosition(Vector(0.9658, 0., 0. ));
   TestMolecule2->AddAtom(Walker);
   Walker = World::getInstance().createAtom();
   CPPUNIT_ASSERT(Walker != NULL && "could not create atom");
-  Walker->type = oxygen;
-  *Walker->node = Vector(0., 0., 0. );
+  Walker->setType(oxygen);
+  Walker->setPosition(Vector(0., 0., 0. ));
   TestMolecule2->AddAtom(Walker);
 
Index: src/unittests/DummyUI.hpp
===================================================================
--- src/unittests/DummyUI.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
+++ src/unittests/DummyUI.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -0,0 +1,60 @@
+/*
+ * DummyUI.h
+ *
+ *  Created on: Jul 29, 2010
+ *      Author: crueger
+ */
+
+#ifndef DUMMYUI_H_
+#define DUMMYUI_H_
+
+#include "UIElements/UIFactory.hpp"
+#include "UIElements/Dialog.hpp"
+
+class DummyDialog : public Dialog
+{
+public:
+  DummyDialog(){}
+  virtual ~DummyDialog(){}
+
+  virtual void queryEmpty(const char *, std::string = ""){}
+  virtual void queryBoolean(const char *, std::string = ""){}
+  virtual void queryInt(const char *, std::string = ""){}
+  virtual void queryInts(const char *, std::string = ""){}
+  virtual void queryString(const char*, std::string = ""){}
+  virtual void queryStrings(const char*, std::string = ""){}
+  virtual void queryDouble(const char*, std::string = ""){}
+  virtual void queryDoubles(const char*, std::string = ""){}
+  virtual void queryAtom(const char*,std::string = ""){}
+  virtual void queryAtoms(const char*,std::string = ""){}
+  virtual void queryMolecule(const char*,std::string = ""){}
+  virtual void queryMolecules(const char*,std::string = ""){}
+  virtual void queryVector(const char*,bool, std::string = ""){}
+  virtual void queryVectors(const char*,bool, std::string = ""){}
+  virtual void queryBox(const char*, std::string = ""){}
+  virtual void queryElement(const char*, std::string = ""){}
+  virtual void queryElements(const char*, std::string = ""){}
+};
+
+class DummyUIFactory : public UIFactory
+{
+public:
+  virtual ~DummyUIFactory(){}
+
+  virtual Dialog* makeDialog(){return new DummyDialog;}
+  virtual MainWindow* makeMainWindow(){return 0;}
+
+  struct description : public UIFactory::factoryDescription {
+    description():
+        UIFactory::factoryDescription("Dummy")
+    {}
+    virtual ~description(){}
+
+    virtual UIFactory* makeFactory(){return new DummyUIFactory;};
+  };
+
+protected:
+  DummyUIFactory(){}
+};
+
+#endif /* DUMMYUI_H_ */
Index: src/unittests/FormulaUnittest.cpp
===================================================================
--- src/unittests/FormulaUnittest.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
+++ src/unittests/FormulaUnittest.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -0,0 +1,263 @@
+/*
+ * FormulaUnittest.cpp
+ *
+ *  Created on: Jul 21, 2010
+ *      Author: crueger
+ */
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "FormulaUnittest.hpp"
+
+#include <cppunit/CompilerOutputter.h>
+#include <cppunit/extensions/TestFactoryRegistry.h>
+#include <cppunit/ui/text/TestRunner.h>
+
+#include <iostream>
+
+#include "Formula.hpp"
+#include "World.hpp"
+
+#ifdef HAVE_TESTRUNNER
+#include "UnitTestMain.hpp"
+#endif /*HAVE_TESTRUNNER*/
+
+using namespace std;
+
+CPPUNIT_TEST_SUITE_REGISTRATION( FormulaUnittest );
+
+void FormulaUnittest::setUp(){}
+void FormulaUnittest::tearDown(){
+  World::purgeInstance();
+}
+
+void FormulaUnittest::baseTest(){
+  Formula formula;
+  CPPUNIT_ASSERT_EQUAL(formula.getElementCount(),(unsigned int)0);
+  CPPUNIT_ASSERT(formula.begin()==formula.end());
+
+  // test some one letter element names
+  formula += "H";
+  CPPUNIT_ASSERT_EQUAL(formula["H"],(unsigned int)1);
+  CPPUNIT_ASSERT_EQUAL(formula["O"],(unsigned int)0);
+  CPPUNIT_ASSERT_EQUAL(formula["C"],(unsigned int)0);
+  CPPUNIT_ASSERT_EQUAL(formula["He"],(unsigned int)0);
+  CPPUNIT_ASSERT_EQUAL(formula.getElementCount(),(unsigned int)1);
+  CPPUNIT_ASSERT(formula.begin()!=formula.end());
+  formula += "H";
+  CPPUNIT_ASSERT_EQUAL(formula["H"],(unsigned int)2);
+  CPPUNIT_ASSERT_EQUAL(formula["O"],(unsigned int)0);
+  CPPUNIT_ASSERT_EQUAL(formula["C"],(unsigned int)0);
+  CPPUNIT_ASSERT_EQUAL(formula["He"],(unsigned int)0);
+  CPPUNIT_ASSERT_EQUAL(formula.getElementCount(),(unsigned int)1);
+  CPPUNIT_ASSERT(formula.begin()!=formula.end());
+  formula += "O";
+  CPPUNIT_ASSERT_EQUAL(formula["H"],(unsigned int)2);
+  CPPUNIT_ASSERT_EQUAL(formula["O"],(unsigned int)1);
+  CPPUNIT_ASSERT_EQUAL(formula["C"],(unsigned int)0);
+  CPPUNIT_ASSERT_EQUAL(formula["He"],(unsigned int)0);
+  CPPUNIT_ASSERT_EQUAL(formula.getElementCount(),(unsigned int)2);
+  CPPUNIT_ASSERT(formula.begin()!=formula.end());
+
+  // test copy constructor
+  Formula formula2=formula;
+  CPPUNIT_ASSERT_EQUAL(formula2["H"],(unsigned int)2);
+  CPPUNIT_ASSERT_EQUAL(formula2["O"],(unsigned int)1);
+  CPPUNIT_ASSERT_EQUAL(formula2["C"],(unsigned int)0);
+  CPPUNIT_ASSERT_EQUAL(formula["He"],(unsigned int)0);
+  CPPUNIT_ASSERT_EQUAL(formula2.getElementCount(),(unsigned int)2);
+  CPPUNIT_ASSERT(formula2.begin()!=formula2.end());
+
+  // test Assignment operator
+  formula2=Formula();
+  CPPUNIT_ASSERT_EQUAL(formula2["H"],(unsigned int)0);
+  CPPUNIT_ASSERT_EQUAL(formula2["O"],(unsigned int)0);
+  CPPUNIT_ASSERT_EQUAL(formula2["C"],(unsigned int)0);
+  CPPUNIT_ASSERT_EQUAL(formula["He"],(unsigned int)0);
+  CPPUNIT_ASSERT_EQUAL(formula2.getElementCount(),(unsigned int)0);
+  CPPUNIT_ASSERT(formula2.begin()==formula2.end());
+
+  // test comparison
+  CPPUNIT_ASSERT(formula!=formula2);
+  Formula formula3;
+  formula3 += "H";
+  formula3 += "H";
+  formula3 += "O";
+  CPPUNIT_ASSERT(formula==formula3);
+
+  // inequality
+  formula3 += "O";
+  CPPUNIT_ASSERT(formula!=formula3);
+
+  // after removing it should be fine again
+  formula3 -= "O";
+  CPPUNIT_ASSERT(formula==formula3);
+
+  // add something from the far end, to test resizing
+  formula3 += "Rh";
+  CPPUNIT_ASSERT(formula!=formula3);
+  formula3 -= "Rh";
+  CPPUNIT_ASSERT(formula==formula3);
+
+  // removal of elements
+  formula -= "H";
+  CPPUNIT_ASSERT_EQUAL(formula["H"],(unsigned int)1);
+  CPPUNIT_ASSERT_EQUAL(formula["O"],(unsigned int)1);
+  CPPUNIT_ASSERT_EQUAL(formula["C"],(unsigned int)0);
+  CPPUNIT_ASSERT_EQUAL(formula["He"],(unsigned int)0);
+  CPPUNIT_ASSERT_EQUAL(formula.getElementCount(),(unsigned int)2);
+  CPPUNIT_ASSERT(formula.begin()!=formula.end());
+
+  formula -= "O";
+  CPPUNIT_ASSERT_EQUAL(formula["H"],(unsigned int)1);
+  CPPUNIT_ASSERT_EQUAL(formula["O"],(unsigned int)0);
+  CPPUNIT_ASSERT_EQUAL(formula["C"],(unsigned int)0);
+  CPPUNIT_ASSERT_EQUAL(formula["He"],(unsigned int)0);
+  CPPUNIT_ASSERT_EQUAL(formula.getElementCount(),(unsigned int)1);
+  CPPUNIT_ASSERT(formula.begin()!=formula.end());
+
+  formula -= "H";
+  CPPUNIT_ASSERT_EQUAL(formula["H"],(unsigned int)0);
+  CPPUNIT_ASSERT_EQUAL(formula["O"],(unsigned int)0);
+  CPPUNIT_ASSERT_EQUAL(formula["C"],(unsigned int)0);
+  CPPUNIT_ASSERT_EQUAL(formula["He"],(unsigned int)0);
+  CPPUNIT_ASSERT_EQUAL(formula.getElementCount(),(unsigned int)0);
+  CPPUNIT_ASSERT(formula.begin()==formula.end());
+}
+
+void FormulaUnittest::parseTest(){
+  {
+    Formula formula("");
+    CPPUNIT_ASSERT_EQUAL(formula["H"],(unsigned int)0);
+    CPPUNIT_ASSERT_EQUAL(formula["O"],(unsigned int)0);
+    CPPUNIT_ASSERT_EQUAL(formula["C"],(unsigned int)0);
+    CPPUNIT_ASSERT_EQUAL(formula["He"],(unsigned int)0);
+  }
+  {
+    Formula formula("H");
+    CPPUNIT_ASSERT_EQUAL(formula["H"],(unsigned int)1);
+    CPPUNIT_ASSERT_EQUAL(formula["O"],(unsigned int)0);
+    CPPUNIT_ASSERT_EQUAL(formula["C"],(unsigned int)0);
+    CPPUNIT_ASSERT_EQUAL(formula["He"],(unsigned int)0);
+  }
+  {
+    Formula formula("H2");
+    CPPUNIT_ASSERT_EQUAL(formula["H"],(unsigned int)2);
+    CPPUNIT_ASSERT_EQUAL(formula["O"],(unsigned int)0);
+    CPPUNIT_ASSERT_EQUAL(formula["C"],(unsigned int)0);
+    CPPUNIT_ASSERT_EQUAL(formula["He"],(unsigned int)0);
+  }
+  {
+    Formula formula("H2O");
+    CPPUNIT_ASSERT_EQUAL(formula["H"],(unsigned int)2);
+    CPPUNIT_ASSERT_EQUAL(formula["O"],(unsigned int)1);
+    CPPUNIT_ASSERT_EQUAL(formula["C"],(unsigned int)0);
+    CPPUNIT_ASSERT_EQUAL(formula["He"],(unsigned int)0);
+  }
+  {
+    Formula formula("CH3COOH");
+    CPPUNIT_ASSERT_EQUAL(formula["H"],(unsigned int)4);
+    CPPUNIT_ASSERT_EQUAL(formula["O"],(unsigned int)2);
+    CPPUNIT_ASSERT_EQUAL(formula["C"],(unsigned int)2);
+    CPPUNIT_ASSERT_EQUAL(formula["He"],(unsigned int)0);
+  }
+  {
+    Formula formula("CH3COONa");
+    CPPUNIT_ASSERT_EQUAL(formula["H"],(unsigned int)3);
+    CPPUNIT_ASSERT_EQUAL(formula["O"],(unsigned int)2);
+    CPPUNIT_ASSERT_EQUAL(formula["C"],(unsigned int)2);
+    CPPUNIT_ASSERT_EQUAL(formula["Na"],(unsigned int)1);
+    CPPUNIT_ASSERT_EQUAL(formula["He"],(unsigned int)0);
+  }
+  {
+    Formula formula("NaCH3COO");
+    CPPUNIT_ASSERT_EQUAL(formula["H"],(unsigned int)3);
+    CPPUNIT_ASSERT_EQUAL(formula["O"],(unsigned int)2);
+    CPPUNIT_ASSERT_EQUAL(formula["C"],(unsigned int)2);
+    CPPUNIT_ASSERT_EQUAL(formula["Na"],(unsigned int)1);
+    CPPUNIT_ASSERT_EQUAL(formula["He"],(unsigned int)0);
+  }
+  {
+    Formula formula("Na2CO3");
+    CPPUNIT_ASSERT_EQUAL(formula["H"],(unsigned int)0);
+    CPPUNIT_ASSERT_EQUAL(formula["O"],(unsigned int)3);
+    CPPUNIT_ASSERT_EQUAL(formula["C"],(unsigned int)1);
+    CPPUNIT_ASSERT_EQUAL(formula["Na"],(unsigned int)2);
+    CPPUNIT_ASSERT_EQUAL(formula["He"],(unsigned int)0);
+  }
+  {
+    Formula formula("CH2(COOH)2");
+    CPPUNIT_ASSERT_EQUAL(formula["H"],(unsigned int)4);
+    CPPUNIT_ASSERT_EQUAL(formula["O"],(unsigned int)4);
+    CPPUNIT_ASSERT_EQUAL(formula["C"],(unsigned int)3);
+    CPPUNIT_ASSERT_EQUAL(formula["Na"],(unsigned int)0);
+    CPPUNIT_ASSERT_EQUAL(formula["He"],(unsigned int)0);
+  }
+  {
+    Formula formula("K4[Fe(CN)6]");
+    CPPUNIT_ASSERT_EQUAL(formula["H"],(unsigned int)0);
+    CPPUNIT_ASSERT_EQUAL(formula["O"],(unsigned int)0);
+    CPPUNIT_ASSERT_EQUAL(formula["C"],(unsigned int)6);
+    CPPUNIT_ASSERT_EQUAL(formula["Na"],(unsigned int)0);
+    CPPUNIT_ASSERT_EQUAL(formula["He"],(unsigned int)0);
+    CPPUNIT_ASSERT_EQUAL(formula["K"],(unsigned int)4);
+    CPPUNIT_ASSERT_EQUAL(formula["Fe"],(unsigned int)1);
+    CPPUNIT_ASSERT_EQUAL(formula["N"],(unsigned int)6);
+  }
+  {
+    Formula formula("[CrCl3(H2O)3]");
+    CPPUNIT_ASSERT_EQUAL(formula["H"],(unsigned int)6);
+    CPPUNIT_ASSERT_EQUAL(formula["O"],(unsigned int)3);
+    CPPUNIT_ASSERT_EQUAL(formula["C"],(unsigned int)0);
+    CPPUNIT_ASSERT_EQUAL(formula["Na"],(unsigned int)0);
+    CPPUNIT_ASSERT_EQUAL(formula["He"],(unsigned int)0);
+    CPPUNIT_ASSERT_EQUAL(formula["Cr"],(unsigned int)1);
+    CPPUNIT_ASSERT_EQUAL(formula["Cl"],(unsigned int)3);
+  }
+  {
+    Formula formula("Mg3[Fe(CN)6]2");
+    CPPUNIT_ASSERT_EQUAL(formula["H"],(unsigned int)0);
+    CPPUNIT_ASSERT_EQUAL(formula["O"],(unsigned int)0);
+    CPPUNIT_ASSERT_EQUAL(formula["C"],(unsigned int)12);
+    CPPUNIT_ASSERT_EQUAL(formula["Na"],(unsigned int)0);
+    CPPUNIT_ASSERT_EQUAL(formula["He"],(unsigned int)0);
+    CPPUNIT_ASSERT_EQUAL(formula["Mg"],(unsigned int)3);
+    CPPUNIT_ASSERT_EQUAL(formula["Fe"],(unsigned int)2);
+    CPPUNIT_ASSERT_EQUAL(formula["N"],(unsigned int)12);
+  }
+  {
+    Formula formula("Na[Fe((HO2CCH2)2NCH2CH2N(CH2CO2H)2)]");
+    CPPUNIT_ASSERT_EQUAL(formula["H"],(unsigned int)16);
+    CPPUNIT_ASSERT_EQUAL(formula["O"],(unsigned int)8);
+    CPPUNIT_ASSERT_EQUAL(formula["C"],(unsigned int)10);
+    CPPUNIT_ASSERT_EQUAL(formula["Na"],(unsigned int)1);
+    CPPUNIT_ASSERT_EQUAL(formula["He"],(unsigned int)0);
+    CPPUNIT_ASSERT_EQUAL(formula["Mg"],(unsigned int)0);
+    CPPUNIT_ASSERT_EQUAL(formula["Fe"],(unsigned int)1);
+    CPPUNIT_ASSERT_EQUAL(formula["N"],(unsigned int)2);
+  }
+  {
+    CPPUNIT_ASSERT_THROW(Formula formula("74107"),ParseError);
+    CPPUNIT_ASSERT_THROW(Formula formula("  "),ParseError);
+    CPPUNIT_ASSERT_THROW(Formula formula("nAcL"),ParseError);
+    CPPUNIT_ASSERT_THROW(Formula formula("NAcL"),ParseError);
+    CPPUNIT_ASSERT_THROW(Formula formula("Na Cl"),ParseError);
+    CPPUNIT_ASSERT_THROW(Formula formula("1NaCl"),ParseError);
+    CPPUNIT_ASSERT_THROW(Formula formula("Mag"),ParseError);
+    CPPUNIT_ASSERT_THROW(Formula formula("AgCl)"),ParseError);
+    CPPUNIT_ASSERT_THROW(Formula formula("(Na"),ParseError);
+    CPPUNIT_ASSERT_THROW(Formula formula("(Mag)"),ParseError);
+    CPPUNIT_ASSERT_THROW(Formula formula("MgCl2)"),ParseError);
+    CPPUNIT_ASSERT_THROW(Formula formula("((MgCl2)"),ParseError);
+    CPPUNIT_ASSERT_THROW(Formula formula("(MgCl2))"),ParseError);
+    CPPUNIT_ASSERT_THROW(Formula formula("(MgCl2]"),ParseError);
+    CPPUNIT_ASSERT_THROW(Formula formula("[MgCl2)"),ParseError);
+    CPPUNIT_ASSERT_THROW(Formula formula("N(aCl"),ParseError);
+    CPPUNIT_ASSERT_THROW(Formula formula("Na()Cl"),ParseError);
+  }
+
+
+}
Index: src/unittests/FormulaUnittest.hpp
===================================================================
--- src/unittests/FormulaUnittest.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
+++ src/unittests/FormulaUnittest.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -0,0 +1,28 @@
+/*
+ * FormulaUnittest.hpp
+ *
+ *  Created on: Jul 21, 2010
+ *      Author: crueger
+ */
+
+#ifndef FORMULAUNITTEST_HPP_
+#define FORMULAUNITTEST_HPP_
+
+#include <cppunit/extensions/HelperMacros.h>
+
+class FormulaUnittest : public CppUnit::TestFixture
+{
+  CPPUNIT_TEST_SUITE( FormulaUnittest );
+  CPPUNIT_TEST ( baseTest );
+  CPPUNIT_TEST ( parseTest );
+  CPPUNIT_TEST_SUITE_END();
+
+public:
+  void setUp();
+  void tearDown();
+
+  void baseTest();
+  void parseTest();
+};
+
+#endif /* FORMULAUNITTEST_HPP_ */
Index: src/unittests/LineUnittest.cpp
===================================================================
--- src/unittests/LineUnittest.cpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/unittests/LineUnittest.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -6,7 +6,12 @@
  */
 
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
 #include "LineUnittest.hpp"
 
-#include "vector.hpp"
+#include "LinearAlgebra/Vector.hpp"
 #include "Exceptions/LinearDependenceException.hpp"
 #include "Exceptions/SkewException.hpp"
@@ -17,4 +22,5 @@
 
 #include <iostream>
+#include <cmath>
 
 using namespace std;
@@ -352,2 +358,52 @@
   CPPUNIT_ASSERT_EQUAL(fixture,zeroVec);
 }
+
+void LineUnittest::sphereIntersectionTest(){
+  {
+    std::vector<Vector> res = la1->getSphereIntersections();
+    CPPUNIT_ASSERT_EQUAL(res.size(),(size_t)2);
+    CPPUNIT_ASSERT(testDirection(res[0],e1));
+    CPPUNIT_ASSERT(testDirection(res[1],e1));
+    CPPUNIT_ASSERT(res[0]!=res[1]);
+  }
+
+  {
+    std::vector<Vector> res = la2->getSphereIntersections();
+    CPPUNIT_ASSERT_EQUAL(res.size(),(size_t)2);
+    CPPUNIT_ASSERT(testDirection(res[0],e2));
+    CPPUNIT_ASSERT(testDirection(res[1],e2));
+    CPPUNIT_ASSERT(res[0]!=res[1]);
+  }
+
+  {
+    std::vector<Vector> res = la3->getSphereIntersections();
+    CPPUNIT_ASSERT_EQUAL(res.size(),(size_t)2);
+    CPPUNIT_ASSERT(testDirection(res[0],e3));
+    CPPUNIT_ASSERT(testDirection(res[1],e3));
+    CPPUNIT_ASSERT(res[0]!=res[1]);
+  }
+
+  {
+    std::vector<Vector> res = lp1->getSphereIntersections();
+    CPPUNIT_ASSERT_EQUAL(res.size(),(size_t)2);
+    CPPUNIT_ASSERT((res[0]==e1) || (res[0]==e2));
+    CPPUNIT_ASSERT((res[1]==e1) || (res[1]==e2));
+    CPPUNIT_ASSERT(res[0]!=res[1]);
+  }
+
+  {
+    std::vector<Vector> res = lp2->getSphereIntersections();
+    CPPUNIT_ASSERT_EQUAL(res.size(),(size_t)2);
+    CPPUNIT_ASSERT((res[0]==e2) || (res[0]==e3));
+    CPPUNIT_ASSERT((res[1]==e2) || (res[1]==e3));
+    CPPUNIT_ASSERT(res[0]!=res[1]);
+  }
+
+  {
+    std::vector<Vector> res = lp3->getSphereIntersections();
+    CPPUNIT_ASSERT_EQUAL(res.size(),(size_t)2);
+    CPPUNIT_ASSERT((res[0]==e3) || (res[0]==e1));
+    CPPUNIT_ASSERT((res[1]==e3) || (res[1]==e1));
+    CPPUNIT_ASSERT(res[0]!=res[1]);
+  }
+}
Index: src/unittests/LineUnittest.hpp
===================================================================
--- src/unittests/LineUnittest.hpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/unittests/LineUnittest.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -11,5 +11,5 @@
 #include <cppunit/extensions/HelperMacros.h>
 
-#include "Line.hpp"
+#include "LinearAlgebra/Line.hpp"
 
 class LineUnittest : public CppUnit::TestFixture
@@ -22,4 +22,5 @@
   CPPUNIT_TEST ( intersectionTest );
   CPPUNIT_TEST ( rotationTest );
+  CPPUNIT_TEST ( sphereIntersectionTest );
   CPPUNIT_TEST_SUITE_END();
 
@@ -33,4 +34,5 @@
   void intersectionTest();
   void rotationTest();
+  void sphereIntersectionTest();
 
 private:
Index: src/unittests/LinkedCellUnitTest.cpp
===================================================================
--- src/unittests/LinkedCellUnitTest.cpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/unittests/LinkedCellUnitTest.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -5,4 +5,9 @@
  *      Author: heber
  */
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
 
 using namespace std;
@@ -50,6 +55,6 @@
         Walker = World::getInstance().createAtom();
         CPPUNIT_ASSERT(Walker != NULL && "could not create atom");
-        Walker->type = hydrogen;
-        *Walker->node = Vector(x, y, z );
+        Walker->setType(hydrogen);
+        Walker->setPosition(Vector(x, y, z ));
         TestMolecule->AddAtom(Walker);
       }
@@ -192,5 +197,5 @@
   atom *newAtom = World::getInstance().createAtom();
   newAtom->setName("test");
-  newAtom->x= Vector(1,1,1);
+  newAtom->setPosition(Vector(1,1,1));
   CPPUNIT_ASSERT_EQUAL( false, LC->SetIndexToNode(newAtom) );
   World::getInstance().destroyAtom(newAtom);
@@ -199,5 +204,5 @@
   newAtom = World::getInstance().createAtom();
   newAtom->setName("test");
-  newAtom->x = Vector(0,-1,0);
+  newAtom->setPosition(Vector(0,-1,0));
   CPPUNIT_ASSERT_EQUAL( false, LC->SetIndexToNode(newAtom) );
   World::getInstance().destroyAtom(newAtom);
@@ -216,5 +221,5 @@
       for (double z=0.5;z<3;z+=1.) {
         tester = Vector(x,y,z);
-        CPPUNIT_ASSERT_EQUAL( true, LC->SetIndexToVector(&tester) );
+        CPPUNIT_ASSERT_EQUAL( true, LC->SetIndexToVector(tester) );
       }
   // check corners of each cell
@@ -224,5 +229,5 @@
         tester= Vector(x,y,z);
         cout << "Tester is at " << tester << "." << endl;
-        CPPUNIT_ASSERT_EQUAL( true, LC->SetIndexToVector(&tester) );
+        CPPUNIT_ASSERT_EQUAL( true, LC->SetIndexToVector(tester) );
       }
   // check out of bounds
@@ -232,10 +237,10 @@
         tester = Vector(x,y,z);
         cout << "The following test is supposed to fail and produce an ERROR." << endl;
-        CPPUNIT_ASSERT_EQUAL( false, LC->SetIndexToVector(&tester) );
+        CPPUNIT_ASSERT_EQUAL( false, LC->SetIndexToVector(tester) );
       }
   // check nonsense vectors
   tester= Vector(-423598,3245978,29349);
   cout << "The following test is supposed to fail and produce an ERROR." << endl;
-  CPPUNIT_ASSERT_EQUAL( false, LC->SetIndexToVector(&tester) );
+  CPPUNIT_ASSERT_EQUAL( false, LC->SetIndexToVector(tester) );
 };
 
@@ -249,5 +254,5 @@
 
   tester= Vector(0.5,0.5,0.5);
-  LC->SetIndexToVector(&tester);
+  LC->SetIndexToVector(tester);
   LC->GetNeighbourBounds(lower, upper);
   for (int i=0;i<NDIM;i++)
@@ -268,5 +273,5 @@
   // get all atoms
   tester= Vector(1.5,1.5,1.5);
-  CPPUNIT_ASSERT_EQUAL ( true, LC->SetIndexToVector(&tester) );
+  CPPUNIT_ASSERT_EQUAL ( true, LC->SetIndexToVector(tester) );
   ListOfPoints = LC->GetallNeighbours();
   size = ListOfPoints->size();
@@ -285,10 +290,10 @@
   // get all atoms in one corner
   tester= Vector(0.5, 0.5, 0.5);
-  CPPUNIT_ASSERT_EQUAL ( true, LC->SetIndexToVector(&tester) );
+  CPPUNIT_ASSERT_EQUAL ( true, LC->SetIndexToVector(tester) );
   ListOfPoints = LC->GetallNeighbours();
   size=ListOfPoints->size();
   CPPUNIT_ASSERT_EQUAL( (size_t)8, size );
   for(molecule::iterator iter = TestMolecule->begin(); iter != TestMolecule->end(); ++iter){
-    if (((*iter)->x[0] <2) && ((*iter)->x[1] <2) && ((*iter)->x[2] <2)) {
+    if (((*iter)->at(0) <2) && ((*iter)->at(1) <2) && ((*iter)->at(2) <2)) {
       ListOfPoints->remove(*iter);
       size--;
@@ -303,5 +308,5 @@
   // get all atoms from one corner
   tester = Vector(0.5, 0.5, 0.5);
-  CPPUNIT_ASSERT_EQUAL ( true, LC->SetIndexToVector(&tester) );
+  CPPUNIT_ASSERT_EQUAL ( true, LC->SetIndexToVector(tester) );
   ListOfPoints = LC->GetallNeighbours(3);
   size=ListOfPoints->size();
@@ -329,10 +334,10 @@
   // get all points around central arom with radius 1.
   tester= Vector(1.5,1.5,1.5);
-  CPPUNIT_ASSERT_EQUAL ( true, LC->SetIndexToVector(&tester) );
+  CPPUNIT_ASSERT_EQUAL ( true, LC->SetIndexToVector(tester) );
   ListOfPoints = LC->GetPointsInsideSphere(1., &tester);
   size = ListOfPoints->size();
   CPPUNIT_ASSERT_EQUAL( (size_t)7, size );
   for(molecule::iterator iter = TestMolecule->begin(); iter!=TestMolecule->end();++iter){
-    if (((*iter)->x.DistanceSquared(tester) - 1.) < MYEPSILON ) {
+    if (((*iter)->DistanceSquared(tester) - 1.) < MYEPSILON ) {
       ListOfPoints->remove(*iter);
       size--;
Index: src/unittests/Makefile.am
===================================================================
--- src/unittests/Makefile.am	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/unittests/Makefile.am	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -7,8 +7,6 @@
 AM_CXXFLAGS = $(CPPUNIT_CFLAGS)
 
-MENUTESTS = \
-  ActionSequenceTest
-
 TESTS = \
+  ActionSequenceTest \
   ActOnAllUnitTest \
   AnalysisBondsUnitTests \
@@ -18,7 +16,10 @@
   atomsCalculationTest \
   AtomDescriptorTest \
+  BaseShapesUnitTest \
   BondGraphUnitTest \
+  BoxUnittest \
   CacheableTest \
   CountBondsUnitTest \
+  FormulaUnittest \
   GSLMatrixSymmetricUnitTest \
   GSLMatrixUnitTest \
@@ -31,6 +32,5 @@
   LogUnitTest \
   manipulateAtomsTest \
-  MemoryUsageObserverUnitTest \
-  MemoryAllocatorUnitTest \
+  MatrixUnittest \
   MoleculeDescriptorTest \
   ObserverTest \
@@ -38,4 +38,5 @@
   periodentafelTest \
   PlaneUnittest \
+  ShapeUnittest \
   SingletonTest \
   StackClassUnitTest \
@@ -43,6 +44,5 @@
   Tesselation_BoundaryTriangleUnitTest \
   Tesselation_InOutsideUnitTest \
-  VectorUnitTest \
-  ${MENUTESTS}
+  VectorUnitTest
   
   
@@ -50,7 +50,18 @@
 noinst_PROGRAMS = $(TESTS) TestRunner
 
-GSLLIBS = ../libgslwrapper.a $(BOOST_LIB) ${BOOST_THREAD_LIB}
-ALLLIBS = ../libmolecuilder.a ${GSLLIBS} 
-PARSERLIBS = ../libparser.a ${ALLLIBS} 
+GSLLIBS = \
+	../LinearAlgebra/libMolecuilderLinearAlgebra-@MOLECUILDER_API_VERSION@.la \
+	../Exceptions/libMolecuilderExceptions-@MOLECUILDER_API_VERSION@.la \
+	../Helpers/libMolecuilderHelpers-@MOLECUILDER_API_VERSION@.la \
+	$(BOOST_LIB) \
+	${BOOST_THREAD_LIB}
+ALLLIBS = \
+	../Actions/libMolecuilderActions-@MOLECUILDER_API_VERSION@.la \
+	${PARSERLIBS} \
+	../libMolecuilder-@MOLECUILDER_API_VERSION@.la \
+	${GSLLIBS} \
+	${BOOST_PROGRAM_OPTIONS_LIB}
+PARSERLIBS = ../Parser/libMolecuilderParser-@MOLECUILDER_API_VERSION@.la
+UILIBS = ../UIElements/libMolecuilderUI-@MOLECUILDER_API_VERSION@.la  
 
 TESTSOURCES = \
@@ -63,7 +74,10 @@
   AtomDescriptorTest.cpp \
   atomsCalculationTest.cpp \
+  BaseShapesUnittest.cpp \
   bondgraphunittest.cpp \
+  BoxUnittest.cpp \
   CacheableTest.cpp \
   CountBondsUnitTest.cpp \
+  FormulaUnittest.cpp \
   gslmatrixsymmetricunittest.cpp \
   gslmatrixunittest.cpp \
@@ -75,7 +89,6 @@
   listofbondsunittest.cpp \
   logunittest.cpp \
+  MatrixUnittest.cpp \
   manipulateAtomsTest.cpp \
-  memoryallocatorunittest.cpp  \
-  memoryusageobserverunittest.cpp \
   MoleculeDescriptorTest.cpp \
   ObserverTest.cpp \
@@ -83,4 +96,5 @@
   periodentafelTest.cpp \
   PlaneUnittest.cpp \
+  ShapeUnittest.cpp \
   SingletonTest.cpp \
   stackclassunittest.cpp \
@@ -99,7 +113,10 @@
   AtomDescriptorTest.hpp \
   atomsCalculationTest.hpp \
+  BaseShapesUnittest.hpp \
   bondgraphunittest.hpp \
+  BoxUnittest.hpp \
   CacheableTest.hpp \
   CountBondsUnitTest.hpp \
+  FormulaUnittest.hpp \
   gslmatrixsymmetricunittest.hpp \
   gslmatrixunittest.hpp \
@@ -112,8 +129,8 @@
   logunittest.hpp \
   manipulateAtomsTest.hpp \
-  memoryallocatorunittest.hpp  \
-  memoryusageobserverunittest.hpp \
+  MatrixUnittest.hpp \
   MoleculeDescriptorTest.hpp \
   periodentafelTest.hpp \
+  ParserUnitTest.hpp \
   PlaneUnittest.hpp \
   ObserverTest.hpp \
@@ -126,6 +143,6 @@
   
 
-ActionSequenceTest_SOURCES = UnitTestMain.cpp ../../../TestRunnerClient.hpp ActionSequenceTest.cpp ActionSequenceTest.hpp
-ActionSequenceTest_LDADD = ${ALLLIBS}
+ActionSequenceTest_SOURCES = UnitTestMain.cpp ActionSequenceTest.cpp ActionSequenceTest.hpp
+ActionSequenceTest_LDADD = ${UILIBS} ${ALLLIBS}
 
 ActOnAllUnitTest_SOURCES = UnitTestMain.cpp ../test/ActOnAllTest.hpp ActOnAllUnitTest.cpp ActOnAllUnitTest.hpp
@@ -150,7 +167,13 @@
 AtomDescriptorTest_LDADD = ${ALLLIBS}
 
+BaseShapesUnitTest_SOURCES = UnitTestMain.cpp BaseShapesUnittest.cpp BaseShapesUnittest.hpp
+BaseShapesUnitTest_LDADD = ${ALLLIBS}
+
 BondGraphUnitTest_SOURCES = UnitTestMain.cpp bondgraphunittest.cpp bondgraphunittest.hpp
 BondGraphUnitTest_LDADD = ${ALLLIBS}
 
+BoxUnittest_SOURCES = UnitTestMain.cpp BoxUnittest.cpp BoxUnittest.hpp
+BoxUnittest_LDADD = ${ALLLIBS}
+
 CacheableTest_SOURCES = UnitTestMain.cpp CacheableTest.cpp CacheableTest.hpp
 CacheableTest_LDADD = ${ALLLIBS}
@@ -159,12 +182,15 @@
 CountBondsUnitTest_LDADD = ${ALLLIBS}
 
+FormulaUnittest_SOURCES = UnitTestMain.cpp FormulaUnittest.cpp FormulaUnittest.hpp
+FormulaUnittest_LDADD = ${ALLLIBS}
+
 GSLMatrixSymmetricUnitTest_SOURCES = UnitTestMain.cpp gslmatrixsymmetricunittest.cpp gslmatrixsymmetricunittest.hpp
-GSLMatrixSymmetricUnitTest_LDADD = ${GSLLIBS}
+GSLMatrixSymmetricUnitTest_LDADD = ${ALLLIBS}
 
 GSLMatrixUnitTest_SOURCES = UnitTestMain.cpp gslmatrixunittest.cpp gslmatrixunittest.hpp
-GSLMatrixUnitTest_LDADD = ${GSLLIBS}
+GSLMatrixUnitTest_LDADD = ${ALLLIBS}
 
 GSLVectorUnitTest_SOURCES = UnitTestMain.cpp gslvectorunittest.cpp gslvectorunittest.hpp
-GSLVectorUnitTest_LDADD = ${GSLLIBS}
+GSLVectorUnitTest_LDADD = ${ALLLIBS}
 
 InfoUnitTest_SOURCES = UnitTestMain.cpp infounittest.cpp infounittest.hpp
@@ -187,11 +213,8 @@
 
 manipulateAtomsTest_SOURCES = UnitTestMain.cpp manipulateAtomsTest.cpp manipulateAtomsTest.hpp
-manipulateAtomsTest_LDADD = ${ALLLIBS}
-
-MemoryAllocatorUnitTest_SOURCES = UnitTestMain.cpp ../memoryallocator.hpp ../memoryallocator.cpp ../memoryusageobserver.cpp ../memoryusageobserver.hpp memoryallocatorunittest.cpp memoryallocatorunittest.hpp 
-MemoryAllocatorUnitTest_LDADD = ${ALLLIBS}
-
-MemoryUsageObserverUnitTest_SOURCES = UnitTestMain.cpp ../memoryallocator.hpp ../memoryusageobserver.cpp ../memoryusageobserver.hpp memoryusageobserverunittest.cpp memoryusageobserverunittest.hpp 
-MemoryUsageObserverUnitTest_LDADD = ${ALLLIBS}
+manipulateAtomsTest_LDADD = ${UILIBS} ${ALLLIBS}
+
+MatrixUnittest_SOURCES = UnitTestMain.cpp MatrixUnittest.cpp MatrixUnittest.hpp
+MatrixUnittest_LDADD = ${ALLLIBS}
 
 MoleculeDescriptorTest_SOURCES = UnitTestMain.cpp MoleculeDescriptorTest.cpp MoleculeDescriptorTest.hpp
@@ -202,5 +225,5 @@
 
 ParserUnitTest_SOURCES = UnitTestMain.cpp ParserUnitTest.cpp ParserUnitTest.hpp
-ParserUnitTest_LDADD = ${PARSERLIBS}
+ParserUnitTest_LDADD = ${ALLLIBS} 
 
 periodentafelTest_SOURCES = UnitTestMain.cpp periodentafelTest.cpp periodentafelTest.hpp
@@ -210,4 +233,7 @@
 PlaneUnittest_LDADD = ${ALLLIBS}
 
+ShapeUnittest_SOURCES = UnitTestMain.cpp ShapeUnittest.cpp ShapeUnittest.hpp
+ShapeUnittest_LDADD = ${ALLLIBS}
+
 SingletonTest_SOURCES = UnitTestMain.cpp SingletonTest.cpp SingletonTest.hpp
 SingletonTest_LDADD = ${ALLLIBS} $(BOOST_LIB) ${BOOST_THREAD_LIB}
@@ -225,6 +251,6 @@
 Tesselation_InOutsideUnitTest_LDADD = ${ALLLIBS}
 
-TestRunner_SOURCES = TestRunnerMain.cpp ../memoryallocator.hpp ../memoryallocator.cpp ../memoryusageobserver.cpp ../memoryusageobserver.hpp $(TESTSOURCES) $(TESTHEADERS)
-TestRunner_LDADD = ${ALLLIBS}
+TestRunner_SOURCES = TestRunnerMain.cpp $(TESTSOURCES) $(TESTHEADERS)
+TestRunner_LDADD = ${UILIBS} ${ALLLIBS}
 
 VectorUnitTest_SOURCES = UnitTestMain.cpp vectorunittest.cpp vectorunittest.hpp 
Index: src/unittests/MapofActionsTest.cpp
===================================================================
--- src/unittests/MapofActionsTest.cpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/unittests/MapofActionsTest.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -5,4 +5,9 @@
  *      Author: heber
  */
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
 
 using namespace std;
Index: src/unittests/MatrixUnittest.cpp
===================================================================
--- src/unittests/MatrixUnittest.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
+++ src/unittests/MatrixUnittest.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -0,0 +1,351 @@
+/*
+ * MatrixUnittest.cpp
+ *
+ *  Created on: Jul 7, 2010
+ *      Author: crueger
+ */
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <cppunit/CompilerOutputter.h>
+#include <cppunit/extensions/TestFactoryRegistry.h>
+#include <cppunit/ui/text/TestRunner.h>
+
+#include <cmath>
+
+#include "MatrixUnittest.hpp"
+#include "LinearAlgebra/Matrix.hpp"
+#include "LinearAlgebra/Vector.hpp"
+#include "Exceptions/NotInvertibleException.hpp"
+
+#ifdef HAVE_TESTRUNNER
+#include "UnitTestMain.hpp"
+#endif /*HAVE_TESTRUNNER*/
+
+// Registers the fixture into the 'registry'
+CPPUNIT_TEST_SUITE_REGISTRATION( MatrixUnittest );
+
+void MatrixUnittest::setUp(){
+  zero = new Matrix();
+  one = new Matrix();
+  for(int i =NDIM;i--;){
+    one->at(i,i)=1.;
+  }
+  full=new Matrix();
+  for(int i=NDIM;i--;){
+    for(int j=NDIM;j--;){
+      full->at(i,j)=1.;
+    }
+  }
+  diagonal = new Matrix();
+  for(int i=NDIM;i--;){
+    diagonal->at(i,i)=i+1.;
+  }
+  perm1 = new Matrix();
+  perm1->column(0) = e1;
+  perm1->column(1) = e3;
+  perm1->column(2) = e2;
+
+
+  perm2 = new Matrix();
+  perm2->column(0) = e2;
+  perm2->column(1) = e1;
+  perm2->column(2) = e3;
+
+  perm3 = new Matrix();
+  perm3->column(0) = e2;
+  perm3->column(1) = e3;
+  perm3->column(2) = e1;
+
+  perm4 = new Matrix();
+  perm4->column(0) = e3;
+  perm4->column(1) = e2;
+  perm4->column(2) = e1;
+
+  perm5 = new Matrix();
+  perm5->column(0) = e3;
+  perm5->column(1) = e1;
+  perm5->column(2) = e2;
+
+}
+void MatrixUnittest::tearDown(){
+  delete zero;
+  delete one;
+  delete full;
+  delete diagonal;
+  delete perm1;
+  delete perm2;
+  delete perm3;
+  delete perm4;
+  delete perm5;
+}
+
+void MatrixUnittest::AccessTest(){
+  Matrix mat;
+  for(int i=NDIM;i--;){
+    for(int j=NDIM;j--;){
+      CPPUNIT_ASSERT_EQUAL(mat.at(i,j),0.);
+    }
+  }
+  int k=1;
+  for(int i=NDIM;i--;){
+    for(int j=NDIM;j--;){
+      mat.at(i,j)=k++;
+    }
+  }
+  k=1;
+  for(int i=NDIM;i--;){
+    for(int j=NDIM;j--;){
+      CPPUNIT_ASSERT_EQUAL(mat.at(i,j),(double)k);
+      ++k;
+    }
+  }
+}
+
+void MatrixUnittest::VectorTest(){
+  Matrix mat;
+  for(int i=NDIM;i--;){
+    CPPUNIT_ASSERT_EQUAL(mat.row(i),zeroVec);
+    CPPUNIT_ASSERT_EQUAL(mat.column(i),zeroVec);
+  }
+  CPPUNIT_ASSERT_EQUAL(mat.diagonal(),zeroVec);
+
+  mat.one();
+  CPPUNIT_ASSERT_EQUAL(mat.row(0),e1);
+  CPPUNIT_ASSERT_EQUAL(mat.row(1),e2);
+  CPPUNIT_ASSERT_EQUAL(mat.row(2),e3);
+  CPPUNIT_ASSERT_EQUAL(mat.column(0),e1);
+  CPPUNIT_ASSERT_EQUAL(mat.column(1),e2);
+  CPPUNIT_ASSERT_EQUAL(mat.column(2),e3);
+
+  Vector t1=Vector(1.,1.,1.);
+  Vector t2=Vector(2.,2.,2.);
+  Vector t3=Vector(3.,3.,3.);
+  Vector t4=Vector(1.,2.,3.);
+
+  mat.row(0)=t1;
+  mat.row(1)=t2;
+  mat.row(2)=t3;
+  CPPUNIT_ASSERT_EQUAL(mat.row(0),t1);
+  CPPUNIT_ASSERT_EQUAL(mat.row(1),t2);
+  CPPUNIT_ASSERT_EQUAL(mat.row(2),t3);
+  CPPUNIT_ASSERT_EQUAL(mat.column(0),t4);
+  CPPUNIT_ASSERT_EQUAL(mat.column(1),t4);
+  CPPUNIT_ASSERT_EQUAL(mat.column(2),t4);
+  CPPUNIT_ASSERT_EQUAL(mat.diagonal(),t4);
+  for(int i=NDIM;i--;){
+    for(int j=NDIM;j--;){
+      CPPUNIT_ASSERT_EQUAL(mat.at(i,j),i+1.);
+    }
+  }
+
+  mat.column(0)=t1;
+  mat.column(1)=t2;
+  mat.column(2)=t3;
+  CPPUNIT_ASSERT_EQUAL(mat.column(0),t1);
+  CPPUNIT_ASSERT_EQUAL(mat.column(1),t2);
+  CPPUNIT_ASSERT_EQUAL(mat.column(2),t3);
+  CPPUNIT_ASSERT_EQUAL(mat.row(0),t4);
+  CPPUNIT_ASSERT_EQUAL(mat.row(1),t4);
+  CPPUNIT_ASSERT_EQUAL(mat.row(2),t4);
+  CPPUNIT_ASSERT_EQUAL(mat.diagonal(),t4);
+  for(int i=NDIM;i--;){
+    for(int j=NDIM;j--;){
+      CPPUNIT_ASSERT_EQUAL(mat.at(i,j),j+1.);
+    }
+  }
+}
+
+void MatrixUnittest::TransposeTest(){
+  Matrix res;
+
+  // transpose of unit is unit
+  res.one();
+  (const Matrix)res.transpose();
+  CPPUNIT_ASSERT_EQUAL(res,*one);
+
+  // transpose of transpose is same matrix
+  res.zero();
+  res.set(2,2, 1.);
+  CPPUNIT_ASSERT_EQUAL(res.transpose().transpose(),res);
+}
+
+void MatrixUnittest::OperationTest(){
+  Matrix res;
+
+  res =(*zero) *(*zero);
+  CPPUNIT_ASSERT_EQUAL(res,*zero);
+  res =(*zero) *(*one);
+  CPPUNIT_ASSERT_EQUAL(res,*zero);
+  res =(*zero) *(*full);
+  CPPUNIT_ASSERT_EQUAL(res,*zero);
+  res =(*zero) *(*diagonal);
+  CPPUNIT_ASSERT_EQUAL(res,*zero);
+  res =(*zero) *(*perm1);
+  CPPUNIT_ASSERT_EQUAL(res,*zero);
+  res =(*zero) *(*perm2);
+  CPPUNIT_ASSERT_EQUAL(res,*zero);
+  res =(*zero) *(*perm3);
+  CPPUNIT_ASSERT_EQUAL(res,*zero);
+  res =(*zero) *(*perm4);
+  CPPUNIT_ASSERT_EQUAL(res,*zero);
+  res =(*zero) *(*perm5);
+  CPPUNIT_ASSERT_EQUAL(res,*zero);
+
+  res =(*one)*(*one);
+  CPPUNIT_ASSERT_EQUAL(res,*one);
+  res =(*one)*(*full);
+  CPPUNIT_ASSERT_EQUAL(res,*full);
+  res =(*one)*(*diagonal);
+  CPPUNIT_ASSERT_EQUAL(res,*diagonal);
+  res =(*one)*(*perm1);
+  CPPUNIT_ASSERT_EQUAL(res,*perm1);
+  res =(*one)*(*perm2);
+  CPPUNIT_ASSERT_EQUAL(res,*perm2);
+  res =(*one)*(*perm3);
+  CPPUNIT_ASSERT_EQUAL(res,*perm3);
+  res =(*one)*(*perm4);
+  CPPUNIT_ASSERT_EQUAL(res,*perm4);
+  res =(*one)*(*perm5);
+  CPPUNIT_ASSERT_EQUAL(res,*perm5);
+
+  res = (*full)*(*perm1);
+  CPPUNIT_ASSERT_EQUAL(res,*full);
+  res = (*full)*(*perm2);
+  CPPUNIT_ASSERT_EQUAL(res,*full);
+  res = (*full)*(*perm3);
+  CPPUNIT_ASSERT_EQUAL(res,*full);
+  res = (*full)*(*perm4);
+  CPPUNIT_ASSERT_EQUAL(res,*full);
+  res = (*full)*(*perm5);
+  CPPUNIT_ASSERT_EQUAL(res,*full);
+
+  res = (*diagonal)*(*perm1);
+  CPPUNIT_ASSERT_EQUAL(res.column(0),e1);
+  CPPUNIT_ASSERT_EQUAL(res.column(1),3*e3);
+  CPPUNIT_ASSERT_EQUAL(res.column(2),2*e2);
+  res = (*diagonal)*(*perm2);
+  CPPUNIT_ASSERT_EQUAL(res.column(0),2*e2);
+  CPPUNIT_ASSERT_EQUAL(res.column(1),e1);
+  CPPUNIT_ASSERT_EQUAL(res.column(2),3*e3);
+  res = (*diagonal)*(*perm3);
+  CPPUNIT_ASSERT_EQUAL(res.column(0),2*e2);
+  CPPUNIT_ASSERT_EQUAL(res.column(1),3*e3);
+  CPPUNIT_ASSERT_EQUAL(res.column(2),e1);
+  res = (*diagonal)*(*perm4);
+  CPPUNIT_ASSERT_EQUAL(res.column(0),3*e3);
+  CPPUNIT_ASSERT_EQUAL(res.column(1),2*e2);
+  CPPUNIT_ASSERT_EQUAL(res.column(2),e1);
+  res = (*diagonal)*(*perm5);
+  CPPUNIT_ASSERT_EQUAL(res.column(0),3*e3);
+  CPPUNIT_ASSERT_EQUAL(res.column(1),e1);
+  CPPUNIT_ASSERT_EQUAL(res.column(2),2*e2);
+}
+
+void MatrixUnittest::RotationTest(){
+  Matrix res;
+  Matrix inverse;
+
+  // zero rotation angles yields unity matrix
+  res.rotation(0,0,0);
+  CPPUNIT_ASSERT_EQUAL(*one, res);
+
+  // arbitrary rotation matrix has det = 1
+  res.rotation(M_PI/3.,1.,M_PI/7.);
+  CPPUNIT_ASSERT(fabs(fabs(res.determinant()) -1.) < MYEPSILON);
+
+  // inverse is rotation matrix with negative angles
+  res.rotation(M_PI/3.,0.,0.);
+  inverse.rotation(-M_PI/3.,0.,0.);
+  CPPUNIT_ASSERT_EQUAL(*one, res * inverse);
+
+  // ... or transposed
+  res.rotation(M_PI/3.,0.,0.);
+  CPPUNIT_ASSERT_EQUAL(inverse, ((const Matrix) res).transpose());
+}
+
+void MatrixUnittest::InvertTest(){
+  CPPUNIT_ASSERT_THROW(zero->invert(),NotInvertibleException);
+  CPPUNIT_ASSERT_THROW(full->invert(),NotInvertibleException);
+
+  Matrix res;
+  res = (*one)*one->invert();
+  CPPUNIT_ASSERT_EQUAL(res,*one);
+  res = (*diagonal)*diagonal->invert();
+  CPPUNIT_ASSERT_EQUAL(res,*one);
+  res = (*perm1)*perm1->invert();
+  CPPUNIT_ASSERT_EQUAL(res,*one);
+  res = (*perm2)*perm2->invert();
+  CPPUNIT_ASSERT_EQUAL(res,*one);
+  res = (*perm3)*perm3->invert();
+  CPPUNIT_ASSERT_EQUAL(res,*one);
+  res = (*perm4)*perm4->invert();
+  CPPUNIT_ASSERT_EQUAL(res,*one);
+  res = (*perm5)*perm5->invert();
+  CPPUNIT_ASSERT_EQUAL(res,*one);
+}
+
+
+void MatrixUnittest::DeterminantTest(){
+  CPPUNIT_ASSERT_EQUAL(zero->determinant(),0.);
+  CPPUNIT_ASSERT_EQUAL(one->determinant(),1.);
+  CPPUNIT_ASSERT_EQUAL(diagonal->determinant(),6.);
+  CPPUNIT_ASSERT_EQUAL(full->determinant(),0.);
+  CPPUNIT_ASSERT_EQUAL(perm1->determinant(),-1.);
+  CPPUNIT_ASSERT_EQUAL(perm2->determinant(),-1.);
+  CPPUNIT_ASSERT_EQUAL(perm3->determinant(),1.);
+  CPPUNIT_ASSERT_EQUAL(perm4->determinant(),-1.);
+  CPPUNIT_ASSERT_EQUAL(perm5->determinant(),1.);
+}
+
+void MatrixUnittest::VecMultTest(){
+  CPPUNIT_ASSERT_EQUAL((*zero)*e1,zeroVec);
+  CPPUNIT_ASSERT_EQUAL((*zero)*e2,zeroVec);
+  CPPUNIT_ASSERT_EQUAL((*zero)*e3,zeroVec);
+  CPPUNIT_ASSERT_EQUAL((*zero)*zeroVec,zeroVec);
+
+  CPPUNIT_ASSERT_EQUAL((*one)*e1,e1);
+  CPPUNIT_ASSERT_EQUAL((*one)*e2,e2);
+  CPPUNIT_ASSERT_EQUAL((*one)*e3,e3);
+  CPPUNIT_ASSERT_EQUAL((*one)*zeroVec,zeroVec);
+
+  CPPUNIT_ASSERT_EQUAL((*diagonal)*e1,e1);
+  CPPUNIT_ASSERT_EQUAL((*diagonal)*e2,2*e2);
+  CPPUNIT_ASSERT_EQUAL((*diagonal)*e3,3*e3);
+  CPPUNIT_ASSERT_EQUAL((*diagonal)*zeroVec,zeroVec);
+
+  CPPUNIT_ASSERT_EQUAL((*perm1)*e1,e1);
+  CPPUNIT_ASSERT_EQUAL((*perm1)*e2,e3);
+  CPPUNIT_ASSERT_EQUAL((*perm1)*e3,e2);
+  CPPUNIT_ASSERT_EQUAL((*perm1)*zeroVec,zeroVec);
+
+  CPPUNIT_ASSERT_EQUAL((*perm2)*e1,e2);
+  CPPUNIT_ASSERT_EQUAL((*perm2)*e2,e1);
+  CPPUNIT_ASSERT_EQUAL((*perm2)*e3,e3);
+  CPPUNIT_ASSERT_EQUAL((*perm2)*zeroVec,zeroVec);
+
+  CPPUNIT_ASSERT_EQUAL((*perm3)*e1,e2);
+  CPPUNIT_ASSERT_EQUAL((*perm3)*e2,e3);
+  CPPUNIT_ASSERT_EQUAL((*perm3)*e3,e1);
+  CPPUNIT_ASSERT_EQUAL((*perm3)*zeroVec,zeroVec);
+
+  CPPUNIT_ASSERT_EQUAL((*perm4)*e1,e3);
+  CPPUNIT_ASSERT_EQUAL((*perm4)*e2,e2);
+  CPPUNIT_ASSERT_EQUAL((*perm4)*e3,e1);
+  CPPUNIT_ASSERT_EQUAL((*perm4)*zeroVec,zeroVec);
+
+  CPPUNIT_ASSERT_EQUAL((*perm5)*e1,e3);
+  CPPUNIT_ASSERT_EQUAL((*perm5)*e2,e1);
+  CPPUNIT_ASSERT_EQUAL((*perm5)*e3,e2);
+  CPPUNIT_ASSERT_EQUAL((*perm5)*zeroVec,zeroVec);
+
+  Vector t = Vector(1.,2.,3.);
+  CPPUNIT_ASSERT_EQUAL((*perm1)*t,Vector(1,3,2));
+  CPPUNIT_ASSERT_EQUAL((*perm2)*t,Vector(2,1,3));
+  CPPUNIT_ASSERT_EQUAL((*perm3)*t,Vector(3,1,2));
+  CPPUNIT_ASSERT_EQUAL((*perm4)*t,Vector(3,2,1));
+  CPPUNIT_ASSERT_EQUAL((*perm5)*t,Vector(2,3,1));
+}
Index: src/unittests/MatrixUnittest.hpp
===================================================================
--- src/unittests/MatrixUnittest.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
+++ src/unittests/MatrixUnittest.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -0,0 +1,52 @@
+/*
+ * MatrixUnittest.hpp
+ *
+ *  Created on: Jul 7, 2010
+ *      Author: crueger
+ */
+
+#ifndef MATRIXUNITTEST_HPP_
+#define MATRIXUNITTEST_HPP_
+
+#include <cppunit/extensions/HelperMacros.h>
+
+class Matrix;
+
+class MatrixUnittest : public CppUnit::TestFixture
+{
+  CPPUNIT_TEST_SUITE( MatrixUnittest) ;
+  CPPUNIT_TEST ( AccessTest );
+  CPPUNIT_TEST ( VectorTest );
+  CPPUNIT_TEST ( OperationTest );
+  CPPUNIT_TEST ( TransposeTest );
+  CPPUNIT_TEST ( RotationTest );
+  CPPUNIT_TEST ( InvertTest );
+  CPPUNIT_TEST ( DeterminantTest );
+  CPPUNIT_TEST ( VecMultTest );
+  CPPUNIT_TEST_SUITE_END();
+
+public:
+  void setUp();
+  void tearDown();
+
+  void AccessTest();
+  void VectorTest();
+  void OperationTest();
+  void TransposeTest();
+  void RotationTest();
+  void InvertTest();
+  void DeterminantTest();
+  void VecMultTest();
+
+  Matrix *zero;
+  Matrix *one;
+  Matrix *full;
+  Matrix *diagonal;
+  Matrix *perm1;
+  Matrix *perm2;
+  Matrix *perm3;
+  Matrix *perm4;
+  Matrix *perm5;
+};
+
+#endif /* MATRIXUNITTEST_HPP_ */
Index: src/unittests/MoleculeDescriptorTest.cpp
===================================================================
--- src/unittests/MoleculeDescriptorTest.cpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/unittests/MoleculeDescriptorTest.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -5,4 +5,9 @@
  *      Author: crueger
  */
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
 
 #include "MoleculeDescriptorTest.hpp"
Index: src/unittests/MoleculeDescriptorTest.hpp
===================================================================
--- src/unittests/MoleculeDescriptorTest.hpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/unittests/MoleculeDescriptorTest.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -13,5 +13,6 @@
 #include "types.hpp"
 
-#define MOLECULE_COUNT (10)
+// we prefer enum over define
+enum { MOLECULE_COUNT = 10 };
 
 class molecule;
Index: src/unittests/ObserverTest.cpp
===================================================================
--- src/unittests/ObserverTest.cpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/unittests/ObserverTest.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -6,4 +6,9 @@
  */
 
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
 #include "ObserverTest.hpp"
 
@@ -182,5 +187,5 @@
 };
 
-class ObservableCollection : public Observable {
+class ObservableSet : public Observable {
 public:
   typedef std::set<SimpleObservable*> set;
@@ -188,5 +193,5 @@
   typedef set::const_iterator const_iterator;
 
-  ObservableCollection(int _num) :
+  ObservableSet(int _num) :
     Observable("ObservableCollection"),
     num(_num)
@@ -199,8 +204,46 @@
   }
 
-  ~ObservableCollection(){
+  ~ObservableSet(){
     set::iterator iter;
     for(iter=theSet.begin(); iter!=theSet.end(); ++iter ){
       delete (*iter);
+    }
+  }
+
+  iterator begin(){
+    return iterator(theSet.begin(),this);
+  }
+
+  iterator end(){
+    return iterator(theSet.end(),this);
+  }
+
+  const int num;
+
+private:
+  set theSet;
+};
+
+class ObservableMap : public Observable {
+public:
+  typedef std::map<int,SimpleObservable*> set;
+  typedef ObservedIterator<set> iterator;
+  typedef set::const_iterator const_iterator;
+
+  ObservableMap(int _num) :
+    Observable("ObservableCollection"),
+    num(_num)
+  {
+    for(int i=0; i<num; ++i){
+      SimpleObservable *content = new SimpleObservable();
+      content->signOn(this);
+      theSet.insert(make_pair(i,content));
+    }
+  }
+
+  ~ObservableMap(){
+    set::iterator iter;
+    for(iter=theSet.begin(); iter!=theSet.end(); ++iter ){
+      delete iter->second;
     }
   }
@@ -231,5 +274,6 @@
   blockObservable = new BlockObservable();
   notificationObservable = new NotificationObservable();
-  collection = new ObservableCollection(5);
+  obsset = new ObservableSet(5);
+  obsmap = new ObservableMap(5);
 
   observer1 = new UpdateCountObserver();
@@ -249,5 +293,6 @@
   delete blockObservable;
   delete notificationObservable;
-  delete collection;
+  delete obsset;
+  delete obsmap;
 
   delete observer1;
@@ -268,4 +313,10 @@
   simpleObservable2->signOn(observer4);
 
+  CPPUNIT_ASSERT_EQUAL( 0, observer1->updates );
+  CPPUNIT_ASSERT_EQUAL( 0, observer2->updates );
+  CPPUNIT_ASSERT_EQUAL( 0, observer3->updates );
+  CPPUNIT_ASSERT_EQUAL( 0, observer4->updates );
+
+
   simpleObservable1->changeMethod();
   CPPUNIT_ASSERT_EQUAL( 1, observer1->updates );
@@ -292,4 +343,5 @@
 void ObserverTest::doesBlockUpdateTest() {
   callObservable->signOn(observer1);
+  CPPUNIT_ASSERT_EQUAL( 0, observer1->updates );
 
   callObservable->changeMethod1();
@@ -311,4 +363,16 @@
   CPPUNIT_ASSERT_EQUAL( 2, observer1->updates );
   CPPUNIT_ASSERT_EQUAL( 2, observer2->updates );
+}
+
+void ObserverTest::outsideLockTest(){
+  callObservable->signOn(observer1);
+  CPPUNIT_ASSERT_EQUAL( 0, observer1->updates );
+
+  {
+    LOCK_OBSERVABLE(*callObservable);
+    CPPUNIT_ASSERT_EQUAL( 0, observer1->updates );
+  }
+  // lock is gone now, observer should have notified
+  CPPUNIT_ASSERT_EQUAL( 1, observer1->updates );
 }
 
@@ -341,21 +405,21 @@
   int i = 0;
   // test the general iterator methods
-  for(ObservableCollection::iterator iter=collection->begin(); iter!=collection->end();++iter){
-    CPPUNIT_ASSERT(i< collection->num);
+  for(ObservableSet::iterator iter=obsset->begin(); iter!=obsset->end();++iter){
+    CPPUNIT_ASSERT(i< obsset->num);
     i++;
   }
 
   i=0;
-  for(ObservableCollection::const_iterator iter=collection->begin(); iter!=collection->end();++iter){
-    CPPUNIT_ASSERT(i<collection->num);
-    i++;
-  }
-
-  collection->signOn(observer1);
+  for(ObservableSet::const_iterator iter=obsset->begin(); iter!=obsset->end();++iter){
+    CPPUNIT_ASSERT(i<obsset->num);
+    i++;
+  }
+
+  obsset->signOn(observer1);
   {
     // we construct this out of the loop, so the iterator dies at the end of
     // the scope and not the end of the loop (allows more testing)
-    ObservableCollection::iterator iter;
-    for(iter=collection->begin(); iter!=collection->end(); ++iter){
+    ObservableSet::iterator iter;
+    for(iter=obsset->begin(); iter!=obsset->end(); ++iter){
       (*iter)->changeMethod();
     }
@@ -367,7 +431,25 @@
 
   // when using a const_iterator no changes should be propagated
-  for(ObservableCollection::const_iterator iter = collection->begin(); iter!=collection->end();++iter);
+  for(ObservableSet::const_iterator iter = obsset->begin(); iter!=obsset->end();++iter);
   CPPUNIT_ASSERT_EQUAL( 1, observer1->updates);
-  collection->signOff(observer1);
+
+  // we need to test the operator-> as well
+  obsmap->signOn(observer2);
+  {
+    // we construct this out of the loop, so the iterator dies at the end of
+    // the scope and not the end of the loop (allows more testing)
+    ObservableMap::iterator iter;
+    for(iter=obsmap->begin(); iter!=obsmap->end(); ++iter){
+      iter->second->changeMethod();
+    }
+    // At this point no change should have been propagated
+    CPPUNIT_ASSERT_EQUAL( 0, observer2->updates);
+  }
+  // After the Iterator has died the propagation should take place
+  CPPUNIT_ASSERT_EQUAL( 1, observer2->updates);
+
+
+  obsset->signOff(observer1);
+  obsmap->signOff(observer2);
 }
 
Index: src/unittests/ObserverTest.hpp
===================================================================
--- src/unittests/ObserverTest.hpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/unittests/ObserverTest.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -17,5 +17,6 @@
 class CallObservable;
 class SuperObservable;
-class ObservableCollection;
+class ObservableSet;
+class ObservableMap;
 class BlockObservable;
 class NotificationObservable;
@@ -27,4 +28,5 @@
   CPPUNIT_TEST ( doesBlockUpdateTest );
   CPPUNIT_TEST ( doesSubObservableTest );
+  CPPUNIT_TEST ( outsideLockTest );
   CPPUNIT_TEST ( doesNotifyTest );
   CPPUNIT_TEST ( doesReportTest );
@@ -40,4 +42,5 @@
   void doesBlockUpdateTest();
   void doesSubObservableTest();
+  void outsideLockTest();
   void doesNotifyTest();
   void doesReportTest();
@@ -60,5 +63,6 @@
   SuperObservable *superObservable;
   NotificationObservable *notificationObservable;
-  ObservableCollection *collection;
+  ObservableSet *obsset;
+  ObservableMap *obsmap;
 
 };
Index: src/unittests/ParserUnitTest.cpp
===================================================================
--- src/unittests/ParserUnitTest.cpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/unittests/ParserUnitTest.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -5,4 +5,9 @@
  *      Author: metzler
  */
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
 
 #include "ParserUnitTest.hpp"
@@ -208,5 +213,5 @@
   input << Tremolo_Atomdata2;
   testParser->load(&input);
-  CPPUNIT_ASSERT(World::getInstance().getAtom(AtomByType(1))->x[0] == 3.0);
+  CPPUNIT_ASSERT(World::getInstance().getAtom(AtomByType(1))->at(0) == 3.0);
   input.clear();
 }
@@ -219,5 +224,5 @@
   input << Tremolo_velocity;
   testParser->load(&input);
-  CPPUNIT_ASSERT(World::getInstance().getAtom(AtomByType(1))->v[0] == 3.0);
+  CPPUNIT_ASSERT(World::getInstance().getAtom(AtomByType(1))->AtomicVelocity[0] == 3.0);
   input.clear();
 }
@@ -271,5 +276,5 @@
   // with the maximum number of fields and minimal information, default values are printed
   atom* newAtom = World::getInstance().createAtom();
-  newAtom->type = World::getInstance().getPeriode()->FindElement(1);
+  newAtom->setType(1);
   testParser->setFieldsForSave("x=3 u=3 F stress Id neighbors=5 imprData GroupMeasureTypeNo Type extType name resName chainID resSeq occupancy tempFactor segID Charge charge GrpTypeNo torsion");
   testParser->save(&output);
@@ -304,12 +309,12 @@
   atom *Walker = NULL;
   Walker = World::getInstance().createAtom();
-  Walker->type = World::getInstance().getPeriode()->FindElement(8);
-  Walker->x = Vector(0,0,0);
+  Walker->setType(8);
+  Walker->setPosition(Vector(0,0,0));
   Walker = World::getInstance().createAtom();
-  Walker->type = World::getInstance().getPeriode()->FindElement(1);
-  Walker->x = Vector(0.758602,0,0.504284);
+  Walker->setType(1);
+  Walker->setPosition(Vector(0.758602,0,0.504284));
   Walker = World::getInstance().createAtom();
-  Walker->type = World::getInstance().getPeriode()->FindElement(1);
-  Walker->x = Vector(0.758602,0,-0.504284);
+  Walker->setType(1);
+  Walker->setPosition(Vector(0.758602,0,-0.504284));
   CPPUNIT_ASSERT_EQUAL(3, World::getInstance().numAtoms());
 
Index: src/unittests/PlaneUnittest.cpp
===================================================================
--- src/unittests/PlaneUnittest.cpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/unittests/PlaneUnittest.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -6,4 +6,9 @@
  */
 
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
 #include "PlaneUnittest.hpp"
 
@@ -12,10 +17,12 @@
 #include <cppunit/ui/text/TestRunner.h>
 
+#include <cmath>
+
 #ifdef HAVE_TESTRUNNER
 #include "UnitTestMain.hpp"
 #endif /*HAVE_TESTRUNNER*/
 
-#include "vector.hpp"
-#include "Line.hpp"
+#include "LinearAlgebra/Vector.hpp"
+#include "LinearAlgebra/Line.hpp"
 
 CPPUNIT_TEST_SUITE_REGISTRATION( PlaneUnittest );
Index: src/unittests/PlaneUnittest.hpp
===================================================================
--- src/unittests/PlaneUnittest.hpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/unittests/PlaneUnittest.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -11,5 +11,5 @@
 #include <cppunit/extensions/HelperMacros.h>
 
-#include "Plane.hpp"
+#include "LinearAlgebra/Plane.hpp"
 
 class PlaneUnittest : public CppUnit::TestFixture
Index: src/unittests/ShapeUnittest.cpp
===================================================================
--- src/unittests/ShapeUnittest.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
+++ src/unittests/ShapeUnittest.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -0,0 +1,372 @@
+/*
+ * ShapeUnittest.cpp
+ *
+ *  Created on: Jun 18, 2010
+ *      Author: crueger
+ */
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "ShapeUnittest.hpp"
+
+#include <cppunit/CompilerOutputter.h>
+#include <cppunit/extensions/TestFactoryRegistry.h>
+#include <cppunit/ui/text/TestRunner.h>
+
+#include <cmath>
+
+#ifdef HAVE_TESTRUNNER
+#include "UnitTestMain.hpp"
+#endif /*HAVE_TESTRUNNER*/
+
+#include "LinearAlgebra/Vector.hpp"
+#include "Shapes/Shape.hpp"
+
+#include "Shapes/BaseShapes.hpp"
+
+// Registers the fixture into the 'registry'
+CPPUNIT_TEST_SUITE_REGISTRATION( ShapeUnittest );
+
+void ShapeUnittest::setUp()
+{
+  v000 =  0*e1+0*e2+0*e3;
+  v100 =  1*e1+0*e2+0*e3;
+  v200 = -1*e1+0*e2+0*e3;
+  v010 =  0*e1+1*e2+0*e3;
+  v110 =  1*e1+1*e2+0*e3;
+  v210 = -1*e1+1*e2+0*e3;
+  v020 =  0*e1-1*e2+0*e3;
+  v120 =  1*e1-1*e2+0*e3;
+  v220 = -1*e1-1*e2+0*e3;
+  v001 =  0*e1+0*e2+1*e3;
+  v101 =  1*e1+0*e2+1*e3;
+  v201 = -1*e1+0*e2+1*e3;
+  v011 =  0*e1+1*e2+1*e3;
+  v111 =  1*e1+1*e2+1*e3;
+  v211 = -1*e1+1*e2+1*e3;
+  v021 =  0*e1-1*e2+1*e3;
+  v121 =  1*e1-1*e2+1*e3;
+  v221 = -1*e1-1*e2+1*e3;
+  v002 =  0*e1+0*e2-1*e3;
+  v102 =  1*e1+0*e2-1*e3;
+  v202 = -1*e1+0*e2-1*e3;
+  v012 =  0*e1+1*e2-1*e3;
+  v112 =  1*e1+1*e2-1*e3;
+  v212 = -1*e1+1*e2-1*e3;
+  v022 =  0*e1-1*e2-1*e3;
+  v122 =  1*e1-1*e2-1*e3;
+  v222 = -1*e1-1*e2-1*e3;
+}
+
+void ShapeUnittest::tearDown()
+{}
+
+
+void ShapeUnittest::baseShapesTest(){
+  CPPUNIT_ASSERT(!Nowhere().isInside(v000));
+  CPPUNIT_ASSERT(!Nowhere().isInside(v100));
+  CPPUNIT_ASSERT(!Nowhere().isInside(v200));
+  CPPUNIT_ASSERT(!Nowhere().isInside(v010));
+  CPPUNIT_ASSERT(!Nowhere().isInside(v110));
+  CPPUNIT_ASSERT(!Nowhere().isInside(v210));
+  CPPUNIT_ASSERT(!Nowhere().isInside(v020));
+  CPPUNIT_ASSERT(!Nowhere().isInside(v120));
+  CPPUNIT_ASSERT(!Nowhere().isInside(v220));
+  CPPUNIT_ASSERT(!Nowhere().isInside(v001));
+  CPPUNIT_ASSERT(!Nowhere().isInside(v101));
+  CPPUNIT_ASSERT(!Nowhere().isInside(v201));
+  CPPUNIT_ASSERT(!Nowhere().isInside(v011));
+  CPPUNIT_ASSERT(!Nowhere().isInside(v111));
+  CPPUNIT_ASSERT(!Nowhere().isInside(v211));
+  CPPUNIT_ASSERT(!Nowhere().isInside(v021));
+  CPPUNIT_ASSERT(!Nowhere().isInside(v121));
+  CPPUNIT_ASSERT(!Nowhere().isInside(v221));
+  CPPUNIT_ASSERT(!Nowhere().isInside(v002));
+  CPPUNIT_ASSERT(!Nowhere().isInside(v102));
+  CPPUNIT_ASSERT(!Nowhere().isInside(v202));
+  CPPUNIT_ASSERT(!Nowhere().isInside(v012));
+  CPPUNIT_ASSERT(!Nowhere().isInside(v112));
+  CPPUNIT_ASSERT(!Nowhere().isInside(v212));
+  CPPUNIT_ASSERT(!Nowhere().isInside(v022));
+  CPPUNIT_ASSERT(!Nowhere().isInside(v122));
+  CPPUNIT_ASSERT(!Nowhere().isInside(v222));
+
+  CPPUNIT_ASSERT(Everywhere().isInside(v000));
+  CPPUNIT_ASSERT(Everywhere().isInside(v100));
+  CPPUNIT_ASSERT(Everywhere().isInside(v200));
+  CPPUNIT_ASSERT(Everywhere().isInside(v010));
+  CPPUNIT_ASSERT(Everywhere().isInside(v110));
+  CPPUNIT_ASSERT(Everywhere().isInside(v210));
+  CPPUNIT_ASSERT(Everywhere().isInside(v020));
+  CPPUNIT_ASSERT(Everywhere().isInside(v120));
+  CPPUNIT_ASSERT(Everywhere().isInside(v220));
+  CPPUNIT_ASSERT(Everywhere().isInside(v001));
+  CPPUNIT_ASSERT(Everywhere().isInside(v101));
+  CPPUNIT_ASSERT(Everywhere().isInside(v201));
+  CPPUNIT_ASSERT(Everywhere().isInside(v011));
+  CPPUNIT_ASSERT(Everywhere().isInside(v111));
+  CPPUNIT_ASSERT(Everywhere().isInside(v211));
+  CPPUNIT_ASSERT(Everywhere().isInside(v021));
+  CPPUNIT_ASSERT(Everywhere().isInside(v121));
+  CPPUNIT_ASSERT(Everywhere().isInside(v221));
+  CPPUNIT_ASSERT(Everywhere().isInside(v002));
+  CPPUNIT_ASSERT(Everywhere().isInside(v102));
+  CPPUNIT_ASSERT(Everywhere().isInside(v202));
+  CPPUNIT_ASSERT(Everywhere().isInside(v012));
+  CPPUNIT_ASSERT(Everywhere().isInside(v112));
+  CPPUNIT_ASSERT(Everywhere().isInside(v212));
+  CPPUNIT_ASSERT(Everywhere().isInside(v022));
+  CPPUNIT_ASSERT(Everywhere().isInside(v122));
+  CPPUNIT_ASSERT(Everywhere().isInside(v222));
+}
+
+void ShapeUnittest::assignmentTest(){
+  Shape s1 = Nowhere();
+  s1 = Everywhere();
+
+  CPPUNIT_ASSERT(s1.isInside(v000));
+  CPPUNIT_ASSERT(s1.isInside(v100));
+  CPPUNIT_ASSERT(s1.isInside(v200));
+  CPPUNIT_ASSERT(s1.isInside(v010));
+  CPPUNIT_ASSERT(s1.isInside(v110));
+  CPPUNIT_ASSERT(s1.isInside(v210));
+  CPPUNIT_ASSERT(s1.isInside(v020));
+  CPPUNIT_ASSERT(s1.isInside(v120));
+  CPPUNIT_ASSERT(s1.isInside(v220));
+  CPPUNIT_ASSERT(s1.isInside(v001));
+  CPPUNIT_ASSERT(s1.isInside(v101));
+  CPPUNIT_ASSERT(s1.isInside(v201));
+  CPPUNIT_ASSERT(s1.isInside(v011));
+  CPPUNIT_ASSERT(s1.isInside(v111));
+  CPPUNIT_ASSERT(s1.isInside(v211));
+  CPPUNIT_ASSERT(s1.isInside(v021));
+  CPPUNIT_ASSERT(s1.isInside(v121));
+  CPPUNIT_ASSERT(s1.isInside(v221));
+  CPPUNIT_ASSERT(s1.isInside(v002));
+  CPPUNIT_ASSERT(s1.isInside(v102));
+  CPPUNIT_ASSERT(s1.isInside(v202));
+  CPPUNIT_ASSERT(s1.isInside(v012));
+  CPPUNIT_ASSERT(s1.isInside(v112));
+  CPPUNIT_ASSERT(s1.isInside(v212));
+  CPPUNIT_ASSERT(s1.isInside(v022));
+  CPPUNIT_ASSERT(s1.isInside(v122));
+  CPPUNIT_ASSERT(s1.isInside(v222));
+
+  Shape s2 = Everywhere();
+  s2 = Nowhere();
+
+  CPPUNIT_ASSERT(!s2.isInside(v000));
+  CPPUNIT_ASSERT(!s2.isInside(v100));
+  CPPUNIT_ASSERT(!s2.isInside(v200));
+  CPPUNIT_ASSERT(!s2.isInside(v010));
+  CPPUNIT_ASSERT(!s2.isInside(v110));
+  CPPUNIT_ASSERT(!s2.isInside(v210));
+  CPPUNIT_ASSERT(!s2.isInside(v020));
+  CPPUNIT_ASSERT(!s2.isInside(v120));
+  CPPUNIT_ASSERT(!s2.isInside(v220));
+  CPPUNIT_ASSERT(!s2.isInside(v001));
+  CPPUNIT_ASSERT(!s2.isInside(v101));
+  CPPUNIT_ASSERT(!s2.isInside(v201));
+  CPPUNIT_ASSERT(!s2.isInside(v011));
+  CPPUNIT_ASSERT(!s2.isInside(v111));
+  CPPUNIT_ASSERT(!s2.isInside(v211));
+  CPPUNIT_ASSERT(!s2.isInside(v021));
+  CPPUNIT_ASSERT(!s2.isInside(v121));
+  CPPUNIT_ASSERT(!s2.isInside(v221));
+  CPPUNIT_ASSERT(!s2.isInside(v002));
+  CPPUNIT_ASSERT(!s2.isInside(v102));
+  CPPUNIT_ASSERT(!s2.isInside(v202));
+  CPPUNIT_ASSERT(!s2.isInside(v012));
+  CPPUNIT_ASSERT(!s2.isInside(v112));
+  CPPUNIT_ASSERT(!s2.isInside(v212));
+  CPPUNIT_ASSERT(!s2.isInside(v022));
+  CPPUNIT_ASSERT(!s2.isInside(v122));
+  CPPUNIT_ASSERT(!s2.isInside(v222));
+
+}
+
+void ShapeUnittest::operatorTest(){
+  {
+    Shape s1 = !Nowhere();
+    CPPUNIT_ASSERT(s1.isInside(v000));
+    CPPUNIT_ASSERT(s1.isInside(v100));
+    CPPUNIT_ASSERT(s1.isInside(v200));
+    CPPUNIT_ASSERT(s1.isInside(v010));
+    CPPUNIT_ASSERT(s1.isInside(v110));
+    CPPUNIT_ASSERT(s1.isInside(v210));
+    CPPUNIT_ASSERT(s1.isInside(v020));
+    CPPUNIT_ASSERT(s1.isInside(v120));
+    CPPUNIT_ASSERT(s1.isInside(v220));
+    CPPUNIT_ASSERT(s1.isInside(v001));
+    CPPUNIT_ASSERT(s1.isInside(v101));
+    CPPUNIT_ASSERT(s1.isInside(v201));
+    CPPUNIT_ASSERT(s1.isInside(v011));
+    CPPUNIT_ASSERT(s1.isInside(v111));
+    CPPUNIT_ASSERT(s1.isInside(v211));
+    CPPUNIT_ASSERT(s1.isInside(v021));
+    CPPUNIT_ASSERT(s1.isInside(v121));
+    CPPUNIT_ASSERT(s1.isInside(v221));
+    CPPUNIT_ASSERT(s1.isInside(v002));
+    CPPUNIT_ASSERT(s1.isInside(v102));
+    CPPUNIT_ASSERT(s1.isInside(v202));
+    CPPUNIT_ASSERT(s1.isInside(v012));
+    CPPUNIT_ASSERT(s1.isInside(v112));
+    CPPUNIT_ASSERT(s1.isInside(v212));
+    CPPUNIT_ASSERT(s1.isInside(v022));
+    CPPUNIT_ASSERT(s1.isInside(v122));
+    CPPUNIT_ASSERT(s1.isInside(v222));
+
+    Shape s2 = !Everywhere();
+    CPPUNIT_ASSERT(!s2.isInside(v000));
+    CPPUNIT_ASSERT(!s2.isInside(v100));
+    CPPUNIT_ASSERT(!s2.isInside(v200));
+    CPPUNIT_ASSERT(!s2.isInside(v010));
+    CPPUNIT_ASSERT(!s2.isInside(v110));
+    CPPUNIT_ASSERT(!s2.isInside(v210));
+    CPPUNIT_ASSERT(!s2.isInside(v020));
+    CPPUNIT_ASSERT(!s2.isInside(v120));
+    CPPUNIT_ASSERT(!s2.isInside(v220));
+    CPPUNIT_ASSERT(!s2.isInside(v001));
+    CPPUNIT_ASSERT(!s2.isInside(v101));
+    CPPUNIT_ASSERT(!s2.isInside(v201));
+    CPPUNIT_ASSERT(!s2.isInside(v011));
+    CPPUNIT_ASSERT(!s2.isInside(v111));
+    CPPUNIT_ASSERT(!s2.isInside(v211));
+    CPPUNIT_ASSERT(!s2.isInside(v021));
+    CPPUNIT_ASSERT(!s2.isInside(v121));
+    CPPUNIT_ASSERT(!s2.isInside(v221));
+    CPPUNIT_ASSERT(!s2.isInside(v002));
+    CPPUNIT_ASSERT(!s2.isInside(v102));
+    CPPUNIT_ASSERT(!s2.isInside(v202));
+    CPPUNIT_ASSERT(!s2.isInside(v012));
+    CPPUNIT_ASSERT(!s2.isInside(v112));
+    CPPUNIT_ASSERT(!s2.isInside(v212));
+    CPPUNIT_ASSERT(!s2.isInside(v022));
+    CPPUNIT_ASSERT(!s2.isInside(v122));
+    CPPUNIT_ASSERT(!s2.isInside(v222));
+  }
+
+  {
+    Shape s1 = Nowhere() || Everywhere();
+    CPPUNIT_ASSERT(s1.isInside(v000));
+    CPPUNIT_ASSERT(s1.isInside(v100));
+    CPPUNIT_ASSERT(s1.isInside(v200));
+    CPPUNIT_ASSERT(s1.isInside(v010));
+    CPPUNIT_ASSERT(s1.isInside(v110));
+    CPPUNIT_ASSERT(s1.isInside(v210));
+    CPPUNIT_ASSERT(s1.isInside(v020));
+    CPPUNIT_ASSERT(s1.isInside(v120));
+    CPPUNIT_ASSERT(s1.isInside(v220));
+    CPPUNIT_ASSERT(s1.isInside(v001));
+    CPPUNIT_ASSERT(s1.isInside(v101));
+    CPPUNIT_ASSERT(s1.isInside(v201));
+    CPPUNIT_ASSERT(s1.isInside(v011));
+    CPPUNIT_ASSERT(s1.isInside(v111));
+    CPPUNIT_ASSERT(s1.isInside(v211));
+    CPPUNIT_ASSERT(s1.isInside(v021));
+    CPPUNIT_ASSERT(s1.isInside(v121));
+    CPPUNIT_ASSERT(s1.isInside(v221));
+    CPPUNIT_ASSERT(s1.isInside(v002));
+    CPPUNIT_ASSERT(s1.isInside(v102));
+    CPPUNIT_ASSERT(s1.isInside(v202));
+    CPPUNIT_ASSERT(s1.isInside(v012));
+    CPPUNIT_ASSERT(s1.isInside(v112));
+    CPPUNIT_ASSERT(s1.isInside(v212));
+    CPPUNIT_ASSERT(s1.isInside(v022));
+    CPPUNIT_ASSERT(s1.isInside(v122));
+    CPPUNIT_ASSERT(s1.isInside(v222));
+
+    Shape s2 = Nowhere() && Everywhere();
+    CPPUNIT_ASSERT(!s2.isInside(v000));
+    CPPUNIT_ASSERT(!s2.isInside(v100));
+    CPPUNIT_ASSERT(!s2.isInside(v200));
+    CPPUNIT_ASSERT(!s2.isInside(v010));
+    CPPUNIT_ASSERT(!s2.isInside(v110));
+    CPPUNIT_ASSERT(!s2.isInside(v210));
+    CPPUNIT_ASSERT(!s2.isInside(v020));
+    CPPUNIT_ASSERT(!s2.isInside(v120));
+    CPPUNIT_ASSERT(!s2.isInside(v220));
+    CPPUNIT_ASSERT(!s2.isInside(v001));
+    CPPUNIT_ASSERT(!s2.isInside(v101));
+    CPPUNIT_ASSERT(!s2.isInside(v201));
+    CPPUNIT_ASSERT(!s2.isInside(v011));
+    CPPUNIT_ASSERT(!s2.isInside(v111));
+    CPPUNIT_ASSERT(!s2.isInside(v211));
+    CPPUNIT_ASSERT(!s2.isInside(v021));
+    CPPUNIT_ASSERT(!s2.isInside(v121));
+    CPPUNIT_ASSERT(!s2.isInside(v221));
+    CPPUNIT_ASSERT(!s2.isInside(v002));
+    CPPUNIT_ASSERT(!s2.isInside(v102));
+    CPPUNIT_ASSERT(!s2.isInside(v202));
+    CPPUNIT_ASSERT(!s2.isInside(v012));
+    CPPUNIT_ASSERT(!s2.isInside(v112));
+    CPPUNIT_ASSERT(!s2.isInside(v212));
+    CPPUNIT_ASSERT(!s2.isInside(v022));
+    CPPUNIT_ASSERT(!s2.isInside(v122));
+    CPPUNIT_ASSERT(!s2.isInside(v222));
+  }
+
+  {
+    Shape s1 = Everywhere() || Nowhere();
+    CPPUNIT_ASSERT(s1.isInside(v000));
+    CPPUNIT_ASSERT(s1.isInside(v100));
+    CPPUNIT_ASSERT(s1.isInside(v200));
+    CPPUNIT_ASSERT(s1.isInside(v010));
+    CPPUNIT_ASSERT(s1.isInside(v110));
+    CPPUNIT_ASSERT(s1.isInside(v210));
+    CPPUNIT_ASSERT(s1.isInside(v020));
+    CPPUNIT_ASSERT(s1.isInside(v120));
+    CPPUNIT_ASSERT(s1.isInside(v220));
+    CPPUNIT_ASSERT(s1.isInside(v001));
+    CPPUNIT_ASSERT(s1.isInside(v101));
+    CPPUNIT_ASSERT(s1.isInside(v201));
+    CPPUNIT_ASSERT(s1.isInside(v011));
+    CPPUNIT_ASSERT(s1.isInside(v111));
+    CPPUNIT_ASSERT(s1.isInside(v211));
+    CPPUNIT_ASSERT(s1.isInside(v021));
+    CPPUNIT_ASSERT(s1.isInside(v121));
+    CPPUNIT_ASSERT(s1.isInside(v221));
+    CPPUNIT_ASSERT(s1.isInside(v002));
+    CPPUNIT_ASSERT(s1.isInside(v102));
+    CPPUNIT_ASSERT(s1.isInside(v202));
+    CPPUNIT_ASSERT(s1.isInside(v012));
+    CPPUNIT_ASSERT(s1.isInside(v112));
+    CPPUNIT_ASSERT(s1.isInside(v212));
+    CPPUNIT_ASSERT(s1.isInside(v022));
+    CPPUNIT_ASSERT(s1.isInside(v122));
+    CPPUNIT_ASSERT(s1.isInside(v222));
+
+    Shape s2 = Everywhere() && Nowhere();
+    CPPUNIT_ASSERT(!s2.isInside(v000));
+    CPPUNIT_ASSERT(!s2.isInside(v100));
+    CPPUNIT_ASSERT(!s2.isInside(v200));
+    CPPUNIT_ASSERT(!s2.isInside(v010));
+    CPPUNIT_ASSERT(!s2.isInside(v110));
+    CPPUNIT_ASSERT(!s2.isInside(v210));
+    CPPUNIT_ASSERT(!s2.isInside(v020));
+    CPPUNIT_ASSERT(!s2.isInside(v120));
+    CPPUNIT_ASSERT(!s2.isInside(v220));
+    CPPUNIT_ASSERT(!s2.isInside(v001));
+    CPPUNIT_ASSERT(!s2.isInside(v101));
+    CPPUNIT_ASSERT(!s2.isInside(v201));
+    CPPUNIT_ASSERT(!s2.isInside(v011));
+    CPPUNIT_ASSERT(!s2.isInside(v111));
+    CPPUNIT_ASSERT(!s2.isInside(v211));
+    CPPUNIT_ASSERT(!s2.isInside(v021));
+    CPPUNIT_ASSERT(!s2.isInside(v121));
+    CPPUNIT_ASSERT(!s2.isInside(v221));
+    CPPUNIT_ASSERT(!s2.isInside(v002));
+    CPPUNIT_ASSERT(!s2.isInside(v102));
+    CPPUNIT_ASSERT(!s2.isInside(v202));
+    CPPUNIT_ASSERT(!s2.isInside(v012));
+    CPPUNIT_ASSERT(!s2.isInside(v112));
+    CPPUNIT_ASSERT(!s2.isInside(v212));
+    CPPUNIT_ASSERT(!s2.isInside(v022));
+    CPPUNIT_ASSERT(!s2.isInside(v122));
+    CPPUNIT_ASSERT(!s2.isInside(v222));
+  }
+
+}
Index: src/unittests/ShapeUnittest.hpp
===================================================================
--- src/unittests/ShapeUnittest.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
+++ src/unittests/ShapeUnittest.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -0,0 +1,66 @@
+/*
+ * ShapeUnittest.hpp
+ *
+ *  Created on: Jun 18, 2010
+ *      Author: crueger
+ */
+
+#ifndef SHAPEUNITTEST_HPP_
+#define SHAPEUNITTEST_HPP_
+
+#include <cppunit/extensions/HelperMacros.h>
+
+class Shape;
+class Vector;
+
+#include "LinearAlgebra/Vector.hpp"
+
+class ShapeUnittest : public CppUnit::TestFixture
+{
+  CPPUNIT_TEST_SUITE( ShapeUnittest) ;
+  CPPUNIT_TEST ( baseShapesTest );
+  CPPUNIT_TEST ( assignmentTest );
+  CPPUNIT_TEST ( operatorTest );
+  CPPUNIT_TEST_SUITE_END();
+
+public:
+  void setUp();
+  void tearDown();
+
+  void baseShapesTest();
+  void assignmentTest();
+  void operatorTest();
+
+  // a lot of vectors.
+  // these define all the edges of a box around -1 +1 on each axis
+  // 0 is 0, 1 is 1 and 2 is -1
+  Vector v000;
+  Vector v100;
+  Vector v200;
+  Vector v010;
+  Vector v110;
+  Vector v210;
+  Vector v020;
+  Vector v120;
+  Vector v220;
+  Vector v001;
+  Vector v101;
+  Vector v201;
+  Vector v011;
+  Vector v111;
+  Vector v211;
+  Vector v021;
+  Vector v121;
+  Vector v221;
+  Vector v002;
+  Vector v102;
+  Vector v202;
+  Vector v012;
+  Vector v112;
+  Vector v212;
+  Vector v022;
+  Vector v122;
+  Vector v222;
+};
+
+#endif /* SHAPEUNITTEST_HPP_ */
Index: src/unittests/SingletonTest.cpp
===================================================================
--- src/unittests/SingletonTest.cpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/unittests/SingletonTest.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -5,4 +5,9 @@
  *      Author: crueger
  */
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
 
 #include "SingletonTest.hpp"
Index: src/unittests/analysisbondsunittest.cpp
===================================================================
--- src/unittests/analysisbondsunittest.cpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/unittests/analysisbondsunittest.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -5,4 +5,9 @@
  *      Author: heber
  */
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
 
 using namespace std;
@@ -16,5 +21,4 @@
 #include <cstring>
 
-#include "World.hpp"
 #include "analysis_bonds.hpp"
 #include "analysisbondsunittest.hpp"
@@ -25,4 +29,5 @@
 #include "molecule.hpp"
 #include "periodentafel.hpp"
+#include "LinearAlgebra/Vector.hpp"
 #include "World.hpp"
 
@@ -52,26 +57,26 @@
   Walker = World::getInstance().createAtom();
   CPPUNIT_ASSERT(Walker != NULL && "could not create atom");
-  Walker->type = hydrogen;
-  *Walker->node = Vector(1.5, 0., 1.5 );
+  Walker->setType(hydrogen);
+  Walker->setPosition(Vector(1.5, 0., 1.5 ));
   TestMolecule->AddAtom(Walker);
   Walker = World::getInstance().createAtom();
   CPPUNIT_ASSERT(Walker != NULL && "could not create atom");
-  Walker->type = hydrogen;
-  *Walker->node = Vector(0., 1.5, 1.5 );
+  Walker->setType(hydrogen);
+  Walker->setPosition(Vector(0., 1.5, 1.5 ));
   TestMolecule->AddAtom(Walker);
   Walker = World::getInstance().createAtom();
   CPPUNIT_ASSERT(Walker != NULL && "could not create atom");
-  Walker->type = hydrogen;
-  *Walker->node = Vector(1.5, 1.5, 0. );
+  Walker->setType(hydrogen);
+  Walker->setPosition(Vector(1.5, 1.5, 0. ));
   TestMolecule->AddAtom(Walker);
   Walker = World::getInstance().createAtom();
   CPPUNIT_ASSERT(Walker != NULL && "could not create atom");
-  Walker->type = hydrogen;
-  *Walker->node = Vector(0., 0., 0. );
+  Walker->setType(hydrogen);
+  Walker->setPosition(Vector(0., 0., 0. ));
   TestMolecule->AddAtom(Walker);
   Walker = World::getInstance().createAtom();
   CPPUNIT_ASSERT(Walker != NULL && "could not create atom");
-  Walker->type = carbon;
-  *Walker->node = Vector(0.5, 0.5, 0.5 );
+  Walker->setType(carbon);
+  Walker->setPosition(Vector(0.5, 0.5, 0.5 ));
   TestMolecule->AddAtom(Walker);
 
Index: src/unittests/atomsCalculationTest.cpp
===================================================================
--- src/unittests/atomsCalculationTest.cpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/unittests/atomsCalculationTest.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -5,4 +5,9 @@
  *      Author: crueger
  */
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
 
 #include "atomsCalculationTest.hpp"
Index: src/unittests/atomsCalculationTest.hpp
===================================================================
--- src/unittests/atomsCalculationTest.hpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/unittests/atomsCalculationTest.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -11,5 +11,6 @@
 #include <cppunit/extensions/HelperMacros.h>
 
-#define ATOM_COUNT (10)
+// we prefer enum over define
+enum { ATOM_COUNT = 10 };
 
 #include "types.hpp"
Index: src/unittests/bondgraphunittest.cpp
===================================================================
--- src/unittests/bondgraphunittest.cpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/unittests/bondgraphunittest.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -5,4 +5,9 @@
  *      Author: heber
  */
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
 
 using namespace std;
@@ -23,5 +28,5 @@
 #include "bondgraph.hpp"
 #include "element.hpp"
-#include "log.hpp"
+#include "Helpers/Log.hpp"
 #include "molecule.hpp"
 #include "periodentafel.hpp"
@@ -54,24 +59,24 @@
   Walker = World::getInstance().createAtom();
   CPPUNIT_ASSERT(Walker != NULL && "could not create atom");
-  Walker->type = carbon;
-  *Walker->node = Vector(1., 0., 1. );
+  Walker->setType(carbon);
+  Walker->setPosition(Vector(1., 0., 1. ));
   TestMolecule->AddAtom(Walker);
 
   Walker = World::getInstance().createAtom();
   CPPUNIT_ASSERT(Walker != NULL && "could not create atom");
-  Walker->type = carbon;
-  *Walker->node = Vector(0., 1., 1. );
+  Walker->setType(carbon);
+  Walker->setPosition(Vector(0., 1., 1. ));
   TestMolecule->AddAtom(Walker);
 
   Walker = World::getInstance().createAtom();
   CPPUNIT_ASSERT(Walker != NULL && "could not create atom");
-  Walker->type = carbon;
-  *Walker->node = Vector(1., 1., 0. );
+  Walker->setType(carbon);
+  Walker->setPosition(Vector(1., 1., 0. ));
   TestMolecule->AddAtom(Walker);
 
   Walker = World::getInstance().createAtom();
   CPPUNIT_ASSERT(Walker != NULL && "could not create atom");
-  Walker->type = carbon;
-  *Walker->node = Vector(0., 0., 0. );
+  Walker->setType(carbon);
+  Walker->setPosition(Vector(0., 0., 0. ));
   TestMolecule->AddAtom(Walker);
 
Index: src/unittests/gslmatrixsymmetricunittest.cpp
===================================================================
--- src/unittests/gslmatrixsymmetricunittest.cpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/unittests/gslmatrixsymmetricunittest.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -5,4 +5,9 @@
  *      Author: heber
  */
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
 
 using namespace std;
Index: src/unittests/gslmatrixsymmetricunittest.hpp
===================================================================
--- src/unittests/gslmatrixsymmetricunittest.hpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/unittests/gslmatrixsymmetricunittest.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -11,5 +11,5 @@
 #include <cppunit/extensions/HelperMacros.h>
 
-#include "gslmatrix.hpp"
+#include "LinearAlgebra/gslmatrix.hpp"
 
 /********************************************** Test classes **************************************/
Index: src/unittests/gslmatrixunittest.cpp
===================================================================
--- src/unittests/gslmatrixunittest.cpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/unittests/gslmatrixunittest.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -5,4 +5,9 @@
  *      Author: heber
  */
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
 
 using namespace std;
Index: src/unittests/gslmatrixunittest.hpp
===================================================================
--- src/unittests/gslmatrixunittest.hpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/unittests/gslmatrixunittest.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -11,5 +11,5 @@
 #include <cppunit/extensions/HelperMacros.h>
 
-#include "gslmatrix.hpp"
+#include "LinearAlgebra/gslmatrix.hpp"
 
 /********************************************** Test classes **************************************/
Index: src/unittests/gslvectorunittest.cpp
===================================================================
--- src/unittests/gslvectorunittest.cpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/unittests/gslvectorunittest.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -5,4 +5,9 @@
  *      Author: heber
  */
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
 
 using namespace std;
Index: src/unittests/gslvectorunittest.hpp
===================================================================
--- src/unittests/gslvectorunittest.hpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/unittests/gslvectorunittest.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -11,5 +11,5 @@
 #include <cppunit/extensions/HelperMacros.h>
 
-#include "gslvector.hpp"
+#include "LinearAlgebra/gslvector.hpp"
 
 /********************************************** Test classes **************************************/
Index: src/unittests/infounittest.cpp
===================================================================
--- src/unittests/infounittest.cpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/unittests/infounittest.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -5,4 +5,9 @@
  *      Author: heber
  */
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
 
 using namespace std;
@@ -15,7 +20,7 @@
 #include <stdio.h>
 
-#include "info.hpp"
+#include "Helpers/Info.hpp"
 #include "infounittest.hpp"
-#include "log.hpp"
+#include "Helpers/Log.hpp"
 
 #ifdef HAVE_TESTRUNNER
Index: src/unittests/linearsystemofequationsunittest.cpp
===================================================================
--- src/unittests/linearsystemofequationsunittest.cpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/unittests/linearsystemofequationsunittest.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -6,4 +6,9 @@
  */
 
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
 using namespace std;
 
@@ -12,7 +17,8 @@
 #include <cppunit/extensions/TestFactoryRegistry.h>
 #include <cppunit/ui/text/TestRunner.h>
+#include <cmath>
 
 #include "linearsystemofequationsunittest.hpp"
-#include "vector.hpp"
+#include "LinearAlgebra/Vector.hpp"
 
 #ifdef HAVE_TESTRUNNER
Index: src/unittests/linearsystemofequationsunittest.hpp
===================================================================
--- src/unittests/linearsystemofequationsunittest.hpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/unittests/linearsystemofequationsunittest.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -11,5 +11,5 @@
 #include <cppunit/extensions/HelperMacros.h>
 
-#include "linearsystemofequations.hpp"
+#include "LinearAlgebra/linearsystemofequations.hpp"
 
 /********************************************** Test classes **************************************/
Index: src/unittests/listofbondsunittest.cpp
===================================================================
--- src/unittests/listofbondsunittest.cpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/unittests/listofbondsunittest.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -5,4 +5,9 @@
  *      Author: user
  */
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
 
 using namespace std;
@@ -47,21 +52,21 @@
   Walker = World::getInstance().createAtom();
   CPPUNIT_ASSERT(Walker != NULL && "could not create atom");
-  Walker->type = hydrogen;
-  *Walker->node = Vector(1., 0., 1. );
-  TestMolecule->AddAtom(Walker);
-  Walker = World::getInstance().createAtom();
-  CPPUNIT_ASSERT(Walker != NULL && "could not create atom");
-  Walker->type = hydrogen;
-  *Walker->node = Vector(0., 1., 1. );
-  TestMolecule->AddAtom(Walker);
-  Walker = World::getInstance().createAtom();
-  CPPUNIT_ASSERT(Walker != NULL && "could not create atom");
-  Walker->type = hydrogen;
-  *Walker->node = Vector(1., 1., 0. );
-  TestMolecule->AddAtom(Walker);
-  Walker = World::getInstance().createAtom();
-  CPPUNIT_ASSERT(Walker != NULL && "could not create atom");
-  Walker->type = hydrogen;
-  *Walker->node = Vector(0., 0., 0. );
+  Walker->setType(hydrogen);
+  Walker->setPosition(Vector(1., 0., 1. ));
+  TestMolecule->AddAtom(Walker);
+  Walker = World::getInstance().createAtom();
+  CPPUNIT_ASSERT(Walker != NULL && "could not create atom");
+  Walker->setType(hydrogen);
+  Walker->setPosition(Vector(0., 1., 1. ));
+  TestMolecule->AddAtom(Walker);
+  Walker = World::getInstance().createAtom();
+  CPPUNIT_ASSERT(Walker != NULL && "could not create atom");
+  Walker->setType(hydrogen);
+  Walker->setPosition(Vector(1., 1., 0. ));
+  TestMolecule->AddAtom(Walker);
+  Walker = World::getInstance().createAtom();
+  CPPUNIT_ASSERT(Walker != NULL && "could not create atom");
+  Walker->setType(hydrogen);
+  Walker->setPosition(Vector(0., 0., 0. ));
   TestMolecule->AddAtom(Walker);
 
Index: src/unittests/logunittest.cpp
===================================================================
--- src/unittests/logunittest.cpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/unittests/logunittest.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -3,4 +3,9 @@
  */
 
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
 
 using namespace std;
@@ -11,7 +16,7 @@
 
 #include "logunittest.hpp"
-#include "log.hpp"
+#include "Helpers/Log.hpp"
 #include "defs.hpp"
-#include "verbose.hpp"
+#include "Helpers/Verbose.hpp"
 
 #ifdef HAVE_TESTRUNNER
Index: src/unittests/manipulateAtomsTest.cpp
===================================================================
--- src/unittests/manipulateAtomsTest.cpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/unittests/manipulateAtomsTest.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -5,4 +5,9 @@
  *      Author: crueger
  */
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
 
 #include "manipulateAtomsTest.hpp"
@@ -22,4 +27,6 @@
 #include "World.hpp"
 #include "atom.hpp"
+
+#include "DummyUI.hpp"
 
 #ifdef HAVE_TESTRUNNER
@@ -72,6 +79,13 @@
 // set up and tear down
 void manipulateAtomsTest::setUp(){
+  static bool hasDescriptor = false;
   ActionHistory::init();
   World::getInstance();
+  // TODO: find a way to really reset the factory to a clean state in tear-down
+  if(!hasDescriptor){
+    UIFactory::registerFactory(new DummyUIFactory::description());
+    hasDescriptor = true;
+  }
+  UIFactory::makeUserInterface("Dummy");
   for(int i=0;i<ATOM_COUNT;++i){
     atoms[i]= new AtomStub(i);
@@ -83,4 +97,5 @@
   ActionRegistry::purgeInstance();
   ActionHistory::purgeInstance();
+  UIFactory::purgeInstance();
 }
 
Index: src/unittests/manipulateAtomsTest.hpp
===================================================================
--- src/unittests/manipulateAtomsTest.hpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/unittests/manipulateAtomsTest.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -11,5 +11,6 @@
 #include <cppunit/extensions/HelperMacros.h>
 
-#define ATOM_COUNT (10)
+// we prefer enum over define
+enum { ATOM_COUNT = 10 };
 
 class atom;
Index: src/unittests/memoryallocatorunittest.cpp
===================================================================
--- src/unittests/memoryallocatorunittest.cpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/unittests/memoryallocatorunittest.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -1,6 +1,12 @@
 /*
  * memoryallocatorunittest.cpp
+ *
  */
 
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
 
 using namespace std;
@@ -13,6 +19,6 @@
 #include "memoryallocatorunittest.hpp"
 #include "memoryusageobserver.hpp"
-#include "helpers.hpp"
-#include "log.hpp"
+#include "Helpers/helpers.hpp"
+#include "Helpers/Log.hpp"
 #include "defs.hpp"
 
Index: src/unittests/memoryusageobserverunittest.cpp
===================================================================
--- src/unittests/memoryusageobserverunittest.cpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/unittests/memoryusageobserverunittest.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -3,4 +3,9 @@
  */
 
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
 
 using namespace std;
Index: src/unittests/periodentafelTest.cpp
===================================================================
--- src/unittests/periodentafelTest.cpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/unittests/periodentafelTest.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -6,4 +6,9 @@
  */
 
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
 using namespace std;
 
@@ -11,4 +16,7 @@
 #include <cppunit/extensions/TestFactoryRegistry.h>
 #include <cppunit/ui/text/TestRunner.h>
+
+#include <sstream>
+#include <iostream>
 
 #include "Helpers/Assert.hpp"
@@ -67,5 +75,6 @@
 {
   // reload all databases
-  CPPUNIT_ASSERT(tafel->LoadElementsDatabase(new stringstream(elementsDB,ios_base::in)) && "General element initialization failed");
+  stringstream elementsDBstream(elementsDB,ios_base::in);
+  CPPUNIT_ASSERT(tafel->LoadElementsDatabase(elementsDBstream) && "General element initialization failed");
   CPPUNIT_ASSERT(tafel->LoadValenceDatabase(new stringstream(valenceDB,ios_base::in)) && "Valence entry of element initialization failed");
   CPPUNIT_ASSERT(tafel->LoadOrbitalsDatabase(new stringstream(orbitalsDB,ios_base::in)) && "Orbitals entry of element initialization failed");
Index: src/unittests/periodentafelTest.hpp
===================================================================
--- src/unittests/periodentafelTest.hpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/unittests/periodentafelTest.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -31,6 +31,6 @@
 private:
 
-      element *hydrogen;
-      element *carbon;
+      const element *hydrogen;
+      const element *carbon;
       periodentafel *tafel;
 
Index: src/unittests/stackclassunittest.cpp
===================================================================
--- src/unittests/stackclassunittest.cpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/unittests/stackclassunittest.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -5,4 +5,9 @@
  *      Author: heber
  */
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
 
 using namespace std;
@@ -13,5 +18,5 @@
 
 #include "stackclassunittest.hpp"
-#include "log.hpp"
+#include "Helpers/Log.hpp"
 
 #ifdef HAVE_TESTRUNNER
Index: src/unittests/tesselation_boundarytriangleunittest.cpp
===================================================================
--- src/unittests/tesselation_boundarytriangleunittest.cpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/unittests/tesselation_boundarytriangleunittest.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -6,4 +6,9 @@
  */
 
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
 using namespace std;
 
@@ -13,7 +18,12 @@
 
 #include <cstring>
+#include <iostream>
 
 #include "defs.hpp"
-#include "tesselation.hpp"
+#include "TesselPoint.hpp"
+#include "BoundaryPointSet.hpp"
+#include "BoundaryLineSet.hpp"
+#include "BoundaryTriangleSet.hpp"
+#include "CandidateForTesselation.hpp"
 #include "tesselation_boundarytriangleunittest.hpp"
 
@@ -22,5 +32,5 @@
 #endif /*HAVE_TESTRUNNER*/
 
-#define SPHERERADIUS 2.
+const double TesselationBoundaryTriangleTest::SPHERERADIUS=2.;
 
 /********************************************** Test classes **************************************/
@@ -36,15 +46,15 @@
   // create nodes
   tesselpoints[0] = new TesselPoint;
-  tesselpoints[0]->node = new Vector(0., 0., 0.);
+  tesselpoints[0]->setPosition(Vector(0., 0., 0.));
   tesselpoints[0]->setName("1");
   tesselpoints[0]->nr = 1;
   points[0] = new BoundaryPointSet(tesselpoints[0]);
   tesselpoints[1] = new TesselPoint;
-  tesselpoints[1]->node = new Vector(0., 1., 0.);
+  tesselpoints[1]->setPosition(Vector(0., 1., 0.));
   tesselpoints[1]->setName("2");
   tesselpoints[1]->nr = 2;
   points[1] = new BoundaryPointSet(tesselpoints[1]);
   tesselpoints[2] = new TesselPoint;
-  tesselpoints[2]->node = new Vector(1., 0., 0.);
+  tesselpoints[2]->setPosition(Vector(1., 0., 0.));
   tesselpoints[2]->setName("3");
   tesselpoints[2]->nr = 3;
@@ -67,5 +77,4 @@
   for (int i=0;i<3;++i) {
     // TesselPoint does not delete its vector as it only got a reference
-    delete tesselpoints[i]->node;
     delete tesselpoints[i];
   }
@@ -83,9 +92,9 @@
   // simple test on y line
   Point = Vector(-1.,0.5,0.);
-  CPPUNIT_ASSERT_EQUAL( 1., triangle->GetClosestPointInsideTriangle(&Point, &TestIntersection) );
+  CPPUNIT_ASSERT_EQUAL( 1., triangle->GetClosestPointInsideTriangle(Point, TestIntersection) );
   Point = Vector(0.,0.5,0.);
   CPPUNIT_ASSERT_EQUAL( true , Point == TestIntersection );
   Point = Vector(-4.,0.5,0.);
-  CPPUNIT_ASSERT_EQUAL( 16., triangle->GetClosestPointInsideTriangle(&Point, &TestIntersection) );
+  CPPUNIT_ASSERT_EQUAL( 16., triangle->GetClosestPointInsideTriangle(Point, TestIntersection) );
   Point = Vector(0.,0.5,0.);
   CPPUNIT_ASSERT_EQUAL( true , Point == TestIntersection );
@@ -93,9 +102,9 @@
   // simple test on x line
   Point = Vector(0.5,-1.,0.);
-  CPPUNIT_ASSERT_EQUAL( 1., triangle->GetClosestPointInsideTriangle(&Point, &TestIntersection) );
+  CPPUNIT_ASSERT_EQUAL( 1., triangle->GetClosestPointInsideTriangle(Point, TestIntersection) );
   Point = Vector(0.5,0.,0.);
   CPPUNIT_ASSERT_EQUAL( true , Point == TestIntersection );
   Point = Vector(0.5,-6.,0.);
-  CPPUNIT_ASSERT_EQUAL( 36., triangle->GetClosestPointInsideTriangle(&Point, &TestIntersection) );
+  CPPUNIT_ASSERT_EQUAL( 36., triangle->GetClosestPointInsideTriangle(Point, TestIntersection) );
   Point = Vector(0.5,0.,0.);
   CPPUNIT_ASSERT_EQUAL( true , Point == TestIntersection );
@@ -103,9 +112,9 @@
   // simple test on slanted line
   Point = Vector(1.,1.,0.);
-  CPPUNIT_ASSERT_EQUAL( 0.5, triangle->GetClosestPointInsideTriangle(&Point, &TestIntersection) );
+  CPPUNIT_ASSERT_EQUAL( 0.5, triangle->GetClosestPointInsideTriangle(Point, TestIntersection) );
   Point = Vector(0.5,0.5,0.);
   CPPUNIT_ASSERT_EQUAL( true , Point == TestIntersection );
   Point = Vector(5.,5.,0.);
-  CPPUNIT_ASSERT_EQUAL( 40.5, triangle->GetClosestPointInsideTriangle(&Point, &TestIntersection) );
+  CPPUNIT_ASSERT_EQUAL( 40.5, triangle->GetClosestPointInsideTriangle(Point, TestIntersection) );
   Point = Vector(0.5,0.5,0.);
   CPPUNIT_ASSERT_EQUAL( true , Point == TestIntersection );
@@ -113,5 +122,5 @@
   // simple test on first node
   Point = Vector(-1.,-1.,0.);
-  CPPUNIT_ASSERT_EQUAL( 2., triangle->GetClosestPointInsideTriangle(&Point, &TestIntersection) );
+  CPPUNIT_ASSERT_EQUAL( 2., triangle->GetClosestPointInsideTriangle(Point, TestIntersection) );
   Point = Vector(0.,0.,0.);
   CPPUNIT_ASSERT_EQUAL( true , Point == TestIntersection );
@@ -119,5 +128,5 @@
   // simple test on second node
   Point = Vector(0.,2.,0.);
-  CPPUNIT_ASSERT_EQUAL( 1., triangle->GetClosestPointInsideTriangle(&Point, &TestIntersection) );
+  CPPUNIT_ASSERT_EQUAL( 1., triangle->GetClosestPointInsideTriangle(Point, TestIntersection) );
   Point = Vector(0.,1.,0.);
   CPPUNIT_ASSERT_EQUAL( true , Point == TestIntersection );
@@ -125,5 +134,5 @@
   // simple test on third node
   Point = Vector(2.,0.,0.);
-  CPPUNIT_ASSERT_EQUAL( 1., triangle->GetClosestPointInsideTriangle(&Point, &TestIntersection) );
+  CPPUNIT_ASSERT_EQUAL( 1., triangle->GetClosestPointInsideTriangle(Point, TestIntersection) );
   Point = Vector(1.,0.,0.);
   CPPUNIT_ASSERT_EQUAL( true , Point == TestIntersection );
@@ -139,9 +148,9 @@
   // straight down/up
   Point = Vector(1./3.,1./3.,+5.);
-  CPPUNIT_ASSERT_EQUAL( 25. , triangle->GetClosestPointInsideTriangle(&Point, &TestIntersection) );
+  CPPUNIT_ASSERT_EQUAL( 25. , triangle->GetClosestPointInsideTriangle(Point, TestIntersection) );
   Point = Vector(1./3.,1./3.,0.);
   CPPUNIT_ASSERT_EQUAL( true , Point == TestIntersection );
   Point = Vector(1./3.,1./3.,-5.);
-  CPPUNIT_ASSERT_EQUAL( 25. , triangle->GetClosestPointInsideTriangle(&Point, &TestIntersection) );
+  CPPUNIT_ASSERT_EQUAL( 25. , triangle->GetClosestPointInsideTriangle(Point, TestIntersection) );
   Point = Vector(1./3.,1./3.,0.);
   CPPUNIT_ASSERT_EQUAL( true , Point == TestIntersection );
@@ -149,9 +158,9 @@
   // simple test on y line
   Point = Vector(-1.,0.5,+2.);
-  CPPUNIT_ASSERT_EQUAL( 5., triangle->GetClosestPointInsideTriangle(&Point, &TestIntersection) );
+  CPPUNIT_ASSERT_EQUAL( 5., triangle->GetClosestPointInsideTriangle(Point, TestIntersection) );
   Point = Vector(0.,0.5,0.);
   CPPUNIT_ASSERT_EQUAL( true , Point == TestIntersection );
   Point = Vector(-1.,0.5,-3.);
-  CPPUNIT_ASSERT_EQUAL( 10., triangle->GetClosestPointInsideTriangle(&Point, &TestIntersection) );
+  CPPUNIT_ASSERT_EQUAL( 10., triangle->GetClosestPointInsideTriangle(Point, TestIntersection) );
   Point = Vector(0.,0.5,0.);
   CPPUNIT_ASSERT_EQUAL( true , Point == TestIntersection );
@@ -159,9 +168,9 @@
   // simple test on x line
   Point = Vector(0.5,-1.,+1.);
-  CPPUNIT_ASSERT_EQUAL( 2., triangle->GetClosestPointInsideTriangle(&Point, &TestIntersection) );
+  CPPUNIT_ASSERT_EQUAL( 2., triangle->GetClosestPointInsideTriangle(Point, TestIntersection) );
   Point = Vector(0.5,0.,0.);
   CPPUNIT_ASSERT_EQUAL( true , Point == TestIntersection );
   Point = Vector(0.5,-1.,-2.);
-  CPPUNIT_ASSERT_EQUAL( 5., triangle->GetClosestPointInsideTriangle(&Point, &TestIntersection) );
+  CPPUNIT_ASSERT_EQUAL( 5., triangle->GetClosestPointInsideTriangle(Point, TestIntersection) );
   Point = Vector(0.5,0.,0.);
   CPPUNIT_ASSERT_EQUAL( true , Point == TestIntersection );
@@ -169,9 +178,9 @@
   // simple test on slanted line
   Point = Vector(1.,1.,+3.);
-  CPPUNIT_ASSERT_EQUAL( 9.5, triangle->GetClosestPointInsideTriangle(&Point, &TestIntersection) );
+  CPPUNIT_ASSERT_EQUAL( 9.5, triangle->GetClosestPointInsideTriangle(Point, TestIntersection) );
   Point = Vector(0.5,0.5,0.);
   CPPUNIT_ASSERT_EQUAL( true , Point == TestIntersection );
   Point = Vector(1.,1.,-4.);
-  CPPUNIT_ASSERT_EQUAL( 16.5, triangle->GetClosestPointInsideTriangle(&Point, &TestIntersection) );
+  CPPUNIT_ASSERT_EQUAL( 16.5, triangle->GetClosestPointInsideTriangle(Point, TestIntersection) );
   Point = Vector(0.5,0.5,0.);
   CPPUNIT_ASSERT_EQUAL( true , Point == TestIntersection );
@@ -179,5 +188,5 @@
   // simple test on first node
   Point = Vector(-1.,-1.,5.);
-  CPPUNIT_ASSERT_EQUAL( 27., triangle->GetClosestPointInsideTriangle(&Point, &TestIntersection) );
+  CPPUNIT_ASSERT_EQUAL( 27., triangle->GetClosestPointInsideTriangle(Point, TestIntersection) );
   Point = Vector(0.,0.,0.);
   CPPUNIT_ASSERT_EQUAL( true , Point == TestIntersection );
@@ -185,5 +194,5 @@
   // simple test on second node
   Point = Vector(0.,2.,5.);
-  CPPUNIT_ASSERT_EQUAL( 26., triangle->GetClosestPointInsideTriangle(&Point, &TestIntersection) );
+  CPPUNIT_ASSERT_EQUAL( 26., triangle->GetClosestPointInsideTriangle(Point, TestIntersection) );
   Point = Vector(0.,1.,0.);
   CPPUNIT_ASSERT_EQUAL( true , Point == TestIntersection );
@@ -191,5 +200,5 @@
   // simple test on third node
   Point = Vector(2.,0.,5.);
-  CPPUNIT_ASSERT_EQUAL( 26., triangle->GetClosestPointInsideTriangle(&Point, &TestIntersection) );
+  CPPUNIT_ASSERT_EQUAL( 26., triangle->GetClosestPointInsideTriangle(Point, TestIntersection) );
   Point = Vector(1.,0.,0.);
   CPPUNIT_ASSERT_EQUAL( true , Point == TestIntersection );
Index: src/unittests/tesselation_boundarytriangleunittest.hpp
===================================================================
--- src/unittests/tesselation_boundarytriangleunittest.hpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/unittests/tesselation_boundarytriangleunittest.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -16,4 +16,6 @@
 #include "tesselation.hpp"
 
+class TesselPoint;
+
 /********************************************** Test classes **************************************/
 
@@ -32,4 +34,6 @@
 
 private:
+      static const double SPHERERADIUS;
+
       class BoundaryTriangleSet *triangle;
       class BoundaryLineSet *lines[3];
Index: src/unittests/tesselation_insideoutsideunittest.cpp
===================================================================
--- src/unittests/tesselation_insideoutsideunittest.cpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/unittests/tesselation_insideoutsideunittest.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -5,4 +5,9 @@
  *      Author: heber
  */
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
 
 using namespace std;
@@ -13,8 +18,13 @@
 
 #include <cstring>
+#include <iostream>
 
 #include "defs.hpp"
-#include "tesselation.hpp"
+#include "TesselPoint.hpp"
+#include "BoundaryLineSet.hpp"
+#include "BoundaryTriangleSet.hpp"
+#include "CandidateForTesselation.hpp"
 #include "tesselation_insideoutsideunittest.hpp"
+#include "Helpers/Verbose.hpp"
 
 #ifdef HAVE_TESTRUNNER
@@ -22,5 +32,5 @@
 #endif /*HAVE_TESTRUNNER*/
 
-#define SPHERERADIUS 2.
+const double TesselationInOutsideTest::SPHERERADIUS=2.;
 
 /********************************************** Test classes **************************************/
@@ -28,5 +38,4 @@
 // Registers the fixture into the 'registry'
 CPPUNIT_TEST_SUITE_REGISTRATION( TesselationInOutsideTest );
-
 
 void TesselationInOutsideTest::setUp()
@@ -37,40 +46,40 @@
   class TesselPoint *Walker;
   Walker = new TesselPoint;
-  Walker->node = new Vector(0., 0., 0.);
+  Walker->setPosition(Vector(0., 0., 0.));
   Walker->setName("1");
   Walker->nr = 1;
   Corners.push_back(Walker);
   Walker = new TesselPoint;
-  Walker->node = new Vector(0., 1., 0.);
+  Walker->setPosition(Vector(0., 1., 0.));
   Walker->setName("2");
   Walker->nr = 2;
   Corners.push_back(Walker);
   Walker = new TesselPoint;
-  Walker->node = new Vector(1., 0., 0.);
+  Walker->setPosition(Vector(1., 0., 0.));
   Walker->setName("3");
   Walker->nr = 3;
   Corners.push_back(Walker);
   Walker = new TesselPoint;
-  Walker->node = new Vector(1., 1., 0.);
+  Walker->setPosition(Vector(1., 1., 0.));
   Walker->setName("4");
   Walker->nr = 4;
   Corners.push_back(Walker);
   Walker = new TesselPoint;
-  Walker->node = new Vector(0., 0., 1.);
+  Walker->setPosition(Vector(0., 0., 1.));
   Walker->setName("5");
   Walker->nr = 5;
   Corners.push_back(Walker);
   Walker = new TesselPoint;
-  Walker->node = new Vector(0., 1., 1.);
+  Walker->setPosition(Vector(0., 1., 1.));
   Walker->setName("6");
   Walker->nr = 6;
   Corners.push_back(Walker);
   Walker = new TesselPoint;
-  Walker->node = new Vector(1., 0., 1.);
+  Walker->setPosition(Vector(1., 0., 1.));
   Walker->setName("7");
   Walker->nr = 7;
   Corners.push_back(Walker);
   Walker = new TesselPoint;
-  Walker->node = new Vector(1., 1., 1.);
+  Walker->setPosition(Vector(1., 1., 1.));
   Walker->setName("8");
   Walker->nr = 8;
@@ -129,8 +138,6 @@
   delete(LinkedList);
   delete(TesselStruct);
-  for (LinkedCell::LinkedNodes::iterator Runner = Corners.begin(); Runner != Corners.end(); Runner++) {
-    delete((*Runner)->node);
+  for (LinkedCell::LinkedNodes::iterator Runner = Corners.begin(); Runner != Corners.end(); Runner++)
     delete(*Runner);
-  }
   Corners.clear();
   logger::purgeInstance();
Index: src/unittests/tesselation_insideoutsideunittest.hpp
===================================================================
--- src/unittests/tesselation_insideoutsideunittest.hpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/unittests/tesselation_insideoutsideunittest.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -30,4 +30,6 @@
 
 private:
+      static const double SPHERERADIUS;
+
       class Tesselation *TesselStruct;
       LinkedCell::LinkedNodes Corners;
Index: src/unittests/tesselationunittest.cpp
===================================================================
--- src/unittests/tesselationunittest.cpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/unittests/tesselationunittest.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -6,4 +6,8 @@
  */
 
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
 
 using namespace std;
@@ -16,5 +20,8 @@
 
 #include "defs.hpp"
-#include "tesselation.hpp"
+#include "TesselPoint.hpp"
+#include "BoundaryLineSet.hpp"
+#include "BoundaryTriangleSet.hpp"
+#include "CandidateForTesselation.hpp"
 #include "tesselationunittest.hpp"
 
@@ -23,5 +30,5 @@
 #endif /*HAVE_TESTRUNNER*/
 
-#define SPHERERADIUS 2.
+const double TesselationTest::SPHERERADIUS=2.;
 
 /********************************************** Test classes **************************************/
@@ -36,20 +43,20 @@
   class TesselPoint *Walker;
   Walker = new TesselPoint;
-  Walker->node = new Vector(1., 0., -1.);
+  Walker->setPosition(Vector(1., 0., -1.));
   Walker->setName("1");
   Walker->nr = 1;
   Corners.push_back(Walker);
   Walker = new TesselPoint;
-  Walker->node = new Vector(-1., 1., -1.);
+  Walker->setPosition(Vector(-1., 1., -1.));
   Walker->setName("2");
   Walker->nr = 2;
   Corners.push_back(Walker);
   Walker = new TesselPoint;
-  Walker->node = new Vector(-1., -1., -1.);
+  Walker->setPosition(Vector(-1., -1., -1.));
   Walker->setName("3");
   Walker->nr = 3;
   Corners.push_back(Walker);
   Walker = new TesselPoint;
-  Walker->node = new Vector(-1., 0., 1.);
+  Walker->setPosition(Vector(-1., 0., 1.));
   Walker->setName("4");
   Walker->nr = 4;
@@ -101,8 +108,6 @@
   delete(LinkedList);
   delete(TesselStruct);
-  for (LinkedCell::LinkedNodes::iterator Runner = Corners.begin(); Runner != Corners.end(); Runner++) {
-    delete((*Runner)->node);
+  for (LinkedCell::LinkedNodes::iterator Runner = Corners.begin(); Runner != Corners.end(); Runner++)
     delete(*Runner);
-  }
   Corners.clear();
   logger::purgeInstance();
Index: src/unittests/tesselationunittest.hpp
===================================================================
--- src/unittests/tesselationunittest.hpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/unittests/tesselationunittest.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -33,4 +33,6 @@
 
 private:
+      static const double SPHERERADIUS;
+
       class Tesselation *TesselStruct;
       LinkedCell::LinkedNodes Corners;
Index: src/unittests/vectorunittest.cpp
===================================================================
--- src/unittests/vectorunittest.cpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/unittests/vectorunittest.cpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -6,4 +6,8 @@
  */
 
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
 
 using namespace std;
@@ -14,11 +18,11 @@
 
 #include "defs.hpp"
-#include "log.hpp"
-#include "memoryusageobserver.hpp"
-#include "vector.hpp"
-#include "vector_ops.hpp"
+#include "Helpers/Log.hpp"
+#include "LinearAlgebra/Vector.hpp"
+#include "LinearAlgebra/vector_ops.hpp"
 #include "vectorunittest.hpp"
-#include "Plane.hpp"
+#include "LinearAlgebra/Plane.hpp"
 #include "Exceptions/LinearDependenceException.hpp"
+#include "LinearAlgebra/Matrix.hpp"
 
 #ifdef HAVE_TESTRUNNER
@@ -52,4 +56,53 @@
   errorLogger::purgeInstance();
 };
+
+/** UnitTest for Constructors and Vector::IsZero() and Vector::IsOne().
+ */
+void VectorTest::AssignmentTest()
+{
+  // test with zero
+  zero.at(0) = 0;
+  zero.at(1) = 0;
+  zero.at(2) = 0;
+  double zero_array[3] = {0., 0., 0.};
+
+  CPPUNIT_ASSERT_EQUAL( zero, Vector(0,0,0));
+  CPPUNIT_ASSERT_EQUAL( zero, Vector(0.,0.,0.));
+  CPPUNIT_ASSERT_EQUAL( zero, Vector(zero_array[0], zero_array[1], zero_array[2]));
+  CPPUNIT_ASSERT_EQUAL( zero, Vector(zero_array));
+
+  // test with unit
+  unit.at(0) = 1;
+  unit.at(1) = 0;
+  unit.at(2) = 0;
+  double unit_array[3] = {1., 0., 0.};
+
+  CPPUNIT_ASSERT_EQUAL( unit, Vector(1,0,0));
+  CPPUNIT_ASSERT_EQUAL( unit, Vector(1.,0.,0.));
+  CPPUNIT_ASSERT_EQUAL( unit, Vector(unit_array[0], unit_array[1], unit_array[2]));
+  CPPUNIT_ASSERT_EQUAL( unit, Vector(unit_array));
+
+  // test with two
+  two.at(0) = 2;
+  two.at(1) = 1;
+  two.at(2) = 0;
+  double two_array[3] = {2., 1., 0.};
+
+  CPPUNIT_ASSERT_EQUAL( two, Vector(2,1,0));
+  CPPUNIT_ASSERT_EQUAL( two, Vector(2.,1.,0.));
+  CPPUNIT_ASSERT_EQUAL( two, Vector(two_array[0], two_array[1], two_array[2]));
+  CPPUNIT_ASSERT_EQUAL( two, Vector(two_array));
+
+  // test with three
+  three.at(0) = 1;
+  three.at(1) = 2;
+  three.at(2) = 3;
+  double three_array[3] = {1., 2., 3.};
+
+  CPPUNIT_ASSERT_EQUAL( three, Vector(1,2,3));
+  CPPUNIT_ASSERT_EQUAL( three, Vector(1.,2.,3.));
+  CPPUNIT_ASSERT_EQUAL( three, Vector(three_array[0], three_array[1], three_array[2]));
+  CPPUNIT_ASSERT_EQUAL( three, Vector(three_array));
+}
 
 /** UnitTest for Constructors and Vector::IsZero() and Vector::IsOne().
@@ -214,36 +267,2 @@
   CPPUNIT_ASSERT(testVector.ScalarProduct(three) < MYEPSILON);
 }
-
-
-/**
- * UnitTest for Vector::IsInParallelepiped().
- */
-void VectorTest::IsInParallelepipedTest()
-{
-  double parallelepiped[NDIM*NDIM];
-  parallelepiped[0] = 1;
-  parallelepiped[1] = 0;
-  parallelepiped[2] = 0;
-  parallelepiped[3] = 0;
-  parallelepiped[4] = 1;
-  parallelepiped[5] = 0;
-  parallelepiped[6] = 0;
-  parallelepiped[7] = 0;
-  parallelepiped[8] = 1;
-
-  fixture = zero;
-  CPPUNIT_ASSERT_EQUAL( false, fixture.IsInParallelepiped(Vector(2.,2.,2.), parallelepiped) );
-  fixture = Vector(2.5,2.5,2.5);
-  CPPUNIT_ASSERT_EQUAL( true, fixture.IsInParallelepiped(Vector(2.,2.,2.), parallelepiped) );
-  fixture = Vector(1.,1.,1.);
-  CPPUNIT_ASSERT_EQUAL( false, fixture.IsInParallelepiped(Vector(2.,2.,2.), parallelepiped) );
-  fixture = Vector(3.5,3.5,3.5);
-  CPPUNIT_ASSERT_EQUAL( false, fixture.IsInParallelepiped(Vector(2.,2.,2.), parallelepiped) );
-  fixture = Vector(2.,2.,2.);
-  CPPUNIT_ASSERT_EQUAL( true, fixture.IsInParallelepiped(Vector(2.,2.,2.), parallelepiped) );
-  fixture = Vector(2.,3.,2.);
-  CPPUNIT_ASSERT_EQUAL( true, fixture.IsInParallelepiped(Vector(2.,2.,2.), parallelepiped) );
-  fixture = Vector(-2.,2.,-1.);
-  CPPUNIT_ASSERT_EQUAL( false, fixture.IsInParallelepiped(Vector(2.,2.,2.), parallelepiped) );
-}
-
Index: src/unittests/vectorunittest.hpp
===================================================================
--- src/unittests/vectorunittest.hpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ src/unittests/vectorunittest.hpp	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -11,5 +11,5 @@
 #include <cppunit/extensions/HelperMacros.h>
 
-#include "vector.hpp"
+#include "LinearAlgebra/Vector.hpp"
 
 /********************************************** Test classes **************************************/
@@ -18,4 +18,5 @@
 {
     CPPUNIT_TEST_SUITE( VectorTest) ;
+    CPPUNIT_TEST ( AssignmentTest );
     CPPUNIT_TEST ( UnityTest );
     CPPUNIT_TEST ( SimpleAlgebraTest );
@@ -27,5 +28,4 @@
     CPPUNIT_TEST ( ProjectionTest );
     CPPUNIT_TEST ( NormalsTest );
-    CPPUNIT_TEST ( IsInParallelepipedTest );
     CPPUNIT_TEST_SUITE_END();
 
@@ -34,4 +34,5 @@
     void tearDown();
 
+    void AssignmentTest();
     void UnityTest();
     void OperatorAlgebraTest();
@@ -45,5 +46,4 @@
     void LineIntersectionTest();
     void VectorRotationTest();
-    void IsInParallelepipedTest();
 
 private:
Index: c/vector.cpp
===================================================================
--- src/vector.cpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ 	(revision )
@@ -1,718 +1,0 @@
-/** \file vector.cpp
- *
- * Function implementations for the class vector.
- *
- */
-
-#include "Helpers/MemDebug.hpp"
-
-#include "vector.hpp"
-#include "verbose.hpp"
-#include "World.hpp"
-#include "Helpers/Assert.hpp"
-#include "Helpers/fast_functions.hpp"
-
-#include <iostream>
-
-using namespace std;
-
-
-/************************************ Functions for class vector ************************************/
-
-/** Constructor of class vector.
- */
-Vector::Vector()
-{
-  content = gsl_vector_calloc (NDIM);
-};
-
-/**
- * Copy constructor
- */
-
-Vector::Vector(const Vector& src)
-{
-  content = gsl_vector_alloc(NDIM);
-  gsl_vector_set(content,0,src[0]);
-  gsl_vector_set(content,1,src[1]);
-  gsl_vector_set(content,2,src[2]);
-}
-
-/** Constructor of class vector.
- */
-Vector::Vector(const double x1, const double x2, const double x3)
-{
-  content = gsl_vector_alloc(NDIM);
-  gsl_vector_set(content,0,x1);
-  gsl_vector_set(content,1,x2);
-  gsl_vector_set(content,2,x3);
-};
-
-/**
- * Assignment operator
- */
-Vector& Vector::operator=(const Vector& src){
-  // check for self assignment
-  if(&src!=this){
-    gsl_vector_set(content,0,src[0]);
-    gsl_vector_set(content,1,src[1]);
-    gsl_vector_set(content,2,src[2]);
-  }
-  return *this;
-}
-
-/** Desctructor of class vector.
- */
-Vector::~Vector() {
-  gsl_vector_free(content);
-};
-
-/** Calculates square of distance between this and another vector.
- * \param *y array to second vector
- * \return \f$| x - y |^2\f$
- */
-double Vector::DistanceSquared(const Vector &y) const
-{
-  double res = 0.;
-  for (int i=NDIM;i--;)
-    res += (at(i)-y[i])*(at(i)-y[i]);
-  return (res);
-};
-
-/** Calculates distance between this and another vector.
- * \param *y array to second vector
- * \return \f$| x - y |\f$
- */
-double Vector::distance(const Vector &y) const
-{
-  return (sqrt(DistanceSquared(y)));
-};
-
-Vector Vector::getClosestPoint(const Vector &point) const{
-  // the closest point to a single point space is always the single point itself
-  return *this;
-}
-
-/** Calculates distance between this and another vector in a periodic cell.
- * \param *y array to second vector
- * \param *cell_size 6-dimensional array with (xx, xy, yy, xz, yz, zz) entries specifying the periodic cell
- * \return \f$| x - y |\f$
- */
-double Vector::PeriodicDistance(const Vector &y, const double * const cell_size) const
-{
-  double res = distance(y), tmp, matrix[NDIM*NDIM];
-    Vector Shiftedy, TranslationVector;
-    int N[NDIM];
-    matrix[0] = cell_size[0];
-    matrix[1] = cell_size[1];
-    matrix[2] = cell_size[3];
-    matrix[3] = cell_size[1];
-    matrix[4] = cell_size[2];
-    matrix[5] = cell_size[4];
-    matrix[6] = cell_size[3];
-    matrix[7] = cell_size[4];
-    matrix[8] = cell_size[5];
-    // in order to check the periodic distance, translate one of the vectors into each of the 27 neighbouring cells
-    for (N[0]=-1;N[0]<=1;N[0]++)
-      for (N[1]=-1;N[1]<=1;N[1]++)
-        for (N[2]=-1;N[2]<=1;N[2]++) {
-          // create the translation vector
-          TranslationVector.Zero();
-          for (int i=NDIM;i--;)
-            TranslationVector[i] = (double)N[i];
-          TranslationVector.MatrixMultiplication(matrix);
-          // add onto the original vector to compare with
-          Shiftedy = y + TranslationVector;
-          // get distance and compare with minimum so far
-          tmp = distance(Shiftedy);
-          if (tmp < res) res = tmp;
-        }
-    return (res);
-};
-
-/** Calculates distance between this and another vector in a periodic cell.
- * \param *y array to second vector
- * \param *cell_size 6-dimensional array with (xx, xy, yy, xz, yz, zz) entries specifying the periodic cell
- * \return \f$| x - y |^2\f$
- */
-double Vector::PeriodicDistanceSquared(const Vector &y, const double * const cell_size) const
-{
-  double res = DistanceSquared(y), tmp, matrix[NDIM*NDIM];
-    Vector Shiftedy, TranslationVector;
-    int N[NDIM];
-    matrix[0] = cell_size[0];
-    matrix[1] = cell_size[1];
-    matrix[2] = cell_size[3];
-    matrix[3] = cell_size[1];
-    matrix[4] = cell_size[2];
-    matrix[5] = cell_size[4];
-    matrix[6] = cell_size[3];
-    matrix[7] = cell_size[4];
-    matrix[8] = cell_size[5];
-    // in order to check the periodic distance, translate one of the vectors into each of the 27 neighbouring cells
-    for (N[0]=-1;N[0]<=1;N[0]++)
-      for (N[1]=-1;N[1]<=1;N[1]++)
-        for (N[2]=-1;N[2]<=1;N[2]++) {
-          // create the translation vector
-          TranslationVector.Zero();
-          for (int i=NDIM;i--;)
-            TranslationVector[i] = (double)N[i];
-          TranslationVector.MatrixMultiplication(matrix);
-          // add onto the original vector to compare with
-          Shiftedy = y + TranslationVector;
-          // get distance and compare with minimum so far
-          tmp = DistanceSquared(Shiftedy);
-          if (tmp < res) res = tmp;
-        }
-    return (res);
-};
-
-/** Keeps the vector in a periodic cell, defined by the symmetric \a *matrix.
- * \param *out ofstream for debugging messages
- * Tries to translate a vector into each adjacent neighbouring cell.
- */
-void Vector::KeepPeriodic(const double * const matrix)
-{
-  //  int N[NDIM];
-  //  bool flag = false;
-    //vector Shifted, TranslationVector;
-  //  Log() << Verbose(1) << "Begin of KeepPeriodic." << endl;
-  //  Log() << Verbose(2) << "Vector is: ";
-  //  Output(out);
-  //  Log() << Verbose(0) << endl;
-    InverseMatrixMultiplication(matrix);
-    for(int i=NDIM;i--;) { // correct periodically
-      if (at(i) < 0) {  // get every coefficient into the interval [0,1)
-        at(i) += ceil(at(i));
-      } else {
-        at(i) -= floor(at(i));
-      }
-    }
-    MatrixMultiplication(matrix);
-  //  Log() << Verbose(2) << "New corrected vector is: ";
-  //  Output(out);
-  //  Log() << Verbose(0) << endl;
-  //  Log() << Verbose(1) << "End of KeepPeriodic." << endl;
-};
-
-/** Calculates scalar product between this and another vector.
- * \param *y array to second vector
- * \return \f$\langle x, y \rangle\f$
- */
-double Vector::ScalarProduct(const Vector &y) const
-{
-  double res = 0.;
-  for (int i=NDIM;i--;)
-    res += at(i)*y[i];
-  return (res);
-};
-
-
-/** Calculates VectorProduct between this and another vector.
- *  -# returns the Product in place of vector from which it was initiated
- *  -# ATTENTION: Only three dim.
- *  \param *y array to vector with which to calculate crossproduct
- *  \return \f$ x \times y \f&
- */
-void Vector::VectorProduct(const Vector &y)
-{
-  Vector tmp;
-  for(int i=NDIM;i--;)
-    tmp[i] = at((i+1)%NDIM)*y[(i+2)%NDIM] - at((i+2)%NDIM)*y[(i+1)%NDIM];
-  (*this) = tmp;
-};
-
-
-/** projects this vector onto plane defined by \a *y.
- * \param *y normal vector of plane
- * \return \f$\langle x, y \rangle\f$
- */
-void Vector::ProjectOntoPlane(const Vector &y)
-{
-  Vector tmp;
-  tmp = y;
-  tmp.Normalize();
-  tmp.Scale(ScalarProduct(tmp));
-  *this -= tmp;
-};
-
-/** Calculates the minimum distance of this vector to the plane.
- * \sa Vector::GetDistanceVectorToPlane()
- * \param *out output stream for debugging
- * \param *PlaneNormal normal of plane
- * \param *PlaneOffset offset of plane
- * \return distance to plane
- */
-double Vector::DistanceToSpace(const Space &space) const
-{
-  return space.distance(*this);
-};
-
-/** Calculates the projection of a vector onto another \a *y.
- * \param *y array to second vector
- */
-void Vector::ProjectIt(const Vector &y)
-{
-  (*this) += (-ScalarProduct(y))*y;
-};
-
-/** Calculates the projection of a vector onto another \a *y.
- * \param *y array to second vector
- * \return Vector
- */
-Vector Vector::Projection(const Vector &y) const
-{
-  Vector helper = y;
-  helper.Scale((ScalarProduct(y)/y.NormSquared()));
-
-  return helper;
-};
-
-/** Calculates norm of this vector.
- * \return \f$|x|\f$
- */
-double Vector::Norm() const
-{
-  return (sqrt(NormSquared()));
-};
-
-/** Calculates squared norm of this vector.
- * \return \f$|x|^2\f$
- */
-double Vector::NormSquared() const
-{
-  return (ScalarProduct(*this));
-};
-
-/** Normalizes this vector.
- */
-void Vector::Normalize()
-{
-  double factor = Norm();
-  (*this) *= 1/factor;
-};
-
-/** Zeros all components of this vector.
- */
-void Vector::Zero()
-{
-  at(0)=at(1)=at(2)=0;
-};
-
-/** Zeros all components of this vector.
- */
-void Vector::One(const double one)
-{
-  at(0)=at(1)=at(2)=one;
-};
-
-/** Checks whether vector has all components zero.
- * @return true - vector is zero, false - vector is not
- */
-bool Vector::IsZero() const
-{
-  return (fabs(at(0))+fabs(at(1))+fabs(at(2)) < MYEPSILON);
-};
-
-/** Checks whether vector has length of 1.
- * @return true - vector is normalized, false - vector is not
- */
-bool Vector::IsOne() const
-{
-  return (fabs(Norm() - 1.) < MYEPSILON);
-};
-
-/** Checks whether vector is normal to \a *normal.
- * @return true - vector is normalized, false - vector is not
- */
-bool Vector::IsNormalTo(const Vector &normal) const
-{
-  if (ScalarProduct(normal) < MYEPSILON)
-    return true;
-  else
-    return false;
-};
-
-/** Checks whether vector is normal to \a *normal.
- * @return true - vector is normalized, false - vector is not
- */
-bool Vector::IsEqualTo(const Vector &a) const
-{
-  bool status = true;
-  for (int i=0;i<NDIM;i++) {
-    if (fabs(at(i) - a[i]) > MYEPSILON)
-      status = false;
-  }
-  return status;
-};
-
-/** Calculates the angle between this and another vector.
- * \param *y array to second vector
- * \return \f$\acos\bigl(frac{\langle x, y \rangle}{|x||y|}\bigr)\f$
- */
-double Vector::Angle(const Vector &y) const
-{
-  double norm1 = Norm(), norm2 = y.Norm();
-  double angle = -1;
-  if ((fabs(norm1) > MYEPSILON) && (fabs(norm2) > MYEPSILON))
-    angle = this->ScalarProduct(y)/norm1/norm2;
-  // -1-MYEPSILON occured due to numerical imprecision, catch ...
-  //Log() << Verbose(2) << "INFO: acos(-1) = " << acos(-1) << ", acos(-1+MYEPSILON) = " << acos(-1+MYEPSILON) << ", acos(-1-MYEPSILON) = " << acos(-1-MYEPSILON) << "." << endl;
-  if (angle < -1)
-    angle = -1;
-  if (angle > 1)
-    angle = 1;
-  return acos(angle);
-};
-
-
-double& Vector::operator[](size_t i){
-  ASSERT(i<=NDIM && i>=0,"Vector Index out of Range");
-  return *gsl_vector_ptr (content, i);
-}
-
-const double& Vector::operator[](size_t i) const{
-  ASSERT(i<=NDIM && i>=0,"Vector Index out of Range");
-  return *gsl_vector_ptr (content, i);
-}
-
-double& Vector::at(size_t i){
-  return (*this)[i];
-}
-
-const double& Vector::at(size_t i) const{
-  return (*this)[i];
-}
-
-gsl_vector* Vector::get(){
-  return content;
-}
-
-/** Compares vector \a to vector \a b component-wise.
- * \param a base vector
- * \param b vector components to add
- * \return a == b
- */
-bool Vector::operator==(const Vector& b) const
-{
-  return IsEqualTo(b);
-};
-
-bool Vector::operator!=(const Vector& b) const
-{
-  return !IsEqualTo(b);
-}
-
-/** Sums vector \a to this lhs component-wise.
- * \param a base vector
- * \param b vector components to add
- * \return lhs + a
- */
-const Vector& Vector::operator+=(const Vector& b)
-{
-  this->AddVector(b);
-  return *this;
-};
-
-/** Subtracts vector \a from this lhs component-wise.
- * \param a base vector
- * \param b vector components to add
- * \return lhs - a
- */
-const Vector& Vector::operator-=(const Vector& b)
-{
-  this->SubtractVector(b);
-  return *this;
-};
-
-/** factor each component of \a a times a double \a m.
- * \param a base vector
- * \param m factor
- * \return lhs.x[i] * m
- */
-const Vector& operator*=(Vector& a, const double m)
-{
-  a.Scale(m);
-  return a;
-};
-
-/** Sums two vectors \a  and \b component-wise.
- * \param a first vector
- * \param b second vector
- * \return a + b
- */
-Vector const Vector::operator+(const Vector& b) const
-{
-  Vector x = *this;
-  x.AddVector(b);
-  return x;
-};
-
-/** Subtracts vector \a from \b component-wise.
- * \param a first vector
- * \param b second vector
- * \return a - b
- */
-Vector const Vector::operator-(const Vector& b) const
-{
-  Vector x = *this;
-  x.SubtractVector(b);
-  return x;
-};
-
-/** Factors given vector \a a times \a m.
- * \param a vector
- * \param m factor
- * \return m * a
- */
-Vector const operator*(const Vector& a, const double m)
-{
-  Vector x(a);
-  x.Scale(m);
-  return x;
-};
-
-/** Factors given vector \a a times \a m.
- * \param m factor
- * \param a vector
- * \return m * a
- */
-Vector const operator*(const double m, const Vector& a )
-{
-  Vector x(a);
-  x.Scale(m);
-  return x;
-};
-
-ostream& operator<<(ostream& ost, const Vector& m)
-{
-  ost << "(";
-  for (int i=0;i<NDIM;i++) {
-    ost << m[i];
-    if (i != 2)
-      ost << ",";
-  }
-  ost << ")";
-  return ost;
-};
-
-
-void Vector::ScaleAll(const double *factor)
-{
-  for (int i=NDIM;i--;)
-    at(i) *= factor[i];
-};
-
-
-
-void Vector::Scale(const double factor)
-{
-  for (int i=NDIM;i--;)
-    at(i) *= factor;
-};
-
-/** Given a box by its matrix \a *M and its inverse *Minv the vector is made to point within that box.
- * \param *M matrix of box
- * \param *Minv inverse matrix
- */
-void Vector::WrapPeriodically(const double * const M, const double * const Minv)
-{
-  MatrixMultiplication(Minv);
-  // truncate to [0,1] for each axis
-  for (int i=0;i<NDIM;i++) {
-    //at(i) += 0.5;  // set to center of box
-    while (at(i) >= 1.)
-      at(i) -= 1.;
-    while (at(i) < 0.)
-      at(i) += 1.;
-  }
-  MatrixMultiplication(M);
-};
-
-std::pair<Vector,Vector> Vector::partition(const Vector &rhs) const{
-  double factor = ScalarProduct(rhs)/rhs.NormSquared();
-  Vector res= factor * rhs;
-  return make_pair(res,(*this)-res);
-}
-
-std::pair<pointset,Vector> Vector::partition(const pointset &points) const{
-  Vector helper = *this;
-  pointset res;
-  for(pointset::const_iterator iter=points.begin();iter!=points.end();++iter){
-    pair<Vector,Vector> currPart = helper.partition(*iter);
-    res.push_back(currPart.first);
-    helper = currPart.second;
-  }
-  return make_pair(res,helper);
-}
-
-/** Do a matrix multiplication.
- * \param *matrix NDIM_NDIM array
- */
-void Vector::MatrixMultiplication(const double * const M)
-{
-  Vector tmp;
-  // do the matrix multiplication
-  for(int i=NDIM;i--;)
-    tmp[i] = M[i]*at(0)+M[i+3]*at(1)+M[i+6]*at(2);
-
-  (*this) = tmp;
-};
-
-/** Do a matrix multiplication with the \a *A' inverse.
- * \param *matrix NDIM_NDIM array
- */
-bool Vector::InverseMatrixMultiplication(const double * const A)
-{
-  double B[NDIM*NDIM];
-  double detA = RDET3(A);
-  double detAReci;
-
-  // calculate the inverse B
-  if (fabs(detA) > MYEPSILON) {;  // RDET3(A) yields precisely zero if A irregular
-    detAReci = 1./detA;
-    B[0] =  detAReci*RDET2(A[4],A[5],A[7],A[8]);    // A_11
-    B[1] = -detAReci*RDET2(A[1],A[2],A[7],A[8]);    // A_12
-    B[2] =  detAReci*RDET2(A[1],A[2],A[4],A[5]);    // A_13
-    B[3] = -detAReci*RDET2(A[3],A[5],A[6],A[8]);    // A_21
-    B[4] =  detAReci*RDET2(A[0],A[2],A[6],A[8]);    // A_22
-    B[5] = -detAReci*RDET2(A[0],A[2],A[3],A[5]);    // A_23
-    B[6] =  detAReci*RDET2(A[3],A[4],A[6],A[7]);    // A_31
-    B[7] = -detAReci*RDET2(A[0],A[1],A[6],A[7]);    // A_32
-    B[8] =  detAReci*RDET2(A[0],A[1],A[3],A[4]);    // A_33
-
-    MatrixMultiplication(B);
-
-    return true;
-  } else {
-    return false;
-  }
-};
-
-
-/** Creates this vector as the b y *factors' components scaled linear combination of the given three.
- * this vector = x1*factors[0] + x2* factors[1] + x3*factors[2]
- * \param *x1 first vector
- * \param *x2 second vector
- * \param *x3 third vector
- * \param *factors three-component vector with the factor for each given vector
- */
-void Vector::LinearCombinationOfVectors(const Vector &x1, const Vector &x2, const Vector &x3, const double * const factors)
-{
-  (*this) = (factors[0]*x1) +
-            (factors[1]*x2) +
-            (factors[2]*x3);
-};
-
-/** Calculates orthonormal vector to one given vectors.
- * Just subtracts the projection onto the given vector from this vector.
- * The removed part of the vector is Vector::Projection()
- * \param *x1 vector
- * \return true - success, false - vector is zero
- */
-bool Vector::MakeNormalTo(const Vector &y1)
-{
-  bool result = false;
-  double factor = y1.ScalarProduct(*this)/y1.NormSquared();
-  Vector x1 = factor * y1;
-  SubtractVector(x1);
-  for (int i=NDIM;i--;)
-    result = result || (fabs(at(i)) > MYEPSILON);
-
-  return result;
-};
-
-/** Creates this vector as one of the possible orthonormal ones to the given one.
- * Just scan how many components of given *vector are unequal to zero and
- * try to get the skp of both to be zero accordingly.
- * \param *vector given vector
- * \return true - success, false - failure (null vector given)
- */
-bool Vector::GetOneNormalVector(const Vector &GivenVector)
-{
-  int Components[NDIM]; // contains indices of non-zero components
-  int Last = 0;   // count the number of non-zero entries in vector
-  int j;  // loop variables
-  double norm;
-
-  for (j=NDIM;j--;)
-    Components[j] = -1;
-
-  // in two component-systems we need to find the one position that is zero
-  int zeroPos = -1;
-  // find two components != 0
-  for (j=0;j<NDIM;j++){
-    if (fabs(GivenVector[j]) > MYEPSILON)
-      Components[Last++] = j;
-    else
-      // this our zero Position
-      zeroPos = j;
-  }
-
-  switch(Last) {
-    case 3:  // threecomponent system
-      // the position of the zero is arbitrary in three component systems
-      zeroPos = Components[2];
-    case 2:  // two component system
-      norm = sqrt(1./(GivenVector[Components[1]]*GivenVector[Components[1]]) + 1./(GivenVector[Components[0]]*GivenVector[Components[0]]));
-      at(zeroPos) = 0.;
-      // in skp both remaining parts shall become zero but with opposite sign and third is zero
-      at(Components[1]) = -1./GivenVector[Components[1]] / norm;
-      at(Components[0]) = 1./GivenVector[Components[0]] / norm;
-      return true;
-      break;
-    case 1: // one component system
-      // set sole non-zero component to 0, and one of the other zero component pendants to 1
-      at((Components[0]+2)%NDIM) = 0.;
-      at((Components[0]+1)%NDIM) = 1.;
-      at(Components[0]) = 0.;
-      return true;
-      break;
-    default:
-      return false;
-  }
-};
-
-/** Adds vector \a *y componentwise.
- * \param *y vector
- */
-void Vector::AddVector(const Vector &y)
-{
-  for(int i=NDIM;i--;)
-    at(i) += y[i];
-}
-
-/** Adds vector \a *y componentwise.
- * \param *y vector
- */
-void Vector::SubtractVector(const Vector &y)
-{
-  for(int i=NDIM;i--;)
-    at(i) -= y[i];
-}
-
-/**
- * Checks whether this vector is within the parallelepiped defined by the given three vectors and
- * their offset.
- *
- * @param offest for the origin of the parallelepiped
- * @param three vectors forming the matrix that defines the shape of the parallelpiped
- */
-bool Vector::IsInParallelepiped(const Vector &offset, const double * const parallelepiped) const
-{
-  Vector a = (*this)-offset;
-  a.InverseMatrixMultiplication(parallelepiped);
-  bool isInside = true;
-
-  for (int i=NDIM;i--;)
-    isInside = isInside && ((a[i] <= 1) && (a[i] >= 0));
-
-  return isInside;
-}
-
-
-// some comonly used vectors
-const Vector zeroVec(0,0,0);
-const Vector e1(1,0,0);
-const Vector e2(0,1,0);
-const Vector e3(0,0,1);
Index: c/vector.hpp
===================================================================
--- src/vector.hpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ 	(revision )
@@ -1,121 +1,0 @@
-#ifndef VECTOR_HPP_
-#define VECTOR_HPP_
-
-using namespace std;
-
-/*********************************************** includes ***********************************/
-
-// include config.h
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <iostream>
-#include <gsl/gsl_vector.h>
-#include <gsl/gsl_multimin.h>
-
-#include <memory>
-#include <vector>
-
-#include "defs.hpp"
-#include "Space.hpp"
-
-/********************************************** declarations *******************************/
-
-class Vector;
-
-typedef std::vector<Vector> pointset;
-
-/** Single vector.
- * basically, just a x[3] but with helpful functions
- */
-class Vector : public Space{
-public:
-
-  Vector();
-  Vector(const double x1, const double x2, const double x3);
-  Vector(const Vector& src);
-  virtual ~Vector();
-
-  // Method implemented by forwarding to the Representation
-
-  double DistanceSquared(const Vector &y) const;
-  double DistanceToSpace(const Space& space) const;
-  double PeriodicDistance(const Vector &y, const double * const cell_size) const;
-  double PeriodicDistanceSquared(const Vector &y, const double * const cell_size) const;
-  double ScalarProduct(const Vector &y) const;
-  double Angle(const Vector &y) const;
-  bool IsZero() const;
-  bool IsOne() const;
-  bool IsNormalTo(const Vector &normal) const;
-  bool IsEqualTo(const Vector &a) const;
-
-  void AddVector(const Vector &y);
-  void SubtractVector(const Vector &y);
-  void VectorProduct(const Vector &y);
-  void ProjectOntoPlane(const Vector &y);
-  void ProjectIt(const Vector &y);
-  Vector Projection(const Vector &y) const;
-  void ScaleAll(const double *factor);
-  void Scale(const double factor);
-  void MatrixMultiplication(const double * const M);
-  bool InverseMatrixMultiplication(const double * const M);
-  void KeepPeriodic(const double * const matrix);
-  bool GetOneNormalVector(const Vector &x1);
-  bool MakeNormalTo(const Vector &y1);
-  bool IsInParallelepiped(const Vector &offset, const double * const parallelepiped) const;
-  void WrapPeriodically(const double * const M, const double * const Minv);
-  std::pair<Vector,Vector> partition(const Vector&) const;
-  std::pair<pointset,Vector> partition(const pointset&) const;
-
-  // Accessors ussually come in pairs... and sometimes even more than that
-  double& operator[](size_t i);
-  const double& operator[](size_t i) const;
-  double& at(size_t i);
-  const double& at(size_t i) const;
-
-  // Assignment operator
-  Vector &operator=(const Vector& src);
-
-  // Access to internal structure
-  gsl_vector* get();
-
-  // Methods that are derived directly from other methods
-  double Norm() const;
-  double NormSquared() const;
-  void Normalize();
-  void Zero();
-  void One(const double one);
-  void LinearCombinationOfVectors(const Vector &x1, const Vector &x2, const Vector &x3, const double * const factors);
-
-  // operators for mathematical operations
-  bool operator==(const Vector& b) const;
-  bool operator!=(const Vector& b) const;
-  const Vector& operator+=(const Vector& b);
-  const Vector& operator-=(const Vector& b);
-  Vector const operator+(const Vector& b) const;
-  Vector const operator-(const Vector& b) const;
-
-  // Methods inherited from Space
-  virtual double distance(const Vector &point) const;
-  virtual Vector getClosestPoint(const Vector &point) const;
-
-protected:
-
-private:
-  gsl_vector *content;
-
-};
-
-// some commonly used and fixed vectors
-const extern Vector zeroVec;
-const extern Vector e1;
-const extern Vector e2;
-const extern Vector e3;
-
-ostream & operator << (ostream& ost, const Vector &m);
-const Vector& operator*=(Vector& a, const double m);
-Vector const operator*(const Vector& a, const double m);
-Vector const operator*(const double m, const Vector& a);
-
-#endif /*VECTOR_HPP_*/
Index: c/vector_ops.cpp
===================================================================
--- src/vector_ops.cpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ 	(revision )
@@ -1,114 +1,0 @@
-/*
- * vector_ops.cpp
- *
- *  Created on: Apr 1, 2010
- *      Author: crueger
- */
-
-#include "Helpers/MemDebug.hpp"
-
-#include "vector.hpp"
-#include "Plane.hpp"
-#include "log.hpp"
-#include "verbose.hpp"
-#include "gslmatrix.hpp"
-#include "leastsquaremin.hpp"
-#include "info.hpp"
-#include "Helpers/fast_functions.hpp"
-#include "Exceptions/LinearDependenceException.hpp"
-#include "Exceptions/SkewException.hpp"
-
-#include <gsl/gsl_linalg.h>
-#include <gsl/gsl_matrix.h>
-#include <gsl/gsl_permutation.h>
-#include <gsl/gsl_vector.h>
-
-/**
- * !@file
- * These files defines several common operation on vectors that should not
- * become part of the main vector class, because they are either to complex
- * or need methods from other subsystems that should not be moved to
- * the LinAlg-Subsystem
- */
-
-/** Creates a new vector as the one with least square distance to a given set of \a vectors.
- * \param *vectors set of vectors
- * \param num number of vectors
- * \return true if success, false if failed due to linear dependency
- */
-bool LSQdistance(Vector &res,const Vector **vectors, int num)
-{
-  int j;
-
-  for (j=0;j<num;j++) {
-    Log() << Verbose(1) << j << "th atom's vector: " << vectors[j] << endl;
-  }
-
-  int np = 3;
-  struct LSQ_params par;
-
-   const gsl_multimin_fminimizer_type *T =
-     gsl_multimin_fminimizer_nmsimplex;
-   gsl_multimin_fminimizer *s = NULL;
-   gsl_vector *ss, *y;
-   gsl_multimin_function minex_func;
-
-   size_t iter = 0, i;
-   int status;
-   double size;
-
-   /* Initial vertex size vector */
-   ss = gsl_vector_alloc (np);
-   y = gsl_vector_alloc (np);
-
-   /* Set all step sizes to 1 */
-   gsl_vector_set_all (ss, 1.0);
-
-   /* Starting point */
-   par.vectors = vectors;
-   par.num = num;
-
-   for (i=NDIM;i--;)
-    gsl_vector_set(y, i, (vectors[0]->at(i) - vectors[1]->at(i))/2.);
-
-   /* Initialize method and iterate */
-   minex_func.f = &LSQ;
-   minex_func.n = np;
-   minex_func.params = (void *)&par;
-
-   s = gsl_multimin_fminimizer_alloc (T, np);
-   gsl_multimin_fminimizer_set (s, &minex_func, y, ss);
-
-   do
-     {
-       iter++;
-       status = gsl_multimin_fminimizer_iterate(s);
-
-       if (status)
-         break;
-
-       size = gsl_multimin_fminimizer_size (s);
-       status = gsl_multimin_test_size (size, 1e-2);
-
-       if (status == GSL_SUCCESS)
-         {
-           printf ("converged to minimum at\n");
-         }
-
-       printf ("%5d ", (int)iter);
-       for (i = 0; i < (size_t)np; i++)
-         {
-           printf ("%10.3e ", gsl_vector_get (s->x, i));
-         }
-       printf ("f() = %7.3f size = %.3f\n", s->fval, size);
-     }
-   while (status == GSL_CONTINUE && iter < 100);
-
-  for (i=(size_t)np;i--;)
-    res[i] = gsl_vector_get(s->x, i);
-   gsl_vector_free(y);
-   gsl_vector_free(ss);
-   gsl_multimin_fminimizer_free (s);
-
-  return true;
-};
Index: c/vector_ops.hpp
===================================================================
--- src/vector_ops.hpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ 	(revision )
@@ -1,13 +1,0 @@
-/*
- * vector_ops.hpp
- *
- *  Created on: Apr 1, 2010
- *      Author: crueger
- */
-
-#ifndef VECTOR_OPS_HPP_
-#define VECTOR_OPS_HPP_
-
-bool LSQdistance(Vector &res,const Vector **vectors, int num);
-
-#endif /* VECTOR_OPS_HPP_ */
Index: c/verbose.cpp
===================================================================
--- src/verbose.cpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ 	(revision )
@@ -1,83 +1,0 @@
-using namespace std;
-
-#include "Helpers/MemDebug.hpp"
-
-#include "info.hpp"
-#include "verbose.hpp"
-
-/** Prints the tabs according to verbosity stored in the temporary constructed class.
- * \param &ost stream to extend with tabs
- * \return &ost stream with tabs
- */
-ostream& Verbose::print (ostream &ost) const
-{
-  for (int i=Verbosity+Info::verbosity;i--;)
-    ost.put('\t');
-  //Log() << Verbose(0) << "Verbose(.) called." << endl;
-  return ost;
-};
-
-/** States whether current output message should be print or not.
- * Compares Verbose::Verbosity plus Info::verbosity against \a verbosityLevel.
- * \param verbosityLevel given global level of verbosity
- * \return true - do output, false - don't
- */
-bool Verbose::DoOutput(int verbosityLevel) const
-{
-  return (verbosityLevel >= Verbosity+Info::verbosity);
-};
-
-/** States whether current error output message should be print or not.
- * Compares Verbose::Verbosity against \a verbosityLevel.
- * \param verbosityLevel given global level of verbosity
- * \return true - do output, false - don't
- */
-bool Verbose::DoErrorOutput(int verbosityLevel) const
-{
-  return (verbosityLevel >= Verbosity);
-};
-
-/** Operator for the Verbose(arg) call.
- * Constructs temporary a Verbose class object, wherein the verbosity is stored.
- * Then << is called, which calls Verbose's print which adds the tabs and returns the stream.
- * \param &ost stream to extend
- * \param &m pointer to created Verbose object
- * \return &ost
- */ 
-ostream& operator<<(ostream& ost,const Verbose& m)
-{
-  return m.print(ost);
-};
-
-/** Prints the tabs according to verbosity stored in the temporary constructed class.
- * Note that highest bit is set artificially to give number of bits to print
- * \param &ost stream to extend with tabs
- * \return &ost stream with tabs
- */
-ostream& Binary::print (ostream &ost) const
-{
-  int bits = 1, counter = 1;
-  while ((bits = 1 << counter) < BinaryNumber)
-    counter++;
-  for (int i=0;i<counter-1;i++) {
-    if ((BinaryNumber & (1 << i)) == 0)
-      ost.put('0');
-     else
-      ost.put('1');
-  }
-  ost.put('b');
-  //Log() << Verbose(0) << "Binary(.) called." << endl;
-  return ost;
-};
-
-/** Operator for the Binary(arg) call.
- * Constructs temporary a Verbose class object, wherein the Binary is stored.
- * Then << is called, which calls Binary's print which adds the tabs and returns the stream.
- * \param &ost stream to extend
- * \param &m pointer to created Binary object
- * \return &ost
- */ 
-ostream& operator<<(ostream& ost,const Binary& m)
-{
-  return m.print(ost);
-};
Index: c/verbose.hpp
===================================================================
--- src/verbose.hpp	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ 	(revision )
@@ -1,62 +1,0 @@
-/*
- * verbose.hpp
- *
- *  Created on: Aug 3, 2009
- *      Author: heber
- */
-
-#ifndef VERBOSE_HPP_
-#define VERBOSE_HPP_
-
-using namespace std;
-
-/*********************************************** includes ***********************************/
-
-// include config.h
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <iostream>
-
-/************************************* Class Verbose & Binary *******************************/
-
-/** Verbose is an IO manipulator, that writes tabs according to \a Verbosity level.
- */
-class Verbose
-{
-  public:
-    Verbose(int value) : Verbosity(value) { }
-
-    // allow access to private variable Verbose::Verbosity
-    friend ostream& operator<<(class errorLogger& l, const Verbose& v);
-    friend ostream& operator<<(class errorLogger* l, const Verbose& v);
-    friend ostream& operator<<(class logger& l, const Verbose& v);
-    friend ostream& operator<<(class logger* l, const Verbose& v);
-
-    ostream& print (ostream &ost) const;
-    bool DoOutput(int verbosityLevel) const;
-    bool DoErrorOutput(int verbosityLevel) const;
-  private:
-    int Verbosity;
-};
-
-ostream& operator<<(ostream& ost,const Verbose& m);
-
-/** Binary is an IO manipulator, that writes 0 and 1 according to number \a Binary.
- */
-class Binary
-{
-  public:
-    Binary(int value) : BinaryNumber(value) { }
-
-    ostream& print (ostream &ost) const;
-  private:
-    int BinaryNumber;
-};
-
-ostream& operator<<(ostream& ost,const Binary& m);
-
-
-
-#endif /* VERBOSE_HPP_ */
Index: test_all.sh
===================================================================
--- test_all.sh	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ test_all.sh	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -21,6 +21,14 @@
 outfile="test.log";
 logfile="full.log";
+noprocs=1;
 docheck=0;
 docheck_mem=0;
+if [ -n "$TMPDIR" ]
+then
+  tmpdir="$TMPDIR";
+else
+  tmpdir="/tmp";
+fi
+tmppattern="MolecuilderTest";
 
 function usage(){
@@ -33,10 +41,13 @@
   echo "  -o <outfile>		Outfile to use for test results";
   echo "  -f <logfile>		File to use for output from commands";
+  echo "  -j <no_proc>          Parallel compiling and tests";
   echo "  -s			Short tests (no memcheck)";
   echo "  -c            	Only configure and compile (implies -s)";
   echo "  -O <opt-level>	Only compile this optimization level";
-}
-
-while getopts âho:f:scO:â OPTION
+  echo "  -t <tmpDir>          	Use tmpDir as temporary directory";
+  echo "  -p <prefix>		Prefix to use for directory names (standard MolecuilderTest)";
+}
+
+while getopts âho:f:j:scO:t:p:â OPTION
 do
   case $OPTION in
@@ -46,8 +57,11 @@
       ;;
    o)
-     outfile=$OPTARG;
+     outfile="$OPTARG";
      ;;
    f)
-     logfile=$OPTARG;
+     logfile="$OPTARG";
+     ;;
+   j)
+     noprocs=("$OPTARG");
      ;;
    s)
@@ -61,4 +75,10 @@
      optimizations=("-O$OPTARG");
      ;;
+   t)
+     tmpdir="$OPTARG";
+     ;;
+   p)
+     tmppattern="$OPTARG";
+     ;;
    ?)
      usage;
@@ -68,5 +88,6 @@
 done
 
-if [[ -z $outfile ]] || [[ -z $logfile ]]
+# test if all arguments were provided
+if [[ -z "$outfile" ]] || [[ -z "$logfile" ]] || [[ -z "$tmpdir" ]] || [[ -z "$tmppattern" ]]
 then
   usage;
@@ -74,6 +95,8 @@
 fi
 
+# turn all relative paths into absolutes
 outfile=`realpath -s $outfile`;
 logfile=`realpath -s $logfile`;
+tmpdir=`realpath -s $tmpdir`;
 
 
@@ -87,10 +110,18 @@
 function compile(){
   echo "Making";
-  make all install >>$logfile 2>&1;
+  if [ $noprocs -gt 1 ]; then
+    make -j$noprocs all >>$logfile 2>&1;
+  else
+    make all >>$logfile 2>&1;
+  fi
 }
 
 function check(){
   echo "Checking";
-  make check >> $logfile 2>&1;
+  if [ $noprocs -gt 1 ]; then
+    make -j$noprocs check >> $logfile 2>&1;
+  else
+    make check >> $logfile 2>&1;
+  fi
 }
 
@@ -98,5 +129,5 @@
   echo "Valgrinding";
   retval=0;
-  for test in molecuilder/src/unittests/*
+  for test in src/unittests/*
   do
     if [ -x "$test" ]
@@ -104,5 +135,5 @@
       echo -n "    $test: " >> $outfile;
       valgrind -v --error-exitcode=255 $test >> $logfile 2>&1;
-      if $?
+      if [ $? ]
       then
       	echo "OK" >> $outfile
@@ -119,4 +150,8 @@
 
   echo "Testing with \"$2\"";
+  echo "" >> $logfile;
+  echo "" >> $logfile;
+  echo "" >> $logfile;
+  echo "Testing with \"$2\"" >> $logfile;
 
   echo -n "  Configuring: " >> $outfile;
@@ -167,5 +202,5 @@
 function run(){
   echo "Testing with \"$1\":" >> $outfile;
-  testdir=`mktemp -d --tmpdir MolecuilderTest.XXXXXXXXXX`;
+  testdir=`mktemp -d --tmpdir=$tmpdir $tmppattern.XXXXXXXXXX`;
   basedir=$PWD;
   cd $testdir;
Index: tests/Tesselations/Makefile.am
===================================================================
--- tests/Tesselations/Makefile.am	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ tests/Tesselations/Makefile.am	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -1,15 +1,17 @@
-TESTS = 1_2-dimethoxyethane.test \
-1_2-dimethylbenzene.test \
-2-methylcyclohexanone.test \
-benzene.test \
-cholesterol.test \
-cycloheptane.test \
-dimethyl_bromomalonate.test \
-glucose.test \
-heptan.test \
-isoleucine.test \
-neohexane.test \
-N_N-dimethylacetamide.test \
-proline.test \
-putrescine.test \
-tartaric_acid.test
+TESTS = \
+	1_2-dimethoxyethane.test \
+	1_2-dimethylbenzene.test \
+	2-methylcyclohexanone.test \
+	benzene.test \
+	cholesterol.test \
+	cycloheptane.test \
+	dimethyl_bromomalonate.test \
+	glucose.test \
+	isoleucine.test \
+	neohexane.test \
+	N_N-dimethylacetamide.test \
+	proline.test \
+	putrescine.test \
+	tartaric_acid.test
+
+#	heptan.test
Index: tests/Tesselations/defs.in
===================================================================
--- tests/Tesselations/defs.in	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ tests/Tesselations/defs.in	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -54,18 +54,18 @@
 	#echo "Current dir is `pwd`, calling $MOLECUILDER $mol.conf -e $exec_prefix -p ../$mol.xyz -N $RADIUS $FILENAME."
 	if [ -e $mol.dbond ]; then
-		$MOLECUILDER $mol.conf -e $exec_prefix -p ../$mol.xyz -A $mol.dbond -N 0 --sphere-radius $RADIUS --nonconvex-file $FILENAME 2>stderr >stdout || exitcode=$?
+		$MOLECUILDER -i ../$mol.xyz -A $mol.dbond --select-molecule-by-id 0 -N $RADIUS --nonconvex-file $FILENAME 2>stderr >stdout || exitcode=$?
 	else
-		$MOLECUILDER $mol.conf -e $exec_prefix -p ../$mol.xyz -N 0 --sphere-radius $RADIUS --nonconvex-file $FILENAME 2>stderr >stdout || exitcode=$?
+		$MOLECUILDER -i ../$mol.xyz --select-molecule-by-id 0 -N $RADIUS --nonconvex-file $FILENAME 2>stderr >stdout || exitcode=$?
 	fi
 	#echo "Molecuilder done with exitcode $exitcode."
+	cd ../..
 	#cat stderr
 	#cat stdout
-        grep -E "^[0-9]* [0-9]* [0-9]*$" ../../@srcdir@/$mol/$2/${FILENAME}-$mol.dat | sort -n >reference-triangles.dat
-        grep -E "^[0-9]* [0-9]* [0-9]*$" ${FILENAME}.dat | sort -n >new-triangles.dat
-        diff reference-triangles.dat new-triangles.dat 2>diffstderr >diffstdout || exitcode=$?
+        grep -E "^[0-9]* [0-9]* [0-9]*$" @srcdir@/$mol/$2/${FILENAME}-$mol.dat | sort -n >$testdir/$RADIUS/reference-triangles.dat
+        grep -E "^[0-9]* [0-9]* [0-9]*$" $testdir/$RADIUS/${FILENAME}.dat | sort -n >$testdir/$RADIUS/new-triangles.dat
+        diff $testdir/$RADIUS/reference-triangles.dat $testdir/$RADIUS/new-triangles.dat 2>$testdir/$RADIUS/diffstderr >$testdir/$RADIUS/diffstdout || exitcode=$?
 	#echo "Diff done with exitcode $exitcode."
 	#cat diffstderr
 	#cat diffstdout
-	cd ../..
 	test $exitcode = $expected_exitcode || exit 1
 }
Index: tests/Tesselations/heptan/1.5/NonConvexEnvelope-heptan.dat
===================================================================
--- tests/Tesselations/heptan/1.5/NonConvexEnvelope-heptan.dat	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ tests/Tesselations/heptan/1.5/NonConvexEnvelope-heptan.dat	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -1,5 +1,5 @@
 TITLE = "3D CONVEX SHELL"
 VARIABLES = "X" "Y" "Z" "U"
-ZONE T="heptan", N=23, E=64, DATAPACKING=POINT, ZONETYPE=FETRIANGLE
+ZONE T="none", N=23, E=64, DATAPACKING=POINT, ZONETYPE=FETRIANGLE
 -7.27e-07 -1.22006 0.930455 18.7229
 -7.27e-07 -1.22006 -0.849545 18.7229
@@ -7,8 +7,8 @@
 -1.2492 0.921941 -0.849545 18.7227
 1.2492 0.921941 -0.849545 18.7222
-1.2492 0.921941 0.930455 27.0641
+1.2492 0.921941 0.930455 18.7222
 -2.4985 -1.22006 -0.849545 19.9769
--2.4985 -1.22006 0.930455 27.4727
-2.4985 -1.22006 0.930455 19.9769
+-2.4985 -1.22006 0.930455 19.9769
+2.4985 -1.22006 0.930455 27.4727
 2.4985 -1.22006 -0.849545 27.4727
 -4.6377 -0.336759 0.0404545 21.541
@@ -17,12 +17,12 @@
 4.6377 -0.336759 0.0404545 10.6618
 3.7477 0.921941 -0.849545 18.5406
-3.7477 0.921941 0.930455 12.1988
+3.7477 0.921941 0.930455 18.5406
 -7.27e-07 -0.590759 0.0404545 23.0174
 -1.2492 0.292641 0.0404545 23.0167
-1.2492 0.292641 0.0404545 20.1632
--2.4985 -0.590759 0.0404545 18.9798
-2.4985 -0.590759 0.0404545 18.9798
+1.2492 0.292641 0.0404545 23.0172
+-2.4985 -0.590759 0.0404545 21.8516
+2.4985 -0.590759 0.0404545 16.0669
 -3.7477 0.292641 0.0404545 39.5267
-3.7477 0.292641 0.0404545 23.2512
+3.7477 0.292641 0.0404545 20.5497
 
 14 15 23
@@ -34,4 +34,6 @@
 15 19 23
 5 15 19
+16 19 23
+6 16 19
 5 6 19
 5 6 19
@@ -42,20 +44,18 @@
 3 4 18
 3 4 18
+3 18 22
+3 12 22
 4 18 22
 4 13 22
-3 18 22
-3 12 22
 12 13 22
 12 13 22
-6 19 23
-6 16 23
+11 12 22
+11 12 22
+8 11 22
+8 12 22
 11 13 22
 11 13 22
 7 11 22
 7 13 22
-11 12 22
-11 12 22
-8 11 22
-8 12 22
 14 16 23
 14 16 23
@@ -76,16 +76,16 @@
 9 10 21
 9 14 21
+9 17 21
+1 9 17
+1 2 17
+1 2 17
 10 17 21
 2 10 17
-1 2 17
-1 2 17
-1 17 21
-1 9 21
+1 17 20
+1 8 20
+7 8 20
+7 8 20
+8 11 20
+7 11 20
 2 17 20
 2 7 20
-7 8 20
-7 8 20
-7 11 20
-8 11 20
-8 17 20
-1 8 17
Index: tests/regression/Domain/4/post/test.conf
===================================================================
--- tests/regression/Domain/4/post/test.conf	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ tests/regression/Domain/4/post/test.conf	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -47,5 +47,5 @@
 BoxLength			# (Length of a unit cell)
 1	
-0	0	
+0	1	
 0	0	2	
 
Index: tests/regression/Makefile.am
===================================================================
--- tests/regression/Makefile.am	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ tests/regression/Makefile.am	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -3,28 +3,37 @@
 TESTSUITE = $(srcdir)/testsuite
 
+max_jobs = 4
+ 
 check-local: atconfig atlocal package.m4 $(TESTSUITE)
-		$(SHELL) '$(TESTSUITE)' $(TESTSUITEFLAGS)
+	nrjobs=; \
+	for flag in $$MAKEFLAGS; do \
+		case $$flag in \
+		--* | =*=) ;; \
+		*j*) nrjobs="-j$(max_jobs)" ;; \
+		esac; \
+	done; \
+	$(SHELL) '$(TESTSUITE)' $$nrjobs $(TESTSUITEFLAGS)
 
 installcheck-local: atconfig atlocal $(TESTSUITE)
-		$(SHELL) '$(TESTSUITE)' AUTOTEST_PATH='$(bindir)' \
-		$(TESTSUITEFLAGS)
-     
+	$(SHELL) '$(TESTSUITE)' AUTOTEST_PATH='$(bindir)' \
+	$(TESTSUITEFLAGS)
+
 clean-local:
-		test ! -f '$(TESTSUITE)' || \
-		$(SHELL) '$(TESTSUITE)' --clean
+	test ! -f '$(TESTSUITE)' || \
+	$(SHELL) '$(TESTSUITE)' --clean
 
 AUTOTEST = $(AUTOM4TE) --language=autotest
 $(TESTSUITE): $(srcdir)/testsuite.at $(srcdir)/testsuite-*.at
-		$(AUTOTEST) -I '$(srcdir)' -o $@.tmp $@.at
-		mv $@.tmp $@
+	$(AUTOTEST) -I '$(srcdir)' -o $@.tmp $@.at
+	mv $@.tmp $@
 
 # The `:;' works around a Bash 3.2 bug when the output is not writeable.
 $(srcdir)/package.m4: $(top_srcdir)/configure.ac
-			:;{ \
-					echo '# Signature of the current package.' && \
-					echo 'm4_define([AT_PACKAGE_NAME],      [@PACKAGE_NAME@])' && \
-					echo 'm4_define([AT_PACKAGE_TARNAME],   [@PACKAGE_TARNAME@])' && \
-					echo 'm4_define([AT_PACKAGE_VERSION],   [@PACKAGE_VERSION@])' && \
-					echo 'm4_define([AT_PACKAGE_STRING],    [@PACKAGE_STRING@])' && \
-					echo 'm4_define([AT_PACKAGE_BUGREPORT], [@PACKAGE_BUGREPORT@])'; \
-				} >'$(srcdir)/package.m4'
+	:;{ \
+		echo '# Signature of the current package.' && \
+		echo 'm4_define([AT_PACKAGE_NAME],      [@PACKAGE_NAME@])' && \
+		echo 'm4_define([AT_PACKAGE_TARNAME],   [@PACKAGE_TARNAME@])' && \
+		echo 'm4_define([AT_PACKAGE_VERSION],   [@PACKAGE_VERSION@])' && \
+		echo 'm4_define([AT_PACKAGE_STRING],    [@PACKAGE_STRING@])' && \
+		echo 'm4_define([AT_PACKAGE_BUGREPORT], [@PACKAGE_BUGREPORT@])'; \
+	} >'$(srcdir)/package.m4'
Index: tests/regression/Molecules/10/post/test-rotated-xYz20.xyz
===================================================================
--- tests/regression/Molecules/10/post/test-rotated-xYz20.xyz	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
+++ tests/regression/Molecules/10/post/test-rotated-xYz20.xyz	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -0,0 +1,13 @@
+11
+	Created by molecuilder on Fri Aug  6 15:40:35 2010
+H	9.8135	2.37271	3.16085
+H	9.33431	2.65703	4.85139
+H	10.6201	3.64185	4.11314
+H	8.96913	4.62097	2.54339
+H	8.48994	4.90529	4.23393
+H	6.55678	4.15323	2.87536
+H	7.44056	2.67134	2.43801
+H	6.96137	2.95567	4.12855
+C	9.67442	3.13152	3.9309
+C	8.62901	4.14648	3.46388
+C	7.30149	3.43016	3.20806
Index: tests/regression/Molecules/10/post/test-rotated-z180.xyz
===================================================================
--- tests/regression/Molecules/10/post/test-rotated-z180.xyz	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
+++ tests/regression/Molecules/10/post/test-rotated-z180.xyz	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -0,0 +1,13 @@
+11
+	Created by molecuilder on Fri Aug  6 15:40:35 2010
+H	7.28356	4.4665	2.64589
+H	7.28356	4.4665	4.42589
+H	6.39365	3.20785	3.53589
+H	8.53286	2.3245	2.64589
+H	8.53286	2.3245	4.42589
+H	10.672	3.20785	3.53589
+H	9.78206	4.4665	2.64589
+H	9.78206	4.4665	4.42589
+C	7.28356	3.8372	3.53589
+C	8.53286	2.9538	3.53589
+C	9.78206	3.8372	3.53589
Index: tests/regression/Molecules/10/post/test-rotated-z360.xyz
===================================================================
--- tests/regression/Molecules/10/post/test-rotated-z360.xyz	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
+++ tests/regression/Molecules/10/post/test-rotated-z360.xyz	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -0,0 +1,13 @@
+11
+	Created by molecuilder on Fri Aug  6 15:40:35 2010
+H	9.78209	2.64589	2.64589
+H	9.78209	2.64589	4.42589
+H	10.672	3.90454	3.53589
+H	8.53279	4.78789	2.64589
+H	8.53279	4.78789	4.42589
+H	6.39363	3.90454	3.53589
+H	7.28359	2.64589	2.64589
+H	7.28359	2.64589	4.42589
+C	9.78209	3.27519	3.53589
+C	8.53279	4.15859	3.53589
+C	7.28359	3.27519	3.53589
Index: tests/regression/Molecules/10/post/test-rotated-z90.xyz
===================================================================
--- tests/regression/Molecules/10/post/test-rotated-z90.xyz	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
+++ tests/regression/Molecules/10/post/test-rotated-z90.xyz	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -0,0 +1,13 @@
+11
+	Created by molecuilder on Fri Aug  6 15:40:35 2010
+H	7.62252	2.30693	2.64589
+H	7.62252	2.30693	4.42589
+H	8.88117	1.41702	3.53589
+H	9.76452	3.55623	2.64589
+H	9.76452	3.55623	4.42589
+H	8.88117	5.69539	3.53589
+H	7.62252	4.80543	2.64589
+H	7.62252	4.80543	4.42589
+C	8.25182	2.30693	3.53589
+C	9.13522	3.55623	3.53589
+C	8.25182	4.80543	3.53589
Index: tests/regression/Molecules/10/pre/test.xyz
===================================================================
--- tests/regression/Molecules/10/pre/test.xyz	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
+++ tests/regression/Molecules/10/pre/test.xyz	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -0,0 +1,13 @@
+11
+	Created by molecuilder on Fri Aug  6 15:40:35 2010
+H	9.78209	2.64589	2.64589
+H	9.78209	2.64589	4.42589
+H	10.672	3.90454	3.53589
+H	8.53279	4.78789	2.64589
+H	8.53279	4.78789	4.42589
+H	6.39363	3.90454	3.53589
+H	7.28359	2.64589	2.64589
+H	7.28359	2.64589	4.42589
+C	9.78209	3.27519	3.53589
+C	8.53279	4.15859	3.53589
+C	7.28359	3.27519	3.53589
Index: tests/regression/Molecules/8/post/test-rotated-xYz20.xyz
===================================================================
--- tests/regression/Molecules/8/post/test-rotated-xYz20.xyz	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
+++ tests/regression/Molecules/8/post/test-rotated-xYz20.xyz	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -0,0 +1,13 @@
+11
+	Created by molecuilder on Fri Aug  6 15:40:35 2010
+H	8.35684	1.92717	6.65103
+H	6.63234	2.36823	6.65103
+H	7.80647	3.36711	7.54093
+H	8.88759	4.00235	5.4017
+H	7.1631	4.44342	5.40171
+H	7.80645	3.36705	3.26256
+H	8.35682	1.92714	4.15253
+H	6.63233	2.3682	4.15254
+C	7.65052	2.75737	6.65102
+C	7.86942	3.61321	5.40172
+C	7.65051	2.75734	4.15253
Index: tests/regression/Molecules/8/post/test-rotated-z180.xyz
===================================================================
--- tests/regression/Molecules/8/post/test-rotated-z180.xyz	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
+++ tests/regression/Molecules/8/post/test-rotated-z180.xyz	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -0,0 +1,13 @@
+11
+	Created by molecuilder on Fri Aug  6 15:40:35 2010
+H	-7.64281	-2.64592	2.28661
+H	-9.42281	-2.64589	2.28661
+H	-8.53283	-3.90457	1.39672
+H	-7.64284	-4.7879	3.53594
+H	-9.42284	-4.78788	3.53594
+H	-8.53283	-3.90451	5.67509
+H	-7.64281	-2.64589	4.78511
+H	-9.42281	-2.64586	4.78511
+C	-8.53282	-3.27521	2.28662
+C	-8.53283	-4.15859	3.53593
+C	-8.53282	-3.27517	4.78512
Index: tests/regression/Molecules/8/post/test-rotated-z360.xyz
===================================================================
--- tests/regression/Molecules/8/post/test-rotated-z360.xyz	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
+++ tests/regression/Molecules/8/post/test-rotated-z360.xyz	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -0,0 +1,13 @@
+11
+	Created by molecuilder on Fri Aug  6 15:40:35 2010
+H	9.42281	2.64589	4.78517
+H	7.64281	2.64592	4.78517
+H	8.53283	3.90457	5.67506
+H	9.42284	4.78788	3.53584
+H	7.64284	4.7879	3.53584
+H	8.53283	3.90451	1.39669
+H	9.42281	2.64586	2.28667
+H	7.64281	2.64589	2.28667
+C	8.53282	3.27521	4.78516
+C	8.53283	4.15859	3.53585
+C	8.53282	3.27517	2.28666
Index: tests/regression/Molecules/8/post/test-rotated-z90.xyz
===================================================================
--- tests/regression/Molecules/8/post/test-rotated-z90.xyz	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
+++ tests/regression/Molecules/8/post/test-rotated-z90.xyz	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -0,0 +1,13 @@
+11
+	Created by molecuilder on Fri Aug  6 15:40:35 2010
+H	2.64589	-9.42281	4.78517
+H	2.64592	-7.64281	4.78517
+H	3.90457	-8.53283	5.67506
+H	4.78788	-9.42284	3.53584
+H	4.7879	-7.64284	3.53584
+H	3.90451	-8.53283	1.39669
+H	2.64586	-9.42281	2.28667
+H	2.64589	-7.64281	2.28667
+C	3.27521	-8.53282	4.78516
+C	4.15859	-8.53283	3.53585
+C	3.27517	-8.53282	2.28666
Index: tests/regression/Molecules/8/pre/test-rotated-xYz20.xyz
===================================================================
--- tests/regression/Molecules/8/pre/test-rotated-xYz20.xyz	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
+++ tests/regression/Molecules/8/pre/test-rotated-xYz20.xyz	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -0,0 +1,13 @@
+11
+	Created by molecuilder on Fri Aug  6 15:40:35 2010
+H	9.00082	1.84611	5.02671
+H	8.52163	2.13043	6.71726
+H	9.80746	3.11525	5.979
+H	8.15645	4.09438	4.40925
+H	7.67726	4.3787	6.0998
+H	5.7441	3.62663	4.74123
+H	6.62788	2.14475	4.30388
+H	6.1487	2.42907	5.99442
+C	8.86174	2.60492	5.79677
+C	7.81634	3.61989	5.32974
+C	6.48881	2.90356	5.07393
Index: tests/regression/Molecules/8/pre/test-rotated-z180.xyz
===================================================================
--- tests/regression/Molecules/8/pre/test-rotated-z180.xyz	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
+++ tests/regression/Molecules/8/pre/test-rotated-z180.xyz	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -0,0 +1,13 @@
+11
+	Created by molecuilder on Fri Aug  6 15:40:35 2010
+H	-9.78209	-2.64589	2.64589
+H	-9.78209	-2.64589	4.42589
+H	-10.672	-3.90454	3.53589
+H	-8.53279	-4.78789	2.64589
+H	-8.53279	-4.78789	4.42589
+H	-6.39363	-3.90454	3.53589
+H	-7.28359	-2.64589	2.64589
+H	-7.28359	-2.64589	4.42589
+C	-9.78209	-3.27519	3.53589
+C	-8.53279	-4.15859	3.53589
+C	-7.28359	-3.27519	3.53589
Index: tests/regression/Molecules/8/pre/test-rotated-z360.xyz
===================================================================
--- tests/regression/Molecules/8/pre/test-rotated-z360.xyz	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
+++ tests/regression/Molecules/8/pre/test-rotated-z360.xyz	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -0,0 +1,13 @@
+11
+	Created by molecuilder on Fri Aug  6 15:40:35 2010
+H	9.78209	2.64589	2.64589
+H	9.78209	2.64589	4.42589
+H	10.672	3.90454	3.53589
+H	8.53279	4.78789	2.64589
+H	8.53279	4.78789	4.42589
+H	6.39363	3.90454	3.53589
+H	7.28359	2.64589	2.64589
+H	7.28359	2.64589	4.42589
+C	9.78209	3.27519	3.53589
+C	8.53279	4.15859	3.53589
+C	7.28359	3.27519	3.53589
Index: tests/regression/Molecules/8/pre/test-rotated-z90.xyz
===================================================================
--- tests/regression/Molecules/8/pre/test-rotated-z90.xyz	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
+++ tests/regression/Molecules/8/pre/test-rotated-z90.xyz	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -0,0 +1,13 @@
+11
+	Created by molecuilder on Fri Aug  6 15:40:35 2010
+H	2.64589	-9.78209	2.64589
+H	2.64589	-9.78209	4.42589
+H	3.90454	-10.672	3.53589
+H	4.78789	-8.53279	2.64589
+H	4.78789	-8.53279	4.42589
+H	3.90454	-6.39363	3.53589
+H	2.64589	-7.28359	2.64589
+H	2.64589	-7.28359	4.42589
+C	3.27519	-9.78209	3.53589
+C	4.15859	-8.53279	3.53589
+C	3.27519	-7.28359	3.53589
Index: sts/regression/Molecules/8/pre/test.conf
===================================================================
--- tests/regression/Molecules/8/pre/test.conf	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ 	(revision )
@@ -1,83 +1,0 @@
-# ParallelCarParinello - main configuration file - created with molecuilder
-
-mainname	pcp	# programm name (for runtime files)
-defaultpath	not specified	# where to put files during runtime
-pseudopotpath	not specified	# where to find pseudopotentials
-
-ProcPEGamma	8	# for parallel computing: share constants
-ProcPEPsi	1	# for parallel computing: share wave functions
-DoOutVis	0	# Output data for OpenDX
-DoOutMes	1	# Output data for measurements
-DoOutOrbitals	0	# Output all Orbitals
-DoOutCurr	0	# Ouput current density for OpenDx
-DoOutNICS	0	# Output Nucleus independent current shieldings
-DoPerturbation	0	# Do perturbation calculate and determine susceptibility and shielding
-DoFullCurrent	0	# Do full perturbation
-DoConstrainedMD	0	# Do perform a constrained (>0, relating to current MD step) instead of unconstrained (0) MD
-Thermostat	Berendsen	2.5	# Which Thermostat and its parameters to use in MD case.
-CommonWannier	0	# Put virtual centers at indivual orbits, all common, merged by variance, to grid point, to cell center
-SawtoothStart	0.01	# Absolute value for smooth transition at cell border 
-VectorPlane	0	# Cut plane axis (x, y or z: 0,1,2) for two-dim current vector plot
-VectorCut	0	# Cut plane axis value
-AddGramSch	1	# Additional GramSchmidtOrtogonalization to be safe
-Seed		1	# initial value for random seed for Psi coefficients
-
-MaxOuterStep	0	# number of MolecularDynamics/Structure optimization steps
-Deltat	0.01	# time per MD step
-OutVisStep	10	# Output visual data every ...th step
-OutSrcStep	5	# Output "restart" data every ..th step
-TargetTemp	0.000950045	# Target temperature
-MaxPsiStep	0	# number of Minimisation steps per state (0 - default)
-EpsWannier	1e-07	# tolerance value for spread minimisation of orbitals
-
-# Values specifying when to stop
-MaxMinStep	100	# Maximum number of steps
-RelEpsTotalE	1e-07	# relative change in total energy
-RelEpsKineticE	1e-05	# relative change in kinetic energy
-MaxMinStopStep	0	# check every ..th steps
-MaxMinGapStopStep	0	# check every ..th steps
-
-# Values specifying when to stop for INIT, otherwise same as above
-MaxInitMinStep	100	# Maximum number of steps
-InitRelEpsTotalE	1e-05	# relative change in total energy
-InitRelEpsKineticE	0.0001	# relative change in kinetic energy
-InitMaxMinStopStep	0	# check every ..th steps
-InitMaxMinGapStopStep	0	# check every ..th steps
-
-BoxLength			# (Length of a unit cell)
-20	
-0	20	
-0	0	20	
-
-ECut		128	# energy cutoff for discretization in Hartrees
-MaxLevel	5	# number of different levels in the code, >=2
-Level0Factor	2	# factor by which node number increases from S to 0 level
-RiemannTensor	0	# (Use metric)
-PsiType		0	# 0 - doubly occupied, 1 - SpinUp,SpinDown
-MaxPsiDouble	0	# here: specifying both maximum number of SpinUp- and -Down-states
-PsiMaxNoUp	0	# here: specifying maximum number of SpinUp-states
-PsiMaxNoDown	0	# here: specifying maximum number of SpinDown-states
-AddPsis		0	# Additional unoccupied Psis for bandgap determination
-
-RCut		20	# R-cut for the ewald summation
-StructOpt	0	# Do structure optimization beforehand
-IsAngstroem	1	# 0 - Bohr, 1 - Angstroem
-RelativeCoord	0	# whether ion coordinates are relative (1) or absolute (0)
-MaxTypes	2	# maximum number of different ion types
-
-# Ion type data (PP = PseudoPotential, Z = atomic number)
-#Ion_TypeNr.	Amount	Z	RGauss	L_Max(PP)L_Loc(PP)IonMass	# chemical name, symbol
-Ion_Type1	8	1	1.0	3	3	1.00800000000	Hydrogen	H
-Ion_Type2	3	6	1.0	3	3	12.01100000000	Carbon	C
-#Ion_TypeNr._Nr.R[0]    R[1]    R[2]    MoveType (0 MoveIon, 1 FixedIon)
-Ion_Type2_1	9.782085945	3.275186040	3.535886037	0 # molecule nr 0
-Ion_Type2_2	8.532785963	4.158586027	3.535886037	0 # molecule nr 1
-Ion_Type2_3	7.283585982	3.275186040	3.535886037	0 # molecule nr 2
-Ion_Type1_1	9.782085945	2.645886050	2.645886050	0 # molecule nr 3
-Ion_Type1_2	9.782085945	2.645886050	4.425886024	0 # molecule nr 4
-Ion_Type1_3	10.672039608	3.904536878	3.535886037	0 # molecule nr 5
-Ion_Type1_4	8.532785963	4.787886018	2.645886050	0 # molecule nr 6
-Ion_Type1_5	8.532785963	4.787886018	4.425886024	0 # molecule nr 7
-Ion_Type1_6	6.393632318	3.904536877	3.535886037	0 # molecule nr 8
-Ion_Type1_7	7.283585982	2.645886050	2.645886050	0 # molecule nr 9
-Ion_Type1_8	7.283585982	2.645886050	4.425886024	0 # molecule nr 10
Index: tests/regression/Molecules/9/post/test-rotated-xYz20.xyz
===================================================================
--- tests/regression/Molecules/9/post/test-rotated-xYz20.xyz	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
+++ tests/regression/Molecules/9/post/test-rotated-xYz20.xyz	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -0,0 +1,13 @@
+11
+	Created by molecuilder on Fri Aug  6 15:40:35 2010
+H	9.00082	1.84611	5.02671
+H	8.52163	2.13043	6.71726
+H	9.80746	3.11525	5.979
+H	8.15645	4.09438	4.40925
+H	7.67726	4.3787	6.0998
+H	5.7441	3.62663	4.74123
+H	6.62788	2.14475	4.30388
+H	6.1487	2.42907	5.99442
+C	8.86174	2.60492	5.79677
+C	7.81634	3.61989	5.32974
+C	6.48881	2.90356	5.07393
Index: tests/regression/Molecules/9/post/test-rotated-z180.xyz
===================================================================
--- tests/regression/Molecules/9/post/test-rotated-z180.xyz	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
+++ tests/regression/Molecules/9/post/test-rotated-z180.xyz	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -0,0 +1,13 @@
+11
+	Created by molecuilder on Fri Aug  6 15:40:35 2010
+H	-9.78209	-2.64589	2.64589
+H	-9.78209	-2.64589	4.42589
+H	-10.672	-3.90454	3.53589
+H	-8.53279	-4.78789	2.64589
+H	-8.53279	-4.78789	4.42589
+H	-6.39363	-3.90454	3.53589
+H	-7.28359	-2.64589	2.64589
+H	-7.28359	-2.64589	4.42589
+C	-9.78209	-3.27519	3.53589
+C	-8.53279	-4.15859	3.53589
+C	-7.28359	-3.27519	3.53589
Index: tests/regression/Molecules/9/post/test-rotated-z360.xyz
===================================================================
--- tests/regression/Molecules/9/post/test-rotated-z360.xyz	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
+++ tests/regression/Molecules/9/post/test-rotated-z360.xyz	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -0,0 +1,13 @@
+11
+	Created by molecuilder on Fri Aug  6 15:40:35 2010
+H	9.78209	2.64589	2.64589
+H	9.78209	2.64589	4.42589
+H	10.672	3.90454	3.53589
+H	8.53279	4.78789	2.64589
+H	8.53279	4.78789	4.42589
+H	6.39363	3.90454	3.53589
+H	7.28359	2.64589	2.64589
+H	7.28359	2.64589	4.42589
+C	9.78209	3.27519	3.53589
+C	8.53279	4.15859	3.53589
+C	7.28359	3.27519	3.53589
Index: tests/regression/Molecules/9/post/test-rotated-z90.xyz
===================================================================
--- tests/regression/Molecules/9/post/test-rotated-z90.xyz	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
+++ tests/regression/Molecules/9/post/test-rotated-z90.xyz	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -0,0 +1,13 @@
+11
+	Created by molecuilder on Fri Aug  6 15:40:35 2010
+H	2.64589	-9.78209	2.64589
+H	2.64589	-9.78209	4.42589
+H	3.90454	-10.672	3.53589
+H	4.78789	-8.53279	2.64589
+H	4.78789	-8.53279	4.42589
+H	3.90454	-6.39363	3.53589
+H	2.64589	-7.28359	2.64589
+H	2.64589	-7.28359	4.42589
+C	3.27519	-9.78209	3.53589
+C	4.15859	-8.53279	3.53589
+C	3.27519	-7.28359	3.53589
Index: tests/regression/Molecules/9/pre/test.xyz
===================================================================
--- tests/regression/Molecules/9/pre/test.xyz	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
+++ tests/regression/Molecules/9/pre/test.xyz	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -0,0 +1,13 @@
+11
+	Created by molecuilder on Fri Aug  6 15:40:35 2010
+H	9.78209	2.64589	2.64589
+H	9.78209	2.64589	4.42589
+H	10.672	3.90454	3.53589
+H	8.53279	4.78789	2.64589
+H	8.53279	4.78789	4.42589
+H	6.39363	3.90454	3.53589
+H	7.28359	2.64589	2.64589
+H	7.28359	2.64589	4.42589
+C	9.78209	3.27519	3.53589
+C	8.53279	4.15859	3.53589
+C	7.28359	3.27519	3.53589
Index: tests/regression/Simple_configuration/3/post/empty.conf
===================================================================
--- tests/regression/Simple_configuration/3/post/empty.conf	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
+++ tests/regression/Simple_configuration/3/post/empty.conf	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -0,0 +1,70 @@
+# ParallelCarParinello - main configuration file - created with molecuilder
+
+mainname	pcp	# programm name (for runtime files)
+defaultpath	not specified	# where to put files during runtime
+pseudopotpath	not specified	# where to find pseudopotentials
+
+ProcPEGamma	8	# for parallel computing: share constants
+ProcPEPsi	1	# for parallel computing: share wave functions
+DoOutVis	0	# Output data for OpenDX
+DoOutMes	1	# Output data for measurements
+DoOutOrbitals	0	# Output all Orbitals
+DoOutCurr	0	# Ouput current density for OpenDx
+DoOutNICS	0	# Output Nucleus independent current shieldings
+DoPerturbation	0	# Do perturbation calculate and determine susceptibility and shielding
+DoFullCurrent	0	# Do full perturbation
+DoConstrainedMD	0	# Do perform a constrained (>0, relating to current MD step) instead of unconstrained (0) MD
+Thermostat	Berendsen	2.5	# Which Thermostat and its parameters to use in MD case.
+CommonWannier	0	# Put virtual centers at indivual orbits, all common, merged by variance, to grid point, to cell center
+SawtoothStart	0.01	# Absolute value for smooth transition at cell border 
+VectorPlane	0	# Cut plane axis (x, y or z: 0,1,2) for two-dim current vector plot
+VectorCut	0	# Cut plane axis value
+AddGramSch	1	# Additional GramSchmidtOrtogonalization to be safe
+Seed		1	# initial value for random seed for Psi coefficients
+
+MaxOuterStep	0	# number of MolecularDynamics/Structure optimization steps
+Deltat	0.01	# time per MD step
+OutVisStep	10	# Output visual data every ...th step
+OutSrcStep	5	# Output "restart" data every ..th step
+TargetTemp	0.000950045	# Target temperature
+MaxPsiStep	0	# number of Minimisation steps per state (0 - default)
+EpsWannier	1e-07	# tolerance value for spread minimisation of orbitals
+
+# Values specifying when to stop
+MaxMinStep	100	# Maximum number of steps
+RelEpsTotalE	1e-07	# relative change in total energy
+RelEpsKineticE	1e-05	# relative change in kinetic energy
+MaxMinStopStep	0	# check every ..th steps
+MaxMinGapStopStep	0	# check every ..th steps
+
+# Values specifying when to stop for INIT, otherwise same as above
+MaxInitMinStep	100	# Maximum number of steps
+InitRelEpsTotalE	1e-05	# relative change in total energy
+InitRelEpsKineticE	0.0001	# relative change in kinetic energy
+InitMaxMinStopStep	0	# check every ..th steps
+InitMaxMinGapStopStep	0	# check every ..th steps
+
+BoxLength			# (Length of a unit cell)
+20	
+0	20	
+0	0	20	
+
+ECut		128	# energy cutoff for discretization in Hartrees
+MaxLevel	5	# number of different levels in the code, >=2
+Level0Factor	2	# factor by which node number increases from S to 0 level
+RiemannTensor	0	# (Use metric)
+PsiType		0	# 0 - doubly occupied, 1 - SpinUp,SpinDown
+MaxPsiDouble	0	# here: specifying both maximum number of SpinUp- and -Down-states
+PsiMaxNoUp	0	# here: specifying maximum number of SpinUp-states
+PsiMaxNoDown	0	# here: specifying maximum number of SpinDown-states
+AddPsis		0	# Additional unoccupied Psis for bandgap determination
+
+RCut		20	# R-cut for the ewald summation
+StructOpt	0	# Do structure optimization beforehand
+IsAngstroem	1	# 0 - Bohr, 1 - Angstroem
+RelativeCoord	0	# whether ion coordinates are relative (1) or absolute (0)
+MaxTypes	0	# maximum number of different ion types
+
+# Ion type data (PP = PseudoPotential, Z = atomic number)
+#Ion_TypeNr.	Amount	Z	RGauss	L_Max(PP)L_Loc(PP)IonMass	# chemical name, symbol
+#Ion_TypeNr._Nr.R[0]    R[1]    R[2]    MoveType (0 MoveIon, 1 FixedIon)
Index: sts/regression/Simple_configuration/3/post/test2.conf
===================================================================
--- tests/regression/Simple_configuration/3/post/test2.conf	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ 	(revision )
@@ -1,72 +1,0 @@
-# ParallelCarParinello - main configuration file - created with molecuilder
-
-mainname	pcp	# programm name (for runtime files)
-defaultpath	not specified	# where to put files during runtime
-pseudopotpath	not specified	# where to find pseudopotentials
-
-ProcPEGamma	8	# for parallel computing: share constants
-ProcPEPsi	1	# for parallel computing: share wave functions
-DoOutVis	0	# Output data for OpenDX
-DoOutMes	1	# Output data for measurements
-DoOutOrbitals	0	# Output all Orbitals
-DoOutCurr	0	# Ouput current density for OpenDx
-DoOutNICS	0	# Output Nucleus independent current shieldings
-DoPerturbation	0	# Do perturbation calculate and determine susceptibility and shielding
-DoFullCurrent	0	# Do full perturbation
-DoConstrainedMD	0	# Do perform a constrained (>0, relating to current MD step) instead of unconstrained (0) MD
-Thermostat	Berendsen	2.5	# Which Thermostat and its parameters to use in MD case.
-CommonWannier	0	# Put virtual centers at indivual orbits, all common, merged by variance, to grid point, to cell center
-SawtoothStart	0.01	# Absolute value for smooth transition at cell border 
-VectorPlane	0	# Cut plane axis (x, y or z: 0,1,2) for two-dim current vector plot
-VectorCut	0	# Cut plane axis value
-AddGramSch	1	# Additional GramSchmidtOrtogonalization to be safe
-Seed		1	# initial value for random seed for Psi coefficients
-
-MaxOuterStep	0	# number of MolecularDynamics/Structure optimization steps
-Deltat	0.01	# time per MD step
-OutVisStep	10	# Output visual data every ...th step
-OutSrcStep	5	# Output "restart" data every ..th step
-TargetTemp	0.000950045	# Target temperature
-MaxPsiStep	0	# number of Minimisation steps per state (0 - default)
-EpsWannier	1e-07	# tolerance value for spread minimisation of orbitals
-
-# Values specifying when to stop
-MaxMinStep	100	# Maximum number of steps
-RelEpsTotalE	1e-07	# relative change in total energy
-RelEpsKineticE	1e-05	# relative change in kinetic energy
-MaxMinStopStep	1	# check every ..th steps
-MaxMinGapStopStep	0	# check every ..th steps
-
-# Values specifying when to stop for INIT, otherwise same as above
-MaxInitMinStep	100	# Maximum number of steps
-InitRelEpsTotalE	1e-05	# relative change in total energy
-InitRelEpsKineticE	0.0001	# relative change in kinetic energy
-InitMaxMinStopStep	1	# check every ..th steps
-InitMaxMinGapStopStep	0	# check every ..th steps
-
-BoxLength			# (Length of a unit cell)
-20	
-0	20	
-0	0	20	
-
-ECut		128	# energy cutoff for discretization in Hartrees
-MaxLevel	5	# number of different levels in the code, >=2
-Level0Factor	2	# factor by which node number increases from S to 0 level
-RiemannTensor	0	# (Use metric)
-PsiType		1	# 0 - doubly occupied, 1 - SpinUp,SpinDown
-MaxPsiDouble	0	# here: specifying both maximum number of SpinUp- and -Down-states
-PsiMaxNoUp	0	# here: specifying maximum number of SpinUp-states
-PsiMaxNoDown	1	# here: specifying maximum number of SpinDown-states
-AddPsis		0	# Additional unoccupied Psis for bandgap determination
-
-RCut		20	# R-cut for the ewald summation
-StructOpt	0	# Do structure optimization beforehand
-IsAngstroem	1	# 0 - Bohr, 1 - Angstroem
-RelativeCoord	0	# whether ion coordinates are relative (1) or absolute (0)
-MaxTypes	1	# maximum number of different ion types
-
-# Ion type data (PP = PseudoPotential, Z = atomic number)
-#Ion_TypeNr.	Amount	Z	RGauss	L_Max(PP)L_Loc(PP)IonMass	# chemical name, symbol
-Ion_Type1	1	1	1.0	3	3	1.00800000000	Hydrogen	H
-#Ion_TypeNr._Nr.R[0]    R[1]    R[2]    MoveType (0 MoveIon, 1 FixedIon)
-Ion_Type1_1	0.000000000	0.000000000	-1.000000000	0 # molecule nr 0
Index: sts/regression/Simple_configuration/3/post/test2.in
===================================================================
--- tests/regression/Simple_configuration/3/post/test2.in	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ 	(revision )
@@ -1,24 +1,0 @@
-% Created by MoleCuilder
-mpqc: (
-	savestate = no
-	do_gradient = yes
-	mole<MBPT2>: (
-		maxiter = 200
-		basis = $:basis
-		molecule = $:molecule
-		reference<CLHF>: (
-			basis = $:basis
-			molecule = $:molecule
-		)
-	)
-)
-molecule<Molecule>: (
-	unit = angstrom
-	{ atoms geometry } = {
-		H [ 0	0	0 ]
-	}
-)
-basis<GaussianBasisSet>: (
-	name = "3-21G"
-	molecule = $:molecule
-)
Index: sts/regression/Simple_configuration/3/post/test2.xyz
===================================================================
--- tests/regression/Simple_configuration/3/post/test2.xyz	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ 	(revision )
@@ -1,3 +1,0 @@
-1
-	Created by molecuilder on Tue Oct  6 18:34:23 2009
-H	0	0	-1
Index: tests/regression/Simple_configuration/5/pre/test.conf
===================================================================
--- tests/regression/Simple_configuration/5/pre/test.conf	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ tests/regression/Simple_configuration/5/pre/test.conf	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -28,5 +28,5 @@
 OutSrcStep	5	# Output "restart" data every ..th step
 TargetTemp	0.000950045	# Target temperature
-MaxPsiStep	0	# number of Minimisation steps per state (0 - default)
+MaxPsiStep	3	# number of Minimisation steps per state (0 - default)
 EpsWannier	1e-07	# tolerance value for spread minimisation of orbitals
 
@@ -35,6 +35,6 @@
 RelEpsTotalE	1e-07	# relative change in total energy
 RelEpsKineticE	1e-05	# relative change in kinetic energy
-MaxMinStopStep	0	# check every ..th steps
-MaxMinGapStopStep	0	# check every ..th steps
+MaxMinStopStep	1	# check every ..th steps
+MaxMinGapStopStep	1	# check every ..th steps
 
 # Values specifying when to stop for INIT, otherwise same as above
@@ -42,6 +42,6 @@
 InitRelEpsTotalE	1e-05	# relative change in total energy
 InitRelEpsKineticE	0.0001	# relative change in kinetic energy
-InitMaxMinStopStep	0	# check every ..th steps
-InitMaxMinGapStopStep	0	# check every ..th steps
+InitMaxMinStopStep	1	# check every ..th steps
+InitMaxMinGapStopStep	1	# check every ..th steps
 
 BoxLength			# (Length of a unit cell)
@@ -54,8 +54,8 @@
 Level0Factor	2	# factor by which node number increases from S to 0 level
 RiemannTensor	0	# (Use metric)
-PsiType		0	# 0 - doubly occupied, 1 - SpinUp,SpinDown
+PsiType		1	# 0 - doubly occupied, 1 - SpinUp,SpinDown
 MaxPsiDouble	0	# here: specifying both maximum number of SpinUp- and -Down-states
 PsiMaxNoUp	0	# here: specifying maximum number of SpinUp-states
-PsiMaxNoDown	0	# here: specifying maximum number of SpinDown-states
+PsiMaxNoDown	1	# here: specifying maximum number of SpinDown-states
 AddPsis		0	# Additional unoccupied Psis for bandgap determination
 
Index: tests/regression/Simple_configuration/8/post/test-cuboid.xyz-sorted
===================================================================
--- tests/regression/Simple_configuration/8/post/test-cuboid.xyz-sorted	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
+++ tests/regression/Simple_configuration/8/post/test-cuboid.xyz-sorted	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -0,0 +1,4 @@
+C	9.78209	3.27519	3.53589
+H	10.672	3.90454	3.53589
+H	9.78209	2.64589	2.64589
+H	9.78209	2.64589	4.42589
Index: tests/regression/Simple_configuration/8/post/test-sphere.xyz-sorted
===================================================================
--- tests/regression/Simple_configuration/8/post/test-sphere.xyz-sorted	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
+++ tests/regression/Simple_configuration/8/post/test-sphere.xyz-sorted	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -0,0 +1,144 @@
+C	7.28359	3.27519	3.53589
+C	8.53279	4.15859	3.53589
+C	9.78209	3.27519	3.53589
+H	0.758602	2.85714	2.85714
+H	0.758602	2.85714	3.86571
+H	0.758602	2.85714	5.71429
+H	0.758602	5.71429	2.85714
+H	0.758602	5.71429	3.86571
+H	10.672	3.90454	3.53589
+H	12.1872	0	0
+H	12.1872	0	1.00857
+H	12.1872	0	2.85714
+H	12.1872	0	3.86571
+H	12.1872	0	5.71429
+H	12.1872	0	6.72285
+H	12.1872	2.85714	0
+H	12.1872	2.85714	1.00857
+H	12.1872	2.85714	5.71429
+H	12.1872	2.85714	6.72285
+H	12.1872	5.71429	0
+H	12.1872	5.71429	1.00857
+H	12.1872	5.71429	2.85714
+H	12.1872	5.71429	3.86571
+H	12.1872	5.71429	5.71429
+H	12.1872	5.71429	6.72285
+H	3.61574	0	0
+H	3.61574	0	1.00857
+H	3.61574	0	2.85714
+H	3.61574	0	3.86571
+H	3.61574	0	5.71429
+H	3.61574	0	6.72285
+H	3.61574	2.85714	0
+H	3.61574	2.85714	1.00857
+H	3.61574	2.85714	2.85714
+H	3.61574	2.85714	3.86571
+H	3.61574	2.85714	5.71429
+H	3.61574	2.85714	6.72285
+H	3.61574	2.85714	8.57143
+H	3.61574	5.71429	0
+H	3.61574	5.71429	1.00857
+H	3.61574	5.71429	2.85714
+H	3.61574	5.71429	3.86571
+H	3.61574	5.71429	5.71429
+H	3.61574	5.71429	6.72285
+H	3.61574	5.71429	8.57143
+H	3.61574	8.57143	1.00857
+H	3.61574	8.57143	2.85714
+H	3.61574	8.57143	3.86571
+H	3.61574	8.57143	5.71429
+H	6.39363	3.90454	3.53589
+H	6.47289	0	0
+H	6.47289	0	1.00857
+H	6.47289	0	2.85714
+H	6.47289	0	3.86571
+H	6.47289	0	5.71429
+H	6.47289	0	6.72285
+H	6.47289	0	8.57143
+H	6.47289	0	9.58
+H	6.47289	2.85714	0
+H	6.47289	2.85714	6.72285
+H	6.47289	2.85714	8.57143
+H	6.47289	2.85714	9.58
+H	6.47289	5.71429	0
+H	6.47289	5.71429	1.00857
+H	6.47289	5.71429	5.71429
+H	6.47289	5.71429	6.72285
+H	6.47289	5.71429	8.57143
+H	6.47289	5.71429	9.58
+H	6.47289	8.57143	0
+H	6.47289	8.57143	1.00857
+H	6.47289	8.57143	2.85714
+H	6.47289	8.57143	3.86571
+H	6.47289	8.57143	5.71429
+H	6.47289	8.57143	6.72285
+H	7.28359	2.64589	2.64589
+H	7.28359	2.64589	4.42589
+H	8.53279	4.78789	2.64589
+H	8.53279	4.78789	4.42589
+H	9.33003	0	0
+H	9.33003	0	1.00857
+H	9.33003	0	2.85714
+H	9.33003	0	3.86571
+H	9.33003	0	5.71429
+H	9.33003	0	6.72285
+H	9.33003	0	8.57143
+H	9.33003	2.85714	0
+H	9.33003	2.85714	6.72285
+H	9.33003	2.85714	8.57143
+H	9.33003	2.85714	9.58
+H	9.33003	5.71429	0
+H	9.33003	5.71429	6.72285
+H	9.33003	5.71429	8.57143
+H	9.33003	5.71429	9.58
+H	9.33003	8.57143	0
+H	9.33003	8.57143	1.00857
+H	9.33003	8.57143	2.85714
+H	9.33003	8.57143	3.86571
+H	9.33003	8.57143	5.71429
+H	9.33003	8.57143	6.72285
+H	9.78209	2.64589	2.64589
+H	9.78209	2.64589	4.42589
+O	11.4286	0	0.504284
+O	11.4286	0	3.36143
+O	11.4286	0	6.21857
+O	11.4286	2.85714	0.504284
+O	11.4286	2.85714	6.21857
+O	11.4286	2.85714	9.07571
+O	11.4286	5.71429	0.504284
+O	11.4286	5.71429	6.21857
+O	11.4286	8.57143	3.36143
+O	2.85714	0	0.504284
+O	2.85714	0	3.36143
+O	2.85714	0	6.21857
+O	2.85714	2.85714	0.504284
+O	2.85714	2.85714	3.36143
+O	2.85714	2.85714	6.21857
+O	2.85714	5.71429	0.504284
+O	2.85714	5.71429	3.36143
+O	2.85714	5.71429	6.21857
+O	2.85714	8.57143	3.36143
+O	5.71429	0	0.504284
+O	5.71429	0	3.36143
+O	5.71429	0	6.21857
+O	5.71429	0	9.07571
+O	5.71429	2.85714	0.504284
+O	5.71429	2.85714	6.21857
+O	5.71429	2.85714	9.07571
+O	5.71429	5.71429	0.504284
+O	5.71429	5.71429	6.21857
+O	5.71429	5.71429	9.07571
+O	5.71429	8.57143	0.504284
+O	5.71429	8.57143	3.36143
+O	5.71429	8.57143	6.21857
+O	8.57143	0	0.504284
+O	8.57143	0	3.36143
+O	8.57143	0	6.21857
+O	8.57143	0	9.07571
+O	8.57143	2.85714	0.504284
+O	8.57143	2.85714	9.07571
+O	8.57143	5.71429	0.504284
+O	8.57143	5.71429	9.07571
+O	8.57143	8.57143	0.504284
+O	8.57143	8.57143	3.36143
+O	8.57143	8.57143	6.21857
Index: tests/regression/Simple_configuration/8/post/test-withoutcuboid.xyz-sorted
===================================================================
--- tests/regression/Simple_configuration/8/post/test-withoutcuboid.xyz-sorted	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
+++ tests/regression/Simple_configuration/8/post/test-withoutcuboid.xyz-sorted	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -0,0 +1,1012 @@
+C	7.28359	3.27519	3.53589
+C	8.53279	4.15859	3.53589
+H	0.758602	0	0
+H	0.758602	0	1.00857
+H	0.758602	0	11.4286
+H	0.758602	0	12.4371
+H	0.758602	0	14.2857
+H	0.758602	0	15.2943
+H	0.758602	0	17.1429
+H	0.758602	0	18.1514
+H	0.758602	0	2.85714
+H	0.758602	0	3.86571
+H	0.758602	0	5.71429
+H	0.758602	0	6.72285
+H	0.758602	0	8.57143
+H	0.758602	0	9.58
+H	0.758602	11.4286	0
+H	0.758602	11.4286	1.00857
+H	0.758602	11.4286	11.4286
+H	0.758602	11.4286	12.4371
+H	0.758602	11.4286	14.2857
+H	0.758602	11.4286	15.2943
+H	0.758602	11.4286	17.1429
+H	0.758602	11.4286	18.1514
+H	0.758602	11.4286	2.85714
+H	0.758602	11.4286	3.86571
+H	0.758602	11.4286	5.71429
+H	0.758602	11.4286	6.72285
+H	0.758602	11.4286	8.57143
+H	0.758602	11.4286	9.58
+H	0.758602	14.2857	0
+H	0.758602	14.2857	1.00857
+H	0.758602	14.2857	11.4286
+H	0.758602	14.2857	12.4371
+H	0.758602	14.2857	14.2857
+H	0.758602	14.2857	15.2943
+H	0.758602	14.2857	17.1429
+H	0.758602	14.2857	18.1514
+H	0.758602	14.2857	2.85714
+H	0.758602	14.2857	3.86571
+H	0.758602	14.2857	5.71429
+H	0.758602	14.2857	6.72285
+H	0.758602	14.2857	8.57143
+H	0.758602	14.2857	9.58
+H	0.758602	17.1429	0
+H	0.758602	17.1429	1.00857
+H	0.758602	17.1429	11.4286
+H	0.758602	17.1429	12.4371
+H	0.758602	17.1429	14.2857
+H	0.758602	17.1429	15.2943
+H	0.758602	17.1429	17.1429
+H	0.758602	17.1429	18.1514
+H	0.758602	17.1429	2.85714
+H	0.758602	17.1429	3.86571
+H	0.758602	17.1429	5.71429
+H	0.758602	17.1429	6.72285
+H	0.758602	17.1429	8.57143
+H	0.758602	17.1429	9.58
+H	0.758602	2.85714	0
+H	0.758602	2.85714	1.00857
+H	0.758602	2.85714	11.4286
+H	0.758602	2.85714	12.4371
+H	0.758602	2.85714	14.2857
+H	0.758602	2.85714	15.2943
+H	0.758602	2.85714	17.1429
+H	0.758602	2.85714	18.1514
+H	0.758602	2.85714	2.85714
+H	0.758602	2.85714	3.86571
+H	0.758602	2.85714	5.71429
+H	0.758602	2.85714	6.72285
+H	0.758602	2.85714	8.57143
+H	0.758602	2.85714	9.58
+H	0.758602	5.71429	0
+H	0.758602	5.71429	1.00857
+H	0.758602	5.71429	11.4286
+H	0.758602	5.71429	12.4371
+H	0.758602	5.71429	14.2857
+H	0.758602	5.71429	15.2943
+H	0.758602	5.71429	17.1429
+H	0.758602	5.71429	18.1514
+H	0.758602	5.71429	2.85714
+H	0.758602	5.71429	3.86571
+H	0.758602	5.71429	5.71429
+H	0.758602	5.71429	6.72285
+H	0.758602	5.71429	8.57143
+H	0.758602	5.71429	9.58
+H	0.758602	8.57143	0
+H	0.758602	8.57143	1.00857
+H	0.758602	8.57143	11.4286
+H	0.758602	8.57143	12.4371
+H	0.758602	8.57143	14.2857
+H	0.758602	8.57143	15.2943
+H	0.758602	8.57143	17.1429
+H	0.758602	8.57143	18.1514
+H	0.758602	8.57143	2.85714
+H	0.758602	8.57143	3.86571
+H	0.758602	8.57143	5.71429
+H	0.758602	8.57143	6.72285
+H	0.758602	8.57143	8.57143
+H	0.758602	8.57143	9.58
+H	12.1872	0	0
+H	12.1872	0	1.00857
+H	12.1872	0	11.4286
+H	12.1872	0	12.4371
+H	12.1872	0	14.2857
+H	12.1872	0	15.2943
+H	12.1872	0	17.1429
+H	12.1872	0	18.1514
+H	12.1872	0	2.85714
+H	12.1872	0	3.86571
+H	12.1872	0	5.71429
+H	12.1872	0	6.72285
+H	12.1872	0	8.57143
+H	12.1872	0	9.58
+H	12.1872	11.4286	0
+H	12.1872	11.4286	1.00857
+H	12.1872	11.4286	11.4286
+H	12.1872	11.4286	12.4371
+H	12.1872	11.4286	14.2857
+H	12.1872	11.4286	15.2943
+H	12.1872	11.4286	17.1429
+H	12.1872	11.4286	18.1514
+H	12.1872	11.4286	2.85714
+H	12.1872	11.4286	3.86571
+H	12.1872	11.4286	5.71429
+H	12.1872	11.4286	6.72285
+H	12.1872	11.4286	8.57143
+H	12.1872	11.4286	9.58
+H	12.1872	14.2857	0
+H	12.1872	14.2857	1.00857
+H	12.1872	14.2857	11.4286
+H	12.1872	14.2857	12.4371
+H	12.1872	14.2857	14.2857
+H	12.1872	14.2857	15.2943
+H	12.1872	14.2857	17.1429
+H	12.1872	14.2857	18.1514
+H	12.1872	14.2857	2.85714
+H	12.1872	14.2857	3.86571
+H	12.1872	14.2857	5.71429
+H	12.1872	14.2857	6.72285
+H	12.1872	14.2857	8.57143
+H	12.1872	14.2857	9.58
+H	12.1872	17.1429	0
+H	12.1872	17.1429	1.00857
+H	12.1872	17.1429	11.4286
+H	12.1872	17.1429	12.4371
+H	12.1872	17.1429	14.2857
+H	12.1872	17.1429	15.2943
+H	12.1872	17.1429	17.1429
+H	12.1872	17.1429	18.1514
+H	12.1872	17.1429	2.85714
+H	12.1872	17.1429	3.86571
+H	12.1872	17.1429	5.71429
+H	12.1872	17.1429	6.72285
+H	12.1872	17.1429	8.57143
+H	12.1872	17.1429	9.58
+H	12.1872	2.85714	0
+H	12.1872	2.85714	1.00857
+H	12.1872	2.85714	11.4286
+H	12.1872	2.85714	12.4371
+H	12.1872	2.85714	14.2857
+H	12.1872	2.85714	15.2943
+H	12.1872	2.85714	17.1429
+H	12.1872	2.85714	18.1514
+H	12.1872	2.85714	5.71429
+H	12.1872	2.85714	6.72285
+H	12.1872	2.85714	8.57143
+H	12.1872	2.85714	9.58
+H	12.1872	5.71429	0
+H	12.1872	5.71429	1.00857
+H	12.1872	5.71429	11.4286
+H	12.1872	5.71429	12.4371
+H	12.1872	5.71429	14.2857
+H	12.1872	5.71429	15.2943
+H	12.1872	5.71429	17.1429
+H	12.1872	5.71429	18.1514
+H	12.1872	5.71429	2.85714
+H	12.1872	5.71429	3.86571
+H	12.1872	5.71429	5.71429
+H	12.1872	5.71429	6.72285
+H	12.1872	5.71429	8.57143
+H	12.1872	5.71429	9.58
+H	12.1872	8.57143	0
+H	12.1872	8.57143	1.00857
+H	12.1872	8.57143	11.4286
+H	12.1872	8.57143	12.4371
+H	12.1872	8.57143	14.2857
+H	12.1872	8.57143	15.2943
+H	12.1872	8.57143	17.1429
+H	12.1872	8.57143	18.1514
+H	12.1872	8.57143	2.85714
+H	12.1872	8.57143	3.86571
+H	12.1872	8.57143	5.71429
+H	12.1872	8.57143	6.72285
+H	12.1872	8.57143	8.57143
+H	12.1872	8.57143	9.58
+H	15.0443	0	0
+H	15.0443	0	1.00857
+H	15.0443	0	11.4286
+H	15.0443	0	12.4371
+H	15.0443	0	14.2857
+H	15.0443	0	15.2943
+H	15.0443	0	17.1429
+H	15.0443	0	18.1514
+H	15.0443	0	2.85714
+H	15.0443	0	3.86571
+H	15.0443	0	5.71429
+H	15.0443	0	6.72285
+H	15.0443	0	8.57143
+H	15.0443	0	9.58
+H	15.0443	11.4286	0
+H	15.0443	11.4286	1.00857
+H	15.0443	11.4286	11.4286
+H	15.0443	11.4286	12.4371
+H	15.0443	11.4286	14.2857
+H	15.0443	11.4286	15.2943
+H	15.0443	11.4286	17.1429
+H	15.0443	11.4286	18.1514
+H	15.0443	11.4286	2.85714
+H	15.0443	11.4286	3.86571
+H	15.0443	11.4286	5.71429
+H	15.0443	11.4286	6.72285
+H	15.0443	11.4286	8.57143
+H	15.0443	11.4286	9.58
+H	15.0443	14.2857	0
+H	15.0443	14.2857	1.00857
+H	15.0443	14.2857	11.4286
+H	15.0443	14.2857	12.4371
+H	15.0443	14.2857	14.2857
+H	15.0443	14.2857	15.2943
+H	15.0443	14.2857	17.1429
+H	15.0443	14.2857	18.1514
+H	15.0443	14.2857	2.85714
+H	15.0443	14.2857	3.86571
+H	15.0443	14.2857	5.71429
+H	15.0443	14.2857	6.72285
+H	15.0443	14.2857	8.57143
+H	15.0443	14.2857	9.58
+H	15.0443	17.1429	0
+H	15.0443	17.1429	1.00857
+H	15.0443	17.1429	11.4286
+H	15.0443	17.1429	12.4371
+H	15.0443	17.1429	14.2857
+H	15.0443	17.1429	15.2943
+H	15.0443	17.1429	17.1429
+H	15.0443	17.1429	18.1514
+H	15.0443	17.1429	2.85714
+H	15.0443	17.1429	3.86571
+H	15.0443	17.1429	5.71429
+H	15.0443	17.1429	6.72285
+H	15.0443	17.1429	8.57143
+H	15.0443	17.1429	9.58
+H	15.0443	2.85714	0
+H	15.0443	2.85714	1.00857
+H	15.0443	2.85714	11.4286
+H	15.0443	2.85714	12.4371
+H	15.0443	2.85714	14.2857
+H	15.0443	2.85714	15.2943
+H	15.0443	2.85714	17.1429
+H	15.0443	2.85714	18.1514
+H	15.0443	2.85714	2.85714
+H	15.0443	2.85714	3.86571
+H	15.0443	2.85714	5.71429
+H	15.0443	2.85714	6.72285
+H	15.0443	2.85714	8.57143
+H	15.0443	2.85714	9.58
+H	15.0443	5.71429	0
+H	15.0443	5.71429	1.00857
+H	15.0443	5.71429	11.4286
+H	15.0443	5.71429	12.4371
+H	15.0443	5.71429	14.2857
+H	15.0443	5.71429	15.2943
+H	15.0443	5.71429	17.1429
+H	15.0443	5.71429	18.1514
+H	15.0443	5.71429	2.85714
+H	15.0443	5.71429	3.86571
+H	15.0443	5.71429	5.71429
+H	15.0443	5.71429	6.72285
+H	15.0443	5.71429	8.57143
+H	15.0443	5.71429	9.58
+H	15.0443	8.57143	0
+H	15.0443	8.57143	1.00857
+H	15.0443	8.57143	11.4286
+H	15.0443	8.57143	12.4371
+H	15.0443	8.57143	14.2857
+H	15.0443	8.57143	15.2943
+H	15.0443	8.57143	17.1429
+H	15.0443	8.57143	18.1514
+H	15.0443	8.57143	2.85714
+H	15.0443	8.57143	3.86571
+H	15.0443	8.57143	5.71429
+H	15.0443	8.57143	6.72285
+H	15.0443	8.57143	8.57143
+H	15.0443	8.57143	9.58
+H	17.9015	0	0
+H	17.9015	0	1.00857
+H	17.9015	0	11.4286
+H	17.9015	0	12.4371
+H	17.9015	0	14.2857
+H	17.9015	0	15.2943
+H	17.9015	0	17.1429
+H	17.9015	0	18.1514
+H	17.9015	0	2.85714
+H	17.9015	0	3.86571
+H	17.9015	0	5.71429
+H	17.9015	0	6.72285
+H	17.9015	0	8.57143
+H	17.9015	0	9.58
+H	17.9015	11.4286	0
+H	17.9015	11.4286	1.00857
+H	17.9015	11.4286	11.4286
+H	17.9015	11.4286	12.4371
+H	17.9015	11.4286	14.2857
+H	17.9015	11.4286	15.2943
+H	17.9015	11.4286	17.1429
+H	17.9015	11.4286	18.1514
+H	17.9015	11.4286	2.85714
+H	17.9015	11.4286	3.86571
+H	17.9015	11.4286	5.71429
+H	17.9015	11.4286	6.72285
+H	17.9015	11.4286	8.57143
+H	17.9015	11.4286	9.58
+H	17.9015	14.2857	0
+H	17.9015	14.2857	1.00857
+H	17.9015	14.2857	11.4286
+H	17.9015	14.2857	12.4371
+H	17.9015	14.2857	14.2857
+H	17.9015	14.2857	15.2943
+H	17.9015	14.2857	17.1429
+H	17.9015	14.2857	18.1514
+H	17.9015	14.2857	2.85714
+H	17.9015	14.2857	3.86571
+H	17.9015	14.2857	5.71429
+H	17.9015	14.2857	6.72285
+H	17.9015	14.2857	8.57143
+H	17.9015	14.2857	9.58
+H	17.9015	17.1429	0
+H	17.9015	17.1429	1.00857
+H	17.9015	17.1429	11.4286
+H	17.9015	17.1429	12.4371
+H	17.9015	17.1429	14.2857
+H	17.9015	17.1429	15.2943
+H	17.9015	17.1429	17.1429
+H	17.9015	17.1429	18.1514
+H	17.9015	17.1429	2.85714
+H	17.9015	17.1429	3.86571
+H	17.9015	17.1429	5.71429
+H	17.9015	17.1429	6.72285
+H	17.9015	17.1429	8.57143
+H	17.9015	17.1429	9.58
+H	17.9015	2.85714	0
+H	17.9015	2.85714	1.00857
+H	17.9015	2.85714	11.4286
+H	17.9015	2.85714	12.4371
+H	17.9015	2.85714	14.2857
+H	17.9015	2.85714	15.2943
+H	17.9015	2.85714	17.1429
+H	17.9015	2.85714	18.1514
+H	17.9015	2.85714	2.85714
+H	17.9015	2.85714	3.86571
+H	17.9015	2.85714	5.71429
+H	17.9015	2.85714	6.72285
+H	17.9015	2.85714	8.57143
+H	17.9015	2.85714	9.58
+H	17.9015	5.71429	0
+H	17.9015	5.71429	1.00857
+H	17.9015	5.71429	11.4286
+H	17.9015	5.71429	12.4371
+H	17.9015	5.71429	14.2857
+H	17.9015	5.71429	15.2943
+H	17.9015	5.71429	17.1429
+H	17.9015	5.71429	18.1514
+H	17.9015	5.71429	2.85714
+H	17.9015	5.71429	3.86571
+H	17.9015	5.71429	5.71429
+H	17.9015	5.71429	6.72285
+H	17.9015	5.71429	8.57143
+H	17.9015	5.71429	9.58
+H	17.9015	8.57143	0
+H	17.9015	8.57143	1.00857
+H	17.9015	8.57143	11.4286
+H	17.9015	8.57143	12.4371
+H	17.9015	8.57143	14.2857
+H	17.9015	8.57143	15.2943
+H	17.9015	8.57143	17.1429
+H	17.9015	8.57143	18.1514
+H	17.9015	8.57143	2.85714
+H	17.9015	8.57143	3.86571
+H	17.9015	8.57143	5.71429
+H	17.9015	8.57143	6.72285
+H	17.9015	8.57143	8.57143
+H	17.9015	8.57143	9.58
+H	3.61574	0	0
+H	3.61574	0	1.00857
+H	3.61574	0	11.4286
+H	3.61574	0	12.4371
+H	3.61574	0	14.2857
+H	3.61574	0	15.2943
+H	3.61574	0	17.1429
+H	3.61574	0	18.1514
+H	3.61574	0	2.85714
+H	3.61574	0	3.86571
+H	3.61574	0	5.71429
+H	3.61574	0	6.72285
+H	3.61574	0	8.57143
+H	3.61574	0	9.58
+H	3.61574	11.4286	0
+H	3.61574	11.4286	1.00857
+H	3.61574	11.4286	11.4286
+H	3.61574	11.4286	12.4371
+H	3.61574	11.4286	14.2857
+H	3.61574	11.4286	15.2943
+H	3.61574	11.4286	17.1429
+H	3.61574	11.4286	18.1514
+H	3.61574	11.4286	2.85714
+H	3.61574	11.4286	3.86571
+H	3.61574	11.4286	5.71429
+H	3.61574	11.4286	6.72285
+H	3.61574	11.4286	8.57143
+H	3.61574	11.4286	9.58
+H	3.61574	14.2857	0
+H	3.61574	14.2857	1.00857
+H	3.61574	14.2857	11.4286
+H	3.61574	14.2857	12.4371
+H	3.61574	14.2857	14.2857
+H	3.61574	14.2857	15.2943
+H	3.61574	14.2857	17.1429
+H	3.61574	14.2857	18.1514
+H	3.61574	14.2857	2.85714
+H	3.61574	14.2857	3.86571
+H	3.61574	14.2857	5.71429
+H	3.61574	14.2857	6.72285
+H	3.61574	14.2857	8.57143
+H	3.61574	14.2857	9.58
+H	3.61574	17.1429	0
+H	3.61574	17.1429	1.00857
+H	3.61574	17.1429	11.4286
+H	3.61574	17.1429	12.4371
+H	3.61574	17.1429	14.2857
+H	3.61574	17.1429	15.2943
+H	3.61574	17.1429	17.1429
+H	3.61574	17.1429	18.1514
+H	3.61574	17.1429	2.85714
+H	3.61574	17.1429	3.86571
+H	3.61574	17.1429	5.71429
+H	3.61574	17.1429	6.72285
+H	3.61574	17.1429	8.57143
+H	3.61574	17.1429	9.58
+H	3.61574	2.85714	0
+H	3.61574	2.85714	1.00857
+H	3.61574	2.85714	11.4286
+H	3.61574	2.85714	12.4371
+H	3.61574	2.85714	14.2857
+H	3.61574	2.85714	15.2943
+H	3.61574	2.85714	17.1429
+H	3.61574	2.85714	18.1514
+H	3.61574	2.85714	2.85714
+H	3.61574	2.85714	3.86571
+H	3.61574	2.85714	5.71429
+H	3.61574	2.85714	6.72285
+H	3.61574	2.85714	8.57143
+H	3.61574	2.85714	9.58
+H	3.61574	5.71429	0
+H	3.61574	5.71429	1.00857
+H	3.61574	5.71429	11.4286
+H	3.61574	5.71429	12.4371
+H	3.61574	5.71429	14.2857
+H	3.61574	5.71429	15.2943
+H	3.61574	5.71429	17.1429
+H	3.61574	5.71429	18.1514
+H	3.61574	5.71429	2.85714
+H	3.61574	5.71429	3.86571
+H	3.61574	5.71429	5.71429
+H	3.61574	5.71429	6.72285
+H	3.61574	5.71429	8.57143
+H	3.61574	5.71429	9.58
+H	3.61574	8.57143	0
+H	3.61574	8.57143	1.00857
+H	3.61574	8.57143	11.4286
+H	3.61574	8.57143	12.4371
+H	3.61574	8.57143	14.2857
+H	3.61574	8.57143	15.2943
+H	3.61574	8.57143	17.1429
+H	3.61574	8.57143	18.1514
+H	3.61574	8.57143	2.85714
+H	3.61574	8.57143	3.86571
+H	3.61574	8.57143	5.71429
+H	3.61574	8.57143	6.72285
+H	3.61574	8.57143	8.57143
+H	3.61574	8.57143	9.58
+H	6.39363	3.90454	3.53589
+H	6.47289	0	0
+H	6.47289	0	1.00857
+H	6.47289	0	11.4286
+H	6.47289	0	12.4371
+H	6.47289	0	14.2857
+H	6.47289	0	15.2943
+H	6.47289	0	17.1429
+H	6.47289	0	18.1514
+H	6.47289	0	2.85714
+H	6.47289	0	3.86571
+H	6.47289	0	5.71429
+H	6.47289	0	6.72285
+H	6.47289	0	8.57143
+H	6.47289	0	9.58
+H	6.47289	11.4286	0
+H	6.47289	11.4286	1.00857
+H	6.47289	11.4286	11.4286
+H	6.47289	11.4286	12.4371
+H	6.47289	11.4286	14.2857
+H	6.47289	11.4286	15.2943
+H	6.47289	11.4286	17.1429
+H	6.47289	11.4286	18.1514
+H	6.47289	11.4286	2.85714
+H	6.47289	11.4286	3.86571
+H	6.47289	11.4286	5.71429
+H	6.47289	11.4286	6.72285
+H	6.47289	11.4286	8.57143
+H	6.47289	11.4286	9.58
+H	6.47289	14.2857	0
+H	6.47289	14.2857	1.00857
+H	6.47289	14.2857	11.4286
+H	6.47289	14.2857	12.4371
+H	6.47289	14.2857	14.2857
+H	6.47289	14.2857	15.2943
+H	6.47289	14.2857	17.1429
+H	6.47289	14.2857	18.1514
+H	6.47289	14.2857	2.85714
+H	6.47289	14.2857	3.86571
+H	6.47289	14.2857	5.71429
+H	6.47289	14.2857	6.72285
+H	6.47289	14.2857	8.57143
+H	6.47289	14.2857	9.58
+H	6.47289	17.1429	0
+H	6.47289	17.1429	1.00857
+H	6.47289	17.1429	11.4286
+H	6.47289	17.1429	12.4371
+H	6.47289	17.1429	14.2857
+H	6.47289	17.1429	15.2943
+H	6.47289	17.1429	17.1429
+H	6.47289	17.1429	18.1514
+H	6.47289	17.1429	2.85714
+H	6.47289	17.1429	3.86571
+H	6.47289	17.1429	5.71429
+H	6.47289	17.1429	6.72285
+H	6.47289	17.1429	8.57143
+H	6.47289	17.1429	9.58
+H	6.47289	2.85714	0
+H	6.47289	2.85714	11.4286
+H	6.47289	2.85714	12.4371
+H	6.47289	2.85714	14.2857
+H	6.47289	2.85714	15.2943
+H	6.47289	2.85714	17.1429
+H	6.47289	2.85714	18.1514
+H	6.47289	2.85714	6.72285
+H	6.47289	2.85714	8.57143
+H	6.47289	2.85714	9.58
+H	6.47289	5.71429	0
+H	6.47289	5.71429	1.00857
+H	6.47289	5.71429	11.4286
+H	6.47289	5.71429	12.4371
+H	6.47289	5.71429	14.2857
+H	6.47289	5.71429	15.2943
+H	6.47289	5.71429	17.1429
+H	6.47289	5.71429	18.1514
+H	6.47289	5.71429	5.71429
+H	6.47289	5.71429	6.72285
+H	6.47289	5.71429	8.57143
+H	6.47289	5.71429	9.58
+H	6.47289	8.57143	0
+H	6.47289	8.57143	1.00857
+H	6.47289	8.57143	11.4286
+H	6.47289	8.57143	12.4371
+H	6.47289	8.57143	14.2857
+H	6.47289	8.57143	15.2943
+H	6.47289	8.57143	17.1429
+H	6.47289	8.57143	18.1514
+H	6.47289	8.57143	2.85714
+H	6.47289	8.57143	3.86571
+H	6.47289	8.57143	5.71429
+H	6.47289	8.57143	6.72285
+H	6.47289	8.57143	8.57143
+H	6.47289	8.57143	9.58
+H	7.28359	2.64589	2.64589
+H	7.28359	2.64589	4.42589
+H	8.53279	4.78789	2.64589
+H	8.53279	4.78789	4.42589
+H	9.33003	0	0
+H	9.33003	0	1.00857
+H	9.33003	0	11.4286
+H	9.33003	0	12.4371
+H	9.33003	0	14.2857
+H	9.33003	0	15.2943
+H	9.33003	0	17.1429
+H	9.33003	0	18.1514
+H	9.33003	0	2.85714
+H	9.33003	0	3.86571
+H	9.33003	0	5.71429
+H	9.33003	0	6.72285
+H	9.33003	0	8.57143
+H	9.33003	0	9.58
+H	9.33003	11.4286	0
+H	9.33003	11.4286	1.00857
+H	9.33003	11.4286	11.4286
+H	9.33003	11.4286	12.4371
+H	9.33003	11.4286	14.2857
+H	9.33003	11.4286	15.2943
+H	9.33003	11.4286	17.1429
+H	9.33003	11.4286	18.1514
+H	9.33003	11.4286	2.85714
+H	9.33003	11.4286	3.86571
+H	9.33003	11.4286	5.71429
+H	9.33003	11.4286	6.72285
+H	9.33003	11.4286	8.57143
+H	9.33003	11.4286	9.58
+H	9.33003	14.2857	0
+H	9.33003	14.2857	1.00857
+H	9.33003	14.2857	11.4286
+H	9.33003	14.2857	12.4371
+H	9.33003	14.2857	14.2857
+H	9.33003	14.2857	15.2943
+H	9.33003	14.2857	17.1429
+H	9.33003	14.2857	18.1514
+H	9.33003	14.2857	2.85714
+H	9.33003	14.2857	3.86571
+H	9.33003	14.2857	5.71429
+H	9.33003	14.2857	6.72285
+H	9.33003	14.2857	8.57143
+H	9.33003	14.2857	9.58
+H	9.33003	17.1429	0
+H	9.33003	17.1429	1.00857
+H	9.33003	17.1429	11.4286
+H	9.33003	17.1429	12.4371
+H	9.33003	17.1429	14.2857
+H	9.33003	17.1429	15.2943
+H	9.33003	17.1429	17.1429
+H	9.33003	17.1429	18.1514
+H	9.33003	17.1429	2.85714
+H	9.33003	17.1429	3.86571
+H	9.33003	17.1429	5.71429
+H	9.33003	17.1429	6.72285
+H	9.33003	17.1429	8.57143
+H	9.33003	17.1429	9.58
+H	9.33003	2.85714	0
+H	9.33003	2.85714	11.4286
+H	9.33003	2.85714	12.4371
+H	9.33003	2.85714	14.2857
+H	9.33003	2.85714	15.2943
+H	9.33003	2.85714	17.1429
+H	9.33003	2.85714	18.1514
+H	9.33003	2.85714	6.72285
+H	9.33003	2.85714	8.57143
+H	9.33003	2.85714	9.58
+H	9.33003	5.71429	0
+H	9.33003	5.71429	11.4286
+H	9.33003	5.71429	12.4371
+H	9.33003	5.71429	14.2857
+H	9.33003	5.71429	15.2943
+H	9.33003	5.71429	17.1429
+H	9.33003	5.71429	18.1514
+H	9.33003	5.71429	6.72285
+H	9.33003	5.71429	8.57143
+H	9.33003	5.71429	9.58
+H	9.33003	8.57143	0
+H	9.33003	8.57143	1.00857
+H	9.33003	8.57143	11.4286
+H	9.33003	8.57143	12.4371
+H	9.33003	8.57143	14.2857
+H	9.33003	8.57143	15.2943
+H	9.33003	8.57143	17.1429
+H	9.33003	8.57143	18.1514
+H	9.33003	8.57143	2.85714
+H	9.33003	8.57143	3.86571
+H	9.33003	8.57143	5.71429
+H	9.33003	8.57143	6.72285
+H	9.33003	8.57143	8.57143
+H	9.33003	8.57143	9.58
+O	0	0	0.504284
+O	0	0	11.9329
+O	0	0	14.79
+O	0	0	17.6471
+O	0	0	3.36143
+O	0	0	6.21857
+O	0	0	9.07571
+O	0	11.4286	0.504284
+O	0	11.4286	11.9329
+O	0	11.4286	14.79
+O	0	11.4286	17.6471
+O	0	11.4286	3.36143
+O	0	11.4286	6.21857
+O	0	11.4286	9.07571
+O	0	14.2857	0.504284
+O	0	14.2857	11.9329
+O	0	14.2857	14.79
+O	0	14.2857	17.6471
+O	0	14.2857	3.36143
+O	0	14.2857	6.21857
+O	0	14.2857	9.07571
+O	0	17.1429	0.504284
+O	0	17.1429	11.9329
+O	0	17.1429	14.79
+O	0	17.1429	17.6471
+O	0	17.1429	3.36143
+O	0	17.1429	6.21857
+O	0	17.1429	9.07571
+O	0	2.85714	0.504284
+O	0	2.85714	11.9329
+O	0	2.85714	14.79
+O	0	2.85714	17.6471
+O	0	2.85714	3.36143
+O	0	2.85714	6.21857
+O	0	2.85714	9.07571
+O	0	5.71429	0.504284
+O	0	5.71429	11.9329
+O	0	5.71429	14.79
+O	0	5.71429	17.6471
+O	0	5.71429	3.36143
+O	0	5.71429	6.21857
+O	0	5.71429	9.07571
+O	0	8.57143	0.504284
+O	0	8.57143	11.9329
+O	0	8.57143	14.79
+O	0	8.57143	17.6471
+O	0	8.57143	3.36143
+O	0	8.57143	6.21857
+O	0	8.57143	9.07571
+O	11.4286	0	0.504284
+O	11.4286	0	11.9329
+O	11.4286	0	14.79
+O	11.4286	0	17.6471
+O	11.4286	0	3.36143
+O	11.4286	0	6.21857
+O	11.4286	0	9.07571
+O	11.4286	11.4286	0.504284
+O	11.4286	11.4286	11.9329
+O	11.4286	11.4286	14.79
+O	11.4286	11.4286	17.6471
+O	11.4286	11.4286	3.36143
+O	11.4286	11.4286	6.21857
+O	11.4286	11.4286	9.07571
+O	11.4286	14.2857	0.504284
+O	11.4286	14.2857	11.9329
+O	11.4286	14.2857	14.79
+O	11.4286	14.2857	17.6471
+O	11.4286	14.2857	3.36143
+O	11.4286	14.2857	6.21857
+O	11.4286	14.2857	9.07571
+O	11.4286	17.1429	0.504284
+O	11.4286	17.1429	11.9329
+O	11.4286	17.1429	14.79
+O	11.4286	17.1429	17.6471
+O	11.4286	17.1429	3.36143
+O	11.4286	17.1429	6.21857
+O	11.4286	17.1429	9.07571
+O	11.4286	2.85714	0.504284
+O	11.4286	2.85714	11.9329
+O	11.4286	2.85714	14.79
+O	11.4286	2.85714	17.6471
+O	11.4286	2.85714	6.21857
+O	11.4286	2.85714	9.07571
+O	11.4286	5.71429	0.504284
+O	11.4286	5.71429	11.9329
+O	11.4286	5.71429	14.79
+O	11.4286	5.71429	17.6471
+O	11.4286	5.71429	6.21857
+O	11.4286	5.71429	9.07571
+O	11.4286	8.57143	0.504284
+O	11.4286	8.57143	11.9329
+O	11.4286	8.57143	14.79
+O	11.4286	8.57143	17.6471
+O	11.4286	8.57143	3.36143
+O	11.4286	8.57143	6.21857
+O	11.4286	8.57143	9.07571
+O	14.2857	0	0.504284
+O	14.2857	0	11.9329
+O	14.2857	0	14.79
+O	14.2857	0	17.6471
+O	14.2857	0	3.36143
+O	14.2857	0	6.21857
+O	14.2857	0	9.07571
+O	14.2857	11.4286	0.504284
+O	14.2857	11.4286	11.9329
+O	14.2857	11.4286	14.79
+O	14.2857	11.4286	17.6471
+O	14.2857	11.4286	3.36143
+O	14.2857	11.4286	6.21857
+O	14.2857	11.4286	9.07571
+O	14.2857	14.2857	0.504284
+O	14.2857	14.2857	11.9329
+O	14.2857	14.2857	14.79
+O	14.2857	14.2857	17.6471
+O	14.2857	14.2857	3.36143
+O	14.2857	14.2857	6.21857
+O	14.2857	14.2857	9.07571
+O	14.2857	17.1429	0.504284
+O	14.2857	17.1429	11.9329
+O	14.2857	17.1429	14.79
+O	14.2857	17.1429	17.6471
+O	14.2857	17.1429	3.36143
+O	14.2857	17.1429	6.21857
+O	14.2857	17.1429	9.07571
+O	14.2857	2.85714	0.504284
+O	14.2857	2.85714	11.9329
+O	14.2857	2.85714	14.79
+O	14.2857	2.85714	17.6471
+O	14.2857	2.85714	3.36143
+O	14.2857	2.85714	6.21857
+O	14.2857	2.85714	9.07571
+O	14.2857	5.71429	0.504284
+O	14.2857	5.71429	11.9329
+O	14.2857	5.71429	14.79
+O	14.2857	5.71429	17.6471
+O	14.2857	5.71429	3.36143
+O	14.2857	5.71429	6.21857
+O	14.2857	5.71429	9.07571
+O	14.2857	8.57143	0.504284
+O	14.2857	8.57143	11.9329
+O	14.2857	8.57143	14.79
+O	14.2857	8.57143	17.6471
+O	14.2857	8.57143	3.36143
+O	14.2857	8.57143	6.21857
+O	14.2857	8.57143	9.07571
+O	17.1429	0	0.504284
+O	17.1429	0	11.9329
+O	17.1429	0	14.79
+O	17.1429	0	17.6471
+O	17.1429	0	3.36143
+O	17.1429	0	6.21857
+O	17.1429	0	9.07571
+O	17.1429	11.4286	0.504284
+O	17.1429	11.4286	11.9329
+O	17.1429	11.4286	14.79
+O	17.1429	11.4286	17.6471
+O	17.1429	11.4286	3.36143
+O	17.1429	11.4286	6.21857
+O	17.1429	11.4286	9.07571
+O	17.1429	14.2857	0.504284
+O	17.1429	14.2857	11.9329
+O	17.1429	14.2857	14.79
+O	17.1429	14.2857	17.6471
+O	17.1429	14.2857	3.36143
+O	17.1429	14.2857	6.21857
+O	17.1429	14.2857	9.07571
+O	17.1429	17.1429	0.504284
+O	17.1429	17.1429	11.9329
+O	17.1429	17.1429	14.79
+O	17.1429	17.1429	17.6471
+O	17.1429	17.1429	3.36143
+O	17.1429	17.1429	6.21857
+O	17.1429	17.1429	9.07571
+O	17.1429	2.85714	0.504284
+O	17.1429	2.85714	11.9329
+O	17.1429	2.85714	14.79
+O	17.1429	2.85714	17.6471
+O	17.1429	2.85714	3.36143
+O	17.1429	2.85714	6.21857
+O	17.1429	2.85714	9.07571
+O	17.1429	5.71429	0.504284
+O	17.1429	5.71429	11.9329
+O	17.1429	5.71429	14.79
+O	17.1429	5.71429	17.6471
+O	17.1429	5.71429	3.36143
+O	17.1429	5.71429	6.21857
+O	17.1429	5.71429	9.07571
+O	17.1429	8.57143	0.504284
+O	17.1429	8.57143	11.9329
+O	17.1429	8.57143	14.79
+O	17.1429	8.57143	17.6471
+O	17.1429	8.57143	3.36143
+O	17.1429	8.57143	6.21857
+O	17.1429	8.57143	9.07571
+O	2.85714	0	0.504284
+O	2.85714	0	11.9329
+O	2.85714	0	14.79
+O	2.85714	0	17.6471
+O	2.85714	0	3.36143
+O	2.85714	0	6.21857
+O	2.85714	0	9.07571
+O	2.85714	11.4286	0.504284
+O	2.85714	11.4286	11.9329
+O	2.85714	11.4286	14.79
+O	2.85714	11.4286	17.6471
+O	2.85714	11.4286	3.36143
+O	2.85714	11.4286	6.21857
+O	2.85714	11.4286	9.07571
+O	2.85714	14.2857	0.504284
+O	2.85714	14.2857	11.9329
+O	2.85714	14.2857	14.79
+O	2.85714	14.2857	17.6471
+O	2.85714	14.2857	3.36143
+O	2.85714	14.2857	6.21857
+O	2.85714	14.2857	9.07571
+O	2.85714	17.1429	0.504284
+O	2.85714	17.1429	11.9329
+O	2.85714	17.1429	14.79
+O	2.85714	17.1429	17.6471
+O	2.85714	17.1429	3.36143
+O	2.85714	17.1429	6.21857
+O	2.85714	17.1429	9.07571
+O	2.85714	2.85714	0.504284
+O	2.85714	2.85714	11.9329
+O	2.85714	2.85714	14.79
+O	2.85714	2.85714	17.6471
+O	2.85714	2.85714	3.36143
+O	2.85714	2.85714	6.21857
+O	2.85714	2.85714	9.07571
+O	2.85714	5.71429	0.504284
+O	2.85714	5.71429	11.9329
+O	2.85714	5.71429	14.79
+O	2.85714	5.71429	17.6471
+O	2.85714	5.71429	3.36143
+O	2.85714	5.71429	6.21857
+O	2.85714	5.71429	9.07571
+O	2.85714	8.57143	0.504284
+O	2.85714	8.57143	11.9329
+O	2.85714	8.57143	14.79
+O	2.85714	8.57143	17.6471
+O	2.85714	8.57143	3.36143
+O	2.85714	8.57143	6.21857
+O	2.85714	8.57143	9.07571
+O	5.71429	0	0.504284
+O	5.71429	0	11.9329
+O	5.71429	0	14.79
+O	5.71429	0	17.6471
+O	5.71429	0	3.36143
+O	5.71429	0	6.21857
+O	5.71429	0	9.07571
+O	5.71429	11.4286	0.504284
+O	5.71429	11.4286	11.9329
+O	5.71429	11.4286	14.79
+O	5.71429	11.4286	17.6471
+O	5.71429	11.4286	3.36143
+O	5.71429	11.4286	6.21857
+O	5.71429	11.4286	9.07571
+O	5.71429	14.2857	0.504284
+O	5.71429	14.2857	11.9329
+O	5.71429	14.2857	14.79
+O	5.71429	14.2857	17.6471
+O	5.71429	14.2857	3.36143
+O	5.71429	14.2857	6.21857
+O	5.71429	14.2857	9.07571
+O	5.71429	17.1429	0.504284
+O	5.71429	17.1429	11.9329
+O	5.71429	17.1429	14.79
+O	5.71429	17.1429	17.6471
+O	5.71429	17.1429	3.36143
+O	5.71429	17.1429	6.21857
+O	5.71429	17.1429	9.07571
+O	5.71429	2.85714	0.504284
+O	5.71429	2.85714	11.9329
+O	5.71429	2.85714	14.79
+O	5.71429	2.85714	17.6471
+O	5.71429	2.85714	6.21857
+O	5.71429	2.85714	9.07571
+O	5.71429	5.71429	0.504284
+O	5.71429	5.71429	11.9329
+O	5.71429	5.71429	14.79
+O	5.71429	5.71429	17.6471
+O	5.71429	5.71429	6.21857
+O	5.71429	5.71429	9.07571
+O	5.71429	8.57143	0.504284
+O	5.71429	8.57143	11.9329
+O	5.71429	8.57143	14.79
+O	5.71429	8.57143	17.6471
+O	5.71429	8.57143	3.36143
+O	5.71429	8.57143	6.21857
+O	5.71429	8.57143	9.07571
+O	8.57143	0	0.504284
+O	8.57143	0	11.9329
+O	8.57143	0	14.79
+O	8.57143	0	17.6471
+O	8.57143	0	3.36143
+O	8.57143	0	6.21857
+O	8.57143	0	9.07571
+O	8.57143	11.4286	0.504284
+O	8.57143	11.4286	11.9329
+O	8.57143	11.4286	14.79
+O	8.57143	11.4286	17.6471
+O	8.57143	11.4286	3.36143
+O	8.57143	11.4286	6.21857
+O	8.57143	11.4286	9.07571
+O	8.57143	14.2857	0.504284
+O	8.57143	14.2857	11.9329
+O	8.57143	14.2857	14.79
+O	8.57143	14.2857	17.6471
+O	8.57143	14.2857	3.36143
+O	8.57143	14.2857	6.21857
+O	8.57143	14.2857	9.07571
+O	8.57143	17.1429	0.504284
+O	8.57143	17.1429	11.9329
+O	8.57143	17.1429	14.79
+O	8.57143	17.1429	17.6471
+O	8.57143	17.1429	3.36143
+O	8.57143	17.1429	6.21857
+O	8.57143	17.1429	9.07571
+O	8.57143	2.85714	0.504284
+O	8.57143	2.85714	11.9329
+O	8.57143	2.85714	14.79
+O	8.57143	2.85714	17.6471
+O	8.57143	2.85714	9.07571
+O	8.57143	5.71429	0.504284
+O	8.57143	5.71429	11.9329
+O	8.57143	5.71429	14.79
+O	8.57143	5.71429	17.6471
+O	8.57143	5.71429	9.07571
+O	8.57143	8.57143	0.504284
+O	8.57143	8.57143	11.9329
+O	8.57143	8.57143	14.79
+O	8.57143	8.57143	17.6471
+O	8.57143	8.57143	3.36143
+O	8.57143	8.57143	6.21857
+O	8.57143	8.57143	9.07571
Index: tests/regression/Simple_configuration/8/post/test-withoutsphere.xyz-sorted
===================================================================
--- tests/regression/Simple_configuration/8/post/test-withoutsphere.xyz-sorted	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
+++ tests/regression/Simple_configuration/8/post/test-withoutsphere.xyz-sorted	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -0,0 +1,872 @@
+H	0.758602	0	0
+H	0.758602	0	1.00857
+H	0.758602	0	11.4286
+H	0.758602	0	12.4371
+H	0.758602	0	14.2857
+H	0.758602	0	15.2943
+H	0.758602	0	17.1429
+H	0.758602	0	18.1514
+H	0.758602	0	2.85714
+H	0.758602	0	3.86571
+H	0.758602	0	5.71429
+H	0.758602	0	6.72285
+H	0.758602	0	8.57143
+H	0.758602	0	9.58
+H	0.758602	11.4286	0
+H	0.758602	11.4286	1.00857
+H	0.758602	11.4286	11.4286
+H	0.758602	11.4286	12.4371
+H	0.758602	11.4286	14.2857
+H	0.758602	11.4286	15.2943
+H	0.758602	11.4286	17.1429
+H	0.758602	11.4286	18.1514
+H	0.758602	11.4286	2.85714
+H	0.758602	11.4286	3.86571
+H	0.758602	11.4286	5.71429
+H	0.758602	11.4286	6.72285
+H	0.758602	11.4286	8.57143
+H	0.758602	11.4286	9.58
+H	0.758602	14.2857	0
+H	0.758602	14.2857	1.00857
+H	0.758602	14.2857	11.4286
+H	0.758602	14.2857	12.4371
+H	0.758602	14.2857	14.2857
+H	0.758602	14.2857	15.2943
+H	0.758602	14.2857	17.1429
+H	0.758602	14.2857	18.1514
+H	0.758602	14.2857	2.85714
+H	0.758602	14.2857	3.86571
+H	0.758602	14.2857	5.71429
+H	0.758602	14.2857	6.72285
+H	0.758602	14.2857	8.57143
+H	0.758602	14.2857	9.58
+H	0.758602	17.1429	0
+H	0.758602	17.1429	1.00857
+H	0.758602	17.1429	11.4286
+H	0.758602	17.1429	12.4371
+H	0.758602	17.1429	14.2857
+H	0.758602	17.1429	15.2943
+H	0.758602	17.1429	17.1429
+H	0.758602	17.1429	18.1514
+H	0.758602	17.1429	2.85714
+H	0.758602	17.1429	3.86571
+H	0.758602	17.1429	5.71429
+H	0.758602	17.1429	6.72285
+H	0.758602	17.1429	8.57143
+H	0.758602	17.1429	9.58
+H	0.758602	2.85714	0
+H	0.758602	2.85714	1.00857
+H	0.758602	2.85714	11.4286
+H	0.758602	2.85714	12.4371
+H	0.758602	2.85714	14.2857
+H	0.758602	2.85714	15.2943
+H	0.758602	2.85714	17.1429
+H	0.758602	2.85714	18.1514
+H	0.758602	2.85714	6.72285
+H	0.758602	2.85714	8.57143
+H	0.758602	2.85714	9.58
+H	0.758602	5.71429	0
+H	0.758602	5.71429	1.00857
+H	0.758602	5.71429	11.4286
+H	0.758602	5.71429	12.4371
+H	0.758602	5.71429	14.2857
+H	0.758602	5.71429	15.2943
+H	0.758602	5.71429	17.1429
+H	0.758602	5.71429	18.1514
+H	0.758602	5.71429	5.71429
+H	0.758602	5.71429	6.72285
+H	0.758602	5.71429	8.57143
+H	0.758602	5.71429	9.58
+H	0.758602	8.57143	0
+H	0.758602	8.57143	1.00857
+H	0.758602	8.57143	11.4286
+H	0.758602	8.57143	12.4371
+H	0.758602	8.57143	14.2857
+H	0.758602	8.57143	15.2943
+H	0.758602	8.57143	17.1429
+H	0.758602	8.57143	18.1514
+H	0.758602	8.57143	2.85714
+H	0.758602	8.57143	3.86571
+H	0.758602	8.57143	5.71429
+H	0.758602	8.57143	6.72285
+H	0.758602	8.57143	8.57143
+H	0.758602	8.57143	9.58
+H	12.1872	0	11.4286
+H	12.1872	0	12.4371
+H	12.1872	0	14.2857
+H	12.1872	0	15.2943
+H	12.1872	0	17.1429
+H	12.1872	0	18.1514
+H	12.1872	0	8.57143
+H	12.1872	0	9.58
+H	12.1872	11.4286	0
+H	12.1872	11.4286	1.00857
+H	12.1872	11.4286	11.4286
+H	12.1872	11.4286	12.4371
+H	12.1872	11.4286	14.2857
+H	12.1872	11.4286	15.2943
+H	12.1872	11.4286	17.1429
+H	12.1872	11.4286	18.1514
+H	12.1872	11.4286	2.85714
+H	12.1872	11.4286	3.86571
+H	12.1872	11.4286	5.71429
+H	12.1872	11.4286	6.72285
+H	12.1872	11.4286	8.57143
+H	12.1872	11.4286	9.58
+H	12.1872	14.2857	0
+H	12.1872	14.2857	1.00857
+H	12.1872	14.2857	11.4286
+H	12.1872	14.2857	12.4371
+H	12.1872	14.2857	14.2857
+H	12.1872	14.2857	15.2943
+H	12.1872	14.2857	17.1429
+H	12.1872	14.2857	18.1514
+H	12.1872	14.2857	2.85714
+H	12.1872	14.2857	3.86571
+H	12.1872	14.2857	5.71429
+H	12.1872	14.2857	6.72285
+H	12.1872	14.2857	8.57143
+H	12.1872	14.2857	9.58
+H	12.1872	17.1429	0
+H	12.1872	17.1429	1.00857
+H	12.1872	17.1429	11.4286
+H	12.1872	17.1429	12.4371
+H	12.1872	17.1429	14.2857
+H	12.1872	17.1429	15.2943
+H	12.1872	17.1429	17.1429
+H	12.1872	17.1429	18.1514
+H	12.1872	17.1429	2.85714
+H	12.1872	17.1429	3.86571
+H	12.1872	17.1429	5.71429
+H	12.1872	17.1429	6.72285
+H	12.1872	17.1429	8.57143
+H	12.1872	17.1429	9.58
+H	12.1872	2.85714	11.4286
+H	12.1872	2.85714	12.4371
+H	12.1872	2.85714	14.2857
+H	12.1872	2.85714	15.2943
+H	12.1872	2.85714	17.1429
+H	12.1872	2.85714	18.1514
+H	12.1872	2.85714	8.57143
+H	12.1872	2.85714	9.58
+H	12.1872	5.71429	11.4286
+H	12.1872	5.71429	12.4371
+H	12.1872	5.71429	14.2857
+H	12.1872	5.71429	15.2943
+H	12.1872	5.71429	17.1429
+H	12.1872	5.71429	18.1514
+H	12.1872	5.71429	8.57143
+H	12.1872	5.71429	9.58
+H	12.1872	8.57143	0
+H	12.1872	8.57143	1.00857
+H	12.1872	8.57143	11.4286
+H	12.1872	8.57143	12.4371
+H	12.1872	8.57143	14.2857
+H	12.1872	8.57143	15.2943
+H	12.1872	8.57143	17.1429
+H	12.1872	8.57143	18.1514
+H	12.1872	8.57143	2.85714
+H	12.1872	8.57143	3.86571
+H	12.1872	8.57143	5.71429
+H	12.1872	8.57143	6.72285
+H	12.1872	8.57143	8.57143
+H	12.1872	8.57143	9.58
+H	15.0443	0	0
+H	15.0443	0	1.00857
+H	15.0443	0	11.4286
+H	15.0443	0	12.4371
+H	15.0443	0	14.2857
+H	15.0443	0	15.2943
+H	15.0443	0	17.1429
+H	15.0443	0	18.1514
+H	15.0443	0	2.85714
+H	15.0443	0	3.86571
+H	15.0443	0	5.71429
+H	15.0443	0	6.72285
+H	15.0443	0	8.57143
+H	15.0443	0	9.58
+H	15.0443	11.4286	0
+H	15.0443	11.4286	1.00857
+H	15.0443	11.4286	11.4286
+H	15.0443	11.4286	12.4371
+H	15.0443	11.4286	14.2857
+H	15.0443	11.4286	15.2943
+H	15.0443	11.4286	17.1429
+H	15.0443	11.4286	18.1514
+H	15.0443	11.4286	2.85714
+H	15.0443	11.4286	3.86571
+H	15.0443	11.4286	5.71429
+H	15.0443	11.4286	6.72285
+H	15.0443	11.4286	8.57143
+H	15.0443	11.4286	9.58
+H	15.0443	14.2857	0
+H	15.0443	14.2857	1.00857
+H	15.0443	14.2857	11.4286
+H	15.0443	14.2857	12.4371
+H	15.0443	14.2857	14.2857
+H	15.0443	14.2857	15.2943
+H	15.0443	14.2857	17.1429
+H	15.0443	14.2857	18.1514
+H	15.0443	14.2857	2.85714
+H	15.0443	14.2857	3.86571
+H	15.0443	14.2857	5.71429
+H	15.0443	14.2857	6.72285
+H	15.0443	14.2857	8.57143
+H	15.0443	14.2857	9.58
+H	15.0443	17.1429	0
+H	15.0443	17.1429	1.00857
+H	15.0443	17.1429	11.4286
+H	15.0443	17.1429	12.4371
+H	15.0443	17.1429	14.2857
+H	15.0443	17.1429	15.2943
+H	15.0443	17.1429	17.1429
+H	15.0443	17.1429	18.1514
+H	15.0443	17.1429	2.85714
+H	15.0443	17.1429	3.86571
+H	15.0443	17.1429	5.71429
+H	15.0443	17.1429	6.72285
+H	15.0443	17.1429	8.57143
+H	15.0443	17.1429	9.58
+H	15.0443	2.85714	0
+H	15.0443	2.85714	1.00857
+H	15.0443	2.85714	11.4286
+H	15.0443	2.85714	12.4371
+H	15.0443	2.85714	14.2857
+H	15.0443	2.85714	15.2943
+H	15.0443	2.85714	17.1429
+H	15.0443	2.85714	18.1514
+H	15.0443	2.85714	2.85714
+H	15.0443	2.85714	3.86571
+H	15.0443	2.85714	5.71429
+H	15.0443	2.85714	6.72285
+H	15.0443	2.85714	8.57143
+H	15.0443	2.85714	9.58
+H	15.0443	5.71429	0
+H	15.0443	5.71429	1.00857
+H	15.0443	5.71429	11.4286
+H	15.0443	5.71429	12.4371
+H	15.0443	5.71429	14.2857
+H	15.0443	5.71429	15.2943
+H	15.0443	5.71429	17.1429
+H	15.0443	5.71429	18.1514
+H	15.0443	5.71429	2.85714
+H	15.0443	5.71429	3.86571
+H	15.0443	5.71429	5.71429
+H	15.0443	5.71429	6.72285
+H	15.0443	5.71429	8.57143
+H	15.0443	5.71429	9.58
+H	15.0443	8.57143	0
+H	15.0443	8.57143	1.00857
+H	15.0443	8.57143	11.4286
+H	15.0443	8.57143	12.4371
+H	15.0443	8.57143	14.2857
+H	15.0443	8.57143	15.2943
+H	15.0443	8.57143	17.1429
+H	15.0443	8.57143	18.1514
+H	15.0443	8.57143	2.85714
+H	15.0443	8.57143	3.86571
+H	15.0443	8.57143	5.71429
+H	15.0443	8.57143	6.72285
+H	15.0443	8.57143	8.57143
+H	15.0443	8.57143	9.58
+H	17.9015	0	0
+H	17.9015	0	1.00857
+H	17.9015	0	11.4286
+H	17.9015	0	12.4371
+H	17.9015	0	14.2857
+H	17.9015	0	15.2943
+H	17.9015	0	17.1429
+H	17.9015	0	18.1514
+H	17.9015	0	2.85714
+H	17.9015	0	3.86571
+H	17.9015	0	5.71429
+H	17.9015	0	6.72285
+H	17.9015	0	8.57143
+H	17.9015	0	9.58
+H	17.9015	11.4286	0
+H	17.9015	11.4286	1.00857
+H	17.9015	11.4286	11.4286
+H	17.9015	11.4286	12.4371
+H	17.9015	11.4286	14.2857
+H	17.9015	11.4286	15.2943
+H	17.9015	11.4286	17.1429
+H	17.9015	11.4286	18.1514
+H	17.9015	11.4286	2.85714
+H	17.9015	11.4286	3.86571
+H	17.9015	11.4286	5.71429
+H	17.9015	11.4286	6.72285
+H	17.9015	11.4286	8.57143
+H	17.9015	11.4286	9.58
+H	17.9015	14.2857	0
+H	17.9015	14.2857	1.00857
+H	17.9015	14.2857	11.4286
+H	17.9015	14.2857	12.4371
+H	17.9015	14.2857	14.2857
+H	17.9015	14.2857	15.2943
+H	17.9015	14.2857	17.1429
+H	17.9015	14.2857	18.1514
+H	17.9015	14.2857	2.85714
+H	17.9015	14.2857	3.86571
+H	17.9015	14.2857	5.71429
+H	17.9015	14.2857	6.72285
+H	17.9015	14.2857	8.57143
+H	17.9015	14.2857	9.58
+H	17.9015	17.1429	0
+H	17.9015	17.1429	1.00857
+H	17.9015	17.1429	11.4286
+H	17.9015	17.1429	12.4371
+H	17.9015	17.1429	14.2857
+H	17.9015	17.1429	15.2943
+H	17.9015	17.1429	17.1429
+H	17.9015	17.1429	18.1514
+H	17.9015	17.1429	2.85714
+H	17.9015	17.1429	3.86571
+H	17.9015	17.1429	5.71429
+H	17.9015	17.1429	6.72285
+H	17.9015	17.1429	8.57143
+H	17.9015	17.1429	9.58
+H	17.9015	2.85714	0
+H	17.9015	2.85714	1.00857
+H	17.9015	2.85714	11.4286
+H	17.9015	2.85714	12.4371
+H	17.9015	2.85714	14.2857
+H	17.9015	2.85714	15.2943
+H	17.9015	2.85714	17.1429
+H	17.9015	2.85714	18.1514
+H	17.9015	2.85714	2.85714
+H	17.9015	2.85714	3.86571
+H	17.9015	2.85714	5.71429
+H	17.9015	2.85714	6.72285
+H	17.9015	2.85714	8.57143
+H	17.9015	2.85714	9.58
+H	17.9015	5.71429	0
+H	17.9015	5.71429	1.00857
+H	17.9015	5.71429	11.4286
+H	17.9015	5.71429	12.4371
+H	17.9015	5.71429	14.2857
+H	17.9015	5.71429	15.2943
+H	17.9015	5.71429	17.1429
+H	17.9015	5.71429	18.1514
+H	17.9015	5.71429	2.85714
+H	17.9015	5.71429	3.86571
+H	17.9015	5.71429	5.71429
+H	17.9015	5.71429	6.72285
+H	17.9015	5.71429	8.57143
+H	17.9015	5.71429	9.58
+H	17.9015	8.57143	0
+H	17.9015	8.57143	1.00857
+H	17.9015	8.57143	11.4286
+H	17.9015	8.57143	12.4371
+H	17.9015	8.57143	14.2857
+H	17.9015	8.57143	15.2943
+H	17.9015	8.57143	17.1429
+H	17.9015	8.57143	18.1514
+H	17.9015	8.57143	2.85714
+H	17.9015	8.57143	3.86571
+H	17.9015	8.57143	5.71429
+H	17.9015	8.57143	6.72285
+H	17.9015	8.57143	8.57143
+H	17.9015	8.57143	9.58
+H	3.61574	0	11.4286
+H	3.61574	0	12.4371
+H	3.61574	0	14.2857
+H	3.61574	0	15.2943
+H	3.61574	0	17.1429
+H	3.61574	0	18.1514
+H	3.61574	0	8.57143
+H	3.61574	0	9.58
+H	3.61574	11.4286	0
+H	3.61574	11.4286	1.00857
+H	3.61574	11.4286	11.4286
+H	3.61574	11.4286	12.4371
+H	3.61574	11.4286	14.2857
+H	3.61574	11.4286	15.2943
+H	3.61574	11.4286	17.1429
+H	3.61574	11.4286	18.1514
+H	3.61574	11.4286	2.85714
+H	3.61574	11.4286	3.86571
+H	3.61574	11.4286	5.71429
+H	3.61574	11.4286	6.72285
+H	3.61574	11.4286	8.57143
+H	3.61574	11.4286	9.58
+H	3.61574	14.2857	0
+H	3.61574	14.2857	1.00857
+H	3.61574	14.2857	11.4286
+H	3.61574	14.2857	12.4371
+H	3.61574	14.2857	14.2857
+H	3.61574	14.2857	15.2943
+H	3.61574	14.2857	17.1429
+H	3.61574	14.2857	18.1514
+H	3.61574	14.2857	2.85714
+H	3.61574	14.2857	3.86571
+H	3.61574	14.2857	5.71429
+H	3.61574	14.2857	6.72285
+H	3.61574	14.2857	8.57143
+H	3.61574	14.2857	9.58
+H	3.61574	17.1429	0
+H	3.61574	17.1429	1.00857
+H	3.61574	17.1429	11.4286
+H	3.61574	17.1429	12.4371
+H	3.61574	17.1429	14.2857
+H	3.61574	17.1429	15.2943
+H	3.61574	17.1429	17.1429
+H	3.61574	17.1429	18.1514
+H	3.61574	17.1429	2.85714
+H	3.61574	17.1429	3.86571
+H	3.61574	17.1429	5.71429
+H	3.61574	17.1429	6.72285
+H	3.61574	17.1429	8.57143
+H	3.61574	17.1429	9.58
+H	3.61574	2.85714	11.4286
+H	3.61574	2.85714	12.4371
+H	3.61574	2.85714	14.2857
+H	3.61574	2.85714	15.2943
+H	3.61574	2.85714	17.1429
+H	3.61574	2.85714	18.1514
+H	3.61574	2.85714	9.58
+H	3.61574	5.71429	11.4286
+H	3.61574	5.71429	12.4371
+H	3.61574	5.71429	14.2857
+H	3.61574	5.71429	15.2943
+H	3.61574	5.71429	17.1429
+H	3.61574	5.71429	18.1514
+H	3.61574	5.71429	9.58
+H	3.61574	8.57143	0
+H	3.61574	8.57143	11.4286
+H	3.61574	8.57143	12.4371
+H	3.61574	8.57143	14.2857
+H	3.61574	8.57143	15.2943
+H	3.61574	8.57143	17.1429
+H	3.61574	8.57143	18.1514
+H	3.61574	8.57143	6.72285
+H	3.61574	8.57143	8.57143
+H	3.61574	8.57143	9.58
+H	6.47289	0	11.4286
+H	6.47289	0	12.4371
+H	6.47289	0	14.2857
+H	6.47289	0	15.2943
+H	6.47289	0	17.1429
+H	6.47289	0	18.1514
+H	6.47289	11.4286	0
+H	6.47289	11.4286	1.00857
+H	6.47289	11.4286	11.4286
+H	6.47289	11.4286	12.4371
+H	6.47289	11.4286	14.2857
+H	6.47289	11.4286	15.2943
+H	6.47289	11.4286	17.1429
+H	6.47289	11.4286	18.1514
+H	6.47289	11.4286	2.85714
+H	6.47289	11.4286	3.86571
+H	6.47289	11.4286	5.71429
+H	6.47289	11.4286	6.72285
+H	6.47289	11.4286	8.57143
+H	6.47289	11.4286	9.58
+H	6.47289	14.2857	0
+H	6.47289	14.2857	1.00857
+H	6.47289	14.2857	11.4286
+H	6.47289	14.2857	12.4371
+H	6.47289	14.2857	14.2857
+H	6.47289	14.2857	15.2943
+H	6.47289	14.2857	17.1429
+H	6.47289	14.2857	18.1514
+H	6.47289	14.2857	2.85714
+H	6.47289	14.2857	3.86571
+H	6.47289	14.2857	5.71429
+H	6.47289	14.2857	6.72285
+H	6.47289	14.2857	8.57143
+H	6.47289	14.2857	9.58
+H	6.47289	17.1429	0
+H	6.47289	17.1429	1.00857
+H	6.47289	17.1429	11.4286
+H	6.47289	17.1429	12.4371
+H	6.47289	17.1429	14.2857
+H	6.47289	17.1429	15.2943
+H	6.47289	17.1429	17.1429
+H	6.47289	17.1429	18.1514
+H	6.47289	17.1429	2.85714
+H	6.47289	17.1429	3.86571
+H	6.47289	17.1429	5.71429
+H	6.47289	17.1429	6.72285
+H	6.47289	17.1429	8.57143
+H	6.47289	17.1429	9.58
+H	6.47289	2.85714	11.4286
+H	6.47289	2.85714	12.4371
+H	6.47289	2.85714	14.2857
+H	6.47289	2.85714	15.2943
+H	6.47289	2.85714	17.1429
+H	6.47289	2.85714	18.1514
+H	6.47289	5.71429	11.4286
+H	6.47289	5.71429	12.4371
+H	6.47289	5.71429	14.2857
+H	6.47289	5.71429	15.2943
+H	6.47289	5.71429	17.1429
+H	6.47289	5.71429	18.1514
+H	6.47289	8.57143	11.4286
+H	6.47289	8.57143	12.4371
+H	6.47289	8.57143	14.2857
+H	6.47289	8.57143	15.2943
+H	6.47289	8.57143	17.1429
+H	6.47289	8.57143	18.1514
+H	6.47289	8.57143	8.57143
+H	6.47289	8.57143	9.58
+H	9.33003	0	11.4286
+H	9.33003	0	12.4371
+H	9.33003	0	14.2857
+H	9.33003	0	15.2943
+H	9.33003	0	17.1429
+H	9.33003	0	18.1514
+H	9.33003	0	9.58
+H	9.33003	11.4286	0
+H	9.33003	11.4286	1.00857
+H	9.33003	11.4286	11.4286
+H	9.33003	11.4286	12.4371
+H	9.33003	11.4286	14.2857
+H	9.33003	11.4286	15.2943
+H	9.33003	11.4286	17.1429
+H	9.33003	11.4286	18.1514
+H	9.33003	11.4286	2.85714
+H	9.33003	11.4286	3.86571
+H	9.33003	11.4286	5.71429
+H	9.33003	11.4286	6.72285
+H	9.33003	11.4286	8.57143
+H	9.33003	11.4286	9.58
+H	9.33003	14.2857	0
+H	9.33003	14.2857	1.00857
+H	9.33003	14.2857	11.4286
+H	9.33003	14.2857	12.4371
+H	9.33003	14.2857	14.2857
+H	9.33003	14.2857	15.2943
+H	9.33003	14.2857	17.1429
+H	9.33003	14.2857	18.1514
+H	9.33003	14.2857	2.85714
+H	9.33003	14.2857	3.86571
+H	9.33003	14.2857	5.71429
+H	9.33003	14.2857	6.72285
+H	9.33003	14.2857	8.57143
+H	9.33003	14.2857	9.58
+H	9.33003	17.1429	0
+H	9.33003	17.1429	1.00857
+H	9.33003	17.1429	11.4286
+H	9.33003	17.1429	12.4371
+H	9.33003	17.1429	14.2857
+H	9.33003	17.1429	15.2943
+H	9.33003	17.1429	17.1429
+H	9.33003	17.1429	18.1514
+H	9.33003	17.1429	2.85714
+H	9.33003	17.1429	3.86571
+H	9.33003	17.1429	5.71429
+H	9.33003	17.1429	6.72285
+H	9.33003	17.1429	8.57143
+H	9.33003	17.1429	9.58
+H	9.33003	2.85714	11.4286
+H	9.33003	2.85714	12.4371
+H	9.33003	2.85714	14.2857
+H	9.33003	2.85714	15.2943
+H	9.33003	2.85714	17.1429
+H	9.33003	2.85714	18.1514
+H	9.33003	5.71429	11.4286
+H	9.33003	5.71429	12.4371
+H	9.33003	5.71429	14.2857
+H	9.33003	5.71429	15.2943
+H	9.33003	5.71429	17.1429
+H	9.33003	5.71429	18.1514
+H	9.33003	8.57143	11.4286
+H	9.33003	8.57143	12.4371
+H	9.33003	8.57143	14.2857
+H	9.33003	8.57143	15.2943
+H	9.33003	8.57143	17.1429
+H	9.33003	8.57143	18.1514
+H	9.33003	8.57143	8.57143
+H	9.33003	8.57143	9.58
+O	0	0	0.504284
+O	0	0	11.9329
+O	0	0	14.79
+O	0	0	17.6471
+O	0	0	3.36143
+O	0	0	6.21857
+O	0	0	9.07571
+O	0	11.4286	0.504284
+O	0	11.4286	11.9329
+O	0	11.4286	14.79
+O	0	11.4286	17.6471
+O	0	11.4286	3.36143
+O	0	11.4286	6.21857
+O	0	11.4286	9.07571
+O	0	14.2857	0.504284
+O	0	14.2857	11.9329
+O	0	14.2857	14.79
+O	0	14.2857	17.6471
+O	0	14.2857	3.36143
+O	0	14.2857	6.21857
+O	0	14.2857	9.07571
+O	0	17.1429	0.504284
+O	0	17.1429	11.9329
+O	0	17.1429	14.79
+O	0	17.1429	17.6471
+O	0	17.1429	3.36143
+O	0	17.1429	6.21857
+O	0	17.1429	9.07571
+O	0	2.85714	0.504284
+O	0	2.85714	11.9329
+O	0	2.85714	14.79
+O	0	2.85714	17.6471
+O	0	2.85714	3.36143
+O	0	2.85714	6.21857
+O	0	2.85714	9.07571
+O	0	5.71429	0.504284
+O	0	5.71429	11.9329
+O	0	5.71429	14.79
+O	0	5.71429	17.6471
+O	0	5.71429	3.36143
+O	0	5.71429	6.21857
+O	0	5.71429	9.07571
+O	0	8.57143	0.504284
+O	0	8.57143	11.9329
+O	0	8.57143	14.79
+O	0	8.57143	17.6471
+O	0	8.57143	3.36143
+O	0	8.57143	6.21857
+O	0	8.57143	9.07571
+O	11.4286	0	11.9329
+O	11.4286	0	14.79
+O	11.4286	0	17.6471
+O	11.4286	0	9.07571
+O	11.4286	11.4286	0.504284
+O	11.4286	11.4286	11.9329
+O	11.4286	11.4286	14.79
+O	11.4286	11.4286	17.6471
+O	11.4286	11.4286	3.36143
+O	11.4286	11.4286	6.21857
+O	11.4286	11.4286	9.07571
+O	11.4286	14.2857	0.504284
+O	11.4286	14.2857	11.9329
+O	11.4286	14.2857	14.79
+O	11.4286	14.2857	17.6471
+O	11.4286	14.2857	3.36143
+O	11.4286	14.2857	6.21857
+O	11.4286	14.2857	9.07571
+O	11.4286	17.1429	0.504284
+O	11.4286	17.1429	11.9329
+O	11.4286	17.1429	14.79
+O	11.4286	17.1429	17.6471
+O	11.4286	17.1429	3.36143
+O	11.4286	17.1429	6.21857
+O	11.4286	17.1429	9.07571
+O	11.4286	2.85714	11.9329
+O	11.4286	2.85714	14.79
+O	11.4286	2.85714	17.6471
+O	11.4286	5.71429	11.9329
+O	11.4286	5.71429	14.79
+O	11.4286	5.71429	17.6471
+O	11.4286	5.71429	9.07571
+O	11.4286	8.57143	0.504284
+O	11.4286	8.57143	11.9329
+O	11.4286	8.57143	14.79
+O	11.4286	8.57143	17.6471
+O	11.4286	8.57143	6.21857
+O	11.4286	8.57143	9.07571
+O	14.2857	0	0.504284
+O	14.2857	0	11.9329
+O	14.2857	0	14.79
+O	14.2857	0	17.6471
+O	14.2857	0	3.36143
+O	14.2857	0	6.21857
+O	14.2857	0	9.07571
+O	14.2857	11.4286	0.504284
+O	14.2857	11.4286	11.9329
+O	14.2857	11.4286	14.79
+O	14.2857	11.4286	17.6471
+O	14.2857	11.4286	3.36143
+O	14.2857	11.4286	6.21857
+O	14.2857	11.4286	9.07571
+O	14.2857	14.2857	0.504284
+O	14.2857	14.2857	11.9329
+O	14.2857	14.2857	14.79
+O	14.2857	14.2857	17.6471
+O	14.2857	14.2857	3.36143
+O	14.2857	14.2857	6.21857
+O	14.2857	14.2857	9.07571
+O	14.2857	17.1429	0.504284
+O	14.2857	17.1429	11.9329
+O	14.2857	17.1429	14.79
+O	14.2857	17.1429	17.6471
+O	14.2857	17.1429	3.36143
+O	14.2857	17.1429	6.21857
+O	14.2857	17.1429	9.07571
+O	14.2857	2.85714	0.504284
+O	14.2857	2.85714	11.9329
+O	14.2857	2.85714	14.79
+O	14.2857	2.85714	17.6471
+O	14.2857	2.85714	3.36143
+O	14.2857	2.85714	6.21857
+O	14.2857	2.85714	9.07571
+O	14.2857	5.71429	0.504284
+O	14.2857	5.71429	11.9329
+O	14.2857	5.71429	14.79
+O	14.2857	5.71429	17.6471
+O	14.2857	5.71429	3.36143
+O	14.2857	5.71429	6.21857
+O	14.2857	5.71429	9.07571
+O	14.2857	8.57143	0.504284
+O	14.2857	8.57143	11.9329
+O	14.2857	8.57143	14.79
+O	14.2857	8.57143	17.6471
+O	14.2857	8.57143	3.36143
+O	14.2857	8.57143	6.21857
+O	14.2857	8.57143	9.07571
+O	17.1429	0	0.504284
+O	17.1429	0	11.9329
+O	17.1429	0	14.79
+O	17.1429	0	17.6471
+O	17.1429	0	3.36143
+O	17.1429	0	6.21857
+O	17.1429	0	9.07571
+O	17.1429	11.4286	0.504284
+O	17.1429	11.4286	11.9329
+O	17.1429	11.4286	14.79
+O	17.1429	11.4286	17.6471
+O	17.1429	11.4286	3.36143
+O	17.1429	11.4286	6.21857
+O	17.1429	11.4286	9.07571
+O	17.1429	14.2857	0.504284
+O	17.1429	14.2857	11.9329
+O	17.1429	14.2857	14.79
+O	17.1429	14.2857	17.6471
+O	17.1429	14.2857	3.36143
+O	17.1429	14.2857	6.21857
+O	17.1429	14.2857	9.07571
+O	17.1429	17.1429	0.504284
+O	17.1429	17.1429	11.9329
+O	17.1429	17.1429	14.79
+O	17.1429	17.1429	17.6471
+O	17.1429	17.1429	3.36143
+O	17.1429	17.1429	6.21857
+O	17.1429	17.1429	9.07571
+O	17.1429	2.85714	0.504284
+O	17.1429	2.85714	11.9329
+O	17.1429	2.85714	14.79
+O	17.1429	2.85714	17.6471
+O	17.1429	2.85714	3.36143
+O	17.1429	2.85714	6.21857
+O	17.1429	2.85714	9.07571
+O	17.1429	5.71429	0.504284
+O	17.1429	5.71429	11.9329
+O	17.1429	5.71429	14.79
+O	17.1429	5.71429	17.6471
+O	17.1429	5.71429	3.36143
+O	17.1429	5.71429	6.21857
+O	17.1429	5.71429	9.07571
+O	17.1429	8.57143	0.504284
+O	17.1429	8.57143	11.9329
+O	17.1429	8.57143	14.79
+O	17.1429	8.57143	17.6471
+O	17.1429	8.57143	3.36143
+O	17.1429	8.57143	6.21857
+O	17.1429	8.57143	9.07571
+O	2.85714	0	11.9329
+O	2.85714	0	14.79
+O	2.85714	0	17.6471
+O	2.85714	0	9.07571
+O	2.85714	11.4286	0.504284
+O	2.85714	11.4286	11.9329
+O	2.85714	11.4286	14.79
+O	2.85714	11.4286	17.6471
+O	2.85714	11.4286	3.36143
+O	2.85714	11.4286	6.21857
+O	2.85714	11.4286	9.07571
+O	2.85714	14.2857	0.504284
+O	2.85714	14.2857	11.9329
+O	2.85714	14.2857	14.79
+O	2.85714	14.2857	17.6471
+O	2.85714	14.2857	3.36143
+O	2.85714	14.2857	6.21857
+O	2.85714	14.2857	9.07571
+O	2.85714	17.1429	0.504284
+O	2.85714	17.1429	11.9329
+O	2.85714	17.1429	14.79
+O	2.85714	17.1429	17.6471
+O	2.85714	17.1429	3.36143
+O	2.85714	17.1429	6.21857
+O	2.85714	17.1429	9.07571
+O	2.85714	2.85714	11.9329
+O	2.85714	2.85714	14.79
+O	2.85714	2.85714	17.6471
+O	2.85714	2.85714	9.07571
+O	2.85714	5.71429	11.9329
+O	2.85714	5.71429	14.79
+O	2.85714	5.71429	17.6471
+O	2.85714	5.71429	9.07571
+O	2.85714	8.57143	0.504284
+O	2.85714	8.57143	11.9329
+O	2.85714	8.57143	14.79
+O	2.85714	8.57143	17.6471
+O	2.85714	8.57143	6.21857
+O	2.85714	8.57143	9.07571
+O	5.71429	0	11.9329
+O	5.71429	0	14.79
+O	5.71429	0	17.6471
+O	5.71429	11.4286	0.504284
+O	5.71429	11.4286	11.9329
+O	5.71429	11.4286	14.79
+O	5.71429	11.4286	17.6471
+O	5.71429	11.4286	3.36143
+O	5.71429	11.4286	6.21857
+O	5.71429	11.4286	9.07571
+O	5.71429	14.2857	0.504284
+O	5.71429	14.2857	11.9329
+O	5.71429	14.2857	14.79
+O	5.71429	14.2857	17.6471
+O	5.71429	14.2857	3.36143
+O	5.71429	14.2857	6.21857
+O	5.71429	14.2857	9.07571
+O	5.71429	17.1429	0.504284
+O	5.71429	17.1429	11.9329
+O	5.71429	17.1429	14.79
+O	5.71429	17.1429	17.6471
+O	5.71429	17.1429	3.36143
+O	5.71429	17.1429	6.21857
+O	5.71429	17.1429	9.07571
+O	5.71429	2.85714	11.9329
+O	5.71429	2.85714	14.79
+O	5.71429	2.85714	17.6471
+O	5.71429	5.71429	11.9329
+O	5.71429	5.71429	14.79
+O	5.71429	5.71429	17.6471
+O	5.71429	8.57143	11.9329
+O	5.71429	8.57143	14.79
+O	5.71429	8.57143	17.6471
+O	5.71429	8.57143	9.07571
+O	8.57143	0	11.9329
+O	8.57143	0	14.79
+O	8.57143	0	17.6471
+O	8.57143	11.4286	0.504284
+O	8.57143	11.4286	11.9329
+O	8.57143	11.4286	14.79
+O	8.57143	11.4286	17.6471
+O	8.57143	11.4286	3.36143
+O	8.57143	11.4286	6.21857
+O	8.57143	11.4286	9.07571
+O	8.57143	14.2857	0.504284
+O	8.57143	14.2857	11.9329
+O	8.57143	14.2857	14.79
+O	8.57143	14.2857	17.6471
+O	8.57143	14.2857	3.36143
+O	8.57143	14.2857	6.21857
+O	8.57143	14.2857	9.07571
+O	8.57143	17.1429	0.504284
+O	8.57143	17.1429	11.9329
+O	8.57143	17.1429	14.79
+O	8.57143	17.1429	17.6471
+O	8.57143	17.1429	3.36143
+O	8.57143	17.1429	6.21857
+O	8.57143	17.1429	9.07571
+O	8.57143	2.85714	11.9329
+O	8.57143	2.85714	14.79
+O	8.57143	2.85714	17.6471
+O	8.57143	5.71429	11.9329
+O	8.57143	5.71429	14.79
+O	8.57143	5.71429	17.6471
+O	8.57143	8.57143	11.9329
+O	8.57143	8.57143	14.79
+O	8.57143	8.57143	17.6471
+O	8.57143	8.57143	9.07571
Index: sts/regression/Simple_configuration/8/post/test.xyz
===================================================================
--- tests/regression/Simple_configuration/8/post/test.xyz	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ 	(revision )
@@ -1,146 +1,0 @@
-144
-	Created by molecuilder on Mon May 31 18:50:20 2010
-H	9.78209	2.64589	2.64589
-H	9.78209	2.64589	4.42589
-H	10.672	3.90454	3.53589
-H	8.53279	4.78789	2.64589
-H	8.53279	4.78789	4.42589
-H	6.39363	3.90454	3.53589
-H	7.28359	2.64589	2.64589
-H	7.28359	2.64589	4.42589
-H	0.758602	2.85714	3.86571
-H	0.758602	2.85714	2.85714
-H	0.758602	2.85714	5.71429
-H	0.758602	5.71429	3.86571
-H	0.758602	5.71429	2.85714
-H	3.61574	0	1.00857
-H	3.61574	0	0
-H	3.61574	0	3.86571
-H	3.61574	0	2.85714
-H	3.61574	0	6.72285
-H	3.61574	0	5.71429
-H	3.61574	2.85714	1.00857
-H	3.61574	2.85714	0
-H	3.61574	2.85714	3.86571
-H	3.61574	2.85714	2.85714
-H	3.61574	2.85714	6.72285
-H	3.61574	2.85714	5.71429
-H	3.61574	2.85714	8.57143
-H	3.61574	5.71429	1.00857
-H	3.61574	5.71429	0
-H	3.61574	5.71429	3.86571
-H	3.61574	5.71429	2.85714
-H	3.61574	5.71429	6.72285
-H	3.61574	5.71429	5.71429
-H	3.61574	5.71429	8.57143
-H	3.61574	8.57143	1.00857
-H	3.61574	8.57143	3.86571
-H	3.61574	8.57143	2.85714
-H	3.61574	8.57143	5.71429
-H	6.47289	0	1.00857
-H	6.47289	0	0
-H	6.47289	0	3.86571
-H	6.47289	0	2.85714
-H	6.47289	0	6.72285
-H	6.47289	0	5.71429
-H	6.47289	0	9.58
-H	6.47289	0	8.57143
-H	6.47289	2.85714	0
-H	6.47289	2.85714	6.72285
-H	6.47289	2.85714	9.58
-H	6.47289	2.85714	8.57143
-H	6.47289	5.71429	1.00857
-H	6.47289	5.71429	0
-H	6.47289	5.71429	6.72285
-H	6.47289	5.71429	5.71429
-H	6.47289	5.71429	9.58
-H	6.47289	5.71429	8.57143
-H	6.47289	8.57143	1.00857
-H	6.47289	8.57143	0
-H	6.47289	8.57143	3.86571
-H	6.47289	8.57143	2.85714
-H	6.47289	8.57143	6.72285
-H	6.47289	8.57143	5.71429
-H	9.33003	0	1.00857
-H	9.33003	0	0
-H	9.33003	0	3.86571
-H	9.33003	0	2.85714
-H	9.33003	0	6.72285
-H	9.33003	0	5.71429
-H	9.33003	0	8.57143
-H	9.33003	2.85714	0
-H	9.33003	2.85714	6.72285
-H	9.33003	2.85714	9.58
-H	9.33003	2.85714	8.57143
-H	9.33003	5.71429	0
-H	9.33003	5.71429	6.72285
-H	9.33003	5.71429	9.58
-H	9.33003	5.71429	8.57143
-H	9.33003	8.57143	1.00857
-H	9.33003	8.57143	0
-H	9.33003	8.57143	3.86571
-H	9.33003	8.57143	2.85714
-H	9.33003	8.57143	6.72285
-H	9.33003	8.57143	5.71429
-H	12.1872	0	1.00857
-H	12.1872	0	0
-H	12.1872	0	3.86571
-H	12.1872	0	2.85714
-H	12.1872	0	6.72285
-H	12.1872	0	5.71429
-H	12.1872	2.85714	1.00857
-H	12.1872	2.85714	0
-H	12.1872	2.85714	6.72285
-H	12.1872	2.85714	5.71429
-H	12.1872	5.71429	1.00857
-H	12.1872	5.71429	0
-H	12.1872	5.71429	3.86571
-H	12.1872	5.71429	2.85714
-H	12.1872	5.71429	6.72285
-H	12.1872	5.71429	5.71429
-C	9.78209	3.27519	3.53589
-C	8.53279	4.15859	3.53589
-C	7.28359	3.27519	3.53589
-O	2.85714	0	0.504284
-O	2.85714	0	3.36143
-O	2.85714	0	6.21857
-O	2.85714	2.85714	0.504284
-O	2.85714	2.85714	3.36143
-O	2.85714	2.85714	6.21857
-O	2.85714	5.71429	0.504284
-O	2.85714	5.71429	3.36143
-O	2.85714	5.71429	6.21857
-O	2.85714	8.57143	3.36143
-O	5.71429	0	0.504284
-O	5.71429	0	3.36143
-O	5.71429	0	6.21857
-O	5.71429	0	9.07571
-O	5.71429	2.85714	0.504284
-O	5.71429	2.85714	6.21857
-O	5.71429	2.85714	9.07571
-O	5.71429	5.71429	0.504284
-O	5.71429	5.71429	6.21857
-O	5.71429	5.71429	9.07571
-O	5.71429	8.57143	0.504284
-O	5.71429	8.57143	3.36143
-O	5.71429	8.57143	6.21857
-O	8.57143	0	0.504284
-O	8.57143	0	3.36143
-O	8.57143	0	6.21857
-O	8.57143	0	9.07571
-O	8.57143	2.85714	0.504284
-O	8.57143	2.85714	9.07571
-O	8.57143	5.71429	0.504284
-O	8.57143	5.71429	9.07571
-O	8.57143	8.57143	0.504284
-O	8.57143	8.57143	3.36143
-O	8.57143	8.57143	6.21857
-O	11.4286	0	0.504284
-O	11.4286	0	3.36143
-O	11.4286	0	6.21857
-O	11.4286	2.85714	0.504284
-O	11.4286	2.85714	6.21857
-O	11.4286	2.85714	9.07571
-O	11.4286	5.71429	0.504284
-O	11.4286	5.71429	6.21857
-O	11.4286	8.57143	3.36143
Index: tests/regression/Simple_configuration/8/post/test.xyz-sorted
===================================================================
--- tests/regression/Simple_configuration/8/post/test.xyz-sorted	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ tests/regression/Simple_configuration/8/post/test.xyz-sorted	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -2,34 +2,459 @@
 C	8.53279	4.15859	3.53589
 C	9.78209	3.27519	3.53589
+H	0.758602	0	0
+H	0.758602	0	1.00857
+H	0.758602	0	11.4286
+H	0.758602	0	12.4371
+H	0.758602	0	14.2857
+H	0.758602	0	15.2943
+H	0.758602	0	17.1429
+H	0.758602	0	18.1514
+H	0.758602	0	2.85714
+H	0.758602	0	3.86571
+H	0.758602	0	5.71429
+H	0.758602	0	6.72285
+H	0.758602	0	8.57143
+H	0.758602	0	9.58
+H	0.758602	11.4286	0
+H	0.758602	11.4286	1.00857
+H	0.758602	11.4286	11.4286
+H	0.758602	11.4286	12.4371
+H	0.758602	11.4286	14.2857
+H	0.758602	11.4286	15.2943
+H	0.758602	11.4286	17.1429
+H	0.758602	11.4286	18.1514
+H	0.758602	11.4286	2.85714
+H	0.758602	11.4286	3.86571
+H	0.758602	11.4286	5.71429
+H	0.758602	11.4286	6.72285
+H	0.758602	11.4286	8.57143
+H	0.758602	11.4286	9.58
+H	0.758602	14.2857	0
+H	0.758602	14.2857	1.00857
+H	0.758602	14.2857	11.4286
+H	0.758602	14.2857	12.4371
+H	0.758602	14.2857	14.2857
+H	0.758602	14.2857	15.2943
+H	0.758602	14.2857	17.1429
+H	0.758602	14.2857	18.1514
+H	0.758602	14.2857	2.85714
+H	0.758602	14.2857	3.86571
+H	0.758602	14.2857	5.71429
+H	0.758602	14.2857	6.72285
+H	0.758602	14.2857	8.57143
+H	0.758602	14.2857	9.58
+H	0.758602	17.1429	0
+H	0.758602	17.1429	1.00857
+H	0.758602	17.1429	11.4286
+H	0.758602	17.1429	12.4371
+H	0.758602	17.1429	14.2857
+H	0.758602	17.1429	15.2943
+H	0.758602	17.1429	17.1429
+H	0.758602	17.1429	18.1514
+H	0.758602	17.1429	2.85714
+H	0.758602	17.1429	3.86571
+H	0.758602	17.1429	5.71429
+H	0.758602	17.1429	6.72285
+H	0.758602	17.1429	8.57143
+H	0.758602	17.1429	9.58
+H	0.758602	2.85714	0
+H	0.758602	2.85714	1.00857
+H	0.758602	2.85714	11.4286
+H	0.758602	2.85714	12.4371
+H	0.758602	2.85714	14.2857
+H	0.758602	2.85714	15.2943
+H	0.758602	2.85714	17.1429
+H	0.758602	2.85714	18.1514
 H	0.758602	2.85714	2.85714
 H	0.758602	2.85714	3.86571
 H	0.758602	2.85714	5.71429
+H	0.758602	2.85714	6.72285
+H	0.758602	2.85714	8.57143
+H	0.758602	2.85714	9.58
+H	0.758602	5.71429	0
+H	0.758602	5.71429	1.00857
+H	0.758602	5.71429	11.4286
+H	0.758602	5.71429	12.4371
+H	0.758602	5.71429	14.2857
+H	0.758602	5.71429	15.2943
+H	0.758602	5.71429	17.1429
+H	0.758602	5.71429	18.1514
 H	0.758602	5.71429	2.85714
 H	0.758602	5.71429	3.86571
+H	0.758602	5.71429	5.71429
+H	0.758602	5.71429	6.72285
+H	0.758602	5.71429	8.57143
+H	0.758602	5.71429	9.58
+H	0.758602	8.57143	0
+H	0.758602	8.57143	1.00857
+H	0.758602	8.57143	11.4286
+H	0.758602	8.57143	12.4371
+H	0.758602	8.57143	14.2857
+H	0.758602	8.57143	15.2943
+H	0.758602	8.57143	17.1429
+H	0.758602	8.57143	18.1514
+H	0.758602	8.57143	2.85714
+H	0.758602	8.57143	3.86571
+H	0.758602	8.57143	5.71429
+H	0.758602	8.57143	6.72285
+H	0.758602	8.57143	8.57143
+H	0.758602	8.57143	9.58
 H	10.672	3.90454	3.53589
 H	12.1872	0	0
 H	12.1872	0	1.00857
+H	12.1872	0	11.4286
+H	12.1872	0	12.4371
+H	12.1872	0	14.2857
+H	12.1872	0	15.2943
+H	12.1872	0	17.1429
+H	12.1872	0	18.1514
 H	12.1872	0	2.85714
 H	12.1872	0	3.86571
 H	12.1872	0	5.71429
 H	12.1872	0	6.72285
+H	12.1872	0	8.57143
+H	12.1872	0	9.58
+H	12.1872	11.4286	0
+H	12.1872	11.4286	1.00857
+H	12.1872	11.4286	11.4286
+H	12.1872	11.4286	12.4371
+H	12.1872	11.4286	14.2857
+H	12.1872	11.4286	15.2943
+H	12.1872	11.4286	17.1429
+H	12.1872	11.4286	18.1514
+H	12.1872	11.4286	2.85714
+H	12.1872	11.4286	3.86571
+H	12.1872	11.4286	5.71429
+H	12.1872	11.4286	6.72285
+H	12.1872	11.4286	8.57143
+H	12.1872	11.4286	9.58
+H	12.1872	14.2857	0
+H	12.1872	14.2857	1.00857
+H	12.1872	14.2857	11.4286
+H	12.1872	14.2857	12.4371
+H	12.1872	14.2857	14.2857
+H	12.1872	14.2857	15.2943
+H	12.1872	14.2857	17.1429
+H	12.1872	14.2857	18.1514
+H	12.1872	14.2857	2.85714
+H	12.1872	14.2857	3.86571
+H	12.1872	14.2857	5.71429
+H	12.1872	14.2857	6.72285
+H	12.1872	14.2857	8.57143
+H	12.1872	14.2857	9.58
+H	12.1872	17.1429	0
+H	12.1872	17.1429	1.00857
+H	12.1872	17.1429	11.4286
+H	12.1872	17.1429	12.4371
+H	12.1872	17.1429	14.2857
+H	12.1872	17.1429	15.2943
+H	12.1872	17.1429	17.1429
+H	12.1872	17.1429	18.1514
+H	12.1872	17.1429	2.85714
+H	12.1872	17.1429	3.86571
+H	12.1872	17.1429	5.71429
+H	12.1872	17.1429	6.72285
+H	12.1872	17.1429	8.57143
+H	12.1872	17.1429	9.58
 H	12.1872	2.85714	0
 H	12.1872	2.85714	1.00857
+H	12.1872	2.85714	11.4286
+H	12.1872	2.85714	12.4371
+H	12.1872	2.85714	14.2857
+H	12.1872	2.85714	15.2943
+H	12.1872	2.85714	17.1429
+H	12.1872	2.85714	18.1514
 H	12.1872	2.85714	5.71429
 H	12.1872	2.85714	6.72285
+H	12.1872	2.85714	8.57143
+H	12.1872	2.85714	9.58
 H	12.1872	5.71429	0
 H	12.1872	5.71429	1.00857
+H	12.1872	5.71429	11.4286
+H	12.1872	5.71429	12.4371
+H	12.1872	5.71429	14.2857
+H	12.1872	5.71429	15.2943
+H	12.1872	5.71429	17.1429
+H	12.1872	5.71429	18.1514
 H	12.1872	5.71429	2.85714
 H	12.1872	5.71429	3.86571
 H	12.1872	5.71429	5.71429
 H	12.1872	5.71429	6.72285
+H	12.1872	5.71429	8.57143
+H	12.1872	5.71429	9.58
+H	12.1872	8.57143	0
+H	12.1872	8.57143	1.00857
+H	12.1872	8.57143	11.4286
+H	12.1872	8.57143	12.4371
+H	12.1872	8.57143	14.2857
+H	12.1872	8.57143	15.2943
+H	12.1872	8.57143	17.1429
+H	12.1872	8.57143	18.1514
+H	12.1872	8.57143	2.85714
+H	12.1872	8.57143	3.86571
+H	12.1872	8.57143	5.71429
+H	12.1872	8.57143	6.72285
+H	12.1872	8.57143	8.57143
+H	12.1872	8.57143	9.58
+H	15.0443	0	0
+H	15.0443	0	1.00857
+H	15.0443	0	11.4286
+H	15.0443	0	12.4371
+H	15.0443	0	14.2857
+H	15.0443	0	15.2943
+H	15.0443	0	17.1429
+H	15.0443	0	18.1514
+H	15.0443	0	2.85714
+H	15.0443	0	3.86571
+H	15.0443	0	5.71429
+H	15.0443	0	6.72285
+H	15.0443	0	8.57143
+H	15.0443	0	9.58
+H	15.0443	11.4286	0
+H	15.0443	11.4286	1.00857
+H	15.0443	11.4286	11.4286
+H	15.0443	11.4286	12.4371
+H	15.0443	11.4286	14.2857
+H	15.0443	11.4286	15.2943
+H	15.0443	11.4286	17.1429
+H	15.0443	11.4286	18.1514
+H	15.0443	11.4286	2.85714
+H	15.0443	11.4286	3.86571
+H	15.0443	11.4286	5.71429
+H	15.0443	11.4286	6.72285
+H	15.0443	11.4286	8.57143
+H	15.0443	11.4286	9.58
+H	15.0443	14.2857	0
+H	15.0443	14.2857	1.00857
+H	15.0443	14.2857	11.4286
+H	15.0443	14.2857	12.4371
+H	15.0443	14.2857	14.2857
+H	15.0443	14.2857	15.2943
+H	15.0443	14.2857	17.1429
+H	15.0443	14.2857	18.1514
+H	15.0443	14.2857	2.85714
+H	15.0443	14.2857	3.86571
+H	15.0443	14.2857	5.71429
+H	15.0443	14.2857	6.72285
+H	15.0443	14.2857	8.57143
+H	15.0443	14.2857	9.58
+H	15.0443	17.1429	0
+H	15.0443	17.1429	1.00857
+H	15.0443	17.1429	11.4286
+H	15.0443	17.1429	12.4371
+H	15.0443	17.1429	14.2857
+H	15.0443	17.1429	15.2943
+H	15.0443	17.1429	17.1429
+H	15.0443	17.1429	18.1514
+H	15.0443	17.1429	2.85714
+H	15.0443	17.1429	3.86571
+H	15.0443	17.1429	5.71429
+H	15.0443	17.1429	6.72285
+H	15.0443	17.1429	8.57143
+H	15.0443	17.1429	9.58
+H	15.0443	2.85714	0
+H	15.0443	2.85714	1.00857
+H	15.0443	2.85714	11.4286
+H	15.0443	2.85714	12.4371
+H	15.0443	2.85714	14.2857
+H	15.0443	2.85714	15.2943
+H	15.0443	2.85714	17.1429
+H	15.0443	2.85714	18.1514
+H	15.0443	2.85714	2.85714
+H	15.0443	2.85714	3.86571
+H	15.0443	2.85714	5.71429
+H	15.0443	2.85714	6.72285
+H	15.0443	2.85714	8.57143
+H	15.0443	2.85714	9.58
+H	15.0443	5.71429	0
+H	15.0443	5.71429	1.00857
+H	15.0443	5.71429	11.4286
+H	15.0443	5.71429	12.4371
+H	15.0443	5.71429	14.2857
+H	15.0443	5.71429	15.2943
+H	15.0443	5.71429	17.1429
+H	15.0443	5.71429	18.1514
+H	15.0443	5.71429	2.85714
+H	15.0443	5.71429	3.86571
+H	15.0443	5.71429	5.71429
+H	15.0443	5.71429	6.72285
+H	15.0443	5.71429	8.57143
+H	15.0443	5.71429	9.58
+H	15.0443	8.57143	0
+H	15.0443	8.57143	1.00857
+H	15.0443	8.57143	11.4286
+H	15.0443	8.57143	12.4371
+H	15.0443	8.57143	14.2857
+H	15.0443	8.57143	15.2943
+H	15.0443	8.57143	17.1429
+H	15.0443	8.57143	18.1514
+H	15.0443	8.57143	2.85714
+H	15.0443	8.57143	3.86571
+H	15.0443	8.57143	5.71429
+H	15.0443	8.57143	6.72285
+H	15.0443	8.57143	8.57143
+H	15.0443	8.57143	9.58
+H	17.9015	0	0
+H	17.9015	0	1.00857
+H	17.9015	0	11.4286
+H	17.9015	0	12.4371
+H	17.9015	0	14.2857
+H	17.9015	0	15.2943
+H	17.9015	0	17.1429
+H	17.9015	0	18.1514
+H	17.9015	0	2.85714
+H	17.9015	0	3.86571
+H	17.9015	0	5.71429
+H	17.9015	0	6.72285
+H	17.9015	0	8.57143
+H	17.9015	0	9.58
+H	17.9015	11.4286	0
+H	17.9015	11.4286	1.00857
+H	17.9015	11.4286	11.4286
+H	17.9015	11.4286	12.4371
+H	17.9015	11.4286	14.2857
+H	17.9015	11.4286	15.2943
+H	17.9015	11.4286	17.1429
+H	17.9015	11.4286	18.1514
+H	17.9015	11.4286	2.85714
+H	17.9015	11.4286	3.86571
+H	17.9015	11.4286	5.71429
+H	17.9015	11.4286	6.72285
+H	17.9015	11.4286	8.57143
+H	17.9015	11.4286	9.58
+H	17.9015	14.2857	0
+H	17.9015	14.2857	1.00857
+H	17.9015	14.2857	11.4286
+H	17.9015	14.2857	12.4371
+H	17.9015	14.2857	14.2857
+H	17.9015	14.2857	15.2943
+H	17.9015	14.2857	17.1429
+H	17.9015	14.2857	18.1514
+H	17.9015	14.2857	2.85714
+H	17.9015	14.2857	3.86571
+H	17.9015	14.2857	5.71429
+H	17.9015	14.2857	6.72285
+H	17.9015	14.2857	8.57143
+H	17.9015	14.2857	9.58
+H	17.9015	17.1429	0
+H	17.9015	17.1429	1.00857
+H	17.9015	17.1429	11.4286
+H	17.9015	17.1429	12.4371
+H	17.9015	17.1429	14.2857
+H	17.9015	17.1429	15.2943
+H	17.9015	17.1429	17.1429
+H	17.9015	17.1429	18.1514
+H	17.9015	17.1429	2.85714
+H	17.9015	17.1429	3.86571
+H	17.9015	17.1429	5.71429
+H	17.9015	17.1429	6.72285
+H	17.9015	17.1429	8.57143
+H	17.9015	17.1429	9.58
+H	17.9015	2.85714	0
+H	17.9015	2.85714	1.00857
+H	17.9015	2.85714	11.4286
+H	17.9015	2.85714	12.4371
+H	17.9015	2.85714	14.2857
+H	17.9015	2.85714	15.2943
+H	17.9015	2.85714	17.1429
+H	17.9015	2.85714	18.1514
+H	17.9015	2.85714	2.85714
+H	17.9015	2.85714	3.86571
+H	17.9015	2.85714	5.71429
+H	17.9015	2.85714	6.72285
+H	17.9015	2.85714	8.57143
+H	17.9015	2.85714	9.58
+H	17.9015	5.71429	0
+H	17.9015	5.71429	1.00857
+H	17.9015	5.71429	11.4286
+H	17.9015	5.71429	12.4371
+H	17.9015	5.71429	14.2857
+H	17.9015	5.71429	15.2943
+H	17.9015	5.71429	17.1429
+H	17.9015	5.71429	18.1514
+H	17.9015	5.71429	2.85714
+H	17.9015	5.71429	3.86571
+H	17.9015	5.71429	5.71429
+H	17.9015	5.71429	6.72285
+H	17.9015	5.71429	8.57143
+H	17.9015	5.71429	9.58
+H	17.9015	8.57143	0
+H	17.9015	8.57143	1.00857
+H	17.9015	8.57143	11.4286
+H	17.9015	8.57143	12.4371
+H	17.9015	8.57143	14.2857
+H	17.9015	8.57143	15.2943
+H	17.9015	8.57143	17.1429
+H	17.9015	8.57143	18.1514
+H	17.9015	8.57143	2.85714
+H	17.9015	8.57143	3.86571
+H	17.9015	8.57143	5.71429
+H	17.9015	8.57143	6.72285
+H	17.9015	8.57143	8.57143
+H	17.9015	8.57143	9.58
 H	3.61574	0	0
 H	3.61574	0	1.00857
+H	3.61574	0	11.4286
+H	3.61574	0	12.4371
+H	3.61574	0	14.2857
+H	3.61574	0	15.2943
+H	3.61574	0	17.1429
+H	3.61574	0	18.1514
 H	3.61574	0	2.85714
 H	3.61574	0	3.86571
 H	3.61574	0	5.71429
 H	3.61574	0	6.72285
+H	3.61574	0	8.57143
+H	3.61574	0	9.58
+H	3.61574	11.4286	0
+H	3.61574	11.4286	1.00857
+H	3.61574	11.4286	11.4286
+H	3.61574	11.4286	12.4371
+H	3.61574	11.4286	14.2857
+H	3.61574	11.4286	15.2943
+H	3.61574	11.4286	17.1429
+H	3.61574	11.4286	18.1514
+H	3.61574	11.4286	2.85714
+H	3.61574	11.4286	3.86571
+H	3.61574	11.4286	5.71429
+H	3.61574	11.4286	6.72285
+H	3.61574	11.4286	8.57143
+H	3.61574	11.4286	9.58
+H	3.61574	14.2857	0
+H	3.61574	14.2857	1.00857
+H	3.61574	14.2857	11.4286
+H	3.61574	14.2857	12.4371
+H	3.61574	14.2857	14.2857
+H	3.61574	14.2857	15.2943
+H	3.61574	14.2857	17.1429
+H	3.61574	14.2857	18.1514
+H	3.61574	14.2857	2.85714
+H	3.61574	14.2857	3.86571
+H	3.61574	14.2857	5.71429
+H	3.61574	14.2857	6.72285
+H	3.61574	14.2857	8.57143
+H	3.61574	14.2857	9.58
+H	3.61574	17.1429	0
+H	3.61574	17.1429	1.00857
+H	3.61574	17.1429	11.4286
+H	3.61574	17.1429	12.4371
+H	3.61574	17.1429	14.2857
+H	3.61574	17.1429	15.2943
+H	3.61574	17.1429	17.1429
+H	3.61574	17.1429	18.1514
+H	3.61574	17.1429	2.85714
+H	3.61574	17.1429	3.86571
+H	3.61574	17.1429	5.71429
+H	3.61574	17.1429	6.72285
+H	3.61574	17.1429	8.57143
+H	3.61574	17.1429	9.58
 H	3.61574	2.85714	0
 H	3.61574	2.85714	1.00857
+H	3.61574	2.85714	11.4286
+H	3.61574	2.85714	12.4371
+H	3.61574	2.85714	14.2857
+H	3.61574	2.85714	15.2943
+H	3.61574	2.85714	17.1429
+H	3.61574	2.85714	18.1514
 H	3.61574	2.85714	2.85714
 H	3.61574	2.85714	3.86571
@@ -37,6 +462,13 @@
 H	3.61574	2.85714	6.72285
 H	3.61574	2.85714	8.57143
+H	3.61574	2.85714	9.58
 H	3.61574	5.71429	0
 H	3.61574	5.71429	1.00857
+H	3.61574	5.71429	11.4286
+H	3.61574	5.71429	12.4371
+H	3.61574	5.71429	14.2857
+H	3.61574	5.71429	15.2943
+H	3.61574	5.71429	17.1429
+H	3.61574	5.71429	18.1514
 H	3.61574	5.71429	2.85714
 H	3.61574	5.71429	3.86571
@@ -44,11 +476,28 @@
 H	3.61574	5.71429	6.72285
 H	3.61574	5.71429	8.57143
+H	3.61574	5.71429	9.58
+H	3.61574	8.57143	0
 H	3.61574	8.57143	1.00857
+H	3.61574	8.57143	11.4286
+H	3.61574	8.57143	12.4371
+H	3.61574	8.57143	14.2857
+H	3.61574	8.57143	15.2943
+H	3.61574	8.57143	17.1429
+H	3.61574	8.57143	18.1514
 H	3.61574	8.57143	2.85714
 H	3.61574	8.57143	3.86571
 H	3.61574	8.57143	5.71429
+H	3.61574	8.57143	6.72285
+H	3.61574	8.57143	8.57143
+H	3.61574	8.57143	9.58
 H	6.39363	3.90454	3.53589
 H	6.47289	0	0
 H	6.47289	0	1.00857
+H	6.47289	0	11.4286
+H	6.47289	0	12.4371
+H	6.47289	0	14.2857
+H	6.47289	0	15.2943
+H	6.47289	0	17.1429
+H	6.47289	0	18.1514
 H	6.47289	0	2.85714
 H	6.47289	0	3.86571
@@ -57,5 +506,53 @@
 H	6.47289	0	8.57143
 H	6.47289	0	9.58
+H	6.47289	11.4286	0
+H	6.47289	11.4286	1.00857
+H	6.47289	11.4286	11.4286
+H	6.47289	11.4286	12.4371
+H	6.47289	11.4286	14.2857
+H	6.47289	11.4286	15.2943
+H	6.47289	11.4286	17.1429
+H	6.47289	11.4286	18.1514
+H	6.47289	11.4286	2.85714
+H	6.47289	11.4286	3.86571
+H	6.47289	11.4286	5.71429
+H	6.47289	11.4286	6.72285
+H	6.47289	11.4286	8.57143
+H	6.47289	11.4286	9.58
+H	6.47289	14.2857	0
+H	6.47289	14.2857	1.00857
+H	6.47289	14.2857	11.4286
+H	6.47289	14.2857	12.4371
+H	6.47289	14.2857	14.2857
+H	6.47289	14.2857	15.2943
+H	6.47289	14.2857	17.1429
+H	6.47289	14.2857	18.1514
+H	6.47289	14.2857	2.85714
+H	6.47289	14.2857	3.86571
+H	6.47289	14.2857	5.71429
+H	6.47289	14.2857	6.72285
+H	6.47289	14.2857	8.57143
+H	6.47289	14.2857	9.58
+H	6.47289	17.1429	0
+H	6.47289	17.1429	1.00857
+H	6.47289	17.1429	11.4286
+H	6.47289	17.1429	12.4371
+H	6.47289	17.1429	14.2857
+H	6.47289	17.1429	15.2943
+H	6.47289	17.1429	17.1429
+H	6.47289	17.1429	18.1514
+H	6.47289	17.1429	2.85714
+H	6.47289	17.1429	3.86571
+H	6.47289	17.1429	5.71429
+H	6.47289	17.1429	6.72285
+H	6.47289	17.1429	8.57143
+H	6.47289	17.1429	9.58
 H	6.47289	2.85714	0
+H	6.47289	2.85714	11.4286
+H	6.47289	2.85714	12.4371
+H	6.47289	2.85714	14.2857
+H	6.47289	2.85714	15.2943
+H	6.47289	2.85714	17.1429
+H	6.47289	2.85714	18.1514
 H	6.47289	2.85714	6.72285
 H	6.47289	2.85714	8.57143
@@ -63,4 +560,10 @@
 H	6.47289	5.71429	0
 H	6.47289	5.71429	1.00857
+H	6.47289	5.71429	11.4286
+H	6.47289	5.71429	12.4371
+H	6.47289	5.71429	14.2857
+H	6.47289	5.71429	15.2943
+H	6.47289	5.71429	17.1429
+H	6.47289	5.71429	18.1514
 H	6.47289	5.71429	5.71429
 H	6.47289	5.71429	6.72285
@@ -69,8 +572,16 @@
 H	6.47289	8.57143	0
 H	6.47289	8.57143	1.00857
+H	6.47289	8.57143	11.4286
+H	6.47289	8.57143	12.4371
+H	6.47289	8.57143	14.2857
+H	6.47289	8.57143	15.2943
+H	6.47289	8.57143	17.1429
+H	6.47289	8.57143	18.1514
 H	6.47289	8.57143	2.85714
 H	6.47289	8.57143	3.86571
 H	6.47289	8.57143	5.71429
 H	6.47289	8.57143	6.72285
+H	6.47289	8.57143	8.57143
+H	6.47289	8.57143	9.58
 H	7.28359	2.64589	2.64589
 H	7.28359	2.64589	4.42589
@@ -79,4 +590,10 @@
 H	9.33003	0	0
 H	9.33003	0	1.00857
+H	9.33003	0	11.4286
+H	9.33003	0	12.4371
+H	9.33003	0	14.2857
+H	9.33003	0	15.2943
+H	9.33003	0	17.1429
+H	9.33003	0	18.1514
 H	9.33003	0	2.85714
 H	9.33003	0	3.86571
@@ -84,9 +601,64 @@
 H	9.33003	0	6.72285
 H	9.33003	0	8.57143
+H	9.33003	0	9.58
+H	9.33003	11.4286	0
+H	9.33003	11.4286	1.00857
+H	9.33003	11.4286	11.4286
+H	9.33003	11.4286	12.4371
+H	9.33003	11.4286	14.2857
+H	9.33003	11.4286	15.2943
+H	9.33003	11.4286	17.1429
+H	9.33003	11.4286	18.1514
+H	9.33003	11.4286	2.85714
+H	9.33003	11.4286	3.86571
+H	9.33003	11.4286	5.71429
+H	9.33003	11.4286	6.72285
+H	9.33003	11.4286	8.57143
+H	9.33003	11.4286	9.58
+H	9.33003	14.2857	0
+H	9.33003	14.2857	1.00857
+H	9.33003	14.2857	11.4286
+H	9.33003	14.2857	12.4371
+H	9.33003	14.2857	14.2857
+H	9.33003	14.2857	15.2943
+H	9.33003	14.2857	17.1429
+H	9.33003	14.2857	18.1514
+H	9.33003	14.2857	2.85714
+H	9.33003	14.2857	3.86571
+H	9.33003	14.2857	5.71429
+H	9.33003	14.2857	6.72285
+H	9.33003	14.2857	8.57143
+H	9.33003	14.2857	9.58
+H	9.33003	17.1429	0
+H	9.33003	17.1429	1.00857
+H	9.33003	17.1429	11.4286
+H	9.33003	17.1429	12.4371
+H	9.33003	17.1429	14.2857
+H	9.33003	17.1429	15.2943
+H	9.33003	17.1429	17.1429
+H	9.33003	17.1429	18.1514
+H	9.33003	17.1429	2.85714
+H	9.33003	17.1429	3.86571
+H	9.33003	17.1429	5.71429
+H	9.33003	17.1429	6.72285
+H	9.33003	17.1429	8.57143
+H	9.33003	17.1429	9.58
 H	9.33003	2.85714	0
+H	9.33003	2.85714	11.4286
+H	9.33003	2.85714	12.4371
+H	9.33003	2.85714	14.2857
+H	9.33003	2.85714	15.2943
+H	9.33003	2.85714	17.1429
+H	9.33003	2.85714	18.1514
 H	9.33003	2.85714	6.72285
 H	9.33003	2.85714	8.57143
 H	9.33003	2.85714	9.58
 H	9.33003	5.71429	0
+H	9.33003	5.71429	11.4286
+H	9.33003	5.71429	12.4371
+H	9.33003	5.71429	14.2857
+H	9.33003	5.71429	15.2943
+H	9.33003	5.71429	17.1429
+H	9.33003	5.71429	18.1514
 H	9.33003	5.71429	6.72285
 H	9.33003	5.71429	8.57143
@@ -94,52 +666,351 @@
 H	9.33003	8.57143	0
 H	9.33003	8.57143	1.00857
+H	9.33003	8.57143	11.4286
+H	9.33003	8.57143	12.4371
+H	9.33003	8.57143	14.2857
+H	9.33003	8.57143	15.2943
+H	9.33003	8.57143	17.1429
+H	9.33003	8.57143	18.1514
 H	9.33003	8.57143	2.85714
 H	9.33003	8.57143	3.86571
 H	9.33003	8.57143	5.71429
 H	9.33003	8.57143	6.72285
+H	9.33003	8.57143	8.57143
+H	9.33003	8.57143	9.58
 H	9.78209	2.64589	2.64589
 H	9.78209	2.64589	4.42589
+O	0	0	0.504284
+O	0	0	11.9329
+O	0	0	14.79
+O	0	0	17.6471
+O	0	0	3.36143
+O	0	0	6.21857
+O	0	0	9.07571
+O	0	11.4286	0.504284
+O	0	11.4286	11.9329
+O	0	11.4286	14.79
+O	0	11.4286	17.6471
+O	0	11.4286	3.36143
+O	0	11.4286	6.21857
+O	0	11.4286	9.07571
+O	0	14.2857	0.504284
+O	0	14.2857	11.9329
+O	0	14.2857	14.79
+O	0	14.2857	17.6471
+O	0	14.2857	3.36143
+O	0	14.2857	6.21857
+O	0	14.2857	9.07571
+O	0	17.1429	0.504284
+O	0	17.1429	11.9329
+O	0	17.1429	14.79
+O	0	17.1429	17.6471
+O	0	17.1429	3.36143
+O	0	17.1429	6.21857
+O	0	17.1429	9.07571
+O	0	2.85714	0.504284
+O	0	2.85714	11.9329
+O	0	2.85714	14.79
+O	0	2.85714	17.6471
+O	0	2.85714	3.36143
+O	0	2.85714	6.21857
+O	0	2.85714	9.07571
+O	0	5.71429	0.504284
+O	0	5.71429	11.9329
+O	0	5.71429	14.79
+O	0	5.71429	17.6471
+O	0	5.71429	3.36143
+O	0	5.71429	6.21857
+O	0	5.71429	9.07571
+O	0	8.57143	0.504284
+O	0	8.57143	11.9329
+O	0	8.57143	14.79
+O	0	8.57143	17.6471
+O	0	8.57143	3.36143
+O	0	8.57143	6.21857
+O	0	8.57143	9.07571
 O	11.4286	0	0.504284
+O	11.4286	0	11.9329
+O	11.4286	0	14.79
+O	11.4286	0	17.6471
 O	11.4286	0	3.36143
 O	11.4286	0	6.21857
+O	11.4286	0	9.07571
+O	11.4286	11.4286	0.504284
+O	11.4286	11.4286	11.9329
+O	11.4286	11.4286	14.79
+O	11.4286	11.4286	17.6471
+O	11.4286	11.4286	3.36143
+O	11.4286	11.4286	6.21857
+O	11.4286	11.4286	9.07571
+O	11.4286	14.2857	0.504284
+O	11.4286	14.2857	11.9329
+O	11.4286	14.2857	14.79
+O	11.4286	14.2857	17.6471
+O	11.4286	14.2857	3.36143
+O	11.4286	14.2857	6.21857
+O	11.4286	14.2857	9.07571
+O	11.4286	17.1429	0.504284
+O	11.4286	17.1429	11.9329
+O	11.4286	17.1429	14.79
+O	11.4286	17.1429	17.6471
+O	11.4286	17.1429	3.36143
+O	11.4286	17.1429	6.21857
+O	11.4286	17.1429	9.07571
 O	11.4286	2.85714	0.504284
+O	11.4286	2.85714	11.9329
+O	11.4286	2.85714	14.79
+O	11.4286	2.85714	17.6471
 O	11.4286	2.85714	6.21857
 O	11.4286	2.85714	9.07571
 O	11.4286	5.71429	0.504284
+O	11.4286	5.71429	11.9329
+O	11.4286	5.71429	14.79
+O	11.4286	5.71429	17.6471
 O	11.4286	5.71429	6.21857
+O	11.4286	5.71429	9.07571
+O	11.4286	8.57143	0.504284
+O	11.4286	8.57143	11.9329
+O	11.4286	8.57143	14.79
+O	11.4286	8.57143	17.6471
 O	11.4286	8.57143	3.36143
+O	11.4286	8.57143	6.21857
+O	11.4286	8.57143	9.07571
+O	14.2857	0	0.504284
+O	14.2857	0	11.9329
+O	14.2857	0	14.79
+O	14.2857	0	17.6471
+O	14.2857	0	3.36143
+O	14.2857	0	6.21857
+O	14.2857	0	9.07571
+O	14.2857	11.4286	0.504284
+O	14.2857	11.4286	11.9329
+O	14.2857	11.4286	14.79
+O	14.2857	11.4286	17.6471
+O	14.2857	11.4286	3.36143
+O	14.2857	11.4286	6.21857
+O	14.2857	11.4286	9.07571
+O	14.2857	14.2857	0.504284
+O	14.2857	14.2857	11.9329
+O	14.2857	14.2857	14.79
+O	14.2857	14.2857	17.6471
+O	14.2857	14.2857	3.36143
+O	14.2857	14.2857	6.21857
+O	14.2857	14.2857	9.07571
+O	14.2857	17.1429	0.504284
+O	14.2857	17.1429	11.9329
+O	14.2857	17.1429	14.79
+O	14.2857	17.1429	17.6471
+O	14.2857	17.1429	3.36143
+O	14.2857	17.1429	6.21857
+O	14.2857	17.1429	9.07571
+O	14.2857	2.85714	0.504284
+O	14.2857	2.85714	11.9329
+O	14.2857	2.85714	14.79
+O	14.2857	2.85714	17.6471
+O	14.2857	2.85714	3.36143
+O	14.2857	2.85714	6.21857
+O	14.2857	2.85714	9.07571
+O	14.2857	5.71429	0.504284
+O	14.2857	5.71429	11.9329
+O	14.2857	5.71429	14.79
+O	14.2857	5.71429	17.6471
+O	14.2857	5.71429	3.36143
+O	14.2857	5.71429	6.21857
+O	14.2857	5.71429	9.07571
+O	14.2857	8.57143	0.504284
+O	14.2857	8.57143	11.9329
+O	14.2857	8.57143	14.79
+O	14.2857	8.57143	17.6471
+O	14.2857	8.57143	3.36143
+O	14.2857	8.57143	6.21857
+O	14.2857	8.57143	9.07571
+O	17.1429	0	0.504284
+O	17.1429	0	11.9329
+O	17.1429	0	14.79
+O	17.1429	0	17.6471
+O	17.1429	0	3.36143
+O	17.1429	0	6.21857
+O	17.1429	0	9.07571
+O	17.1429	11.4286	0.504284
+O	17.1429	11.4286	11.9329
+O	17.1429	11.4286	14.79
+O	17.1429	11.4286	17.6471
+O	17.1429	11.4286	3.36143
+O	17.1429	11.4286	6.21857
+O	17.1429	11.4286	9.07571
+O	17.1429	14.2857	0.504284
+O	17.1429	14.2857	11.9329
+O	17.1429	14.2857	14.79
+O	17.1429	14.2857	17.6471
+O	17.1429	14.2857	3.36143
+O	17.1429	14.2857	6.21857
+O	17.1429	14.2857	9.07571
+O	17.1429	17.1429	0.504284
+O	17.1429	17.1429	11.9329
+O	17.1429	17.1429	14.79
+O	17.1429	17.1429	17.6471
+O	17.1429	17.1429	3.36143
+O	17.1429	17.1429	6.21857
+O	17.1429	17.1429	9.07571
+O	17.1429	2.85714	0.504284
+O	17.1429	2.85714	11.9329
+O	17.1429	2.85714	14.79
+O	17.1429	2.85714	17.6471
+O	17.1429	2.85714	3.36143
+O	17.1429	2.85714	6.21857
+O	17.1429	2.85714	9.07571
+O	17.1429	5.71429	0.504284
+O	17.1429	5.71429	11.9329
+O	17.1429	5.71429	14.79
+O	17.1429	5.71429	17.6471
+O	17.1429	5.71429	3.36143
+O	17.1429	5.71429	6.21857
+O	17.1429	5.71429	9.07571
+O	17.1429	8.57143	0.504284
+O	17.1429	8.57143	11.9329
+O	17.1429	8.57143	14.79
+O	17.1429	8.57143	17.6471
+O	17.1429	8.57143	3.36143
+O	17.1429	8.57143	6.21857
+O	17.1429	8.57143	9.07571
 O	2.85714	0	0.504284
+O	2.85714	0	11.9329
+O	2.85714	0	14.79
+O	2.85714	0	17.6471
 O	2.85714	0	3.36143
 O	2.85714	0	6.21857
+O	2.85714	0	9.07571
+O	2.85714	11.4286	0.504284
+O	2.85714	11.4286	11.9329
+O	2.85714	11.4286	14.79
+O	2.85714	11.4286	17.6471
+O	2.85714	11.4286	3.36143
+O	2.85714	11.4286	6.21857
+O	2.85714	11.4286	9.07571
+O	2.85714	14.2857	0.504284
+O	2.85714	14.2857	11.9329
+O	2.85714	14.2857	14.79
+O	2.85714	14.2857	17.6471
+O	2.85714	14.2857	3.36143
+O	2.85714	14.2857	6.21857
+O	2.85714	14.2857	9.07571
+O	2.85714	17.1429	0.504284
+O	2.85714	17.1429	11.9329
+O	2.85714	17.1429	14.79
+O	2.85714	17.1429	17.6471
+O	2.85714	17.1429	3.36143
+O	2.85714	17.1429	6.21857
+O	2.85714	17.1429	9.07571
 O	2.85714	2.85714	0.504284
+O	2.85714	2.85714	11.9329
+O	2.85714	2.85714	14.79
+O	2.85714	2.85714	17.6471
 O	2.85714	2.85714	3.36143
 O	2.85714	2.85714	6.21857
+O	2.85714	2.85714	9.07571
 O	2.85714	5.71429	0.504284
+O	2.85714	5.71429	11.9329
+O	2.85714	5.71429	14.79
+O	2.85714	5.71429	17.6471
 O	2.85714	5.71429	3.36143
 O	2.85714	5.71429	6.21857
+O	2.85714	5.71429	9.07571
+O	2.85714	8.57143	0.504284
+O	2.85714	8.57143	11.9329
+O	2.85714	8.57143	14.79
+O	2.85714	8.57143	17.6471
 O	2.85714	8.57143	3.36143
+O	2.85714	8.57143	6.21857
+O	2.85714	8.57143	9.07571
 O	5.71429	0	0.504284
+O	5.71429	0	11.9329
+O	5.71429	0	14.79
+O	5.71429	0	17.6471
 O	5.71429	0	3.36143
 O	5.71429	0	6.21857
 O	5.71429	0	9.07571
+O	5.71429	11.4286	0.504284
+O	5.71429	11.4286	11.9329
+O	5.71429	11.4286	14.79
+O	5.71429	11.4286	17.6471
+O	5.71429	11.4286	3.36143
+O	5.71429	11.4286	6.21857
+O	5.71429	11.4286	9.07571
+O	5.71429	14.2857	0.504284
+O	5.71429	14.2857	11.9329
+O	5.71429	14.2857	14.79
+O	5.71429	14.2857	17.6471
+O	5.71429	14.2857	3.36143
+O	5.71429	14.2857	6.21857
+O	5.71429	14.2857	9.07571
+O	5.71429	17.1429	0.504284
+O	5.71429	17.1429	11.9329
+O	5.71429	17.1429	14.79
+O	5.71429	17.1429	17.6471
+O	5.71429	17.1429	3.36143
+O	5.71429	17.1429	6.21857
+O	5.71429	17.1429	9.07571
 O	5.71429	2.85714	0.504284
+O	5.71429	2.85714	11.9329
+O	5.71429	2.85714	14.79
+O	5.71429	2.85714	17.6471
 O	5.71429	2.85714	6.21857
 O	5.71429	2.85714	9.07571
 O	5.71429	5.71429	0.504284
+O	5.71429	5.71429	11.9329
+O	5.71429	5.71429	14.79
+O	5.71429	5.71429	17.6471
 O	5.71429	5.71429	6.21857
 O	5.71429	5.71429	9.07571
 O	5.71429	8.57143	0.504284
+O	5.71429	8.57143	11.9329
+O	5.71429	8.57143	14.79
+O	5.71429	8.57143	17.6471
 O	5.71429	8.57143	3.36143
 O	5.71429	8.57143	6.21857
+O	5.71429	8.57143	9.07571
 O	8.57143	0	0.504284
+O	8.57143	0	11.9329
+O	8.57143	0	14.79
+O	8.57143	0	17.6471
 O	8.57143	0	3.36143
 O	8.57143	0	6.21857
 O	8.57143	0	9.07571
+O	8.57143	11.4286	0.504284
+O	8.57143	11.4286	11.9329
+O	8.57143	11.4286	14.79
+O	8.57143	11.4286	17.6471
+O	8.57143	11.4286	3.36143
+O	8.57143	11.4286	6.21857
+O	8.57143	11.4286	9.07571
+O	8.57143	14.2857	0.504284
+O	8.57143	14.2857	11.9329
+O	8.57143	14.2857	14.79
+O	8.57143	14.2857	17.6471
+O	8.57143	14.2857	3.36143
+O	8.57143	14.2857	6.21857
+O	8.57143	14.2857	9.07571
+O	8.57143	17.1429	0.504284
+O	8.57143	17.1429	11.9329
+O	8.57143	17.1429	14.79
+O	8.57143	17.1429	17.6471
+O	8.57143	17.1429	3.36143
+O	8.57143	17.1429	6.21857
+O	8.57143	17.1429	9.07571
 O	8.57143	2.85714	0.504284
+O	8.57143	2.85714	11.9329
+O	8.57143	2.85714	14.79
+O	8.57143	2.85714	17.6471
 O	8.57143	2.85714	9.07571
 O	8.57143	5.71429	0.504284
+O	8.57143	5.71429	11.9329
+O	8.57143	5.71429	14.79
+O	8.57143	5.71429	17.6471
 O	8.57143	5.71429	9.07571
 O	8.57143	8.57143	0.504284
+O	8.57143	8.57143	11.9329
+O	8.57143	8.57143	14.79
+O	8.57143	8.57143	17.6471
 O	8.57143	8.57143	3.36143
 O	8.57143	8.57143	6.21857
-144
+O	8.57143	8.57143	9.07571
Index: sts/regression/Simple_configuration/8/pre/test.conf
===================================================================
--- tests/regression/Simple_configuration/8/pre/test.conf	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ 	(revision )
@@ -1,1089 +1,0 @@
-# ParallelCarParinello - main configuration file - created with molecuilder
-
-mainname	pcp	# programm name (for runtime files)
-defaultpath	not specified	# where to put files during runtime
-pseudopotpath	not specified	# where to find pseudopotentials
-
-ProcPEGamma	8	# for parallel computing: share constants
-ProcPEPsi	1	# for parallel computing: share wave functions
-DoOutVis	0	# Output data for OpenDX
-DoOutMes	1	# Output data for measurements
-DoOutOrbitals	0	# Output all Orbitals
-DoOutCurr	0	# Ouput current density for OpenDx
-DoOutNICS	0	# Output Nucleus independent current shieldings
-DoPerturbation	0	# Do perturbation calculate and determine susceptibility and shielding
-DoFullCurrent	0	# Do full perturbation
-DoConstrainedMD	0	# Do perform a constrained (>0, relating to current MD step) instead of unconstrained (0) MD
-Thermostat	Berendsen	2.5	# Which Thermostat and its parameters to use in MD case.
-CommonWannier	0	# Put virtual centers at indivual orbits, all common, merged by variance, to grid point, to cell center
-SawtoothStart	0.01	# Absolute value for smooth transition at cell border 
-VectorPlane	0	# Cut plane axis (x, y or z: 0,1,2) for two-dim current vector plot
-VectorCut	0	# Cut plane axis value
-AddGramSch	1	# Additional GramSchmidtOrtogonalization to be safe
-Seed		1	# initial value for random seed for Psi coefficients
-
-MaxOuterStep	0	# number of MolecularDynamics/Structure optimization steps
-Deltat	0.01	# time per MD step
-OutVisStep	10	# Output visual data every ...th step
-OutSrcStep	5	# Output "restart" data every ..th step
-TargetTemp	0.000950045	# Target temperature
-MaxPsiStep	3	# number of Minimisation steps per state (0 - default)
-EpsWannier	1e-07	# tolerance value for spread minimisation of orbitals
-
-# Values specifying when to stop
-MaxMinStep	100	# Maximum number of steps
-RelEpsTotalE	1e-07	# relative change in total energy
-RelEpsKineticE	1e-05	# relative change in kinetic energy
-MaxMinStopStep	0	# check every ..th steps
-MaxMinGapStopStep	1	# check every ..th steps
-
-# Values specifying when to stop for INIT, otherwise same as above
-MaxInitMinStep	100	# Maximum number of steps
-InitRelEpsTotalE	1e-05	# relative change in total energy
-InitRelEpsKineticE	0.0001	# relative change in kinetic energy
-InitMaxMinStopStep	0	# check every ..th steps
-InitMaxMinGapStopStep	1	# check every ..th steps
-
-BoxLength			# (Length of a unit cell)
-20	
-0	20	
-0	0	20	
-
-ECut		128	# energy cutoff for discretization in Hartrees
-MaxLevel	5	# number of different levels in the code, >=2
-Level0Factor	2	# factor by which node number increases from S to 0 level
-RiemannTensor	0	# (Use metric)
-PsiType		0	# 0 - doubly occupied, 1 - SpinUp,SpinDown
-MaxPsiDouble	0	# here: specifying both maximum number of SpinUp- and -Down-states
-PsiMaxNoUp	0	# here: specifying maximum number of SpinUp-states
-PsiMaxNoDown	0	# here: specifying maximum number of SpinDown-states
-AddPsis		0	# Additional unoccupied Psis for bandgap determination
-
-RCut		20	# R-cut for the ewald summation
-StructOpt	0	# Do structure optimization beforehand
-IsAngstroem	1	# 0 - Bohr, 1 - Angstroem
-RelativeCoord	0	# whether ion coordinates are relative (1) or absolute (0)
-MaxTypes	3	# maximum number of different ion types
-
-# Ion type data (PP = PseudoPotential, Z = atomic number)
-#Ion_TypeNr.	Amount	Z	RGauss	L_Max(PP)L_Loc(PP)IonMass	# chemical name, symbol
-Ion_Type1	678	1	1.0	3	3	1.00800000000	Hydrogen	H
-Ion_Type2	3	6	1.0	3	3	12.01100000000	Carbon	C
-Ion_Type3	335	8	1.0	3	3	15.99900000000	Oxygen	O
-#Ion_TypeNr._Nr.R[0]    R[1]    R[2]    MoveType (0 MoveIon, 1 FixedIon)
-Ion_Type2_1	9.782085945	3.275186040	3.535886037	0 # molecule nr 0
-Ion_Type2_2	8.532785963	4.158586027	3.535886037	0 # molecule nr 1
-Ion_Type2_3	7.283585982	3.275186040	3.535886037	0 # molecule nr 2
-Ion_Type1_1	9.782085945	2.645886050	2.645886050	0 # molecule nr 3
-Ion_Type1_2	9.782085945	2.645886050	4.425886024	0 # molecule nr 4
-Ion_Type1_3	10.672039608	3.904536878	3.535886037	0 # molecule nr 5
-Ion_Type1_4	8.532785963	4.787886018	2.645886050	0 # molecule nr 6
-Ion_Type1_5	8.532785963	4.787886018	4.425886024	0 # molecule nr 7
-Ion_Type1_6	6.393632318	3.904536877	3.535886037	0 # molecule nr 8
-Ion_Type1_7	7.283585982	2.645886050	2.645886050	0 # molecule nr 9
-Ion_Type1_8	7.283585982	2.645886050	4.425886024	0 # molecule nr 10
-Ion_Type3_1	0.000000000	0.000000000	0.504284000	0 # molecule nr 11
-Ion_Type1_9	0.758602000	0.000000000	1.008568000	0 # molecule nr 12
-Ion_Type1_10	0.758602000	0.000000000	0.000000000	0 # molecule nr 13
-Ion_Type3_2	0.000000000	0.000000000	3.361426857	0 # molecule nr 14
-Ion_Type1_11	0.758602000	0.000000000	3.865710857	0 # molecule nr 15
-Ion_Type1_12	0.758602000	0.000000000	2.857142857	0 # molecule nr 16
-Ion_Type3_3	0.000000000	0.000000000	6.218569714	0 # molecule nr 17
-Ion_Type1_13	0.758602000	0.000000000	6.722853714	0 # molecule nr 18
-Ion_Type1_14	0.758602000	0.000000000	5.714285714	0 # molecule nr 19
-Ion_Type3_4	0.000000000	0.000000000	9.075712571	0 # molecule nr 20
-Ion_Type1_15	0.758602000	0.000000000	9.579996571	0 # molecule nr 21
-Ion_Type1_16	0.758602000	0.000000000	8.571428571	0 # molecule nr 22
-Ion_Type3_5	0.000000000	0.000000000	11.932855429	0 # molecule nr 23
-Ion_Type1_17	0.758602000	0.000000000	12.437139429	0 # molecule nr 24
-Ion_Type1_18	0.758602000	0.000000000	11.428571429	0 # molecule nr 25
-Ion_Type3_6	0.000000000	0.000000000	14.789998286	0 # molecule nr 26
-Ion_Type1_19	0.758602000	0.000000000	15.294282286	0 # molecule nr 27
-Ion_Type1_20	0.758602000	0.000000000	14.285714286	0 # molecule nr 28
-Ion_Type3_7	0.000000000	0.000000000	17.647141143	0 # molecule nr 29
-Ion_Type1_21	0.758602000	0.000000000	18.151425143	0 # molecule nr 30
-Ion_Type1_22	0.758602000	0.000000000	17.142857143	0 # molecule nr 31
-Ion_Type3_8	0.000000000	2.857142857	0.504284000	0 # molecule nr 32
-Ion_Type1_23	0.758602000	2.857142857	1.008568000	0 # molecule nr 33
-Ion_Type1_24	0.758602000	2.857142857	0.000000000	0 # molecule nr 34
-Ion_Type3_9	0.000000000	2.857142857	3.361426857	0 # molecule nr 35
-Ion_Type1_25	0.758602000	2.857142857	3.865710857	0 # molecule nr 36
-Ion_Type1_26	0.758602000	2.857142857	2.857142857	0 # molecule nr 37
-Ion_Type3_10	0.000000000	2.857142857	6.218569714	0 # molecule nr 38
-Ion_Type1_27	0.758602000	2.857142857	6.722853714	0 # molecule nr 39
-Ion_Type1_28	0.758602000	2.857142857	5.714285714	0 # molecule nr 40
-Ion_Type3_11	0.000000000	2.857142857	9.075712571	0 # molecule nr 41
-Ion_Type1_29	0.758602000	2.857142857	9.579996571	0 # molecule nr 42
-Ion_Type1_30	0.758602000	2.857142857	8.571428571	0 # molecule nr 43
-Ion_Type3_12	0.000000000	2.857142857	11.932855429	0 # molecule nr 44
-Ion_Type1_31	0.758602000	2.857142857	12.437139429	0 # molecule nr 45
-Ion_Type1_32	0.758602000	2.857142857	11.428571429	0 # molecule nr 46
-Ion_Type3_13	0.000000000	2.857142857	14.789998286	0 # molecule nr 47
-Ion_Type1_33	0.758602000	2.857142857	15.294282286	0 # molecule nr 48
-Ion_Type1_34	0.758602000	2.857142857	14.285714286	0 # molecule nr 49
-Ion_Type3_14	0.000000000	2.857142857	17.647141143	0 # molecule nr 50
-Ion_Type1_35	0.758602000	2.857142857	18.151425143	0 # molecule nr 51
-Ion_Type1_36	0.758602000	2.857142857	17.142857143	0 # molecule nr 52
-Ion_Type3_15	0.000000000	5.714285714	0.504284000	0 # molecule nr 53
-Ion_Type1_37	0.758602000	5.714285714	1.008568000	0 # molecule nr 54
-Ion_Type1_38	0.758602000	5.714285714	0.000000000	0 # molecule nr 55
-Ion_Type3_16	0.000000000	5.714285714	3.361426857	0 # molecule nr 56
-Ion_Type1_39	0.758602000	5.714285714	3.865710857	0 # molecule nr 57
-Ion_Type1_40	0.758602000	5.714285714	2.857142857	0 # molecule nr 58
-Ion_Type3_17	0.000000000	5.714285714	6.218569714	0 # molecule nr 59
-Ion_Type1_41	0.758602000	5.714285714	6.722853714	0 # molecule nr 60
-Ion_Type1_42	0.758602000	5.714285714	5.714285714	0 # molecule nr 61
-Ion_Type3_18	0.000000000	5.714285714	9.075712571	0 # molecule nr 62
-Ion_Type1_43	0.758602000	5.714285714	9.579996571	0 # molecule nr 63
-Ion_Type1_44	0.758602000	5.714285714	8.571428571	0 # molecule nr 64
-Ion_Type3_19	0.000000000	5.714285714	11.932855429	0 # molecule nr 65
-Ion_Type1_45	0.758602000	5.714285714	12.437139429	0 # molecule nr 66
-Ion_Type1_46	0.758602000	5.714285714	11.428571429	0 # molecule nr 67
-Ion_Type3_20	0.000000000	5.714285714	14.789998286	0 # molecule nr 68
-Ion_Type1_47	0.758602000	5.714285714	15.294282286	0 # molecule nr 69
-Ion_Type1_48	0.758602000	5.714285714	14.285714286	0 # molecule nr 70
-Ion_Type3_21	0.000000000	5.714285714	17.647141143	0 # molecule nr 71
-Ion_Type1_49	0.758602000	5.714285714	18.151425143	0 # molecule nr 72
-Ion_Type1_50	0.758602000	5.714285714	17.142857143	0 # molecule nr 73
-Ion_Type3_22	0.000000000	8.571428571	0.504284000	0 # molecule nr 74
-Ion_Type1_51	0.758602000	8.571428571	1.008568000	0 # molecule nr 75
-Ion_Type1_52	0.758602000	8.571428571	0.000000000	0 # molecule nr 76
-Ion_Type3_23	0.000000000	8.571428571	3.361426857	0 # molecule nr 77
-Ion_Type1_53	0.758602000	8.571428571	3.865710857	0 # molecule nr 78
-Ion_Type1_54	0.758602000	8.571428571	2.857142857	0 # molecule nr 79
-Ion_Type3_24	0.000000000	8.571428571	6.218569714	0 # molecule nr 80
-Ion_Type1_55	0.758602000	8.571428571	6.722853714	0 # molecule nr 81
-Ion_Type1_56	0.758602000	8.571428571	5.714285714	0 # molecule nr 82
-Ion_Type3_25	0.000000000	8.571428571	9.075712571	0 # molecule nr 83
-Ion_Type1_57	0.758602000	8.571428571	9.579996571	0 # molecule nr 84
-Ion_Type1_58	0.758602000	8.571428571	8.571428571	0 # molecule nr 85
-Ion_Type3_26	0.000000000	8.571428571	11.932855429	0 # molecule nr 86
-Ion_Type1_59	0.758602000	8.571428571	12.437139429	0 # molecule nr 87
-Ion_Type1_60	0.758602000	8.571428571	11.428571429	0 # molecule nr 88
-Ion_Type3_27	0.000000000	8.571428571	14.789998286	0 # molecule nr 89
-Ion_Type1_61	0.758602000	8.571428571	15.294282286	0 # molecule nr 90
-Ion_Type1_62	0.758602000	8.571428571	14.285714286	0 # molecule nr 91
-Ion_Type3_28	0.000000000	8.571428571	17.647141143	0 # molecule nr 92
-Ion_Type1_63	0.758602000	8.571428571	18.151425143	0 # molecule nr 93
-Ion_Type1_64	0.758602000	8.571428571	17.142857143	0 # molecule nr 94
-Ion_Type3_29	0.000000000	11.428571429	0.504284000	0 # molecule nr 95
-Ion_Type1_65	0.758602000	11.428571429	1.008568000	0 # molecule nr 96
-Ion_Type1_66	0.758602000	11.428571429	0.000000000	0 # molecule nr 97
-Ion_Type3_30	0.000000000	11.428571429	3.361426857	0 # molecule nr 98
-Ion_Type1_67	0.758602000	11.428571429	3.865710857	0 # molecule nr 99
-Ion_Type1_68	0.758602000	11.428571429	2.857142857	0 # molecule nr 100
-Ion_Type3_31	0.000000000	11.428571429	6.218569714	0 # molecule nr 101
-Ion_Type1_69	0.758602000	11.428571429	6.722853714	0 # molecule nr 102
-Ion_Type1_70	0.758602000	11.428571429	5.714285714	0 # molecule nr 103
-Ion_Type3_32	0.000000000	11.428571429	9.075712571	0 # molecule nr 104
-Ion_Type1_71	0.758602000	11.428571429	9.579996571	0 # molecule nr 105
-Ion_Type1_72	0.758602000	11.428571429	8.571428571	0 # molecule nr 106
-Ion_Type3_33	0.000000000	11.428571429	11.932855429	0 # molecule nr 107
-Ion_Type1_73	0.758602000	11.428571429	12.437139429	0 # molecule nr 108
-Ion_Type1_74	0.758602000	11.428571429	11.428571429	0 # molecule nr 109
-Ion_Type3_34	0.000000000	11.428571429	14.789998286	0 # molecule nr 110
-Ion_Type1_75	0.758602000	11.428571429	15.294282286	0 # molecule nr 111
-Ion_Type1_76	0.758602000	11.428571429	14.285714286	0 # molecule nr 112
-Ion_Type3_35	0.000000000	11.428571429	17.647141143	0 # molecule nr 113
-Ion_Type1_77	0.758602000	11.428571429	18.151425143	0 # molecule nr 114
-Ion_Type1_78	0.758602000	11.428571429	17.142857143	0 # molecule nr 115
-Ion_Type3_36	0.000000000	14.285714286	0.504284000	0 # molecule nr 116
-Ion_Type1_79	0.758602000	14.285714286	1.008568000	0 # molecule nr 117
-Ion_Type1_80	0.758602000	14.285714286	0.000000000	0 # molecule nr 118
-Ion_Type3_37	0.000000000	14.285714286	3.361426857	0 # molecule nr 119
-Ion_Type1_81	0.758602000	14.285714286	3.865710857	0 # molecule nr 120
-Ion_Type1_82	0.758602000	14.285714286	2.857142857	0 # molecule nr 121
-Ion_Type3_38	0.000000000	14.285714286	6.218569714	0 # molecule nr 122
-Ion_Type1_83	0.758602000	14.285714286	6.722853714	0 # molecule nr 123
-Ion_Type1_84	0.758602000	14.285714286	5.714285714	0 # molecule nr 124
-Ion_Type3_39	0.000000000	14.285714286	9.075712571	0 # molecule nr 125
-Ion_Type1_85	0.758602000	14.285714286	9.579996571	0 # molecule nr 126
-Ion_Type1_86	0.758602000	14.285714286	8.571428571	0 # molecule nr 127
-Ion_Type3_40	0.000000000	14.285714286	11.932855429	0 # molecule nr 128
-Ion_Type1_87	0.758602000	14.285714286	12.437139429	0 # molecule nr 129
-Ion_Type1_88	0.758602000	14.285714286	11.428571429	0 # molecule nr 130
-Ion_Type3_41	0.000000000	14.285714286	14.789998286	0 # molecule nr 131
-Ion_Type1_89	0.758602000	14.285714286	15.294282286	0 # molecule nr 132
-Ion_Type1_90	0.758602000	14.285714286	14.285714286	0 # molecule nr 133
-Ion_Type3_42	0.000000000	14.285714286	17.647141143	0 # molecule nr 134
-Ion_Type1_91	0.758602000	14.285714286	18.151425143	0 # molecule nr 135
-Ion_Type1_92	0.758602000	14.285714286	17.142857143	0 # molecule nr 136
-Ion_Type3_43	0.000000000	17.142857143	0.504284000	0 # molecule nr 137
-Ion_Type1_93	0.758602000	17.142857143	1.008568000	0 # molecule nr 138
-Ion_Type1_94	0.758602000	17.142857143	0.000000000	0 # molecule nr 139
-Ion_Type3_44	0.000000000	17.142857143	3.361426857	0 # molecule nr 140
-Ion_Type1_95	0.758602000	17.142857143	3.865710857	0 # molecule nr 141
-Ion_Type1_96	0.758602000	17.142857143	2.857142857	0 # molecule nr 142
-Ion_Type3_45	0.000000000	17.142857143	6.218569714	0 # molecule nr 143
-Ion_Type1_97	0.758602000	17.142857143	6.722853714	0 # molecule nr 144
-Ion_Type1_98	0.758602000	17.142857143	5.714285714	0 # molecule nr 145
-Ion_Type3_46	0.000000000	17.142857143	9.075712571	0 # molecule nr 146
-Ion_Type1_99	0.758602000	17.142857143	9.579996571	0 # molecule nr 147
-Ion_Type1_100	0.758602000	17.142857143	8.571428571	0 # molecule nr 148
-Ion_Type3_47	0.000000000	17.142857143	11.932855429	0 # molecule nr 149
-Ion_Type1_101	0.758602000	17.142857143	12.437139429	0 # molecule nr 150
-Ion_Type1_102	0.758602000	17.142857143	11.428571429	0 # molecule nr 151
-Ion_Type3_48	0.000000000	17.142857143	14.789998286	0 # molecule nr 152
-Ion_Type1_103	0.758602000	17.142857143	15.294282286	0 # molecule nr 153
-Ion_Type1_104	0.758602000	17.142857143	14.285714286	0 # molecule nr 154
-Ion_Type3_49	0.000000000	17.142857143	17.647141143	0 # molecule nr 155
-Ion_Type1_105	0.758602000	17.142857143	18.151425143	0 # molecule nr 156
-Ion_Type1_106	0.758602000	17.142857143	17.142857143	0 # molecule nr 157
-Ion_Type3_50	2.857142857	0.000000000	0.504284000	0 # molecule nr 158
-Ion_Type1_107	3.615744857	0.000000000	1.008568000	0 # molecule nr 159
-Ion_Type1_108	3.615744857	0.000000000	0.000000000	0 # molecule nr 160
-Ion_Type3_51	2.857142857	0.000000000	3.361426857	0 # molecule nr 161
-Ion_Type1_109	3.615744857	0.000000000	3.865710857	0 # molecule nr 162
-Ion_Type1_110	3.615744857	0.000000000	2.857142857	0 # molecule nr 163
-Ion_Type3_52	2.857142857	0.000000000	6.218569714	0 # molecule nr 164
-Ion_Type1_111	3.615744857	0.000000000	6.722853714	0 # molecule nr 165
-Ion_Type1_112	3.615744857	0.000000000	5.714285714	0 # molecule nr 166
-Ion_Type3_53	2.857142857	0.000000000	9.075712571	0 # molecule nr 167
-Ion_Type1_113	3.615744857	0.000000000	9.579996571	0 # molecule nr 168
-Ion_Type1_114	3.615744857	0.000000000	8.571428571	0 # molecule nr 169
-Ion_Type3_54	2.857142857	0.000000000	11.932855429	0 # molecule nr 170
-Ion_Type1_115	3.615744857	0.000000000	12.437139429	0 # molecule nr 171
-Ion_Type1_116	3.615744857	0.000000000	11.428571429	0 # molecule nr 172
-Ion_Type3_55	2.857142857	0.000000000	14.789998286	0 # molecule nr 173
-Ion_Type1_117	3.615744857	0.000000000	15.294282286	0 # molecule nr 174
-Ion_Type1_118	3.615744857	0.000000000	14.285714286	0 # molecule nr 175
-Ion_Type3_56	2.857142857	0.000000000	17.647141143	0 # molecule nr 176
-Ion_Type1_119	3.615744857	0.000000000	18.151425143	0 # molecule nr 177
-Ion_Type1_120	3.615744857	0.000000000	17.142857143	0 # molecule nr 178
-Ion_Type3_57	2.857142857	2.857142857	0.504284000	0 # molecule nr 179
-Ion_Type1_121	3.615744857	2.857142857	1.008568000	0 # molecule nr 180
-Ion_Type1_122	3.615744857	2.857142857	0.000000000	0 # molecule nr 181
-Ion_Type3_58	2.857142857	2.857142857	3.361426857	0 # molecule nr 182
-Ion_Type1_123	3.615744857	2.857142857	3.865710857	0 # molecule nr 183
-Ion_Type1_124	3.615744857	2.857142857	2.857142857	0 # molecule nr 184
-Ion_Type3_59	2.857142857	2.857142857	6.218569714	0 # molecule nr 185
-Ion_Type1_125	3.615744857	2.857142857	6.722853714	0 # molecule nr 186
-Ion_Type1_126	3.615744857	2.857142857	5.714285714	0 # molecule nr 187
-Ion_Type3_60	2.857142857	2.857142857	9.075712571	0 # molecule nr 188
-Ion_Type1_127	3.615744857	2.857142857	9.579996571	0 # molecule nr 189
-Ion_Type1_128	3.615744857	2.857142857	8.571428571	0 # molecule nr 190
-Ion_Type3_61	2.857142857	2.857142857	11.932855429	0 # molecule nr 191
-Ion_Type1_129	3.615744857	2.857142857	12.437139429	0 # molecule nr 192
-Ion_Type1_130	3.615744857	2.857142857	11.428571429	0 # molecule nr 193
-Ion_Type3_62	2.857142857	2.857142857	14.789998286	0 # molecule nr 194
-Ion_Type1_131	3.615744857	2.857142857	15.294282286	0 # molecule nr 195
-Ion_Type1_132	3.615744857	2.857142857	14.285714286	0 # molecule nr 196
-Ion_Type3_63	2.857142857	2.857142857	17.647141143	0 # molecule nr 197
-Ion_Type1_133	3.615744857	2.857142857	18.151425143	0 # molecule nr 198
-Ion_Type1_134	3.615744857	2.857142857	17.142857143	0 # molecule nr 199
-Ion_Type3_64	2.857142857	5.714285714	0.504284000	0 # molecule nr 200
-Ion_Type1_135	3.615744857	5.714285714	1.008568000	0 # molecule nr 201
-Ion_Type1_136	3.615744857	5.714285714	0.000000000	0 # molecule nr 202
-Ion_Type3_65	2.857142857	5.714285714	3.361426857	0 # molecule nr 203
-Ion_Type1_137	3.615744857	5.714285714	3.865710857	0 # molecule nr 204
-Ion_Type1_138	3.615744857	5.714285714	2.857142857	0 # molecule nr 205
-Ion_Type3_66	2.857142857	5.714285714	6.218569714	0 # molecule nr 206
-Ion_Type1_139	3.615744857	5.714285714	6.722853714	0 # molecule nr 207
-Ion_Type1_140	3.615744857	5.714285714	5.714285714	0 # molecule nr 208
-Ion_Type3_67	2.857142857	5.714285714	9.075712571	0 # molecule nr 209
-Ion_Type1_141	3.615744857	5.714285714	9.579996571	0 # molecule nr 210
-Ion_Type1_142	3.615744857	5.714285714	8.571428571	0 # molecule nr 211
-Ion_Type3_68	2.857142857	5.714285714	11.932855429	0 # molecule nr 212
-Ion_Type1_143	3.615744857	5.714285714	12.437139429	0 # molecule nr 213
-Ion_Type1_144	3.615744857	5.714285714	11.428571429	0 # molecule nr 214
-Ion_Type3_69	2.857142857	5.714285714	14.789998286	0 # molecule nr 215
-Ion_Type1_145	3.615744857	5.714285714	15.294282286	0 # molecule nr 216
-Ion_Type1_146	3.615744857	5.714285714	14.285714286	0 # molecule nr 217
-Ion_Type3_70	2.857142857	5.714285714	17.647141143	0 # molecule nr 218
-Ion_Type1_147	3.615744857	5.714285714	18.151425143	0 # molecule nr 219
-Ion_Type1_148	3.615744857	5.714285714	17.142857143	0 # molecule nr 220
-Ion_Type3_71	2.857142857	8.571428571	0.504284000	0 # molecule nr 221
-Ion_Type1_149	3.615744857	8.571428571	1.008568000	0 # molecule nr 222
-Ion_Type1_150	3.615744857	8.571428571	0.000000000	0 # molecule nr 223
-Ion_Type3_72	2.857142857	8.571428571	3.361426857	0 # molecule nr 224
-Ion_Type1_151	3.615744857	8.571428571	3.865710857	0 # molecule nr 225
-Ion_Type1_152	3.615744857	8.571428571	2.857142857	0 # molecule nr 226
-Ion_Type3_73	2.857142857	8.571428571	6.218569714	0 # molecule nr 227
-Ion_Type1_153	3.615744857	8.571428571	6.722853714	0 # molecule nr 228
-Ion_Type1_154	3.615744857	8.571428571	5.714285714	0 # molecule nr 229
-Ion_Type3_74	2.857142857	8.571428571	9.075712571	0 # molecule nr 230
-Ion_Type1_155	3.615744857	8.571428571	9.579996571	0 # molecule nr 231
-Ion_Type1_156	3.615744857	8.571428571	8.571428571	0 # molecule nr 232
-Ion_Type3_75	2.857142857	8.571428571	11.932855429	0 # molecule nr 233
-Ion_Type1_157	3.615744857	8.571428571	12.437139429	0 # molecule nr 234
-Ion_Type1_158	3.615744857	8.571428571	11.428571429	0 # molecule nr 235
-Ion_Type3_76	2.857142857	8.571428571	14.789998286	0 # molecule nr 236
-Ion_Type1_159	3.615744857	8.571428571	15.294282286	0 # molecule nr 237
-Ion_Type1_160	3.615744857	8.571428571	14.285714286	0 # molecule nr 238
-Ion_Type3_77	2.857142857	8.571428571	17.647141143	0 # molecule nr 239
-Ion_Type1_161	3.615744857	8.571428571	18.151425143	0 # molecule nr 240
-Ion_Type1_162	3.615744857	8.571428571	17.142857143	0 # molecule nr 241
-Ion_Type3_78	2.857142857	11.428571429	0.504284000	0 # molecule nr 242
-Ion_Type1_163	3.615744857	11.428571429	1.008568000	0 # molecule nr 243
-Ion_Type1_164	3.615744857	11.428571429	0.000000000	0 # molecule nr 244
-Ion_Type3_79	2.857142857	11.428571429	3.361426857	0 # molecule nr 245
-Ion_Type1_165	3.615744857	11.428571429	3.865710857	0 # molecule nr 246
-Ion_Type1_166	3.615744857	11.428571429	2.857142857	0 # molecule nr 247
-Ion_Type3_80	2.857142857	11.428571429	6.218569714	0 # molecule nr 248
-Ion_Type1_167	3.615744857	11.428571429	6.722853714	0 # molecule nr 249
-Ion_Type1_168	3.615744857	11.428571429	5.714285714	0 # molecule nr 250
-Ion_Type3_81	2.857142857	11.428571429	9.075712571	0 # molecule nr 251
-Ion_Type1_169	3.615744857	11.428571429	9.579996571	0 # molecule nr 252
-Ion_Type1_170	3.615744857	11.428571429	8.571428571	0 # molecule nr 253
-Ion_Type3_82	2.857142857	11.428571429	11.932855429	0 # molecule nr 254
-Ion_Type1_171	3.615744857	11.428571429	12.437139429	0 # molecule nr 255
-Ion_Type1_172	3.615744857	11.428571429	11.428571429	0 # molecule nr 256
-Ion_Type3_83	2.857142857	11.428571429	14.789998286	0 # molecule nr 257
-Ion_Type1_173	3.615744857	11.428571429	15.294282286	0 # molecule nr 258
-Ion_Type1_174	3.615744857	11.428571429	14.285714286	0 # molecule nr 259
-Ion_Type3_84	2.857142857	11.428571429	17.647141143	0 # molecule nr 260
-Ion_Type1_175	3.615744857	11.428571429	18.151425143	0 # molecule nr 261
-Ion_Type1_176	3.615744857	11.428571429	17.142857143	0 # molecule nr 262
-Ion_Type3_85	2.857142857	14.285714286	0.504284000	0 # molecule nr 263
-Ion_Type1_177	3.615744857	14.285714286	1.008568000	0 # molecule nr 264
-Ion_Type1_178	3.615744857	14.285714286	0.000000000	0 # molecule nr 265
-Ion_Type3_86	2.857142857	14.285714286	3.361426857	0 # molecule nr 266
-Ion_Type1_179	3.615744857	14.285714286	3.865710857	0 # molecule nr 267
-Ion_Type1_180	3.615744857	14.285714286	2.857142857	0 # molecule nr 268
-Ion_Type3_87	2.857142857	14.285714286	6.218569714	0 # molecule nr 269
-Ion_Type1_181	3.615744857	14.285714286	6.722853714	0 # molecule nr 270
-Ion_Type1_182	3.615744857	14.285714286	5.714285714	0 # molecule nr 271
-Ion_Type3_88	2.857142857	14.285714286	9.075712571	0 # molecule nr 272
-Ion_Type1_183	3.615744857	14.285714286	9.579996571	0 # molecule nr 273
-Ion_Type1_184	3.615744857	14.285714286	8.571428571	0 # molecule nr 274
-Ion_Type3_89	2.857142857	14.285714286	11.932855429	0 # molecule nr 275
-Ion_Type1_185	3.615744857	14.285714286	12.437139429	0 # molecule nr 276
-Ion_Type1_186	3.615744857	14.285714286	11.428571429	0 # molecule nr 277
-Ion_Type3_90	2.857142857	14.285714286	14.789998286	0 # molecule nr 278
-Ion_Type1_187	3.615744857	14.285714286	15.294282286	0 # molecule nr 279
-Ion_Type1_188	3.615744857	14.285714286	14.285714286	0 # molecule nr 280
-Ion_Type3_91	2.857142857	14.285714286	17.647141143	0 # molecule nr 281
-Ion_Type1_189	3.615744857	14.285714286	18.151425143	0 # molecule nr 282
-Ion_Type1_190	3.615744857	14.285714286	17.142857143	0 # molecule nr 283
-Ion_Type3_92	2.857142857	17.142857143	0.504284000	0 # molecule nr 284
-Ion_Type1_191	3.615744857	17.142857143	1.008568000	0 # molecule nr 285
-Ion_Type1_192	3.615744857	17.142857143	0.000000000	0 # molecule nr 286
-Ion_Type3_93	2.857142857	17.142857143	3.361426857	0 # molecule nr 287
-Ion_Type1_193	3.615744857	17.142857143	3.865710857	0 # molecule nr 288
-Ion_Type1_194	3.615744857	17.142857143	2.857142857	0 # molecule nr 289
-Ion_Type3_94	2.857142857	17.142857143	6.218569714	0 # molecule nr 290
-Ion_Type1_195	3.615744857	17.142857143	6.722853714	0 # molecule nr 291
-Ion_Type1_196	3.615744857	17.142857143	5.714285714	0 # molecule nr 292
-Ion_Type3_95	2.857142857	17.142857143	9.075712571	0 # molecule nr 293
-Ion_Type1_197	3.615744857	17.142857143	9.579996571	0 # molecule nr 294
-Ion_Type1_198	3.615744857	17.142857143	8.571428571	0 # molecule nr 295
-Ion_Type3_96	2.857142857	17.142857143	11.932855429	0 # molecule nr 296
-Ion_Type1_199	3.615744857	17.142857143	12.437139429	0 # molecule nr 297
-Ion_Type1_200	3.615744857	17.142857143	11.428571429	0 # molecule nr 298
-Ion_Type3_97	2.857142857	17.142857143	14.789998286	0 # molecule nr 299
-Ion_Type1_201	3.615744857	17.142857143	15.294282286	0 # molecule nr 300
-Ion_Type1_202	3.615744857	17.142857143	14.285714286	0 # molecule nr 301
-Ion_Type3_98	2.857142857	17.142857143	17.647141143	0 # molecule nr 302
-Ion_Type1_203	3.615744857	17.142857143	18.151425143	0 # molecule nr 303
-Ion_Type1_204	3.615744857	17.142857143	17.142857143	0 # molecule nr 304
-Ion_Type3_99	5.714285714	0.000000000	0.504284000	0 # molecule nr 305
-Ion_Type1_205	6.472887714	0.000000000	1.008568000	0 # molecule nr 306
-Ion_Type1_206	6.472887714	0.000000000	0.000000000	0 # molecule nr 307
-Ion_Type3_100	5.714285714	0.000000000	3.361426857	0 # molecule nr 308
-Ion_Type1_207	6.472887714	0.000000000	3.865710857	0 # molecule nr 309
-Ion_Type1_208	6.472887714	0.000000000	2.857142857	0 # molecule nr 310
-Ion_Type3_101	5.714285714	0.000000000	6.218569714	0 # molecule nr 311
-Ion_Type1_209	6.472887714	0.000000000	6.722853714	0 # molecule nr 312
-Ion_Type1_210	6.472887714	0.000000000	5.714285714	0 # molecule nr 313
-Ion_Type3_102	5.714285714	0.000000000	9.075712571	0 # molecule nr 314
-Ion_Type1_211	6.472887714	0.000000000	9.579996571	0 # molecule nr 315
-Ion_Type1_212	6.472887714	0.000000000	8.571428571	0 # molecule nr 316
-Ion_Type3_103	5.714285714	0.000000000	11.932855429	0 # molecule nr 317
-Ion_Type1_213	6.472887714	0.000000000	12.437139429	0 # molecule nr 318
-Ion_Type1_214	6.472887714	0.000000000	11.428571429	0 # molecule nr 319
-Ion_Type3_104	5.714285714	0.000000000	14.789998286	0 # molecule nr 320
-Ion_Type1_215	6.472887714	0.000000000	15.294282286	0 # molecule nr 321
-Ion_Type1_216	6.472887714	0.000000000	14.285714286	0 # molecule nr 322
-Ion_Type3_105	5.714285714	0.000000000	17.647141143	0 # molecule nr 323
-Ion_Type1_217	6.472887714	0.000000000	18.151425143	0 # molecule nr 324
-Ion_Type1_218	6.472887714	0.000000000	17.142857143	0 # molecule nr 325
-Ion_Type3_106	5.714285714	2.857142857	0.504284000	0 # molecule nr 326
-Ion_Type1_219	6.472887714	2.857142857	0.000000000	0 # molecule nr 327
-Ion_Type3_107	5.714285714	2.857142857	6.218569714	0 # molecule nr 328
-Ion_Type1_220	6.472887714	2.857142857	6.722853714	0 # molecule nr 329
-Ion_Type3_108	5.714285714	2.857142857	9.075712571	0 # molecule nr 330
-Ion_Type1_221	6.472887714	2.857142857	9.579996571	0 # molecule nr 331
-Ion_Type1_222	6.472887714	2.857142857	8.571428571	0 # molecule nr 332
-Ion_Type3_109	5.714285714	2.857142857	11.932855429	0 # molecule nr 333
-Ion_Type1_223	6.472887714	2.857142857	12.437139429	0 # molecule nr 334
-Ion_Type1_224	6.472887714	2.857142857	11.428571429	0 # molecule nr 335
-Ion_Type3_110	5.714285714	2.857142857	14.789998286	0 # molecule nr 336
-Ion_Type1_225	6.472887714	2.857142857	15.294282286	0 # molecule nr 337
-Ion_Type1_226	6.472887714	2.857142857	14.285714286	0 # molecule nr 338
-Ion_Type3_111	5.714285714	2.857142857	17.647141143	0 # molecule nr 339
-Ion_Type1_227	6.472887714	2.857142857	18.151425143	0 # molecule nr 340
-Ion_Type1_228	6.472887714	2.857142857	17.142857143	0 # molecule nr 341
-Ion_Type3_112	5.714285714	5.714285714	0.504284000	0 # molecule nr 342
-Ion_Type1_229	6.472887714	5.714285714	1.008568000	0 # molecule nr 343
-Ion_Type1_230	6.472887714	5.714285714	0.000000000	0 # molecule nr 344
-Ion_Type3_113	5.714285714	5.714285714	6.218569714	0 # molecule nr 345
-Ion_Type1_231	6.472887714	5.714285714	6.722853714	0 # molecule nr 346
-Ion_Type1_232	6.472887714	5.714285714	5.714285714	0 # molecule nr 347
-Ion_Type3_114	5.714285714	5.714285714	9.075712571	0 # molecule nr 348
-Ion_Type1_233	6.472887714	5.714285714	9.579996571	0 # molecule nr 349
-Ion_Type1_234	6.472887714	5.714285714	8.571428571	0 # molecule nr 350
-Ion_Type3_115	5.714285714	5.714285714	11.932855429	0 # molecule nr 351
-Ion_Type1_235	6.472887714	5.714285714	12.437139429	0 # molecule nr 352
-Ion_Type1_236	6.472887714	5.714285714	11.428571429	0 # molecule nr 353
-Ion_Type3_116	5.714285714	5.714285714	14.789998286	0 # molecule nr 354
-Ion_Type1_237	6.472887714	5.714285714	15.294282286	0 # molecule nr 355
-Ion_Type1_238	6.472887714	5.714285714	14.285714286	0 # molecule nr 356
-Ion_Type3_117	5.714285714	5.714285714	17.647141143	0 # molecule nr 357
-Ion_Type1_239	6.472887714	5.714285714	18.151425143	0 # molecule nr 358
-Ion_Type1_240	6.472887714	5.714285714	17.142857143	0 # molecule nr 359
-Ion_Type3_118	5.714285714	8.571428571	0.504284000	0 # molecule nr 360
-Ion_Type1_241	6.472887714	8.571428571	1.008568000	0 # molecule nr 361
-Ion_Type1_242	6.472887714	8.571428571	0.000000000	0 # molecule nr 362
-Ion_Type3_119	5.714285714	8.571428571	3.361426857	0 # molecule nr 363
-Ion_Type1_243	6.472887714	8.571428571	3.865710857	0 # molecule nr 364
-Ion_Type1_244	6.472887714	8.571428571	2.857142857	0 # molecule nr 365
-Ion_Type3_120	5.714285714	8.571428571	6.218569714	0 # molecule nr 366
-Ion_Type1_245	6.472887714	8.571428571	6.722853714	0 # molecule nr 367
-Ion_Type1_246	6.472887714	8.571428571	5.714285714	0 # molecule nr 368
-Ion_Type3_121	5.714285714	8.571428571	9.075712571	0 # molecule nr 369
-Ion_Type1_247	6.472887714	8.571428571	9.579996571	0 # molecule nr 370
-Ion_Type1_248	6.472887714	8.571428571	8.571428571	0 # molecule nr 371
-Ion_Type3_122	5.714285714	8.571428571	11.932855429	0 # molecule nr 372
-Ion_Type1_249	6.472887714	8.571428571	12.437139429	0 # molecule nr 373
-Ion_Type1_250	6.472887714	8.571428571	11.428571429	0 # molecule nr 374
-Ion_Type3_123	5.714285714	8.571428571	14.789998286	0 # molecule nr 375
-Ion_Type1_251	6.472887714	8.571428571	15.294282286	0 # molecule nr 376
-Ion_Type1_252	6.472887714	8.571428571	14.285714286	0 # molecule nr 377
-Ion_Type3_124	5.714285714	8.571428571	17.647141143	0 # molecule nr 378
-Ion_Type1_253	6.472887714	8.571428571	18.151425143	0 # molecule nr 379
-Ion_Type1_254	6.472887714	8.571428571	17.142857143	0 # molecule nr 380
-Ion_Type3_125	5.714285714	11.428571429	0.504284000	0 # molecule nr 381
-Ion_Type1_255	6.472887714	11.428571429	1.008568000	0 # molecule nr 382
-Ion_Type1_256	6.472887714	11.428571429	0.000000000	0 # molecule nr 383
-Ion_Type3_126	5.714285714	11.428571429	3.361426857	0 # molecule nr 384
-Ion_Type1_257	6.472887714	11.428571429	3.865710857	0 # molecule nr 385
-Ion_Type1_258	6.472887714	11.428571429	2.857142857	0 # molecule nr 386
-Ion_Type3_127	5.714285714	11.428571429	6.218569714	0 # molecule nr 387
-Ion_Type1_259	6.472887714	11.428571429	6.722853714	0 # molecule nr 388
-Ion_Type1_260	6.472887714	11.428571429	5.714285714	0 # molecule nr 389
-Ion_Type3_128	5.714285714	11.428571429	9.075712571	0 # molecule nr 390
-Ion_Type1_261	6.472887714	11.428571429	9.579996571	0 # molecule nr 391
-Ion_Type1_262	6.472887714	11.428571429	8.571428571	0 # molecule nr 392
-Ion_Type3_129	5.714285714	11.428571429	11.932855429	0 # molecule nr 393
-Ion_Type1_263	6.472887714	11.428571429	12.437139429	0 # molecule nr 394
-Ion_Type1_264	6.472887714	11.428571429	11.428571429	0 # molecule nr 395
-Ion_Type3_130	5.714285714	11.428571429	14.789998286	0 # molecule nr 396
-Ion_Type1_265	6.472887714	11.428571429	15.294282286	0 # molecule nr 397
-Ion_Type1_266	6.472887714	11.428571429	14.285714286	0 # molecule nr 398
-Ion_Type3_131	5.714285714	11.428571429	17.647141143	0 # molecule nr 399
-Ion_Type1_267	6.472887714	11.428571429	18.151425143	0 # molecule nr 400
-Ion_Type1_268	6.472887714	11.428571429	17.142857143	0 # molecule nr 401
-Ion_Type3_132	5.714285714	14.285714286	0.504284000	0 # molecule nr 402
-Ion_Type1_269	6.472887714	14.285714286	1.008568000	0 # molecule nr 403
-Ion_Type1_270	6.472887714	14.285714286	0.000000000	0 # molecule nr 404
-Ion_Type3_133	5.714285714	14.285714286	3.361426857	0 # molecule nr 405
-Ion_Type1_271	6.472887714	14.285714286	3.865710857	0 # molecule nr 406
-Ion_Type1_272	6.472887714	14.285714286	2.857142857	0 # molecule nr 407
-Ion_Type3_134	5.714285714	14.285714286	6.218569714	0 # molecule nr 408
-Ion_Type1_273	6.472887714	14.285714286	6.722853714	0 # molecule nr 409
-Ion_Type1_274	6.472887714	14.285714286	5.714285714	0 # molecule nr 410
-Ion_Type3_135	5.714285714	14.285714286	9.075712571	0 # molecule nr 411
-Ion_Type1_275	6.472887714	14.285714286	9.579996571	0 # molecule nr 412
-Ion_Type1_276	6.472887714	14.285714286	8.571428571	0 # molecule nr 413
-Ion_Type3_136	5.714285714	14.285714286	11.932855429	0 # molecule nr 414
-Ion_Type1_277	6.472887714	14.285714286	12.437139429	0 # molecule nr 415
-Ion_Type1_278	6.472887714	14.285714286	11.428571429	0 # molecule nr 416
-Ion_Type3_137	5.714285714	14.285714286	14.789998286	0 # molecule nr 417
-Ion_Type1_279	6.472887714	14.285714286	15.294282286	0 # molecule nr 418
-Ion_Type1_280	6.472887714	14.285714286	14.285714286	0 # molecule nr 419
-Ion_Type3_138	5.714285714	14.285714286	17.647141143	0 # molecule nr 420
-Ion_Type1_281	6.472887714	14.285714286	18.151425143	0 # molecule nr 421
-Ion_Type1_282	6.472887714	14.285714286	17.142857143	0 # molecule nr 422
-Ion_Type3_139	5.714285714	17.142857143	0.504284000	0 # molecule nr 423
-Ion_Type1_283	6.472887714	17.142857143	1.008568000	0 # molecule nr 424
-Ion_Type1_284	6.472887714	17.142857143	0.000000000	0 # molecule nr 425
-Ion_Type3_140	5.714285714	17.142857143	3.361426857	0 # molecule nr 426
-Ion_Type1_285	6.472887714	17.142857143	3.865710857	0 # molecule nr 427
-Ion_Type1_286	6.472887714	17.142857143	2.857142857	0 # molecule nr 428
-Ion_Type3_141	5.714285714	17.142857143	6.218569714	0 # molecule nr 429
-Ion_Type1_287	6.472887714	17.142857143	6.722853714	0 # molecule nr 430
-Ion_Type1_288	6.472887714	17.142857143	5.714285714	0 # molecule nr 431
-Ion_Type3_142	5.714285714	17.142857143	9.075712571	0 # molecule nr 432
-Ion_Type1_289	6.472887714	17.142857143	9.579996571	0 # molecule nr 433
-Ion_Type1_290	6.472887714	17.142857143	8.571428571	0 # molecule nr 434
-Ion_Type3_143	5.714285714	17.142857143	11.932855429	0 # molecule nr 435
-Ion_Type1_291	6.472887714	17.142857143	12.437139429	0 # molecule nr 436
-Ion_Type1_292	6.472887714	17.142857143	11.428571429	0 # molecule nr 437
-Ion_Type3_144	5.714285714	17.142857143	14.789998286	0 # molecule nr 438
-Ion_Type1_293	6.472887714	17.142857143	15.294282286	0 # molecule nr 439
-Ion_Type1_294	6.472887714	17.142857143	14.285714286	0 # molecule nr 440
-Ion_Type3_145	5.714285714	17.142857143	17.647141143	0 # molecule nr 441
-Ion_Type1_295	6.472887714	17.142857143	18.151425143	0 # molecule nr 442
-Ion_Type1_296	6.472887714	17.142857143	17.142857143	0 # molecule nr 443
-Ion_Type3_146	8.571428571	0.000000000	0.504284000	0 # molecule nr 444
-Ion_Type1_297	9.330030571	0.000000000	1.008568000	0 # molecule nr 445
-Ion_Type1_298	9.330030571	0.000000000	0.000000000	0 # molecule nr 446
-Ion_Type3_147	8.571428571	0.000000000	3.361426857	0 # molecule nr 447
-Ion_Type1_299	9.330030571	0.000000000	3.865710857	0 # molecule nr 448
-Ion_Type1_300	9.330030571	0.000000000	2.857142857	0 # molecule nr 449
-Ion_Type3_148	8.571428571	0.000000000	6.218569714	0 # molecule nr 450
-Ion_Type1_301	9.330030571	0.000000000	6.722853714	0 # molecule nr 451
-Ion_Type1_302	9.330030571	0.000000000	5.714285714	0 # molecule nr 452
-Ion_Type3_149	8.571428571	0.000000000	9.075712571	0 # molecule nr 453
-Ion_Type1_303	9.330030571	0.000000000	9.579996571	0 # molecule nr 454
-Ion_Type1_304	9.330030571	0.000000000	8.571428571	0 # molecule nr 455
-Ion_Type3_150	8.571428571	0.000000000	11.932855429	0 # molecule nr 456
-Ion_Type1_305	9.330030571	0.000000000	12.437139429	0 # molecule nr 457
-Ion_Type1_306	9.330030571	0.000000000	11.428571429	0 # molecule nr 458
-Ion_Type3_151	8.571428571	0.000000000	14.789998286	0 # molecule nr 459
-Ion_Type1_307	9.330030571	0.000000000	15.294282286	0 # molecule nr 460
-Ion_Type1_308	9.330030571	0.000000000	14.285714286	0 # molecule nr 461
-Ion_Type3_152	8.571428571	0.000000000	17.647141143	0 # molecule nr 462
-Ion_Type1_309	9.330030571	0.000000000	18.151425143	0 # molecule nr 463
-Ion_Type1_310	9.330030571	0.000000000	17.142857143	0 # molecule nr 464
-Ion_Type3_153	8.571428571	2.857142857	0.504284000	0 # molecule nr 465
-Ion_Type1_311	9.330030571	2.857142857	0.000000000	0 # molecule nr 466
-Ion_Type1_312	9.330030571	2.857142857	6.722853714	0 # molecule nr 467
-Ion_Type3_154	8.571428571	2.857142857	9.075712571	0 # molecule nr 468
-Ion_Type1_313	9.330030571	2.857142857	9.579996571	0 # molecule nr 469
-Ion_Type1_314	9.330030571	2.857142857	8.571428571	0 # molecule nr 470
-Ion_Type3_155	8.571428571	2.857142857	11.932855429	0 # molecule nr 471
-Ion_Type1_315	9.330030571	2.857142857	12.437139429	0 # molecule nr 472
-Ion_Type1_316	9.330030571	2.857142857	11.428571429	0 # molecule nr 473
-Ion_Type3_156	8.571428571	2.857142857	14.789998286	0 # molecule nr 474
-Ion_Type1_317	9.330030571	2.857142857	15.294282286	0 # molecule nr 475
-Ion_Type1_318	9.330030571	2.857142857	14.285714286	0 # molecule nr 476
-Ion_Type3_157	8.571428571	2.857142857	17.647141143	0 # molecule nr 477
-Ion_Type1_319	9.330030571	2.857142857	18.151425143	0 # molecule nr 478
-Ion_Type1_320	9.330030571	2.857142857	17.142857143	0 # molecule nr 479
-Ion_Type3_158	8.571428571	5.714285714	0.504284000	0 # molecule nr 480
-Ion_Type1_321	9.330030571	5.714285714	0.000000000	0 # molecule nr 481
-Ion_Type1_322	9.330030571	5.714285714	6.722853714	0 # molecule nr 482
-Ion_Type3_159	8.571428571	5.714285714	9.075712571	0 # molecule nr 483
-Ion_Type1_323	9.330030571	5.714285714	9.579996571	0 # molecule nr 484
-Ion_Type1_324	9.330030571	5.714285714	8.571428571	0 # molecule nr 485
-Ion_Type3_160	8.571428571	5.714285714	11.932855429	0 # molecule nr 486
-Ion_Type1_325	9.330030571	5.714285714	12.437139429	0 # molecule nr 487
-Ion_Type1_326	9.330030571	5.714285714	11.428571429	0 # molecule nr 488
-Ion_Type3_161	8.571428571	5.714285714	14.789998286	0 # molecule nr 489
-Ion_Type1_327	9.330030571	5.714285714	15.294282286	0 # molecule nr 490
-Ion_Type1_328	9.330030571	5.714285714	14.285714286	0 # molecule nr 491
-Ion_Type3_162	8.571428571	5.714285714	17.647141143	0 # molecule nr 492
-Ion_Type1_329	9.330030571	5.714285714	18.151425143	0 # molecule nr 493
-Ion_Type1_330	9.330030571	5.714285714	17.142857143	0 # molecule nr 494
-Ion_Type3_163	8.571428571	8.571428571	0.504284000	0 # molecule nr 495
-Ion_Type1_331	9.330030571	8.571428571	1.008568000	0 # molecule nr 496
-Ion_Type1_332	9.330030571	8.571428571	0.000000000	0 # molecule nr 497
-Ion_Type3_164	8.571428571	8.571428571	3.361426857	0 # molecule nr 498
-Ion_Type1_333	9.330030571	8.571428571	3.865710857	0 # molecule nr 499
-Ion_Type1_334	9.330030571	8.571428571	2.857142857	0 # molecule nr 500
-Ion_Type3_165	8.571428571	8.571428571	6.218569714	0 # molecule nr 501
-Ion_Type1_335	9.330030571	8.571428571	6.722853714	0 # molecule nr 502
-Ion_Type1_336	9.330030571	8.571428571	5.714285714	0 # molecule nr 503
-Ion_Type3_166	8.571428571	8.571428571	9.075712571	0 # molecule nr 504
-Ion_Type1_337	9.330030571	8.571428571	9.579996571	0 # molecule nr 505
-Ion_Type1_338	9.330030571	8.571428571	8.571428571	0 # molecule nr 506
-Ion_Type3_167	8.571428571	8.571428571	11.932855429	0 # molecule nr 507
-Ion_Type1_339	9.330030571	8.571428571	12.437139429	0 # molecule nr 508
-Ion_Type1_340	9.330030571	8.571428571	11.428571429	0 # molecule nr 509
-Ion_Type3_168	8.571428571	8.571428571	14.789998286	0 # molecule nr 510
-Ion_Type1_341	9.330030571	8.571428571	15.294282286	0 # molecule nr 511
-Ion_Type1_342	9.330030571	8.571428571	14.285714286	0 # molecule nr 512
-Ion_Type3_169	8.571428571	8.571428571	17.647141143	0 # molecule nr 513
-Ion_Type1_343	9.330030571	8.571428571	18.151425143	0 # molecule nr 514
-Ion_Type1_344	9.330030571	8.571428571	17.142857143	0 # molecule nr 515
-Ion_Type3_170	8.571428571	11.428571429	0.504284000	0 # molecule nr 516
-Ion_Type1_345	9.330030571	11.428571429	1.008568000	0 # molecule nr 517
-Ion_Type1_346	9.330030571	11.428571429	0.000000000	0 # molecule nr 518
-Ion_Type3_171	8.571428571	11.428571429	3.361426857	0 # molecule nr 519
-Ion_Type1_347	9.330030571	11.428571429	3.865710857	0 # molecule nr 520
-Ion_Type1_348	9.330030571	11.428571429	2.857142857	0 # molecule nr 521
-Ion_Type3_172	8.571428571	11.428571429	6.218569714	0 # molecule nr 522
-Ion_Type1_349	9.330030571	11.428571429	6.722853714	0 # molecule nr 523
-Ion_Type1_350	9.330030571	11.428571429	5.714285714	0 # molecule nr 524
-Ion_Type3_173	8.571428571	11.428571429	9.075712571	0 # molecule nr 525
-Ion_Type1_351	9.330030571	11.428571429	9.579996571	0 # molecule nr 526
-Ion_Type1_352	9.330030571	11.428571429	8.571428571	0 # molecule nr 527
-Ion_Type3_174	8.571428571	11.428571429	11.932855429	0 # molecule nr 528
-Ion_Type1_353	9.330030571	11.428571429	12.437139429	0 # molecule nr 529
-Ion_Type1_354	9.330030571	11.428571429	11.428571429	0 # molecule nr 530
-Ion_Type3_175	8.571428571	11.428571429	14.789998286	0 # molecule nr 531
-Ion_Type1_355	9.330030571	11.428571429	15.294282286	0 # molecule nr 532
-Ion_Type1_356	9.330030571	11.428571429	14.285714286	0 # molecule nr 533
-Ion_Type3_176	8.571428571	11.428571429	17.647141143	0 # molecule nr 534
-Ion_Type1_357	9.330030571	11.428571429	18.151425143	0 # molecule nr 535
-Ion_Type1_358	9.330030571	11.428571429	17.142857143	0 # molecule nr 536
-Ion_Type3_177	8.571428571	14.285714286	0.504284000	0 # molecule nr 537
-Ion_Type1_359	9.330030571	14.285714286	1.008568000	0 # molecule nr 538
-Ion_Type1_360	9.330030571	14.285714286	0.000000000	0 # molecule nr 539
-Ion_Type3_178	8.571428571	14.285714286	3.361426857	0 # molecule nr 540
-Ion_Type1_361	9.330030571	14.285714286	3.865710857	0 # molecule nr 541
-Ion_Type1_362	9.330030571	14.285714286	2.857142857	0 # molecule nr 542
-Ion_Type3_179	8.571428571	14.285714286	6.218569714	0 # molecule nr 543
-Ion_Type1_363	9.330030571	14.285714286	6.722853714	0 # molecule nr 544
-Ion_Type1_364	9.330030571	14.285714286	5.714285714	0 # molecule nr 545
-Ion_Type3_180	8.571428571	14.285714286	9.075712571	0 # molecule nr 546
-Ion_Type1_365	9.330030571	14.285714286	9.579996571	0 # molecule nr 547
-Ion_Type1_366	9.330030571	14.285714286	8.571428571	0 # molecule nr 548
-Ion_Type3_181	8.571428571	14.285714286	11.932855429	0 # molecule nr 549
-Ion_Type1_367	9.330030571	14.285714286	12.437139429	0 # molecule nr 550
-Ion_Type1_368	9.330030571	14.285714286	11.428571429	0 # molecule nr 551
-Ion_Type3_182	8.571428571	14.285714286	14.789998286	0 # molecule nr 552
-Ion_Type1_369	9.330030571	14.285714286	15.294282286	0 # molecule nr 553
-Ion_Type1_370	9.330030571	14.285714286	14.285714286	0 # molecule nr 554
-Ion_Type3_183	8.571428571	14.285714286	17.647141143	0 # molecule nr 555
-Ion_Type1_371	9.330030571	14.285714286	18.151425143	0 # molecule nr 556
-Ion_Type1_372	9.330030571	14.285714286	17.142857143	0 # molecule nr 557
-Ion_Type3_184	8.571428571	17.142857143	0.504284000	0 # molecule nr 558
-Ion_Type1_373	9.330030571	17.142857143	1.008568000	0 # molecule nr 559
-Ion_Type1_374	9.330030571	17.142857143	0.000000000	0 # molecule nr 560
-Ion_Type3_185	8.571428571	17.142857143	3.361426857	0 # molecule nr 561
-Ion_Type1_375	9.330030571	17.142857143	3.865710857	0 # molecule nr 562
-Ion_Type1_376	9.330030571	17.142857143	2.857142857	0 # molecule nr 563
-Ion_Type3_186	8.571428571	17.142857143	6.218569714	0 # molecule nr 564
-Ion_Type1_377	9.330030571	17.142857143	6.722853714	0 # molecule nr 565
-Ion_Type1_378	9.330030571	17.142857143	5.714285714	0 # molecule nr 566
-Ion_Type3_187	8.571428571	17.142857143	9.075712571	0 # molecule nr 567
-Ion_Type1_379	9.330030571	17.142857143	9.579996571	0 # molecule nr 568
-Ion_Type1_380	9.330030571	17.142857143	8.571428571	0 # molecule nr 569
-Ion_Type3_188	8.571428571	17.142857143	11.932855429	0 # molecule nr 570
-Ion_Type1_381	9.330030571	17.142857143	12.437139429	0 # molecule nr 571
-Ion_Type1_382	9.330030571	17.142857143	11.428571429	0 # molecule nr 572
-Ion_Type3_189	8.571428571	17.142857143	14.789998286	0 # molecule nr 573
-Ion_Type1_383	9.330030571	17.142857143	15.294282286	0 # molecule nr 574
-Ion_Type1_384	9.330030571	17.142857143	14.285714286	0 # molecule nr 575
-Ion_Type3_190	8.571428571	17.142857143	17.647141143	0 # molecule nr 576
-Ion_Type1_385	9.330030571	17.142857143	18.151425143	0 # molecule nr 577
-Ion_Type1_386	9.330030571	17.142857143	17.142857143	0 # molecule nr 578
-Ion_Type3_191	11.428571429	0.000000000	0.504284000	0 # molecule nr 579
-Ion_Type1_387	12.187173429	0.000000000	1.008568000	0 # molecule nr 580
-Ion_Type1_388	12.187173429	0.000000000	0.000000000	0 # molecule nr 581
-Ion_Type3_192	11.428571429	0.000000000	3.361426857	0 # molecule nr 582
-Ion_Type1_389	12.187173429	0.000000000	3.865710857	0 # molecule nr 583
-Ion_Type1_390	12.187173429	0.000000000	2.857142857	0 # molecule nr 584
-Ion_Type3_193	11.428571429	0.000000000	6.218569714	0 # molecule nr 585
-Ion_Type1_391	12.187173429	0.000000000	6.722853714	0 # molecule nr 586
-Ion_Type1_392	12.187173429	0.000000000	5.714285714	0 # molecule nr 587
-Ion_Type3_194	11.428571429	0.000000000	9.075712571	0 # molecule nr 588
-Ion_Type1_393	12.187173429	0.000000000	9.579996571	0 # molecule nr 589
-Ion_Type1_394	12.187173429	0.000000000	8.571428571	0 # molecule nr 590
-Ion_Type3_195	11.428571429	0.000000000	11.932855429	0 # molecule nr 591
-Ion_Type1_395	12.187173429	0.000000000	12.437139429	0 # molecule nr 592
-Ion_Type1_396	12.187173429	0.000000000	11.428571429	0 # molecule nr 593
-Ion_Type3_196	11.428571429	0.000000000	14.789998286	0 # molecule nr 594
-Ion_Type1_397	12.187173429	0.000000000	15.294282286	0 # molecule nr 595
-Ion_Type1_398	12.187173429	0.000000000	14.285714286	0 # molecule nr 596
-Ion_Type3_197	11.428571429	0.000000000	17.647141143	0 # molecule nr 597
-Ion_Type1_399	12.187173429	0.000000000	18.151425143	0 # molecule nr 598
-Ion_Type1_400	12.187173429	0.000000000	17.142857143	0 # molecule nr 599
-Ion_Type3_198	11.428571429	2.857142857	0.504284000	0 # molecule nr 600
-Ion_Type1_401	12.187173429	2.857142857	1.008568000	0 # molecule nr 601
-Ion_Type1_402	12.187173429	2.857142857	0.000000000	0 # molecule nr 602
-Ion_Type3_199	11.428571429	2.857142857	6.218569714	0 # molecule nr 603
-Ion_Type1_403	12.187173429	2.857142857	6.722853714	0 # molecule nr 604
-Ion_Type1_404	12.187173429	2.857142857	5.714285714	0 # molecule nr 605
-Ion_Type3_200	11.428571429	2.857142857	9.075712571	0 # molecule nr 606
-Ion_Type1_405	12.187173429	2.857142857	9.579996571	0 # molecule nr 607
-Ion_Type1_406	12.187173429	2.857142857	8.571428571	0 # molecule nr 608
-Ion_Type3_201	11.428571429	2.857142857	11.932855429	0 # molecule nr 609
-Ion_Type1_407	12.187173429	2.857142857	12.437139429	0 # molecule nr 610
-Ion_Type1_408	12.187173429	2.857142857	11.428571429	0 # molecule nr 611
-Ion_Type3_202	11.428571429	2.857142857	14.789998286	0 # molecule nr 612
-Ion_Type1_409	12.187173429	2.857142857	15.294282286	0 # molecule nr 613
-Ion_Type1_410	12.187173429	2.857142857	14.285714286	0 # molecule nr 614
-Ion_Type3_203	11.428571429	2.857142857	17.647141143	0 # molecule nr 615
-Ion_Type1_411	12.187173429	2.857142857	18.151425143	0 # molecule nr 616
-Ion_Type1_412	12.187173429	2.857142857	17.142857143	0 # molecule nr 617
-Ion_Type3_204	11.428571429	5.714285714	0.504284000	0 # molecule nr 618
-Ion_Type1_413	12.187173429	5.714285714	1.008568000	0 # molecule nr 619
-Ion_Type1_414	12.187173429	5.714285714	0.000000000	0 # molecule nr 620
-Ion_Type1_415	12.187173429	5.714285714	3.865710857	0 # molecule nr 621
-Ion_Type1_416	12.187173429	5.714285714	2.857142857	0 # molecule nr 622
-Ion_Type3_205	11.428571429	5.714285714	6.218569714	0 # molecule nr 623
-Ion_Type1_417	12.187173429	5.714285714	6.722853714	0 # molecule nr 624
-Ion_Type1_418	12.187173429	5.714285714	5.714285714	0 # molecule nr 625
-Ion_Type3_206	11.428571429	5.714285714	9.075712571	0 # molecule nr 626
-Ion_Type1_419	12.187173429	5.714285714	9.579996571	0 # molecule nr 627
-Ion_Type1_420	12.187173429	5.714285714	8.571428571	0 # molecule nr 628
-Ion_Type3_207	11.428571429	5.714285714	11.932855429	0 # molecule nr 629
-Ion_Type1_421	12.187173429	5.714285714	12.437139429	0 # molecule nr 630
-Ion_Type1_422	12.187173429	5.714285714	11.428571429	0 # molecule nr 631
-Ion_Type3_208	11.428571429	5.714285714	14.789998286	0 # molecule nr 632
-Ion_Type1_423	12.187173429	5.714285714	15.294282286	0 # molecule nr 633
-Ion_Type1_424	12.187173429	5.714285714	14.285714286	0 # molecule nr 634
-Ion_Type3_209	11.428571429	5.714285714	17.647141143	0 # molecule nr 635
-Ion_Type1_425	12.187173429	5.714285714	18.151425143	0 # molecule nr 636
-Ion_Type1_426	12.187173429	5.714285714	17.142857143	0 # molecule nr 637
-Ion_Type3_210	11.428571429	8.571428571	0.504284000	0 # molecule nr 638
-Ion_Type1_427	12.187173429	8.571428571	1.008568000	0 # molecule nr 639
-Ion_Type1_428	12.187173429	8.571428571	0.000000000	0 # molecule nr 640
-Ion_Type3_211	11.428571429	8.571428571	3.361426857	0 # molecule nr 641
-Ion_Type1_429	12.187173429	8.571428571	3.865710857	0 # molecule nr 642
-Ion_Type1_430	12.187173429	8.571428571	2.857142857	0 # molecule nr 643
-Ion_Type3_212	11.428571429	8.571428571	6.218569714	0 # molecule nr 644
-Ion_Type1_431	12.187173429	8.571428571	6.722853714	0 # molecule nr 645
-Ion_Type1_432	12.187173429	8.571428571	5.714285714	0 # molecule nr 646
-Ion_Type3_213	11.428571429	8.571428571	9.075712571	0 # molecule nr 647
-Ion_Type1_433	12.187173429	8.571428571	9.579996571	0 # molecule nr 648
-Ion_Type1_434	12.187173429	8.571428571	8.571428571	0 # molecule nr 649
-Ion_Type3_214	11.428571429	8.571428571	11.932855429	0 # molecule nr 650
-Ion_Type1_435	12.187173429	8.571428571	12.437139429	0 # molecule nr 651
-Ion_Type1_436	12.187173429	8.571428571	11.428571429	0 # molecule nr 652
-Ion_Type3_215	11.428571429	8.571428571	14.789998286	0 # molecule nr 653
-Ion_Type1_437	12.187173429	8.571428571	15.294282286	0 # molecule nr 654
-Ion_Type1_438	12.187173429	8.571428571	14.285714286	0 # molecule nr 655
-Ion_Type3_216	11.428571429	8.571428571	17.647141143	0 # molecule nr 656
-Ion_Type1_439	12.187173429	8.571428571	18.151425143	0 # molecule nr 657
-Ion_Type1_440	12.187173429	8.571428571	17.142857143	0 # molecule nr 658
-Ion_Type3_217	11.428571429	11.428571429	0.504284000	0 # molecule nr 659
-Ion_Type1_441	12.187173429	11.428571429	1.008568000	0 # molecule nr 660
-Ion_Type1_442	12.187173429	11.428571429	0.000000000	0 # molecule nr 661
-Ion_Type3_218	11.428571429	11.428571429	3.361426857	0 # molecule nr 662
-Ion_Type1_443	12.187173429	11.428571429	3.865710857	0 # molecule nr 663
-Ion_Type1_444	12.187173429	11.428571429	2.857142857	0 # molecule nr 664
-Ion_Type3_219	11.428571429	11.428571429	6.218569714	0 # molecule nr 665
-Ion_Type1_445	12.187173429	11.428571429	6.722853714	0 # molecule nr 666
-Ion_Type1_446	12.187173429	11.428571429	5.714285714	0 # molecule nr 667
-Ion_Type3_220	11.428571429	11.428571429	9.075712571	0 # molecule nr 668
-Ion_Type1_447	12.187173429	11.428571429	9.579996571	0 # molecule nr 669
-Ion_Type1_448	12.187173429	11.428571429	8.571428571	0 # molecule nr 670
-Ion_Type3_221	11.428571429	11.428571429	11.932855429	0 # molecule nr 671
-Ion_Type1_449	12.187173429	11.428571429	12.437139429	0 # molecule nr 672
-Ion_Type1_450	12.187173429	11.428571429	11.428571429	0 # molecule nr 673
-Ion_Type3_222	11.428571429	11.428571429	14.789998286	0 # molecule nr 674
-Ion_Type1_451	12.187173429	11.428571429	15.294282286	0 # molecule nr 675
-Ion_Type1_452	12.187173429	11.428571429	14.285714286	0 # molecule nr 676
-Ion_Type3_223	11.428571429	11.428571429	17.647141143	0 # molecule nr 677
-Ion_Type1_453	12.187173429	11.428571429	18.151425143	0 # molecule nr 678
-Ion_Type1_454	12.187173429	11.428571429	17.142857143	0 # molecule nr 679
-Ion_Type3_224	11.428571429	14.285714286	0.504284000	0 # molecule nr 680
-Ion_Type1_455	12.187173429	14.285714286	1.008568000	0 # molecule nr 681
-Ion_Type1_456	12.187173429	14.285714286	0.000000000	0 # molecule nr 682
-Ion_Type3_225	11.428571429	14.285714286	3.361426857	0 # molecule nr 683
-Ion_Type1_457	12.187173429	14.285714286	3.865710857	0 # molecule nr 684
-Ion_Type1_458	12.187173429	14.285714286	2.857142857	0 # molecule nr 685
-Ion_Type3_226	11.428571429	14.285714286	6.218569714	0 # molecule nr 686
-Ion_Type1_459	12.187173429	14.285714286	6.722853714	0 # molecule nr 687
-Ion_Type1_460	12.187173429	14.285714286	5.714285714	0 # molecule nr 688
-Ion_Type3_227	11.428571429	14.285714286	9.075712571	0 # molecule nr 689
-Ion_Type1_461	12.187173429	14.285714286	9.579996571	0 # molecule nr 690
-Ion_Type1_462	12.187173429	14.285714286	8.571428571	0 # molecule nr 691
-Ion_Type3_228	11.428571429	14.285714286	11.932855429	0 # molecule nr 692
-Ion_Type1_463	12.187173429	14.285714286	12.437139429	0 # molecule nr 693
-Ion_Type1_464	12.187173429	14.285714286	11.428571429	0 # molecule nr 694
-Ion_Type3_229	11.428571429	14.285714286	14.789998286	0 # molecule nr 695
-Ion_Type1_465	12.187173429	14.285714286	15.294282286	0 # molecule nr 696
-Ion_Type1_466	12.187173429	14.285714286	14.285714286	0 # molecule nr 697
-Ion_Type3_230	11.428571429	14.285714286	17.647141143	0 # molecule nr 698
-Ion_Type1_467	12.187173429	14.285714286	18.151425143	0 # molecule nr 699
-Ion_Type1_468	12.187173429	14.285714286	17.142857143	0 # molecule nr 700
-Ion_Type3_231	11.428571429	17.142857143	0.504284000	0 # molecule nr 701
-Ion_Type1_469	12.187173429	17.142857143	1.008568000	0 # molecule nr 702
-Ion_Type1_470	12.187173429	17.142857143	0.000000000	0 # molecule nr 703
-Ion_Type3_232	11.428571429	17.142857143	3.361426857	0 # molecule nr 704
-Ion_Type1_471	12.187173429	17.142857143	3.865710857	0 # molecule nr 705
-Ion_Type1_472	12.187173429	17.142857143	2.857142857	0 # molecule nr 706
-Ion_Type3_233	11.428571429	17.142857143	6.218569714	0 # molecule nr 707
-Ion_Type1_473	12.187173429	17.142857143	6.722853714	0 # molecule nr 708
-Ion_Type1_474	12.187173429	17.142857143	5.714285714	0 # molecule nr 709
-Ion_Type3_234	11.428571429	17.142857143	9.075712571	0 # molecule nr 710
-Ion_Type1_475	12.187173429	17.142857143	9.579996571	0 # molecule nr 711
-Ion_Type1_476	12.187173429	17.142857143	8.571428571	0 # molecule nr 712
-Ion_Type3_235	11.428571429	17.142857143	11.932855429	0 # molecule nr 713
-Ion_Type1_477	12.187173429	17.142857143	12.437139429	0 # molecule nr 714
-Ion_Type1_478	12.187173429	17.142857143	11.428571429	0 # molecule nr 715
-Ion_Type3_236	11.428571429	17.142857143	14.789998286	0 # molecule nr 716
-Ion_Type1_479	12.187173429	17.142857143	15.294282286	0 # molecule nr 717
-Ion_Type1_480	12.187173429	17.142857143	14.285714286	0 # molecule nr 718
-Ion_Type3_237	11.428571429	17.142857143	17.647141143	0 # molecule nr 719
-Ion_Type1_481	12.187173429	17.142857143	18.151425143	0 # molecule nr 720
-Ion_Type1_482	12.187173429	17.142857143	17.142857143	0 # molecule nr 721
-Ion_Type3_238	14.285714286	0.000000000	0.504284000	0 # molecule nr 722
-Ion_Type1_483	15.044316286	0.000000000	1.008568000	0 # molecule nr 723
-Ion_Type1_484	15.044316286	0.000000000	0.000000000	0 # molecule nr 724
-Ion_Type3_239	14.285714286	0.000000000	3.361426857	0 # molecule nr 725
-Ion_Type1_485	15.044316286	0.000000000	3.865710857	0 # molecule nr 726
-Ion_Type1_486	15.044316286	0.000000000	2.857142857	0 # molecule nr 727
-Ion_Type3_240	14.285714286	0.000000000	6.218569714	0 # molecule nr 728
-Ion_Type1_487	15.044316286	0.000000000	6.722853714	0 # molecule nr 729
-Ion_Type1_488	15.044316286	0.000000000	5.714285714	0 # molecule nr 730
-Ion_Type3_241	14.285714286	0.000000000	9.075712571	0 # molecule nr 731
-Ion_Type1_489	15.044316286	0.000000000	9.579996571	0 # molecule nr 732
-Ion_Type1_490	15.044316286	0.000000000	8.571428571	0 # molecule nr 733
-Ion_Type3_242	14.285714286	0.000000000	11.932855429	0 # molecule nr 734
-Ion_Type1_491	15.044316286	0.000000000	12.437139429	0 # molecule nr 735
-Ion_Type1_492	15.044316286	0.000000000	11.428571429	0 # molecule nr 736
-Ion_Type3_243	14.285714286	0.000000000	14.789998286	0 # molecule nr 737
-Ion_Type1_493	15.044316286	0.000000000	15.294282286	0 # molecule nr 738
-Ion_Type1_494	15.044316286	0.000000000	14.285714286	0 # molecule nr 739
-Ion_Type3_244	14.285714286	0.000000000	17.647141143	0 # molecule nr 740
-Ion_Type1_495	15.044316286	0.000000000	18.151425143	0 # molecule nr 741
-Ion_Type1_496	15.044316286	0.000000000	17.142857143	0 # molecule nr 742
-Ion_Type3_245	14.285714286	2.857142857	0.504284000	0 # molecule nr 743
-Ion_Type1_497	15.044316286	2.857142857	1.008568000	0 # molecule nr 744
-Ion_Type1_498	15.044316286	2.857142857	0.000000000	0 # molecule nr 745
-Ion_Type3_246	14.285714286	2.857142857	3.361426857	0 # molecule nr 746
-Ion_Type1_499	15.044316286	2.857142857	3.865710857	0 # molecule nr 747
-Ion_Type1_500	15.044316286	2.857142857	2.857142857	0 # molecule nr 748
-Ion_Type3_247	14.285714286	2.857142857	6.218569714	0 # molecule nr 749
-Ion_Type1_501	15.044316286	2.857142857	6.722853714	0 # molecule nr 750
-Ion_Type1_502	15.044316286	2.857142857	5.714285714	0 # molecule nr 751
-Ion_Type3_248	14.285714286	2.857142857	9.075712571	0 # molecule nr 752
-Ion_Type1_503	15.044316286	2.857142857	9.579996571	0 # molecule nr 753
-Ion_Type1_504	15.044316286	2.857142857	8.571428571	0 # molecule nr 754
-Ion_Type3_249	14.285714286	2.857142857	11.932855429	0 # molecule nr 755
-Ion_Type1_505	15.044316286	2.857142857	12.437139429	0 # molecule nr 756
-Ion_Type1_506	15.044316286	2.857142857	11.428571429	0 # molecule nr 757
-Ion_Type3_250	14.285714286	2.857142857	14.789998286	0 # molecule nr 758
-Ion_Type1_507	15.044316286	2.857142857	15.294282286	0 # molecule nr 759
-Ion_Type1_508	15.044316286	2.857142857	14.285714286	0 # molecule nr 760
-Ion_Type3_251	14.285714286	2.857142857	17.647141143	0 # molecule nr 761
-Ion_Type1_509	15.044316286	2.857142857	18.151425143	0 # molecule nr 762
-Ion_Type1_510	15.044316286	2.857142857	17.142857143	0 # molecule nr 763
-Ion_Type3_252	14.285714286	5.714285714	0.504284000	0 # molecule nr 764
-Ion_Type1_511	15.044316286	5.714285714	1.008568000	0 # molecule nr 765
-Ion_Type1_512	15.044316286	5.714285714	0.000000000	0 # molecule nr 766
-Ion_Type3_253	14.285714286	5.714285714	3.361426857	0 # molecule nr 767
-Ion_Type1_513	15.044316286	5.714285714	3.865710857	0 # molecule nr 768
-Ion_Type1_514	15.044316286	5.714285714	2.857142857	0 # molecule nr 769
-Ion_Type3_254	14.285714286	5.714285714	6.218569714	0 # molecule nr 770
-Ion_Type1_515	15.044316286	5.714285714	6.722853714	0 # molecule nr 771
-Ion_Type1_516	15.044316286	5.714285714	5.714285714	0 # molecule nr 772
-Ion_Type3_255	14.285714286	5.714285714	9.075712571	0 # molecule nr 773
-Ion_Type1_517	15.044316286	5.714285714	9.579996571	0 # molecule nr 774
-Ion_Type1_518	15.044316286	5.714285714	8.571428571	0 # molecule nr 775
-Ion_Type3_256	14.285714286	5.714285714	11.932855429	0 # molecule nr 776
-Ion_Type1_519	15.044316286	5.714285714	12.437139429	0 # molecule nr 777
-Ion_Type1_520	15.044316286	5.714285714	11.428571429	0 # molecule nr 778
-Ion_Type3_257	14.285714286	5.714285714	14.789998286	0 # molecule nr 779
-Ion_Type1_521	15.044316286	5.714285714	15.294282286	0 # molecule nr 780
-Ion_Type1_522	15.044316286	5.714285714	14.285714286	0 # molecule nr 781
-Ion_Type3_258	14.285714286	5.714285714	17.647141143	0 # molecule nr 782
-Ion_Type1_523	15.044316286	5.714285714	18.151425143	0 # molecule nr 783
-Ion_Type1_524	15.044316286	5.714285714	17.142857143	0 # molecule nr 784
-Ion_Type3_259	14.285714286	8.571428571	0.504284000	0 # molecule nr 785
-Ion_Type1_525	15.044316286	8.571428571	1.008568000	0 # molecule nr 786
-Ion_Type1_526	15.044316286	8.571428571	0.000000000	0 # molecule nr 787
-Ion_Type3_260	14.285714286	8.571428571	3.361426857	0 # molecule nr 788
-Ion_Type1_527	15.044316286	8.571428571	3.865710857	0 # molecule nr 789
-Ion_Type1_528	15.044316286	8.571428571	2.857142857	0 # molecule nr 790
-Ion_Type3_261	14.285714286	8.571428571	6.218569714	0 # molecule nr 791
-Ion_Type1_529	15.044316286	8.571428571	6.722853714	0 # molecule nr 792
-Ion_Type1_530	15.044316286	8.571428571	5.714285714	0 # molecule nr 793
-Ion_Type3_262	14.285714286	8.571428571	9.075712571	0 # molecule nr 794
-Ion_Type1_531	15.044316286	8.571428571	9.579996571	0 # molecule nr 795
-Ion_Type1_532	15.044316286	8.571428571	8.571428571	0 # molecule nr 796
-Ion_Type3_263	14.285714286	8.571428571	11.932855429	0 # molecule nr 797
-Ion_Type1_533	15.044316286	8.571428571	12.437139429	0 # molecule nr 798
-Ion_Type1_534	15.044316286	8.571428571	11.428571429	0 # molecule nr 799
-Ion_Type3_264	14.285714286	8.571428571	14.789998286	0 # molecule nr 800
-Ion_Type1_535	15.044316286	8.571428571	15.294282286	0 # molecule nr 801
-Ion_Type1_536	15.044316286	8.571428571	14.285714286	0 # molecule nr 802
-Ion_Type3_265	14.285714286	8.571428571	17.647141143	0 # molecule nr 803
-Ion_Type1_537	15.044316286	8.571428571	18.151425143	0 # molecule nr 804
-Ion_Type1_538	15.044316286	8.571428571	17.142857143	0 # molecule nr 805
-Ion_Type3_266	14.285714286	11.428571429	0.504284000	0 # molecule nr 806
-Ion_Type1_539	15.044316286	11.428571429	1.008568000	0 # molecule nr 807
-Ion_Type1_540	15.044316286	11.428571429	0.000000000	0 # molecule nr 808
-Ion_Type3_267	14.285714286	11.428571429	3.361426857	0 # molecule nr 809
-Ion_Type1_541	15.044316286	11.428571429	3.865710857	0 # molecule nr 810
-Ion_Type1_542	15.044316286	11.428571429	2.857142857	0 # molecule nr 811
-Ion_Type3_268	14.285714286	11.428571429	6.218569714	0 # molecule nr 812
-Ion_Type1_543	15.044316286	11.428571429	6.722853714	0 # molecule nr 813
-Ion_Type1_544	15.044316286	11.428571429	5.714285714	0 # molecule nr 814
-Ion_Type3_269	14.285714286	11.428571429	9.075712571	0 # molecule nr 815
-Ion_Type1_545	15.044316286	11.428571429	9.579996571	0 # molecule nr 816
-Ion_Type1_546	15.044316286	11.428571429	8.571428571	0 # molecule nr 817
-Ion_Type3_270	14.285714286	11.428571429	11.932855429	0 # molecule nr 818
-Ion_Type1_547	15.044316286	11.428571429	12.437139429	0 # molecule nr 819
-Ion_Type1_548	15.044316286	11.428571429	11.428571429	0 # molecule nr 820
-Ion_Type3_271	14.285714286	11.428571429	14.789998286	0 # molecule nr 821
-Ion_Type1_549	15.044316286	11.428571429	15.294282286	0 # molecule nr 822
-Ion_Type1_550	15.044316286	11.428571429	14.285714286	0 # molecule nr 823
-Ion_Type3_272	14.285714286	11.428571429	17.647141143	0 # molecule nr 824
-Ion_Type1_551	15.044316286	11.428571429	18.151425143	0 # molecule nr 825
-Ion_Type1_552	15.044316286	11.428571429	17.142857143	0 # molecule nr 826
-Ion_Type3_273	14.285714286	14.285714286	0.504284000	0 # molecule nr 827
-Ion_Type1_553	15.044316286	14.285714286	1.008568000	0 # molecule nr 828
-Ion_Type1_554	15.044316286	14.285714286	0.000000000	0 # molecule nr 829
-Ion_Type3_274	14.285714286	14.285714286	3.361426857	0 # molecule nr 830
-Ion_Type1_555	15.044316286	14.285714286	3.865710857	0 # molecule nr 831
-Ion_Type1_556	15.044316286	14.285714286	2.857142857	0 # molecule nr 832
-Ion_Type3_275	14.285714286	14.285714286	6.218569714	0 # molecule nr 833
-Ion_Type1_557	15.044316286	14.285714286	6.722853714	0 # molecule nr 834
-Ion_Type1_558	15.044316286	14.285714286	5.714285714	0 # molecule nr 835
-Ion_Type3_276	14.285714286	14.285714286	9.075712571	0 # molecule nr 836
-Ion_Type1_559	15.044316286	14.285714286	9.579996571	0 # molecule nr 837
-Ion_Type1_560	15.044316286	14.285714286	8.571428571	0 # molecule nr 838
-Ion_Type3_277	14.285714286	14.285714286	11.932855429	0 # molecule nr 839
-Ion_Type1_561	15.044316286	14.285714286	12.437139429	0 # molecule nr 840
-Ion_Type1_562	15.044316286	14.285714286	11.428571429	0 # molecule nr 841
-Ion_Type3_278	14.285714286	14.285714286	14.789998286	0 # molecule nr 842
-Ion_Type1_563	15.044316286	14.285714286	15.294282286	0 # molecule nr 843
-Ion_Type1_564	15.044316286	14.285714286	14.285714286	0 # molecule nr 844
-Ion_Type3_279	14.285714286	14.285714286	17.647141143	0 # molecule nr 845
-Ion_Type1_565	15.044316286	14.285714286	18.151425143	0 # molecule nr 846
-Ion_Type1_566	15.044316286	14.285714286	17.142857143	0 # molecule nr 847
-Ion_Type3_280	14.285714286	17.142857143	0.504284000	0 # molecule nr 848
-Ion_Type1_567	15.044316286	17.142857143	1.008568000	0 # molecule nr 849
-Ion_Type1_568	15.044316286	17.142857143	0.000000000	0 # molecule nr 850
-Ion_Type3_281	14.285714286	17.142857143	3.361426857	0 # molecule nr 851
-Ion_Type1_569	15.044316286	17.142857143	3.865710857	0 # molecule nr 852
-Ion_Type1_570	15.044316286	17.142857143	2.857142857	0 # molecule nr 853
-Ion_Type3_282	14.285714286	17.142857143	6.218569714	0 # molecule nr 854
-Ion_Type1_571	15.044316286	17.142857143	6.722853714	0 # molecule nr 855
-Ion_Type1_572	15.044316286	17.142857143	5.714285714	0 # molecule nr 856
-Ion_Type3_283	14.285714286	17.142857143	9.075712571	0 # molecule nr 857
-Ion_Type1_573	15.044316286	17.142857143	9.579996571	0 # molecule nr 858
-Ion_Type1_574	15.044316286	17.142857143	8.571428571	0 # molecule nr 859
-Ion_Type3_284	14.285714286	17.142857143	11.932855429	0 # molecule nr 860
-Ion_Type1_575	15.044316286	17.142857143	12.437139429	0 # molecule nr 861
-Ion_Type1_576	15.044316286	17.142857143	11.428571429	0 # molecule nr 862
-Ion_Type3_285	14.285714286	17.142857143	14.789998286	0 # molecule nr 863
-Ion_Type1_577	15.044316286	17.142857143	15.294282286	0 # molecule nr 864
-Ion_Type1_578	15.044316286	17.142857143	14.285714286	0 # molecule nr 865
-Ion_Type3_286	14.285714286	17.142857143	17.647141143	0 # molecule nr 866
-Ion_Type1_579	15.044316286	17.142857143	18.151425143	0 # molecule nr 867
-Ion_Type1_580	15.044316286	17.142857143	17.142857143	0 # molecule nr 868
-Ion_Type3_287	17.142857143	0.000000000	0.504284000	0 # molecule nr 869
-Ion_Type1_581	17.901459143	0.000000000	1.008568000	0 # molecule nr 870
-Ion_Type1_582	17.901459143	0.000000000	0.000000000	0 # molecule nr 871
-Ion_Type3_288	17.142857143	0.000000000	3.361426857	0 # molecule nr 872
-Ion_Type1_583	17.901459143	0.000000000	3.865710857	0 # molecule nr 873
-Ion_Type1_584	17.901459143	0.000000000	2.857142857	0 # molecule nr 874
-Ion_Type3_289	17.142857143	0.000000000	6.218569714	0 # molecule nr 875
-Ion_Type1_585	17.901459143	0.000000000	6.722853714	0 # molecule nr 876
-Ion_Type1_586	17.901459143	0.000000000	5.714285714	0 # molecule nr 877
-Ion_Type3_290	17.142857143	0.000000000	9.075712571	0 # molecule nr 878
-Ion_Type1_587	17.901459143	0.000000000	9.579996571	0 # molecule nr 879
-Ion_Type1_588	17.901459143	0.000000000	8.571428571	0 # molecule nr 880
-Ion_Type3_291	17.142857143	0.000000000	11.932855429	0 # molecule nr 881
-Ion_Type1_589	17.901459143	0.000000000	12.437139429	0 # molecule nr 882
-Ion_Type1_590	17.901459143	0.000000000	11.428571429	0 # molecule nr 883
-Ion_Type3_292	17.142857143	0.000000000	14.789998286	0 # molecule nr 884
-Ion_Type1_591	17.901459143	0.000000000	15.294282286	0 # molecule nr 885
-Ion_Type1_592	17.901459143	0.000000000	14.285714286	0 # molecule nr 886
-Ion_Type3_293	17.142857143	0.000000000	17.647141143	0 # molecule nr 887
-Ion_Type1_593	17.901459143	0.000000000	18.151425143	0 # molecule nr 888
-Ion_Type1_594	17.901459143	0.000000000	17.142857143	0 # molecule nr 889
-Ion_Type3_294	17.142857143	2.857142857	0.504284000	0 # molecule nr 890
-Ion_Type1_595	17.901459143	2.857142857	1.008568000	0 # molecule nr 891
-Ion_Type1_596	17.901459143	2.857142857	0.000000000	0 # molecule nr 892
-Ion_Type3_295	17.142857143	2.857142857	3.361426857	0 # molecule nr 893
-Ion_Type1_597	17.901459143	2.857142857	3.865710857	0 # molecule nr 894
-Ion_Type1_598	17.901459143	2.857142857	2.857142857	0 # molecule nr 895
-Ion_Type3_296	17.142857143	2.857142857	6.218569714	0 # molecule nr 896
-Ion_Type1_599	17.901459143	2.857142857	6.722853714	0 # molecule nr 897
-Ion_Type1_600	17.901459143	2.857142857	5.714285714	0 # molecule nr 898
-Ion_Type3_297	17.142857143	2.857142857	9.075712571	0 # molecule nr 899
-Ion_Type1_601	17.901459143	2.857142857	9.579996571	0 # molecule nr 900
-Ion_Type1_602	17.901459143	2.857142857	8.571428571	0 # molecule nr 901
-Ion_Type3_298	17.142857143	2.857142857	11.932855429	0 # molecule nr 902
-Ion_Type1_603	17.901459143	2.857142857	12.437139429	0 # molecule nr 903
-Ion_Type1_604	17.901459143	2.857142857	11.428571429	0 # molecule nr 904
-Ion_Type3_299	17.142857143	2.857142857	14.789998286	0 # molecule nr 905
-Ion_Type1_605	17.901459143	2.857142857	15.294282286	0 # molecule nr 906
-Ion_Type1_606	17.901459143	2.857142857	14.285714286	0 # molecule nr 907
-Ion_Type3_300	17.142857143	2.857142857	17.647141143	0 # molecule nr 908
-Ion_Type1_607	17.901459143	2.857142857	18.151425143	0 # molecule nr 909
-Ion_Type1_608	17.901459143	2.857142857	17.142857143	0 # molecule nr 910
-Ion_Type3_301	17.142857143	5.714285714	0.504284000	0 # molecule nr 911
-Ion_Type1_609	17.901459143	5.714285714	1.008568000	0 # molecule nr 912
-Ion_Type1_610	17.901459143	5.714285714	0.000000000	0 # molecule nr 913
-Ion_Type3_302	17.142857143	5.714285714	3.361426857	0 # molecule nr 914
-Ion_Type1_611	17.901459143	5.714285714	3.865710857	0 # molecule nr 915
-Ion_Type1_612	17.901459143	5.714285714	2.857142857	0 # molecule nr 916
-Ion_Type3_303	17.142857143	5.714285714	6.218569714	0 # molecule nr 917
-Ion_Type1_613	17.901459143	5.714285714	6.722853714	0 # molecule nr 918
-Ion_Type1_614	17.901459143	5.714285714	5.714285714	0 # molecule nr 919
-Ion_Type3_304	17.142857143	5.714285714	9.075712571	0 # molecule nr 920
-Ion_Type1_615	17.901459143	5.714285714	9.579996571	0 # molecule nr 921
-Ion_Type1_616	17.901459143	5.714285714	8.571428571	0 # molecule nr 922
-Ion_Type3_305	17.142857143	5.714285714	11.932855429	0 # molecule nr 923
-Ion_Type1_617	17.901459143	5.714285714	12.437139429	0 # molecule nr 924
-Ion_Type1_618	17.901459143	5.714285714	11.428571429	0 # molecule nr 925
-Ion_Type3_306	17.142857143	5.714285714	14.789998286	0 # molecule nr 926
-Ion_Type1_619	17.901459143	5.714285714	15.294282286	0 # molecule nr 927
-Ion_Type1_620	17.901459143	5.714285714	14.285714286	0 # molecule nr 928
-Ion_Type3_307	17.142857143	5.714285714	17.647141143	0 # molecule nr 929
-Ion_Type1_621	17.901459143	5.714285714	18.151425143	0 # molecule nr 930
-Ion_Type1_622	17.901459143	5.714285714	17.142857143	0 # molecule nr 931
-Ion_Type3_308	17.142857143	8.571428571	0.504284000	0 # molecule nr 932
-Ion_Type1_623	17.901459143	8.571428571	1.008568000	0 # molecule nr 933
-Ion_Type1_624	17.901459143	8.571428571	0.000000000	0 # molecule nr 934
-Ion_Type3_309	17.142857143	8.571428571	3.361426857	0 # molecule nr 935
-Ion_Type1_625	17.901459143	8.571428571	3.865710857	0 # molecule nr 936
-Ion_Type1_626	17.901459143	8.571428571	2.857142857	0 # molecule nr 937
-Ion_Type3_310	17.142857143	8.571428571	6.218569714	0 # molecule nr 938
-Ion_Type1_627	17.901459143	8.571428571	6.722853714	0 # molecule nr 939
-Ion_Type1_628	17.901459143	8.571428571	5.714285714	0 # molecule nr 940
-Ion_Type3_311	17.142857143	8.571428571	9.075712571	0 # molecule nr 941
-Ion_Type1_629	17.901459143	8.571428571	9.579996571	0 # molecule nr 942
-Ion_Type1_630	17.901459143	8.571428571	8.571428571	0 # molecule nr 943
-Ion_Type3_312	17.142857143	8.571428571	11.932855429	0 # molecule nr 944
-Ion_Type1_631	17.901459143	8.571428571	12.437139429	0 # molecule nr 945
-Ion_Type1_632	17.901459143	8.571428571	11.428571429	0 # molecule nr 946
-Ion_Type3_313	17.142857143	8.571428571	14.789998286	0 # molecule nr 947
-Ion_Type1_633	17.901459143	8.571428571	15.294282286	0 # molecule nr 948
-Ion_Type1_634	17.901459143	8.571428571	14.285714286	0 # molecule nr 949
-Ion_Type3_314	17.142857143	8.571428571	17.647141143	0 # molecule nr 950
-Ion_Type1_635	17.901459143	8.571428571	18.151425143	0 # molecule nr 951
-Ion_Type1_636	17.901459143	8.571428571	17.142857143	0 # molecule nr 952
-Ion_Type3_315	17.142857143	11.428571429	0.504284000	0 # molecule nr 953
-Ion_Type1_637	17.901459143	11.428571429	1.008568000	0 # molecule nr 954
-Ion_Type1_638	17.901459143	11.428571429	0.000000000	0 # molecule nr 955
-Ion_Type3_316	17.142857143	11.428571429	3.361426857	0 # molecule nr 956
-Ion_Type1_639	17.901459143	11.428571429	3.865710857	0 # molecule nr 957
-Ion_Type1_640	17.901459143	11.428571429	2.857142857	0 # molecule nr 958
-Ion_Type3_317	17.142857143	11.428571429	6.218569714	0 # molecule nr 959
-Ion_Type1_641	17.901459143	11.428571429	6.722853714	0 # molecule nr 960
-Ion_Type1_642	17.901459143	11.428571429	5.714285714	0 # molecule nr 961
-Ion_Type3_318	17.142857143	11.428571429	9.075712571	0 # molecule nr 962
-Ion_Type1_643	17.901459143	11.428571429	9.579996571	0 # molecule nr 963
-Ion_Type1_644	17.901459143	11.428571429	8.571428571	0 # molecule nr 964
-Ion_Type3_319	17.142857143	11.428571429	11.932855429	0 # molecule nr 965
-Ion_Type1_645	17.901459143	11.428571429	12.437139429	0 # molecule nr 966
-Ion_Type1_646	17.901459143	11.428571429	11.428571429	0 # molecule nr 967
-Ion_Type3_320	17.142857143	11.428571429	14.789998286	0 # molecule nr 968
-Ion_Type1_647	17.901459143	11.428571429	15.294282286	0 # molecule nr 969
-Ion_Type1_648	17.901459143	11.428571429	14.285714286	0 # molecule nr 970
-Ion_Type3_321	17.142857143	11.428571429	17.647141143	0 # molecule nr 971
-Ion_Type1_649	17.901459143	11.428571429	18.151425143	0 # molecule nr 972
-Ion_Type1_650	17.901459143	11.428571429	17.142857143	0 # molecule nr 973
-Ion_Type3_322	17.142857143	14.285714286	0.504284000	0 # molecule nr 974
-Ion_Type1_651	17.901459143	14.285714286	1.008568000	0 # molecule nr 975
-Ion_Type1_652	17.901459143	14.285714286	0.000000000	0 # molecule nr 976
-Ion_Type3_323	17.142857143	14.285714286	3.361426857	0 # molecule nr 977
-Ion_Type1_653	17.901459143	14.285714286	3.865710857	0 # molecule nr 978
-Ion_Type1_654	17.901459143	14.285714286	2.857142857	0 # molecule nr 979
-Ion_Type3_324	17.142857143	14.285714286	6.218569714	0 # molecule nr 980
-Ion_Type1_655	17.901459143	14.285714286	6.722853714	0 # molecule nr 981
-Ion_Type1_656	17.901459143	14.285714286	5.714285714	0 # molecule nr 982
-Ion_Type3_325	17.142857143	14.285714286	9.075712571	0 # molecule nr 983
-Ion_Type1_657	17.901459143	14.285714286	9.579996571	0 # molecule nr 984
-Ion_Type1_658	17.901459143	14.285714286	8.571428571	0 # molecule nr 985
-Ion_Type3_326	17.142857143	14.285714286	11.932855429	0 # molecule nr 986
-Ion_Type1_659	17.901459143	14.285714286	12.437139429	0 # molecule nr 987
-Ion_Type1_660	17.901459143	14.285714286	11.428571429	0 # molecule nr 988
-Ion_Type3_327	17.142857143	14.285714286	14.789998286	0 # molecule nr 989
-Ion_Type1_661	17.901459143	14.285714286	15.294282286	0 # molecule nr 990
-Ion_Type1_662	17.901459143	14.285714286	14.285714286	0 # molecule nr 991
-Ion_Type3_328	17.142857143	14.285714286	17.647141143	0 # molecule nr 992
-Ion_Type1_663	17.901459143	14.285714286	18.151425143	0 # molecule nr 993
-Ion_Type1_664	17.901459143	14.285714286	17.142857143	0 # molecule nr 994
-Ion_Type3_329	17.142857143	17.142857143	0.504284000	0 # molecule nr 995
-Ion_Type1_665	17.901459143	17.142857143	1.008568000	0 # molecule nr 996
-Ion_Type1_666	17.901459143	17.142857143	0.000000000	0 # molecule nr 997
-Ion_Type3_330	17.142857143	17.142857143	3.361426857	0 # molecule nr 998
-Ion_Type1_667	17.901459143	17.142857143	3.865710857	0 # molecule nr 999
-Ion_Type1_668	17.901459143	17.142857143	2.857142857	0 # molecule nr 1000
-Ion_Type3_331	17.142857143	17.142857143	6.218569714	0 # molecule nr 1001
-Ion_Type1_669	17.901459143	17.142857143	6.722853714	0 # molecule nr 1002
-Ion_Type1_670	17.901459143	17.142857143	5.714285714	0 # molecule nr 1003
-Ion_Type3_332	17.142857143	17.142857143	9.075712571	0 # molecule nr 1004
-Ion_Type1_671	17.901459143	17.142857143	9.579996571	0 # molecule nr 1005
-Ion_Type1_672	17.901459143	17.142857143	8.571428571	0 # molecule nr 1006
-Ion_Type3_333	17.142857143	17.142857143	11.932855429	0 # molecule nr 1007
-Ion_Type1_673	17.901459143	17.142857143	12.437139429	0 # molecule nr 1008
-Ion_Type1_674	17.901459143	17.142857143	11.428571429	0 # molecule nr 1009
-Ion_Type3_334	17.142857143	17.142857143	14.789998286	0 # molecule nr 1010
-Ion_Type1_675	17.901459143	17.142857143	15.294282286	0 # molecule nr 1011
-Ion_Type1_676	17.901459143	17.142857143	14.285714286	0 # molecule nr 1012
-Ion_Type3_335	17.142857143	17.142857143	17.647141143	0 # molecule nr 1013
-Ion_Type1_677	17.901459143	17.142857143	18.151425143	0 # molecule nr 1014
-Ion_Type1_678	17.901459143	17.142857143	17.142857143	0 # molecule nr 1015
Index: tests/regression/Simple_configuration/8/pre/test.xyz
===================================================================
--- tests/regression/Simple_configuration/8/pre/test.xyz	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
+++ tests/regression/Simple_configuration/8/pre/test.xyz	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -0,0 +1,1018 @@
+1016
+	Created by molecuilder on Mon Aug  9 19:15:41 2010
+H	9.78209	2.64589	2.64589
+H	9.78209	2.64589	4.42589
+H	10.672	3.90454	3.53589
+H	8.53279	4.78789	2.64589
+H	8.53279	4.78789	4.42589
+H	6.39363	3.90454	3.53589
+H	7.28359	2.64589	2.64589
+H	7.28359	2.64589	4.42589
+H	0.758602	0	1.00857
+H	0.758602	0	0
+H	0.758602	0	3.86571
+H	0.758602	0	2.85714
+H	0.758602	0	6.72285
+H	0.758602	0	5.71429
+H	0.758602	0	9.58
+H	0.758602	0	8.57143
+H	0.758602	0	12.4371
+H	0.758602	0	11.4286
+H	0.758602	0	15.2943
+H	0.758602	0	14.2857
+H	0.758602	0	18.1514
+H	0.758602	0	17.1429
+H	0.758602	2.85714	1.00857
+H	0.758602	2.85714	0
+H	0.758602	2.85714	3.86571
+H	0.758602	2.85714	2.85714
+H	0.758602	2.85714	6.72285
+H	0.758602	2.85714	5.71429
+H	0.758602	2.85714	9.58
+H	0.758602	2.85714	8.57143
+H	0.758602	2.85714	12.4371
+H	0.758602	2.85714	11.4286
+H	0.758602	2.85714	15.2943
+H	0.758602	2.85714	14.2857
+H	0.758602	2.85714	18.1514
+H	0.758602	2.85714	17.1429
+H	0.758602	5.71429	1.00857
+H	0.758602	5.71429	0
+H	0.758602	5.71429	3.86571
+H	0.758602	5.71429	2.85714
+H	0.758602	5.71429	6.72285
+H	0.758602	5.71429	5.71429
+H	0.758602	5.71429	9.58
+H	0.758602	5.71429	8.57143
+H	0.758602	5.71429	12.4371
+H	0.758602	5.71429	11.4286
+H	0.758602	5.71429	15.2943
+H	0.758602	5.71429	14.2857
+H	0.758602	5.71429	18.1514
+H	0.758602	5.71429	17.1429
+H	0.758602	8.57143	1.00857
+H	0.758602	8.57143	0
+H	0.758602	8.57143	3.86571
+H	0.758602	8.57143	2.85714
+H	0.758602	8.57143	6.72285
+H	0.758602	8.57143	5.71429
+H	0.758602	8.57143	9.58
+H	0.758602	8.57143	8.57143
+H	0.758602	8.57143	12.4371
+H	0.758602	8.57143	11.4286
+H	0.758602	8.57143	15.2943
+H	0.758602	8.57143	14.2857
+H	0.758602	8.57143	18.1514
+H	0.758602	8.57143	17.1429
+H	0.758602	11.4286	1.00857
+H	0.758602	11.4286	0
+H	0.758602	11.4286	3.86571
+H	0.758602	11.4286	2.85714
+H	0.758602	11.4286	6.72285
+H	0.758602	11.4286	5.71429
+H	0.758602	11.4286	9.58
+H	0.758602	11.4286	8.57143
+H	0.758602	11.4286	12.4371
+H	0.758602	11.4286	11.4286
+H	0.758602	11.4286	15.2943
+H	0.758602	11.4286	14.2857
+H	0.758602	11.4286	18.1514
+H	0.758602	11.4286	17.1429
+H	0.758602	14.2857	1.00857
+H	0.758602	14.2857	0
+H	0.758602	14.2857	3.86571
+H	0.758602	14.2857	2.85714
+H	0.758602	14.2857	6.72285
+H	0.758602	14.2857	5.71429
+H	0.758602	14.2857	9.58
+H	0.758602	14.2857	8.57143
+H	0.758602	14.2857	12.4371
+H	0.758602	14.2857	11.4286
+H	0.758602	14.2857	15.2943
+H	0.758602	14.2857	14.2857
+H	0.758602	14.2857	18.1514
+H	0.758602	14.2857	17.1429
+H	0.758602	17.1429	1.00857
+H	0.758602	17.1429	0
+H	0.758602	17.1429	3.86571
+H	0.758602	17.1429	2.85714
+H	0.758602	17.1429	6.72285
+H	0.758602	17.1429	5.71429
+H	0.758602	17.1429	9.58
+H	0.758602	17.1429	8.57143
+H	0.758602	17.1429	12.4371
+H	0.758602	17.1429	11.4286
+H	0.758602	17.1429	15.2943
+H	0.758602	17.1429	14.2857
+H	0.758602	17.1429	18.1514
+H	0.758602	17.1429	17.1429
+H	3.61574	0	1.00857
+H	3.61574	0	0
+H	3.61574	0	3.86571
+H	3.61574	0	2.85714
+H	3.61574	0	6.72285
+H	3.61574	0	5.71429
+H	3.61574	0	9.58
+H	3.61574	0	8.57143
+H	3.61574	0	12.4371
+H	3.61574	0	11.4286
+H	3.61574	0	15.2943
+H	3.61574	0	14.2857
+H	3.61574	0	18.1514
+H	3.61574	0	17.1429
+H	3.61574	2.85714	1.00857
+H	3.61574	2.85714	0
+H	3.61574	2.85714	3.86571
+H	3.61574	2.85714	2.85714
+H	3.61574	2.85714	6.72285
+H	3.61574	2.85714	5.71429
+H	3.61574	2.85714	9.58
+H	3.61574	2.85714	8.57143
+H	3.61574	2.85714	12.4371
+H	3.61574	2.85714	11.4286
+H	3.61574	2.85714	15.2943
+H	3.61574	2.85714	14.2857
+H	3.61574	2.85714	18.1514
+H	3.61574	2.85714	17.1429
+H	3.61574	5.71429	1.00857
+H	3.61574	5.71429	0
+H	3.61574	5.71429	3.86571
+H	3.61574	5.71429	2.85714
+H	3.61574	5.71429	6.72285
+H	3.61574	5.71429	5.71429
+H	3.61574	5.71429	9.58
+H	3.61574	5.71429	8.57143
+H	3.61574	5.71429	12.4371
+H	3.61574	5.71429	11.4286
+H	3.61574	5.71429	15.2943
+H	3.61574	5.71429	14.2857
+H	3.61574	5.71429	18.1514
+H	3.61574	5.71429	17.1429
+H	3.61574	8.57143	1.00857
+H	3.61574	8.57143	0
+H	3.61574	8.57143	3.86571
+H	3.61574	8.57143	2.85714
+H	3.61574	8.57143	6.72285
+H	3.61574	8.57143	5.71429
+H	3.61574	8.57143	9.58
+H	3.61574	8.57143	8.57143
+H	3.61574	8.57143	12.4371
+H	3.61574	8.57143	11.4286
+H	3.61574	8.57143	15.2943
+H	3.61574	8.57143	14.2857
+H	3.61574	8.57143	18.1514
+H	3.61574	8.57143	17.1429
+H	3.61574	11.4286	1.00857
+H	3.61574	11.4286	0
+H	3.61574	11.4286	3.86571
+H	3.61574	11.4286	2.85714
+H	3.61574	11.4286	6.72285
+H	3.61574	11.4286	5.71429
+H	3.61574	11.4286	9.58
+H	3.61574	11.4286	8.57143
+H	3.61574	11.4286	12.4371
+H	3.61574	11.4286	11.4286
+H	3.61574	11.4286	15.2943
+H	3.61574	11.4286	14.2857
+H	3.61574	11.4286	18.1514
+H	3.61574	11.4286	17.1429
+H	3.61574	14.2857	1.00857
+H	3.61574	14.2857	0
+H	3.61574	14.2857	3.86571
+H	3.61574	14.2857	2.85714
+H	3.61574	14.2857	6.72285
+H	3.61574	14.2857	5.71429
+H	3.61574	14.2857	9.58
+H	3.61574	14.2857	8.57143
+H	3.61574	14.2857	12.4371
+H	3.61574	14.2857	11.4286
+H	3.61574	14.2857	15.2943
+H	3.61574	14.2857	14.2857
+H	3.61574	14.2857	18.1514
+H	3.61574	14.2857	17.1429
+H	3.61574	17.1429	1.00857
+H	3.61574	17.1429	0
+H	3.61574	17.1429	3.86571
+H	3.61574	17.1429	2.85714
+H	3.61574	17.1429	6.72285
+H	3.61574	17.1429	5.71429
+H	3.61574	17.1429	9.58
+H	3.61574	17.1429	8.57143
+H	3.61574	17.1429	12.4371
+H	3.61574	17.1429	11.4286
+H	3.61574	17.1429	15.2943
+H	3.61574	17.1429	14.2857
+H	3.61574	17.1429	18.1514
+H	3.61574	17.1429	17.1429
+H	6.47289	0	1.00857
+H	6.47289	0	0
+H	6.47289	0	3.86571
+H	6.47289	0	2.85714
+H	6.47289	0	6.72285
+H	6.47289	0	5.71429
+H	6.47289	0	9.58
+H	6.47289	0	8.57143
+H	6.47289	0	12.4371
+H	6.47289	0	11.4286
+H	6.47289	0	15.2943
+H	6.47289	0	14.2857
+H	6.47289	0	18.1514
+H	6.47289	0	17.1429
+H	6.47289	2.85714	0
+H	6.47289	2.85714	6.72285
+H	6.47289	2.85714	9.58
+H	6.47289	2.85714	8.57143
+H	6.47289	2.85714	12.4371
+H	6.47289	2.85714	11.4286
+H	6.47289	2.85714	15.2943
+H	6.47289	2.85714	14.2857
+H	6.47289	2.85714	18.1514
+H	6.47289	2.85714	17.1429
+H	6.47289	5.71429	1.00857
+H	6.47289	5.71429	0
+H	6.47289	5.71429	6.72285
+H	6.47289	5.71429	5.71429
+H	6.47289	5.71429	9.58
+H	6.47289	5.71429	8.57143
+H	6.47289	5.71429	12.4371
+H	6.47289	5.71429	11.4286
+H	6.47289	5.71429	15.2943
+H	6.47289	5.71429	14.2857
+H	6.47289	5.71429	18.1514
+H	6.47289	5.71429	17.1429
+H	6.47289	8.57143	1.00857
+H	6.47289	8.57143	0
+H	6.47289	8.57143	3.86571
+H	6.47289	8.57143	2.85714
+H	6.47289	8.57143	6.72285
+H	6.47289	8.57143	5.71429
+H	6.47289	8.57143	9.58
+H	6.47289	8.57143	8.57143
+H	6.47289	8.57143	12.4371
+H	6.47289	8.57143	11.4286
+H	6.47289	8.57143	15.2943
+H	6.47289	8.57143	14.2857
+H	6.47289	8.57143	18.1514
+H	6.47289	8.57143	17.1429
+H	6.47289	11.4286	1.00857
+H	6.47289	11.4286	0
+H	6.47289	11.4286	3.86571
+H	6.47289	11.4286	2.85714
+H	6.47289	11.4286	6.72285
+H	6.47289	11.4286	5.71429
+H	6.47289	11.4286	9.58
+H	6.47289	11.4286	8.57143
+H	6.47289	11.4286	12.4371
+H	6.47289	11.4286	11.4286
+H	6.47289	11.4286	15.2943
+H	6.47289	11.4286	14.2857
+H	6.47289	11.4286	18.1514
+H	6.47289	11.4286	17.1429
+H	6.47289	14.2857	1.00857
+H	6.47289	14.2857	0
+H	6.47289	14.2857	3.86571
+H	6.47289	14.2857	2.85714
+H	6.47289	14.2857	6.72285
+H	6.47289	14.2857	5.71429
+H	6.47289	14.2857	9.58
+H	6.47289	14.2857	8.57143
+H	6.47289	14.2857	12.4371
+H	6.47289	14.2857	11.4286
+H	6.47289	14.2857	15.2943
+H	6.47289	14.2857	14.2857
+H	6.47289	14.2857	18.1514
+H	6.47289	14.2857	17.1429
+H	6.47289	17.1429	1.00857
+H	6.47289	17.1429	0
+H	6.47289	17.1429	3.86571
+H	6.47289	17.1429	2.85714
+H	6.47289	17.1429	6.72285
+H	6.47289	17.1429	5.71429
+H	6.47289	17.1429	9.58
+H	6.47289	17.1429	8.57143
+H	6.47289	17.1429	12.4371
+H	6.47289	17.1429	11.4286
+H	6.47289	17.1429	15.2943
+H	6.47289	17.1429	14.2857
+H	6.47289	17.1429	18.1514
+H	6.47289	17.1429	17.1429
+H	9.33003	0	1.00857
+H	9.33003	0	0
+H	9.33003	0	3.86571
+H	9.33003	0	2.85714
+H	9.33003	0	6.72285
+H	9.33003	0	5.71429
+H	9.33003	0	9.58
+H	9.33003	0	8.57143
+H	9.33003	0	12.4371
+H	9.33003	0	11.4286
+H	9.33003	0	15.2943
+H	9.33003	0	14.2857
+H	9.33003	0	18.1514
+H	9.33003	0	17.1429
+H	9.33003	2.85714	0
+H	9.33003	2.85714	6.72285
+H	9.33003	2.85714	9.58
+H	9.33003	2.85714	8.57143
+H	9.33003	2.85714	12.4371
+H	9.33003	2.85714	11.4286
+H	9.33003	2.85714	15.2943
+H	9.33003	2.85714	14.2857
+H	9.33003	2.85714	18.1514
+H	9.33003	2.85714	17.1429
+H	9.33003	5.71429	0
+H	9.33003	5.71429	6.72285
+H	9.33003	5.71429	9.58
+H	9.33003	5.71429	8.57143
+H	9.33003	5.71429	12.4371
+H	9.33003	5.71429	11.4286
+H	9.33003	5.71429	15.2943
+H	9.33003	5.71429	14.2857
+H	9.33003	5.71429	18.1514
+H	9.33003	5.71429	17.1429
+H	9.33003	8.57143	1.00857
+H	9.33003	8.57143	0
+H	9.33003	8.57143	3.86571
+H	9.33003	8.57143	2.85714
+H	9.33003	8.57143	6.72285
+H	9.33003	8.57143	5.71429
+H	9.33003	8.57143	9.58
+H	9.33003	8.57143	8.57143
+H	9.33003	8.57143	12.4371
+H	9.33003	8.57143	11.4286
+H	9.33003	8.57143	15.2943
+H	9.33003	8.57143	14.2857
+H	9.33003	8.57143	18.1514
+H	9.33003	8.57143	17.1429
+H	9.33003	11.4286	1.00857
+H	9.33003	11.4286	0
+H	9.33003	11.4286	3.86571
+H	9.33003	11.4286	2.85714
+H	9.33003	11.4286	6.72285
+H	9.33003	11.4286	5.71429
+H	9.33003	11.4286	9.58
+H	9.33003	11.4286	8.57143
+H	9.33003	11.4286	12.4371
+H	9.33003	11.4286	11.4286
+H	9.33003	11.4286	15.2943
+H	9.33003	11.4286	14.2857
+H	9.33003	11.4286	18.1514
+H	9.33003	11.4286	17.1429
+H	9.33003	14.2857	1.00857
+H	9.33003	14.2857	0
+H	9.33003	14.2857	3.86571
+H	9.33003	14.2857	2.85714
+H	9.33003	14.2857	6.72285
+H	9.33003	14.2857	5.71429
+H	9.33003	14.2857	9.58
+H	9.33003	14.2857	8.57143
+H	9.33003	14.2857	12.4371
+H	9.33003	14.2857	11.4286
+H	9.33003	14.2857	15.2943
+H	9.33003	14.2857	14.2857
+H	9.33003	14.2857	18.1514
+H	9.33003	14.2857	17.1429
+H	9.33003	17.1429	1.00857
+H	9.33003	17.1429	0
+H	9.33003	17.1429	3.86571
+H	9.33003	17.1429	2.85714
+H	9.33003	17.1429	6.72285
+H	9.33003	17.1429	5.71429
+H	9.33003	17.1429	9.58
+H	9.33003	17.1429	8.57143
+H	9.33003	17.1429	12.4371
+H	9.33003	17.1429	11.4286
+H	9.33003	17.1429	15.2943
+H	9.33003	17.1429	14.2857
+H	9.33003	17.1429	18.1514
+H	9.33003	17.1429	17.1429
+H	12.1872	0	1.00857
+H	12.1872	0	0
+H	12.1872	0	3.86571
+H	12.1872	0	2.85714
+H	12.1872	0	6.72285
+H	12.1872	0	5.71429
+H	12.1872	0	9.58
+H	12.1872	0	8.57143
+H	12.1872	0	12.4371
+H	12.1872	0	11.4286
+H	12.1872	0	15.2943
+H	12.1872	0	14.2857
+H	12.1872	0	18.1514
+H	12.1872	0	17.1429
+H	12.1872	2.85714	1.00857
+H	12.1872	2.85714	0
+H	12.1872	2.85714	6.72285
+H	12.1872	2.85714	5.71429
+H	12.1872	2.85714	9.58
+H	12.1872	2.85714	8.57143
+H	12.1872	2.85714	12.4371
+H	12.1872	2.85714	11.4286
+H	12.1872	2.85714	15.2943
+H	12.1872	2.85714	14.2857
+H	12.1872	2.85714	18.1514
+H	12.1872	2.85714	17.1429
+H	12.1872	5.71429	1.00857
+H	12.1872	5.71429	0
+H	12.1872	5.71429	3.86571
+H	12.1872	5.71429	2.85714
+H	12.1872	5.71429	6.72285
+H	12.1872	5.71429	5.71429
+H	12.1872	5.71429	9.58
+H	12.1872	5.71429	8.57143
+H	12.1872	5.71429	12.4371
+H	12.1872	5.71429	11.4286
+H	12.1872	5.71429	15.2943
+H	12.1872	5.71429	14.2857
+H	12.1872	5.71429	18.1514
+H	12.1872	5.71429	17.1429
+H	12.1872	8.57143	1.00857
+H	12.1872	8.57143	0
+H	12.1872	8.57143	3.86571
+H	12.1872	8.57143	2.85714
+H	12.1872	8.57143	6.72285
+H	12.1872	8.57143	5.71429
+H	12.1872	8.57143	9.58
+H	12.1872	8.57143	8.57143
+H	12.1872	8.57143	12.4371
+H	12.1872	8.57143	11.4286
+H	12.1872	8.57143	15.2943
+H	12.1872	8.57143	14.2857
+H	12.1872	8.57143	18.1514
+H	12.1872	8.57143	17.1429
+H	12.1872	11.4286	1.00857
+H	12.1872	11.4286	0
+H	12.1872	11.4286	3.86571
+H	12.1872	11.4286	2.85714
+H	12.1872	11.4286	6.72285
+H	12.1872	11.4286	5.71429
+H	12.1872	11.4286	9.58
+H	12.1872	11.4286	8.57143
+H	12.1872	11.4286	12.4371
+H	12.1872	11.4286	11.4286
+H	12.1872	11.4286	15.2943
+H	12.1872	11.4286	14.2857
+H	12.1872	11.4286	18.1514
+H	12.1872	11.4286	17.1429
+H	12.1872	14.2857	1.00857
+H	12.1872	14.2857	0
+H	12.1872	14.2857	3.86571
+H	12.1872	14.2857	2.85714
+H	12.1872	14.2857	6.72285
+H	12.1872	14.2857	5.71429
+H	12.1872	14.2857	9.58
+H	12.1872	14.2857	8.57143
+H	12.1872	14.2857	12.4371
+H	12.1872	14.2857	11.4286
+H	12.1872	14.2857	15.2943
+H	12.1872	14.2857	14.2857
+H	12.1872	14.2857	18.1514
+H	12.1872	14.2857	17.1429
+H	12.1872	17.1429	1.00857
+H	12.1872	17.1429	0
+H	12.1872	17.1429	3.86571
+H	12.1872	17.1429	2.85714
+H	12.1872	17.1429	6.72285
+H	12.1872	17.1429	5.71429
+H	12.1872	17.1429	9.58
+H	12.1872	17.1429	8.57143
+H	12.1872	17.1429	12.4371
+H	12.1872	17.1429	11.4286
+H	12.1872	17.1429	15.2943
+H	12.1872	17.1429	14.2857
+H	12.1872	17.1429	18.1514
+H	12.1872	17.1429	17.1429
+H	15.0443	0	1.00857
+H	15.0443	0	0
+H	15.0443	0	3.86571
+H	15.0443	0	2.85714
+H	15.0443	0	6.72285
+H	15.0443	0	5.71429
+H	15.0443	0	9.58
+H	15.0443	0	8.57143
+H	15.0443	0	12.4371
+H	15.0443	0	11.4286
+H	15.0443	0	15.2943
+H	15.0443	0	14.2857
+H	15.0443	0	18.1514
+H	15.0443	0	17.1429
+H	15.0443	2.85714	1.00857
+H	15.0443	2.85714	0
+H	15.0443	2.85714	3.86571
+H	15.0443	2.85714	2.85714
+H	15.0443	2.85714	6.72285
+H	15.0443	2.85714	5.71429
+H	15.0443	2.85714	9.58
+H	15.0443	2.85714	8.57143
+H	15.0443	2.85714	12.4371
+H	15.0443	2.85714	11.4286
+H	15.0443	2.85714	15.2943
+H	15.0443	2.85714	14.2857
+H	15.0443	2.85714	18.1514
+H	15.0443	2.85714	17.1429
+H	15.0443	5.71429	1.00857
+H	15.0443	5.71429	0
+H	15.0443	5.71429	3.86571
+H	15.0443	5.71429	2.85714
+H	15.0443	5.71429	6.72285
+H	15.0443	5.71429	5.71429
+H	15.0443	5.71429	9.58
+H	15.0443	5.71429	8.57143
+H	15.0443	5.71429	12.4371
+H	15.0443	5.71429	11.4286
+H	15.0443	5.71429	15.2943
+H	15.0443	5.71429	14.2857
+H	15.0443	5.71429	18.1514
+H	15.0443	5.71429	17.1429
+H	15.0443	8.57143	1.00857
+H	15.0443	8.57143	0
+H	15.0443	8.57143	3.86571
+H	15.0443	8.57143	2.85714
+H	15.0443	8.57143	6.72285
+H	15.0443	8.57143	5.71429
+H	15.0443	8.57143	9.58
+H	15.0443	8.57143	8.57143
+H	15.0443	8.57143	12.4371
+H	15.0443	8.57143	11.4286
+H	15.0443	8.57143	15.2943
+H	15.0443	8.57143	14.2857
+H	15.0443	8.57143	18.1514
+H	15.0443	8.57143	17.1429
+H	15.0443	11.4286	1.00857
+H	15.0443	11.4286	0
+H	15.0443	11.4286	3.86571
+H	15.0443	11.4286	2.85714
+H	15.0443	11.4286	6.72285
+H	15.0443	11.4286	5.71429
+H	15.0443	11.4286	9.58
+H	15.0443	11.4286	8.57143
+H	15.0443	11.4286	12.4371
+H	15.0443	11.4286	11.4286
+H	15.0443	11.4286	15.2943
+H	15.0443	11.4286	14.2857
+H	15.0443	11.4286	18.1514
+H	15.0443	11.4286	17.1429
+H	15.0443	14.2857	1.00857
+H	15.0443	14.2857	0
+H	15.0443	14.2857	3.86571
+H	15.0443	14.2857	2.85714
+H	15.0443	14.2857	6.72285
+H	15.0443	14.2857	5.71429
+H	15.0443	14.2857	9.58
+H	15.0443	14.2857	8.57143
+H	15.0443	14.2857	12.4371
+H	15.0443	14.2857	11.4286
+H	15.0443	14.2857	15.2943
+H	15.0443	14.2857	14.2857
+H	15.0443	14.2857	18.1514
+H	15.0443	14.2857	17.1429
+H	15.0443	17.1429	1.00857
+H	15.0443	17.1429	0
+H	15.0443	17.1429	3.86571
+H	15.0443	17.1429	2.85714
+H	15.0443	17.1429	6.72285
+H	15.0443	17.1429	5.71429
+H	15.0443	17.1429	9.58
+H	15.0443	17.1429	8.57143
+H	15.0443	17.1429	12.4371
+H	15.0443	17.1429	11.4286
+H	15.0443	17.1429	15.2943
+H	15.0443	17.1429	14.2857
+H	15.0443	17.1429	18.1514
+H	15.0443	17.1429	17.1429
+H	17.9015	0	1.00857
+H	17.9015	0	0
+H	17.9015	0	3.86571
+H	17.9015	0	2.85714
+H	17.9015	0	6.72285
+H	17.9015	0	5.71429
+H	17.9015	0	9.58
+H	17.9015	0	8.57143
+H	17.9015	0	12.4371
+H	17.9015	0	11.4286
+H	17.9015	0	15.2943
+H	17.9015	0	14.2857
+H	17.9015	0	18.1514
+H	17.9015	0	17.1429
+H	17.9015	2.85714	1.00857
+H	17.9015	2.85714	0
+H	17.9015	2.85714	3.86571
+H	17.9015	2.85714	2.85714
+H	17.9015	2.85714	6.72285
+H	17.9015	2.85714	5.71429
+H	17.9015	2.85714	9.58
+H	17.9015	2.85714	8.57143
+H	17.9015	2.85714	12.4371
+H	17.9015	2.85714	11.4286
+H	17.9015	2.85714	15.2943
+H	17.9015	2.85714	14.2857
+H	17.9015	2.85714	18.1514
+H	17.9015	2.85714	17.1429
+H	17.9015	5.71429	1.00857
+H	17.9015	5.71429	0
+H	17.9015	5.71429	3.86571
+H	17.9015	5.71429	2.85714
+H	17.9015	5.71429	6.72285
+H	17.9015	5.71429	5.71429
+H	17.9015	5.71429	9.58
+H	17.9015	5.71429	8.57143
+H	17.9015	5.71429	12.4371
+H	17.9015	5.71429	11.4286
+H	17.9015	5.71429	15.2943
+H	17.9015	5.71429	14.2857
+H	17.9015	5.71429	18.1514
+H	17.9015	5.71429	17.1429
+H	17.9015	8.57143	1.00857
+H	17.9015	8.57143	0
+H	17.9015	8.57143	3.86571
+H	17.9015	8.57143	2.85714
+H	17.9015	8.57143	6.72285
+H	17.9015	8.57143	5.71429
+H	17.9015	8.57143	9.58
+H	17.9015	8.57143	8.57143
+H	17.9015	8.57143	12.4371
+H	17.9015	8.57143	11.4286
+H	17.9015	8.57143	15.2943
+H	17.9015	8.57143	14.2857
+H	17.9015	8.57143	18.1514
+H	17.9015	8.57143	17.1429
+H	17.9015	11.4286	1.00857
+H	17.9015	11.4286	0
+H	17.9015	11.4286	3.86571
+H	17.9015	11.4286	2.85714
+H	17.9015	11.4286	6.72285
+H	17.9015	11.4286	5.71429
+H	17.9015	11.4286	9.58
+H	17.9015	11.4286	8.57143
+H	17.9015	11.4286	12.4371
+H	17.9015	11.4286	11.4286
+H	17.9015	11.4286	15.2943
+H	17.9015	11.4286	14.2857
+H	17.9015	11.4286	18.1514
+H	17.9015	11.4286	17.1429
+H	17.9015	14.2857	1.00857
+H	17.9015	14.2857	0
+H	17.9015	14.2857	3.86571
+H	17.9015	14.2857	2.85714
+H	17.9015	14.2857	6.72285
+H	17.9015	14.2857	5.71429
+H	17.9015	14.2857	9.58
+H	17.9015	14.2857	8.57143
+H	17.9015	14.2857	12.4371
+H	17.9015	14.2857	11.4286
+H	17.9015	14.2857	15.2943
+H	17.9015	14.2857	14.2857
+H	17.9015	14.2857	18.1514
+H	17.9015	14.2857	17.1429
+H	17.9015	17.1429	1.00857
+H	17.9015	17.1429	0
+H	17.9015	17.1429	3.86571
+H	17.9015	17.1429	2.85714
+H	17.9015	17.1429	6.72285
+H	17.9015	17.1429	5.71429
+H	17.9015	17.1429	9.58
+H	17.9015	17.1429	8.57143
+H	17.9015	17.1429	12.4371
+H	17.9015	17.1429	11.4286
+H	17.9015	17.1429	15.2943
+H	17.9015	17.1429	14.2857
+H	17.9015	17.1429	18.1514
+H	17.9015	17.1429	17.1429
+C	9.78209	3.27519	3.53589
+C	8.53279	4.15859	3.53589
+C	7.28359	3.27519	3.53589
+O	0	0	0.504284
+O	0	0	3.36143
+O	0	0	6.21857
+O	0	0	9.07571
+O	0	0	11.9329
+O	0	0	14.79
+O	0	0	17.6471
+O	0	2.85714	0.504284
+O	0	2.85714	3.36143
+O	0	2.85714	6.21857
+O	0	2.85714	9.07571
+O	0	2.85714	11.9329
+O	0	2.85714	14.79
+O	0	2.85714	17.6471
+O	0	5.71429	0.504284
+O	0	5.71429	3.36143
+O	0	5.71429	6.21857
+O	0	5.71429	9.07571
+O	0	5.71429	11.9329
+O	0	5.71429	14.79
+O	0	5.71429	17.6471
+O	0	8.57143	0.504284
+O	0	8.57143	3.36143
+O	0	8.57143	6.21857
+O	0	8.57143	9.07571
+O	0	8.57143	11.9329
+O	0	8.57143	14.79
+O	0	8.57143	17.6471
+O	0	11.4286	0.504284
+O	0	11.4286	3.36143
+O	0	11.4286	6.21857
+O	0	11.4286	9.07571
+O	0	11.4286	11.9329
+O	0	11.4286	14.79
+O	0	11.4286	17.6471
+O	0	14.2857	0.504284
+O	0	14.2857	3.36143
+O	0	14.2857	6.21857
+O	0	14.2857	9.07571
+O	0	14.2857	11.9329
+O	0	14.2857	14.79
+O	0	14.2857	17.6471
+O	0	17.1429	0.504284
+O	0	17.1429	3.36143
+O	0	17.1429	6.21857
+O	0	17.1429	9.07571
+O	0	17.1429	11.9329
+O	0	17.1429	14.79
+O	0	17.1429	17.6471
+O	2.85714	0	0.504284
+O	2.85714	0	3.36143
+O	2.85714	0	6.21857
+O	2.85714	0	9.07571
+O	2.85714	0	11.9329
+O	2.85714	0	14.79
+O	2.85714	0	17.6471
+O	2.85714	2.85714	0.504284
+O	2.85714	2.85714	3.36143
+O	2.85714	2.85714	6.21857
+O	2.85714	2.85714	9.07571
+O	2.85714	2.85714	11.9329
+O	2.85714	2.85714	14.79
+O	2.85714	2.85714	17.6471
+O	2.85714	5.71429	0.504284
+O	2.85714	5.71429	3.36143
+O	2.85714	5.71429	6.21857
+O	2.85714	5.71429	9.07571
+O	2.85714	5.71429	11.9329
+O	2.85714	5.71429	14.79
+O	2.85714	5.71429	17.6471
+O	2.85714	8.57143	0.504284
+O	2.85714	8.57143	3.36143
+O	2.85714	8.57143	6.21857
+O	2.85714	8.57143	9.07571
+O	2.85714	8.57143	11.9329
+O	2.85714	8.57143	14.79
+O	2.85714	8.57143	17.6471
+O	2.85714	11.4286	0.504284
+O	2.85714	11.4286	3.36143
+O	2.85714	11.4286	6.21857
+O	2.85714	11.4286	9.07571
+O	2.85714	11.4286	11.9329
+O	2.85714	11.4286	14.79
+O	2.85714	11.4286	17.6471
+O	2.85714	14.2857	0.504284
+O	2.85714	14.2857	3.36143
+O	2.85714	14.2857	6.21857
+O	2.85714	14.2857	9.07571
+O	2.85714	14.2857	11.9329
+O	2.85714	14.2857	14.79
+O	2.85714	14.2857	17.6471
+O	2.85714	17.1429	0.504284
+O	2.85714	17.1429	3.36143
+O	2.85714	17.1429	6.21857
+O	2.85714	17.1429	9.07571
+O	2.85714	17.1429	11.9329
+O	2.85714	17.1429	14.79
+O	2.85714	17.1429	17.6471
+O	5.71429	0	0.504284
+O	5.71429	0	3.36143
+O	5.71429	0	6.21857
+O	5.71429	0	9.07571
+O	5.71429	0	11.9329
+O	5.71429	0	14.79
+O	5.71429	0	17.6471
+O	5.71429	2.85714	0.504284
+O	5.71429	2.85714	6.21857
+O	5.71429	2.85714	9.07571
+O	5.71429	2.85714	11.9329
+O	5.71429	2.85714	14.79
+O	5.71429	2.85714	17.6471
+O	5.71429	5.71429	0.504284
+O	5.71429	5.71429	6.21857
+O	5.71429	5.71429	9.07571
+O	5.71429	5.71429	11.9329
+O	5.71429	5.71429	14.79
+O	5.71429	5.71429	17.6471
+O	5.71429	8.57143	0.504284
+O	5.71429	8.57143	3.36143
+O	5.71429	8.57143	6.21857
+O	5.71429	8.57143	9.07571
+O	5.71429	8.57143	11.9329
+O	5.71429	8.57143	14.79
+O	5.71429	8.57143	17.6471
+O	5.71429	11.4286	0.504284
+O	5.71429	11.4286	3.36143
+O	5.71429	11.4286	6.21857
+O	5.71429	11.4286	9.07571
+O	5.71429	11.4286	11.9329
+O	5.71429	11.4286	14.79
+O	5.71429	11.4286	17.6471
+O	5.71429	14.2857	0.504284
+O	5.71429	14.2857	3.36143
+O	5.71429	14.2857	6.21857
+O	5.71429	14.2857	9.07571
+O	5.71429	14.2857	11.9329
+O	5.71429	14.2857	14.79
+O	5.71429	14.2857	17.6471
+O	5.71429	17.1429	0.504284
+O	5.71429	17.1429	3.36143
+O	5.71429	17.1429	6.21857
+O	5.71429	17.1429	9.07571
+O	5.71429	17.1429	11.9329
+O	5.71429	17.1429	14.79
+O	5.71429	17.1429	17.6471
+O	8.57143	0	0.504284
+O	8.57143	0	3.36143
+O	8.57143	0	6.21857
+O	8.57143	0	9.07571
+O	8.57143	0	11.9329
+O	8.57143	0	14.79
+O	8.57143	0	17.6471
+O	8.57143	2.85714	0.504284
+O	8.57143	2.85714	9.07571
+O	8.57143	2.85714	11.9329
+O	8.57143	2.85714	14.79
+O	8.57143	2.85714	17.6471
+O	8.57143	5.71429	0.504284
+O	8.57143	5.71429	9.07571
+O	8.57143	5.71429	11.9329
+O	8.57143	5.71429	14.79
+O	8.57143	5.71429	17.6471
+O	8.57143	8.57143	0.504284
+O	8.57143	8.57143	3.36143
+O	8.57143	8.57143	6.21857
+O	8.57143	8.57143	9.07571
+O	8.57143	8.57143	11.9329
+O	8.57143	8.57143	14.79
+O	8.57143	8.57143	17.6471
+O	8.57143	11.4286	0.504284
+O	8.57143	11.4286	3.36143
+O	8.57143	11.4286	6.21857
+O	8.57143	11.4286	9.07571
+O	8.57143	11.4286	11.9329
+O	8.57143	11.4286	14.79
+O	8.57143	11.4286	17.6471
+O	8.57143	14.2857	0.504284
+O	8.57143	14.2857	3.36143
+O	8.57143	14.2857	6.21857
+O	8.57143	14.2857	9.07571
+O	8.57143	14.2857	11.9329
+O	8.57143	14.2857	14.79
+O	8.57143	14.2857	17.6471
+O	8.57143	17.1429	0.504284
+O	8.57143	17.1429	3.36143
+O	8.57143	17.1429	6.21857
+O	8.57143	17.1429	9.07571
+O	8.57143	17.1429	11.9329
+O	8.57143	17.1429	14.79
+O	8.57143	17.1429	17.6471
+O	11.4286	0	0.504284
+O	11.4286	0	3.36143
+O	11.4286	0	6.21857
+O	11.4286	0	9.07571
+O	11.4286	0	11.9329
+O	11.4286	0	14.79
+O	11.4286	0	17.6471
+O	11.4286	2.85714	0.504284
+O	11.4286	2.85714	6.21857
+O	11.4286	2.85714	9.07571
+O	11.4286	2.85714	11.9329
+O	11.4286	2.85714	14.79
+O	11.4286	2.85714	17.6471
+O	11.4286	5.71429	0.504284
+O	11.4286	5.71429	6.21857
+O	11.4286	5.71429	9.07571
+O	11.4286	5.71429	11.9329
+O	11.4286	5.71429	14.79
+O	11.4286	5.71429	17.6471
+O	11.4286	8.57143	0.504284
+O	11.4286	8.57143	3.36143
+O	11.4286	8.57143	6.21857
+O	11.4286	8.57143	9.07571
+O	11.4286	8.57143	11.9329
+O	11.4286	8.57143	14.79
+O	11.4286	8.57143	17.6471
+O	11.4286	11.4286	0.504284
+O	11.4286	11.4286	3.36143
+O	11.4286	11.4286	6.21857
+O	11.4286	11.4286	9.07571
+O	11.4286	11.4286	11.9329
+O	11.4286	11.4286	14.79
+O	11.4286	11.4286	17.6471
+O	11.4286	14.2857	0.504284
+O	11.4286	14.2857	3.36143
+O	11.4286	14.2857	6.21857
+O	11.4286	14.2857	9.07571
+O	11.4286	14.2857	11.9329
+O	11.4286	14.2857	14.79
+O	11.4286	14.2857	17.6471
+O	11.4286	17.1429	0.504284
+O	11.4286	17.1429	3.36143
+O	11.4286	17.1429	6.21857
+O	11.4286	17.1429	9.07571
+O	11.4286	17.1429	11.9329
+O	11.4286	17.1429	14.79
+O	11.4286	17.1429	17.6471
+O	14.2857	0	0.504284
+O	14.2857	0	3.36143
+O	14.2857	0	6.21857
+O	14.2857	0	9.07571
+O	14.2857	0	11.9329
+O	14.2857	0	14.79
+O	14.2857	0	17.6471
+O	14.2857	2.85714	0.504284
+O	14.2857	2.85714	3.36143
+O	14.2857	2.85714	6.21857
+O	14.2857	2.85714	9.07571
+O	14.2857	2.85714	11.9329
+O	14.2857	2.85714	14.79
+O	14.2857	2.85714	17.6471
+O	14.2857	5.71429	0.504284
+O	14.2857	5.71429	3.36143
+O	14.2857	5.71429	6.21857
+O	14.2857	5.71429	9.07571
+O	14.2857	5.71429	11.9329
+O	14.2857	5.71429	14.79
+O	14.2857	5.71429	17.6471
+O	14.2857	8.57143	0.504284
+O	14.2857	8.57143	3.36143
+O	14.2857	8.57143	6.21857
+O	14.2857	8.57143	9.07571
+O	14.2857	8.57143	11.9329
+O	14.2857	8.57143	14.79
+O	14.2857	8.57143	17.6471
+O	14.2857	11.4286	0.504284
+O	14.2857	11.4286	3.36143
+O	14.2857	11.4286	6.21857
+O	14.2857	11.4286	9.07571
+O	14.2857	11.4286	11.9329
+O	14.2857	11.4286	14.79
+O	14.2857	11.4286	17.6471
+O	14.2857	14.2857	0.504284
+O	14.2857	14.2857	3.36143
+O	14.2857	14.2857	6.21857
+O	14.2857	14.2857	9.07571
+O	14.2857	14.2857	11.9329
+O	14.2857	14.2857	14.79
+O	14.2857	14.2857	17.6471
+O	14.2857	17.1429	0.504284
+O	14.2857	17.1429	3.36143
+O	14.2857	17.1429	6.21857
+O	14.2857	17.1429	9.07571
+O	14.2857	17.1429	11.9329
+O	14.2857	17.1429	14.79
+O	14.2857	17.1429	17.6471
+O	17.1429	0	0.504284
+O	17.1429	0	3.36143
+O	17.1429	0	6.21857
+O	17.1429	0	9.07571
+O	17.1429	0	11.9329
+O	17.1429	0	14.79
+O	17.1429	0	17.6471
+O	17.1429	2.85714	0.504284
+O	17.1429	2.85714	3.36143
+O	17.1429	2.85714	6.21857
+O	17.1429	2.85714	9.07571
+O	17.1429	2.85714	11.9329
+O	17.1429	2.85714	14.79
+O	17.1429	2.85714	17.6471
+O	17.1429	5.71429	0.504284
+O	17.1429	5.71429	3.36143
+O	17.1429	5.71429	6.21857
+O	17.1429	5.71429	9.07571
+O	17.1429	5.71429	11.9329
+O	17.1429	5.71429	14.79
+O	17.1429	5.71429	17.6471
+O	17.1429	8.57143	0.504284
+O	17.1429	8.57143	3.36143
+O	17.1429	8.57143	6.21857
+O	17.1429	8.57143	9.07571
+O	17.1429	8.57143	11.9329
+O	17.1429	8.57143	14.79
+O	17.1429	8.57143	17.6471
+O	17.1429	11.4286	0.504284
+O	17.1429	11.4286	3.36143
+O	17.1429	11.4286	6.21857
+O	17.1429	11.4286	9.07571
+O	17.1429	11.4286	11.9329
+O	17.1429	11.4286	14.79
+O	17.1429	11.4286	17.6471
+O	17.1429	14.2857	0.504284
+O	17.1429	14.2857	3.36143
+O	17.1429	14.2857	6.21857
+O	17.1429	14.2857	9.07571
+O	17.1429	14.2857	11.9329
+O	17.1429	14.2857	14.79
+O	17.1429	14.2857	17.6471
+O	17.1429	17.1429	0.504284
+O	17.1429	17.1429	3.36143
+O	17.1429	17.1429	6.21857
+O	17.1429	17.1429	9.07571
+O	17.1429	17.1429	11.9329
+O	17.1429	17.1429	14.79
+O	17.1429	17.1429	17.6471
Index: tests/regression/Simple_configuration/9/post/test-shifted.xyz
===================================================================
--- tests/regression/Simple_configuration/9/post/test-shifted.xyz	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
+++ tests/regression/Simple_configuration/9/post/test-shifted.xyz	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -0,0 +1,3 @@
+1
+	Created by molecuilder on Mon Aug  9 17:31:25 2010
+H	1	0	0
Index: tests/regression/Simple_configuration/9/post/test.xyz
===================================================================
--- tests/regression/Simple_configuration/9/post/test.xyz	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
+++ tests/regression/Simple_configuration/9/post/test.xyz	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -0,0 +1,3 @@
+1
+	Created by molecuilder on Mon Aug  9 17:31:25 2010
+H	0	0	0
Index: tests/regression/Simple_configuration/9/pre/test.xyz
===================================================================
--- tests/regression/Simple_configuration/9/pre/test.xyz	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
+++ tests/regression/Simple_configuration/9/pre/test.xyz	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -0,0 +1,3 @@
+1
+	Created by molecuilder on Mon Aug  9 17:31:25 2010
+H	0	0	0
Index: tests/regression/testsuite-analysis.at
===================================================================
--- tests/regression/testsuite-analysis.at	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ tests/regression/testsuite-analysis.at	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -4,5 +4,5 @@
 AT_KEYWORDS([analysis])
 AT_CHECK([/bin/cp -f ${abs_top_srcdir}/${AUTOTEST_PATH}/Analysis/1/pre/test.conf .], 0)
-AT_CHECK([../../molecuilder -i test.conf -e ${abs_top_srcdir}/src/ -v 3 -C E --elements 1 8 --output-file output.csv --bin-output-file bin_output.csv --bin-start 0 --bin-end 20], 0, [stdout], [stderr])
+AT_CHECK([../../molecuilder -i test.conf -e ${abs_top_srcdir}/src/ -v 3 --select-all-molecules --pair-correlation --elements 1 8 --output-file output.csv --bin-output-file bin_output.csv --bin-start 0 --bin-end 20], 0, [stdout], [stderr])
 AT_CHECK([fgrep "Begin of PairCorrelation" stdout], 0, [ignore], [ignore])
 #AT_CHECK([file=output.csv; diff $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Analysis/1/post/$file], 0, [ignore], [ignore])
@@ -14,11 +14,11 @@
 AT_KEYWORDS([analysis])
 AT_CHECK([/bin/cp -f ${abs_top_srcdir}/${AUTOTEST_PATH}/Analysis/2/pre/test.conf .], 0)
-AT_CHECK([../../molecuilder -i test.conf -e ${abs_top_srcdir}/src/ -v 3 -C E --elements 1 8 --output-file output-5.csv --bin-output-file bin_output-5.csv --bin-start 0 --bin-end 5], 0, [stdout], [stderr])
+AT_CHECK([../../molecuilder -i test.conf -e ${abs_top_srcdir}/src/ -v 3 --select-all-molecules --pair-correlation --elements 1 8 --output-file output-5.csv --bin-output-file bin_output-5.csv --bin-start 0 --bin-end 5], 0, [stdout], [stderr])
 #AT_CHECK([file=output-5.csv; diff $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Analysis/2/post/$file], 0, [ignore], [ignore])
 AT_CHECK([file=bin_output-5.csv; diff $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Analysis/2/post/$file], 0, [ignore], [ignore])
-AT_CHECK([../../molecuilder -i test.conf -e ${abs_top_srcdir}/src/ -v 3 -C E --elements 1 8 --output-file output-10.csv --bin-output-file bin_output-10.csv --bin-start 5 --bin-end 10], 0, [stdout], [stderr])
+AT_CHECK([../../molecuilder -i test.conf -e ${abs_top_srcdir}/src/ -v 3 --select-all-molecules --pair-correlation --elements 1 8 --output-file output-10.csv --bin-output-file bin_output-10.csv --bin-start 5 --bin-end 10], 0, [stdout], [stderr])
 #AT_CHECK([file=output-10.csv; diff $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Analysis/2/post/$file], 0, [ignore], [ignore])
 AT_CHECK([file=bin_output-10.csv; diff $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Analysis/2/post/$file], 0, [ignore], [ignore])
-AT_CHECK([../../molecuilder -i test.conf -e ${abs_top_srcdir}/src/ -v 3 -C E --elements 1 8 --output-file output-20.csv --bin-output-file bin_output-20.csv --bin-start 10 --bin-end 20], 0, [stdout], [stderr])
+AT_CHECK([../../molecuilder -i test.conf -e ${abs_top_srcdir}/src/ -v 3 --select-all-molecules --pair-correlation --elements 1 8 --output-file output-20.csv --bin-output-file bin_output-20.csv --bin-start 10 --bin-end 20], 0, [stdout], [stderr])
 #AT_CHECK([file=output-20.csv; diff $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Analysis/2/post/$file], 0, [ignore], [ignore])
 AT_CHECK([file=bin_output-20.csv; diff $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Analysis/2/post/$file], 0, [ignore], [ignore])
@@ -29,5 +29,5 @@
 AT_KEYWORDS([analysis])
 AT_CHECK([/bin/cp -f ${abs_top_srcdir}/${AUTOTEST_PATH}/Analysis/3/pre/test.conf .], 0)
-AT_CHECK([../../molecuilder -i test.conf -e ${abs_top_srcdir}/src/ -v 7 -C P --elements 1 --position "10., 10., 10." --output-file output.csv --bin-output-file bin_output.csv --bin-start 0 --bin-end 20], 0, [stdout], [stderr])
+AT_CHECK([../../molecuilder -i test.conf -e ${abs_top_srcdir}/src/ -v 7 --select-all-molecules --point-correlation --elements 1 --position "10., 10., 10." --output-file output.csv --bin-output-file bin_output.csv --bin-start 0 --bin-end 20], 0, [stdout], [stderr])
 AT_CHECK([fgrep "Begin of CorrelationToPoint" stdout], 0, [ignore], [ignore])
 #AT_CHECK([file=output.csv; diff $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Analysis/3/post/$file], 0, [ignore], [ignore])
@@ -39,5 +39,5 @@
 AT_KEYWORDS([analysis])
 AT_CHECK([/bin/cp -f ${abs_top_srcdir}/${AUTOTEST_PATH}/Analysis/4/pre/test.conf .], 0)
-AT_CHECK([../../molecuilder -i test.conf -e ${abs_top_srcdir}/src/ -v 3 -I -C S --elements 1 --output-file output.csv --bin-output-file bin_output.csv --bin-start 0 --bin-width 1. --bin-end 20 --molecule-by-id 208], 0, [stdout], [stderr])
+AT_CHECK([../../molecuilder -i test.conf -e ${abs_top_srcdir}/src/ -v 3 -I --select-all-molecules --unselect-molecule-by-formula C3H8 --surface-correlation --elements 1 --output-file output.csv --bin-output-file bin_output.csv --bin-start 0 --bin-width 1. --bin-end 20 --molecule-by-id 1], 0, [stdout], [stderr])
 AT_CHECK([fgrep "Begin of CorrelationToSurface" stdout], 0, [ignore], [ignore])
 #AT_CHECK([file=output.csv; diff $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Analysis/4/post/$file], 0, [ignore], [ignore])
Index: tests/regression/testsuite-filling.at
===================================================================
--- tests/regression/testsuite-filling.at	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ tests/regression/testsuite-filling.at	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -18,5 +18,5 @@
 AT_KEYWORDS([filling])
 AT_CHECK([/bin/cp -f ${abs_top_srcdir}/${AUTOTEST_PATH}/Filling/2/pre/test.conf .], 0)
-AT_CHECK([../../molecuilder -i test.conf -e ${abs_top_srcdir}/src/ -v 3 -u 1.3 --molecule-by-id 0], 0, [stdout], [stderr])
+AT_CHECK([../../molecuilder -i test.conf -e ${abs_top_srcdir}/src/ -v 3 --select-molecule-by-id 0 -u 1.3], 0, [stdout], [stderr])
 #AT_CHECK([file=test.conf; diff $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Filling/2/post/$file], 0, [ignore], [ignore])
 AT_CLEANUP
Index: tests/regression/testsuite-fragmentation.at
===================================================================
--- tests/regression/testsuite-fragmentation.at	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ tests/regression/testsuite-fragmentation.at	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -12,5 +12,5 @@
 AT_SETUP([Fragmentation - Fragmentation])
 AT_CHECK([/bin/cp -f ${abs_top_srcdir}/${AUTOTEST_PATH}/Fragmentation/2/pre/test.conf .], 0)
-AT_CHECK([../../molecuilder -i test.conf -e ${abs_top_srcdir}/src/ -v 1 -f ./BondFragment --molecule-by-id 0 --distance 1.55 --order 2], 0, [ignore], [ignore])
+AT_CHECK([../../molecuilder -i test.conf -e ${abs_top_srcdir}/src/ -v 1 --select-molecule-by-id 0 -f ./BondFragment --distance 1.55 --order 2], 0, [ignore], [ignore])
 AT_CHECK([ls -l BondFragment*.conf | wc -l], 0, [5
 ], [ignore])
@@ -21,5 +21,5 @@
 AT_SETUP([Fragmentation - BROKEN: Fragmentation is at MaxOrder])
 AT_CHECK([/bin/cp -f ${abs_top_srcdir}/${AUTOTEST_PATH}/Fragmentation/3/pre/test.conf .], 0)
-AT_CHECK([../../molecuilder -i test.conf -e ${abs_top_srcdir}/src/ -v 1 -f ./BondFragment --molecule-by-id 0 --distance 1.55 --order 2], 0, [ignore], [ignore])
-AT_CHECK([../../molecuilder -i test.conf -e ${abs_top_srcdir}/src/ -v 1 -f ./BondFragment --molecule-by-id 0 --distance 1.55 --order 2], [ignore], [ignore], [ignore])
+AT_CHECK([../../molecuilder -i test.conf -e ${abs_top_srcdir}/src/ -v 1 --select-molecule-by-id 0 -f ./BondFragment --distance 1.55 --order 2], 0, [ignore], [ignore])
+AT_CHECK([../../molecuilder -i test.conf -e ${abs_top_srcdir}/src/ -v 1 --select-molecule-by-id 0 -f ./BondFragment --distance 1.55 --order 2], [ignore], [ignore], [ignore])
 AT_CLEANUP
Index: tests/regression/testsuite-graph.at
===================================================================
--- tests/regression/testsuite-graph.at	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ tests/regression/testsuite-graph.at	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -16,2 +16,16 @@
 AT_CLEANUP
 
+AT_SETUP([Graph - subgraph dissection with Undo/Redo])
+AT_KEYWORDS([graph])
+AT_CHECK([/bin/cp -f ${abs_top_srcdir}/${AUTOTEST_PATH}/Graph/2/pre/test.conf .], 0)
+AT_CHECK([../../molecuilder -i test.conf -e ${abs_top_srcdir}/src/ -v 3 -I], 0, [stdout], [stderr])
+AT_CHECK([fgrep "I scanned 31 molecules." stdout], 0, [ignore], [ignore])
+AT_CHECK([/bin/cp -f ${abs_top_srcdir}/${AUTOTEST_PATH}/Graph/2/pre/test.conf .], 0)
+AT_CHECK([../../molecuilder -i test.conf -e ${abs_top_srcdir}/src/ -v 3 -I --undo], 0, [stdout], [stderr])
+AT_CHECK([fgrep "I scanned 31 molecules." stdout], 0, [ignore], [ignore])
+AT_CHECK([/bin/cp -f ${abs_top_srcdir}/${AUTOTEST_PATH}/Graph/2/pre/test.conf .], 0)
+AT_CHECK([../../molecuilder -i test.conf -e ${abs_top_srcdir}/src/ -v 3 -I --undo --redo], 0, [stdout], [stderr])
+AT_CHECK([grep -c "I scanned 31 molecules." stdout], 0, [2
+], [ignore])
+AT_CLEANUP
+
Index: tests/regression/testsuite-molecules.at
===================================================================
--- tests/regression/testsuite-molecules.at	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ tests/regression/testsuite-molecules.at	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -4,5 +4,5 @@
 AT_KEYWORDS([Molecules])
 AT_CHECK([/bin/cp -f ${abs_top_srcdir}/${AUTOTEST_PATH}/Molecules/1/pre/test.* .], 0)
-AT_CHECK([../../molecuilder -i test.conf -e ${abs_top_srcdir}/src/ -v 4 -A test.dbond --molecule-by-id 0], 0, [stdout], [stderr])
+AT_CHECK([../../molecuilder -i test.conf -e ${abs_top_srcdir}/src/ -v 4 --select-molecule-by-id 0 -A test.dbond], 0, [stdout], [stderr])
 AT_CHECK([fgrep "Looking for atoms 2 and 9." stdout], 0, [ignore], [ignore])
 AT_CLEANUP
@@ -12,7 +12,7 @@
 AT_KEYWORDS([Molecules])
 AT_CHECK([/bin/cp -f ${abs_top_srcdir}/${AUTOTEST_PATH}/Molecules/2/pre/test.conf .], 0)
-AT_CHECK([../../molecuilder -i test.conf -e ${abs_top_srcdir}/src/ -v 1 -j test.dbond --molecule-by-id 0], 0, [stdout], [stderr])
+AT_CHECK([../../molecuilder -i test.conf -e ${abs_top_srcdir}/src/ -v 1 --select-molecule-by-id 0 -j test.dbond], 0, [stdout], [stderr])
 AT_CHECK([file=test.dbond; diff $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Molecules/2/post/$file], 0, [ignore], [ignore])
-AT_CHECK([../../molecuilder -i test.conf -e ${abs_top_srcdir}/src/ -v 1 -J test.adj --molecule-by-id 0], 0, [stdout], [stderr])
+AT_CHECK([../../molecuilder -i test.conf -e ${abs_top_srcdir}/src/ -v 1 --select-molecule-by-id 0 -J test.adj], 0, [stdout], [stderr])
 AT_CHECK([file=test.adj; diff $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Molecules/2/post/$file], 0, [ignore], [ignore])
 AT_CLEANUP
@@ -22,5 +22,5 @@
 AT_KEYWORDS([Molecules])
 AT_CHECK([/bin/cp -f ${abs_top_srcdir}/${AUTOTEST_PATH}/Molecules/3/pre/test.conf .], 0)
-AT_CHECK([../../molecuilder -i test.conf -e ${abs_top_srcdir}/src/ -S test.ekin --molecule-by-id 0], 0, [stdout], [stderr])
+AT_CHECK([../../molecuilder -i test.conf -e ${abs_top_srcdir}/src/ --select-molecule-by-id 0 -S test.ekin], 0, [stdout], [stderr])
 AT_CHECK([file=test.ekin; diff $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Molecules/3/post/$file], 0, [ignore], [ignore])
 AT_CLEANUP
@@ -30,5 +30,5 @@
 AT_KEYWORDS([Molecules])
 AT_CHECK([/bin/cp -f ${abs_top_srcdir}/${AUTOTEST_PATH}/Molecules/4/pre/test.conf .], 0)
-AT_CHECK([../../molecuilder -i test.conf -e ${abs_top_srcdir}/src/ -L teststep --start-step 0 --end-step 1 --molecule-by-id 0 --id-mapping 1], 0, [stdout], [stderr])
+AT_CHECK([../../molecuilder -i test.conf -e ${abs_top_srcdir}/src/ --select-molecule-by-id 0 -L teststep --start-step 0 --end-step 1 --id-mapping 1], 0, [stdout], [stderr])
 AT_CLEANUP
 
@@ -37,5 +37,5 @@
 AT_KEYWORDS([Molecules])
 AT_CHECK([/bin/cp -f ${abs_top_srcdir}/${AUTOTEST_PATH}/Molecules/5/pre/test.* .], 0)
-AT_CHECK([../../molecuilder -i test.conf -e ${abs_top_srcdir}/src/ -P test.forces --molecule-by-id 0], 0, [stdout], [stderr])
+AT_CHECK([../../molecuilder -i test.conf -e ${abs_top_srcdir}/src/ --select-molecule-by-id 0 -P test.forces], 0, [stdout], [stderr])
 #AT_CHECK([file=test.conf; diff $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Molecules/5/post/$file], 0, [ignore], [ignore])
 AT_CLEANUP
@@ -45,25 +45,59 @@
 AT_KEYWORDS([Molecules])
 AT_CHECK([/bin/cp -f ${abs_top_srcdir}/${AUTOTEST_PATH}/Molecules/6/pre/test.* .], 0)
-AT_CHECK([../../molecuilder -i test.conf -e ${abs_top_srcdir}/src/ -t "1., 1., 1." --molecule-by-id 0 --periodic 0], 0, [stdout], [stderr])
+AT_CHECK([../../molecuilder -i test.conf -e ${abs_top_srcdir}/src/ --select-molecules-atoms 0 -t "1., 1., 1." --periodic 0], 0, [stdout], [stderr])
 AT_CHECK([file=test.conf; diff $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Molecules/6/post/$file], 0, [ignore], [ignore])
 AT_CHECK([/bin/cp -f ${abs_top_srcdir}/${AUTOTEST_PATH}/Molecules/6/pre/test2.* .], 0)
-AT_CHECK([../../molecuilder -i test2.conf -e ${abs_top_srcdir}/src/ -t "-1., -1., -1." --molecule-by-id 0 --periodic 0], 0, [stdout], [stderr])
+AT_CHECK([../../molecuilder -i test2.conf -e ${abs_top_srcdir}/src/ --select-molecules-atoms 0 -t "-1., -1., -1." --periodic 0], 0, [stdout], [stderr])
 AT_CHECK([file=test2.conf; diff $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Molecules/6/post/$file], 0, [ignore], [ignore])
 AT_CLEANUP
 
-# 7. Periodic translation
-AT_SETUP([Molecules - Periodic translation])
+# 8. Rotate to PAS
+AT_SETUP([Molecules - Rotate to PAS])
 AT_KEYWORDS([Molecules])
-AT_CHECK([/bin/cp -f ${abs_top_srcdir}/${AUTOTEST_PATH}/Molecules/7/pre/test.* .], 0)
-AT_CHECK([../../molecuilder -i test.conf -e ${abs_top_srcdir}/src/ -t "12., 12., 12." --molecule-by-id 0 --periodic 1], 0, [stdout], [stderr])
-AT_CHECK([file=test.conf; diff $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Molecules/7/post/$file], 0, [ignore], [ignore])
+AT_CHECK([/bin/cp -f ${abs_top_srcdir}/${AUTOTEST_PATH}/Molecules/8/pre/test-*.xyz .], 0)
+AT_CHECK([../../molecuilder -i test-rotated-z90.xyz -e ${abs_top_srcdir}/src/ --select-molecule-by-id 0 -m "0,0,1"], 0, [stdout], [stderr])
+AT_CHECK([file="test-rotated-z90.xyz"; diff $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Molecules/8/post/$file], 0, [ignore], [ignore])
+AT_CHECK([../../molecuilder -i test-rotated-z180.xyz -e ${abs_top_srcdir}/src/ --select-molecule-by-id 0 -m "0,0,1"], 0, [stdout], [stderr])
+AT_CHECK([file="test-rotated-z180.xyz"; diff $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Molecules/8/post/$file], 0, [ignore], [ignore])
+AT_CHECK([../../molecuilder -i test-rotated-z360.xyz -e ${abs_top_srcdir}/src/ --select-molecule-by-id 0 -m "0,0,1"], 0, [stdout], [stderr])
+AT_CHECK([file="test-rotated-z360.xyz"; diff $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Molecules/8/post/$file], 0, [ignore], [ignore])
+AT_CHECK([../../molecuilder -i test-rotated-xYz20.xyz -e ${abs_top_srcdir}/src/ --select-molecule-by-id 0 -m "0,0,1"], 0, [stdout], [stderr])
+AT_CHECK([file="test-rotated-xYz20.xyz"; diff $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Molecules/8/post/$file], 0, [ignore], [ignore])
 AT_CLEANUP
 
-# 8. Rotate to PAS
-AT_SETUP([Molecules - BROKEN: Rotate to PAS])
+# 9. Rotate around origin
+AT_SETUP([Molecules - Rotate around origin])
 AT_KEYWORDS([Molecules])
-AT_CHECK([/bin/cp -f ${abs_top_srcdir}/${AUTOTEST_PATH}/Molecules/8/pre/test.* .], 0)
-AT_CHECK([../../molecuilder -i test.conf -e ${abs_top_srcdir}/src/ -m 0], 0, [stdout], [stderr])
-#AT_CHECK([file=test.conf; diff $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Molecules/8/post/$file], 0, [ignore], [ignore])
+AT_CHECK([/bin/cp -f ${abs_top_srcdir}/${AUTOTEST_PATH}/Molecules/9/pre/test.xyz .], 0)
+AT_CHECK([../../molecuilder -i test.xyz -e ${abs_top_srcdir}/src/ --select-all-atoms --rotate-origin 90. --position "0,0,1"], 0, [stdout], [stderr])
+AT_CHECK([diff test.xyz ${abs_top_srcdir}/${AUTOTEST_PATH}/Molecules/9/post/test-rotated-z90.xyz], 0, [ignore], [ignore])
+AT_CHECK([/bin/cp -f ${abs_top_srcdir}/${AUTOTEST_PATH}/Molecules/9/pre/test.xyz .], 0)
+AT_CHECK([../../molecuilder -i test.xyz -e ${abs_top_srcdir}/src/ --select-all-atoms --rotate-origin 180. --position "0,0,1"], 0, [stdout], [stderr])
+AT_CHECK([diff test.xyz ${abs_top_srcdir}/${AUTOTEST_PATH}/Molecules/9/post/test-rotated-z180.xyz], 0, [ignore], [ignore])
+AT_CHECK([/bin/cp -f ${abs_top_srcdir}/${AUTOTEST_PATH}/Molecules/9/pre/test.xyz .], 0)
+AT_CHECK([../../molecuilder -i test.xyz -e ${abs_top_srcdir}/src/ --select-all-atoms --rotate-origin 360. --position "0,0,1"], 0, [stdout], [stderr])
+AT_CHECK([diff test.xyz ${abs_top_srcdir}/${AUTOTEST_PATH}/Molecules/9/post/test-rotated-z360.xyz], 0, [ignore], [ignore])
+AT_CHECK([diff test.xyz ${abs_top_srcdir}/${AUTOTEST_PATH}/Molecules/9/pre/test.xyz], 0, [ignore], [ignore])
+AT_CHECK([/bin/cp -f ${abs_top_srcdir}/${AUTOTEST_PATH}/Molecules/9/pre/test.xyz .], 0)
+AT_CHECK([../../molecuilder -i test.xyz -e ${abs_top_srcdir}/src/ --select-all-atoms --rotate-origin 20. --position "1,2,1"], 0, [stdout], [stderr])
+AT_CHECK([diff test.xyz ${abs_top_srcdir}/${AUTOTEST_PATH}/Molecules/9/post/test-rotated-xYz20.xyz], 0, [ignore], [ignore])
 AT_CLEANUP
 
+# 10. Rotate around self
+AT_SETUP([Molecules - Rotate around self])
+AT_KEYWORDS([Molecules])
+AT_CHECK([/bin/cp -f ${abs_top_srcdir}/${AUTOTEST_PATH}/Molecules/10/pre/test.xyz .], 0)
+AT_CHECK([../../molecuilder -i test.xyz -e ${abs_top_srcdir}/src/ --select-all-molecules --rotate-self 90. --position "0,0,1"], 0, [stdout], [stderr])
+AT_CHECK([diff test.xyz ${abs_top_srcdir}/${AUTOTEST_PATH}/Molecules/10/post/test-rotated-z90.xyz], 0, [ignore], [ignore])
+AT_CHECK([/bin/cp -f ${abs_top_srcdir}/${AUTOTEST_PATH}/Molecules/10/pre/test.xyz .], 0)
+AT_CHECK([../../molecuilder -i test.xyz -e ${abs_top_srcdir}/src/ --select-all-molecules --rotate-self 180. --position "0,0,1"], 0, [stdout], [stderr])
+AT_CHECK([diff test.xyz ${abs_top_srcdir}/${AUTOTEST_PATH}/Molecules/10/post/test-rotated-z180.xyz], 0, [ignore], [ignore])
+AT_CHECK([/bin/cp -f ${abs_top_srcdir}/${AUTOTEST_PATH}/Molecules/10/pre/test.xyz .], 0)
+AT_CHECK([../../molecuilder -i test.xyz -e ${abs_top_srcdir}/src/ --select-all-molecules --rotate-self 360. --position "0,0,1"], 0, [stdout], [stderr])
+AT_CHECK([diff test.xyz ${abs_top_srcdir}/${AUTOTEST_PATH}/Molecules/10/post/test-rotated-z360.xyz], 0, [ignore], [ignore])
+AT_CHECK([diff test.xyz ${abs_top_srcdir}/${AUTOTEST_PATH}/Molecules/10/pre/test.xyz], 0, [ignore], [ignore])
+AT_CHECK([/bin/cp -f ${abs_top_srcdir}/${AUTOTEST_PATH}/Molecules/10/pre/test.xyz .], 0)
+AT_CHECK([../../molecuilder -i test.xyz -e ${abs_top_srcdir}/src/ --select-all-molecules --rotate-self 20. --position "1,2,1"], 0, [stdout], [stderr])
+AT_CHECK([diff test.xyz ${abs_top_srcdir}/${AUTOTEST_PATH}/Molecules/10/post/test-rotated-xYz20.xyz], 0, [ignore], [ignore])
+AT_CLEANUP
+
Index: tests/regression/testsuite-simple_configuration.at
===================================================================
--- tests/regression/testsuite-simple_configuration.at	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ tests/regression/testsuite-simple_configuration.at	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -29,8 +29,14 @@
 AT_CHECK([file=test.in; diff $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Simple_configuration/3/post/$file], 0, [ignore], [ignore])
 AT_CHECK([file=test.xyz; diff -I '.*Created by molecuilder.*' $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Simple_configuration/3/post/$file], 0, [ignore], [ignore])
-AT_CHECK([../../molecuilder -i test2.conf -e ${abs_top_srcdir}/src/ -o mpqc pcp xyz -a 1 --position "0., 0., -1."], 0, [ignore], [ignore])
-AT_CHECK([file=test2.conf; diff $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Simple_configuration/3/post/$file], 0, [ignore], [ignore])
-AT_CHECK([file=test2.in; diff $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Simple_configuration/3/post/$file], 0, [ignore], [ignore])
-AT_CHECK([file=test2.xyz; diff -I '.*Created by molecuilder.*' $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Simple_configuration/3/post/$file], 0, [ignore], [ignore])
+AT_CHECK([../../molecuilder -i test2.conf -e ${abs_top_srcdir}/src/ -o mpqc pcp xyz -a 1 --position "0., 0., -1."], 134, [ignore], [ignore])
+AT_CLEANUP
+AT_SETUP([Simple configuration - adding atom with Undo/Redo])
+AT_KEYWORDS([configuration])
+AT_CHECK([../../molecuilder -i empty.conf -o pcp -a 1 --position "10., 10., 10." --undo], 0, [ignore], [ignore])
+AT_CHECK([file=empty.conf; diff $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Simple_configuration/3/post/$file], 0, [ignore], [ignore])
+AT_CHECK([../../molecuilder -i test.conf -o mpqc pcp xyz -a 1 --position "10., 10., 10." --undo --redo], 0, [ignore], [ignore])
+AT_CHECK([file=test.conf; diff $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Simple_configuration/3/post/$file], 0, [ignore], [ignore])
+AT_CHECK([file=test.in; diff $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Simple_configuration/3/post/$file], 0, [ignore], [ignore])
+AT_CHECK([file=test.xyz; diff -I '.*Created by molecuilder.*' $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Simple_configuration/3/post/$file], 0, [ignore], [ignore])
 AT_CLEANUP
 
@@ -39,5 +45,14 @@
 AT_KEYWORDS([configuration])
 AT_CHECK([/bin/cp -f ${abs_top_srcdir}/${AUTOTEST_PATH}/Simple_configuration/4/pre/test.xyz test.xyz], 0)
-AT_CHECK([../../molecuilder -i test.xyz -e ${abs_top_srcdir}/src/ -E 6 --atom-by-id 0], 0, [ignore], [ignore])
+AT_CHECK([../../molecuilder -i test.xyz -e ${abs_top_srcdir}/src/ --select-atom-by-id 0 -E 6 ], 0, [ignore], [ignore])
+AT_CHECK([file=test.xyz; diff $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Simple_configuration/4/post/$file], 0, [ignore], [ignore])
+AT_CLEANUP
+AT_SETUP([Simple configuration - Changing element with Undo/Redo])
+AT_KEYWORDS([configuration])
+AT_CHECK([/bin/cp -f ${abs_top_srcdir}/${AUTOTEST_PATH}/Simple_configuration/4/pre/test.xyz test.xyz], 0)
+AT_CHECK([../../molecuilder -i test.xyz -e ${abs_top_srcdir}/src/ --select-atom-by-id 0 -E 6 --undo], 0, [ignore], [ignore])
+AT_CHECK([file=test.xyz; diff $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Simple_configuration/4/pre/$file], 0, [ignore], [ignore])
+AT_CHECK([/bin/cp -f ${abs_top_srcdir}/${AUTOTEST_PATH}/Simple_configuration/4/pre/test.xyz test.xyz], 0)
+AT_CHECK([../../molecuilder -i test.xyz -e ${abs_top_srcdir}/src/ --select-atom-by-id 0 -E 6 --undo --redo], 0, [ignore], [ignore])
 AT_CHECK([file=test.xyz; diff $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Simple_configuration/4/post/$file], 0, [ignore], [ignore])
 AT_CLEANUP
@@ -47,8 +62,17 @@
 AT_KEYWORDS([configuration])
 AT_CHECK([/bin/cp -f ${abs_top_srcdir}/${AUTOTEST_PATH}/Simple_configuration/5/pre/test.conf .], 0)
-AT_CHECK([../../molecuilder -i test.conf -e ${abs_top_srcdir}/src/ -o mpqc pcp xyz -r 0], 0, [ignore], [ignore])
+AT_CHECK([../../molecuilder -i test.conf -e ${abs_top_srcdir}/src/ -o mpqc pcp xyz --select-atom-by-id 0 -r], 0, [ignore], [ignore])
 AT_CHECK([file=test.conf; diff $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Simple_configuration/5/post/$file], 0, [ignore], [ignore])
 AT_CHECK([file=test.in; diff $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Simple_configuration/5/post/$file], 0, [ignore], [ignore])
 AT_CHECK([file=test.xyz; diff -I '.*Created by molecuilder.*' $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Simple_configuration/5/post/$file], 0, [ignore], [ignore])
+AT_CLEANUP
+AT_SETUP([Simple configuration - Atom removal with Undo/Redo])
+AT_KEYWORDS([configuration])
+AT_CHECK([/bin/cp -f ${abs_top_srcdir}/${AUTOTEST_PATH}/Simple_configuration/5/pre/test.conf .], 0)
+AT_CHECK([../../molecuilder -i test.conf --select-atom-by-id 0 -r --undo], 0, [ignore], [ignore])
+AT_CHECK([file=test.conf; diff -I '.*Created by molecuilder.*' $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Simple_configuration/5/pre/$file], 0, [ignore], [ignore])
+AT_CHECK([/bin/cp -f ${abs_top_srcdir}/${AUTOTEST_PATH}/Simple_configuration/5/pre/test.conf .], 0)
+AT_CHECK([../../molecuilder -i test.conf --select-atom-by-id 0 -r --undo --redo], 0, [ignore], [ignore])
+AT_CHECK([file=test.conf; diff -I '.*Created by molecuilder.*' $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Simple_configuration/5/post/$file], 0, [ignore], [ignore])
 AT_CLEANUP
 
@@ -75,11 +99,85 @@
 AT_CLEANUP
 
-# 8. Removing sphere of atoms
+# 8. Removing _shape_ of atoms
 AT_SETUP([Simple configuration - Removing sphere of atoms])
 AT_KEYWORDS([configuration])
-AT_CHECK([/bin/cp -f ${abs_top_srcdir}/${AUTOTEST_PATH}/Simple_configuration/8/pre/test.* .], 0)
-AT_CHECK([../../molecuilder -i test.conf -e ${abs_top_srcdir}/src/ -o xyz -R 7. --position "7.283585982, 3.275186040, 3.535886037"], 0, [stdout], [stderr])
-AT_CHECK([sort -n test.xyz | grep -v "Created by" >test.xyz-sorted], 0, [ignore], [ignore])
-AT_CHECK([sort -n ${abs_top_srcdir}/${AUTOTEST_PATH}/Simple_configuration/8/post/test.xyz  | grep -v "Created by" >${abs_top_srcdir}/${AUTOTEST_PATH}/Simple_configuration/8/post/test.xyz-sorted], 0, [ignore], [ignore])
+AT_CHECK([/bin/cp -f ${abs_top_srcdir}/${AUTOTEST_PATH}/Simple_configuration/8/pre/test.xyz test-withoutsphere.xyz], 0)
+AT_CHECK([../../molecuilder -i test-withoutsphere.xyz --select-atoms-inside-sphere 7. --position "7.283585982, 3.275186040, 3.535886037" -r], 0, [stdout], [stderr])
+AT_CHECK([sort -n test-withoutsphere.xyz | grep -v -E "^[[[:digit:]]]+" | grep -v "Created by" >test-withoutsphere.xyz-sorted], 0, [ignore], [ignore])
+AT_CHECK([file=test-withoutsphere.xyz-sorted; diff $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Simple_configuration/8/post/$file], 0, [ignore], [ignore])
+AT_CHECK([/bin/cp -f ${abs_top_srcdir}/${AUTOTEST_PATH}/Simple_configuration/8/pre/test.xyz test-sphere.xyz], 0)
+AT_CHECK([../../molecuilder -i test-sphere.xyz --select-all-atoms --unselect-atoms-inside-sphere 7. --position "7.283585982, 3.275186040, 3.535886037" -r], 0, [stdout], [stderr])
+AT_CHECK([sort -n test-sphere.xyz | grep -v -E "^[[[:digit:]]]+" | grep -v "Created by" >test-sphere.xyz-sorted], 0, [ignore], [ignore])
+AT_CHECK([file=test-sphere.xyz-sorted; diff $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Simple_configuration/8/post/$file], 0, [ignore], [ignore])
+AT_CHECK([cat test-sphere.xyz-sorted test-withoutsphere.xyz-sorted | sort -n >test.xyz-sorted], 0, [ignore], [ignore])
 AT_CHECK([file=test.xyz-sorted; diff $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Simple_configuration/8/post/$file], 0, [ignore], [ignore])
 AT_CLEANUP
+AT_SETUP([Simple configuration - Removing sphere of atoms with Undo/Redo])
+AT_KEYWORDS([configuration])
+AT_CHECK([/bin/cp -f ${abs_top_srcdir}/${AUTOTEST_PATH}/Simple_configuration/8/pre/test.xyz .], 0)
+AT_CHECK([../../molecuilder -i test.xyz --select-atoms-inside-sphere 7. --position "7.283585982, 3.275186040, 3.535886037" -r --undo], 0, [stdout], [stderr])
+AT_CHECK([file=test.xyz; diff -I '.*Created by molecuilder.*' $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Simple_configuration/8/pre/$file], 0, [ignore], [ignore])
+AT_CHECK([/bin/cp -f ${abs_top_srcdir}/${AUTOTEST_PATH}/Simple_configuration/8/pre/test.xyz test-withoutsphere.xyz], 0)
+AT_CHECK([../../molecuilder -i test-withoutsphere.xyz --select-atoms-inside-sphere 7. --position "7.283585982, 3.275186040, 3.535886037" -r --undo --redo], 0, [stdout], [stderr])
+AT_CHECK([sort -n test-withoutsphere.xyz | grep -v -E "^[[[:digit:]]]+" | grep -v "Created by" >test-withoutsphere.xyz-sorted], 0, [ignore], [ignore])
+AT_CHECK([file=test-withoutsphere.xyz-sorted; diff $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Simple_configuration/8/post/$file], 0, [ignore], [ignore])
+AT_CHECK([/bin/cp -f ${abs_top_srcdir}/${AUTOTEST_PATH}/Simple_configuration/8/pre/test.xyz .], 0)
+AT_CHECK([../../molecuilder -i test.xyz --select-all-atoms --unselect-atoms-inside-sphere 7. --position "7.283585982, 3.275186040, 3.535886037" -r --undo], 0, [stdout], [stderr])
+AT_CHECK([file=test.xyz; diff -I '.*Created by molecuilder.*' $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Simple_configuration/8/pre/$file], 0, [ignore], [ignore])
+AT_CHECK([/bin/cp -f ${abs_top_srcdir}/${AUTOTEST_PATH}/Simple_configuration/8/pre/test.xyz test-sphere.xyz], 0)
+AT_CHECK([../../molecuilder -i test-sphere.xyz --select-all-atoms --unselect-atoms-inside-sphere 7. --position "7.283585982, 3.275186040, 3.535886037" -r --undo --redo], 0, [stdout], [stderr])
+AT_CHECK([sort -n test-sphere.xyz | grep -v -E "^[[[:digit:]]]+" | grep -v "Created by" >test-sphere.xyz-sorted], 0, [ignore], [ignore])
+AT_CHECK([file=test-sphere.xyz-sorted; diff $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Simple_configuration/8/post/$file], 0, [ignore], [ignore])
+AT_CHECK([cat test-sphere.xyz-sorted test-withoutsphere.xyz-sorted | sort -n >test.xyz-sorted], 0, [ignore], [ignore])
+AT_CHECK([file=test.xyz-sorted; diff $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Simple_configuration/8/post/$file], 0, [ignore], [ignore])
+AT_CLEANUP
+
+AT_SETUP([Simple configuration - Removing cuboid of atoms])
+AT_KEYWORDS([configuration])
+AT_CHECK([/bin/cp -f ${abs_top_srcdir}/${AUTOTEST_PATH}/Simple_configuration/8/pre/test.xyz test-withoutcuboid.xyz], 0)
+AT_CHECK([../../molecuilder -i test-withoutcuboid.xyz --select-atoms-inside-cuboid "2,2,2" --position "9.78,2.64,2.64" -r], 0, [stdout], [stderr])
+AT_CHECK([sort -n test-withoutcuboid.xyz | grep -v -E "^[[[:digit:]]]+" | grep -v "Created by" >test-withoutcuboid.xyz-sorted], 0, [ignore], [ignore])
+AT_CHECK([file=test-withoutcuboid.xyz-sorted; diff $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Simple_configuration/8/post/$file], 0, [ignore], [ignore])
+AT_CHECK([/bin/cp -f ${abs_top_srcdir}/${AUTOTEST_PATH}/Simple_configuration/8/pre/test.xyz test-cuboid.xyz], 0)
+AT_CHECK([../../molecuilder -i test-cuboid.xyz --select-all-atoms --unselect-atoms-inside-cuboid "2,2,2" --position "9.78,2.64,2.64" -r], 0, [stdout], [stderr])
+AT_CHECK([sort -n test-cuboid.xyz | grep -v -E "^[[[:digit:]]]+" | grep -v "Created by" >test-cuboid.xyz-sorted], 0, [ignore], [ignore])
+AT_CHECK([file=test-cuboid.xyz-sorted; diff $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Simple_configuration/8/post/$file], 0, [ignore], [ignore])
+AT_CHECK([cat test-cuboid.xyz-sorted test-withoutcuboid.xyz-sorted | sort -n >test.xyz-sorted], 0, [ignore], [ignore])
+AT_CHECK([file=test.xyz-sorted; diff $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Simple_configuration/8/post/$file], 0, [ignore], [ignore])
+AT_CLEANUP
+AT_SETUP([Simple configuration - Removing cuboid of atoms with Undo/Redo])
+AT_KEYWORDS([configuration])
+AT_CHECK([/bin/cp -f ${abs_top_srcdir}/${AUTOTEST_PATH}/Simple_configuration/8/pre/test.xyz .], 0)
+AT_CHECK([../../molecuilder -i test.xyz --select-atoms-inside-cuboid "2,2,2" --position "9.78,2.64,2.64" -r --undo], 0, [stdout], [stderr])
+AT_CHECK([file=test.xyz; diff -I '.*Created by molecuilder.*' $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Simple_configuration/8/pre/$file], 0, [ignore], [ignore])
+AT_CHECK([/bin/cp -f ${abs_top_srcdir}/${AUTOTEST_PATH}/Simple_configuration/8/pre/test.xyz test-withoutcuboid.xyz], 0)
+AT_CHECK([../../molecuilder -i test-withoutcuboid.xyz --select-atoms-inside-cuboid "2,2,2" --position "9.78,2.64,2.64" -r --undo --redo], 0, [stdout], [stderr])
+AT_CHECK([sort -n test-withoutcuboid.xyz | grep -v -E "^[[[:digit:]]]+" | grep -v "Created by" >test-withoutcuboid.xyz-sorted], 0, [ignore], [ignore])
+AT_CHECK([file=test-withoutcuboid.xyz-sorted; diff $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Simple_configuration/8/post/$file], 0, [ignore], [ignore])
+AT_CHECK([/bin/cp -f ${abs_top_srcdir}/${AUTOTEST_PATH}/Simple_configuration/8/pre/test.xyz .], 0)
+AT_CHECK([../../molecuilder -i test.xyz --select-all-atoms --unselect-atoms-inside-cuboid "2,2,2" --position "9.78,2.64,2.64" -r --undo], 0, [stdout], [stderr])
+AT_CHECK([file=test.xyz; diff -I '.*Created by molecuilder.*' $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Simple_configuration/8/pre/$file], 0, [ignore], [ignore])
+AT_CHECK([/bin/cp -f ${abs_top_srcdir}/${AUTOTEST_PATH}/Simple_configuration/8/pre/test.xyz test-cuboid.xyz], 0)
+AT_CHECK([../../molecuilder -i test-cuboid.xyz --select-all-atoms --unselect-atoms-inside-cuboid "2,2,2" --position "9.78,2.64,2.64" -r --undo --redo], 0, [stdout], [stderr])
+AT_CHECK([sort -n test-cuboid.xyz | grep -v -E "^[[[:digit:]]]+" | grep -v "Created by" >test-cuboid.xyz-sorted], 0, [ignore], [ignore])
+AT_CHECK([file=test-cuboid.xyz-sorted; diff $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Simple_configuration/8/post/$file], 0, [ignore], [ignore])
+AT_CHECK([cat test-cuboid.xyz-sorted test-withoutcuboid.xyz-sorted | sort -n >test.xyz-sorted], 0, [ignore], [ignore])
+AT_CHECK([file=test.xyz-sorted; diff $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Simple_configuration/8/post/$file], 0, [ignore], [ignore])
+AT_CLEANUP
+
+# 9. Undo and redo a translation
+AT_SETUP([Simple configuration - Translation])
+AT_KEYWORDS([configuration])
+AT_CHECK([/bin/cp -f ${abs_top_srcdir}/${AUTOTEST_PATH}/Simple_configuration/9/pre/test.xyz .], 0)
+AT_CHECK([../../molecuilder -i test.xyz --select-all-atoms -t "1,0,0"], 0, [stdout], [stderr])
+AT_CHECK([diff test.xyz ${abs_top_srcdir}/${AUTOTEST_PATH}/Simple_configuration/9/post/test-shifted.xyz], 0, [ignore], [ignore])
+AT_CLEANUP
+AT_SETUP([Simple configuration - Translation with Undo/Redo])
+AT_KEYWORDS([configuration])
+AT_CHECK([/bin/cp -f ${abs_top_srcdir}/${AUTOTEST_PATH}/Simple_configuration/9/pre/test.xyz .], 0)
+AT_CHECK([../../molecuilder -i test.xyz --select-all-atoms -t "1,0,0" --undo], 0, [stdout], [stderr])
+AT_CHECK([diff test.xyz ${abs_top_srcdir}/${AUTOTEST_PATH}/Simple_configuration/9/pre/test.xyz], 0, [ignore], [ignore])
+AT_CHECK([/bin/cp -f ${abs_top_srcdir}/${AUTOTEST_PATH}/Simple_configuration/9/pre/test.xyz .], 0)
+AT_CHECK([../../molecuilder -i test.xyz --select-all-atoms -t "1,0,0" --undo --redo], 0, [stdout], [stderr])
+AT_CHECK([diff test.xyz ${abs_top_srcdir}/${AUTOTEST_PATH}/Simple_configuration/9/post/test-shifted.xyz], 0, [ignore], [ignore])
+AT_CLEANUP
Index: tests/regression/testsuite-standard_options.at
===================================================================
--- tests/regression/testsuite-standard_options.at	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ tests/regression/testsuite-standard_options.at	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -5,5 +5,12 @@
 AT_CHECK([pwd],[ignore],[ignore])
 AT_CHECK([../../molecuilder -v 1], 0, [stdout], [ignore])
-AT_CHECK([fgrep olecuilder stdout], 0, [ignore], [ignore])
+AT_CHECK([grep "Setting verbosity from .* to 1" stdout], 0, [ignore], [ignore])
+AT_CLEANUP
+AT_SETUP([Standard Options - verbosity with Undo/Redo])
+AT_KEYWORDS([options])
+AT_CHECK([../../molecuilder -v 1 --undo], 0, [stdout], [ignore])
+AT_CHECK([grep "Setting verbosity from 1 to .*" stdout], 0, [ignore], [ignore])
+AT_CHECK([../../molecuilder -v 1 --undo --redo], 0, [stdout], [ignore])
+AT_CHECK([grep "Setting verbosity from .* to 1" stdout], 0, [ignore], [ignore])
 AT_CLEANUP
 
@@ -53,4 +60,12 @@
 AT_CHECK([fgrep "I won't parse trajectories" stdout], 0, [ignore], [ignore])
 AT_CLEANUP
+AT_SETUP([Standard Options - fast trajectories with Undo/Redo])
+AT_KEYWORDS([options])
+AT_CHECK([../../molecuilder -i test.conf -n 1 --undo], 0, [stdout], [stderr])
+AT_CHECK([fgrep "I will parse trajectories." stdout], 0, [ignore], [ignore])
+AT_CHECK([../../molecuilder -i test.conf -n 1 --undo --redo], 0, [stdout], [stderr])
+AT_CHECK([grep -c "I won't parse trajectories" stdout], 0, 2
+, [ignore])
+AT_CLEANUP
 
 # 7. molecule default name
@@ -60,2 +75,9 @@
 AT_CHECK([fgrep "Default name of new molecules set to test." stdout], 0, [ignore], [ignore])
 AT_CLEANUP
+AT_SETUP([Standard Options - molecule default name with Undo/Redo])
+AT_KEYWORDS([options])
+AT_CHECK([../../molecuilder -i test.conf -X test --undo], 0, [stdout], [stderr])
+AT_CHECK([fgrep "Default name of new molecules set to none." stdout], 0, [ignore], [ignore])
+AT_CHECK([../../molecuilder -i test.conf -X test --undo --redo], 0, [stdout], [stderr])
+AT_CHECK([fgrep "Default name of new molecules set to test." stdout], 0, [ignore], [ignore])
+AT_CLEANUP
Index: tests/regression/testsuite-tesselation.at
===================================================================
--- tests/regression/testsuite-tesselation.at	(revision 8e463e3743873aa2485a58f66cc88fde13f11d11)
+++ tests/regression/testsuite-tesselation.at	(revision 49a1362bb32b57e917e16bb423d8f5a7ec95ac2f)
@@ -4,5 +4,5 @@
 AT_KEYWORDS([Tesselation])
 AT_CHECK([/bin/cp -f ${abs_top_srcdir}/${AUTOTEST_PATH}/Tesselation/1/pre/* .], 0)
-AT_CHECK([../../molecuilder -i test.conf -e ${abs_top_srcdir}/src/ -N 0 --sphere-radius 4. --nonconvex-file NonConvexEnvelope], 0, [stdout], [stderr])
+AT_CHECK([../../molecuilder -i test.conf -e ${abs_top_srcdir}/src/ --select-molecule-by-id 0 -N 4. --nonconvex-file NonConvexEnvelope], 0, [stdout], [stderr])
 AT_CHECK([file=NonConvexEnvelope.dat; diff $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Tesselation/1/post/$file], 0, [ignore], [ignore])
 #AT_CHECK([file=NonConvexEnvelope.r3d; diff $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Tesselation/1/post/$file], 0, [ignore], [ignore])
@@ -12,5 +12,5 @@
 AT_SETUP([Tesselation - Convex Envelope])
 AT_CHECK([/bin/cp -f ${abs_top_srcdir}/${AUTOTEST_PATH}/Tesselation/2/pre/* .], 0)
-AT_CHECK([../../molecuilder -i test.conf -e ${abs_top_srcdir}/src/ --convex-envelope 0 --convex-file ConvexEnvelope --nonconvex-file NonConvexEnvelope], 0, [stdout], [stderr])
+AT_CHECK([../../molecuilder -i test.conf -e ${abs_top_srcdir}/src/ --select-molecule-by-id 0 --convex-envelope --convex-file ConvexEnvelope --nonconvex-file NonConvexEnvelope], 0, [stdout], [stderr])
 AT_CHECK([file=ConvexEnvelope.dat; diff $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Tesselation/2/post/$file], 0, [ignore], [ignore])
 #AT_CHECK([file=ConvexEnvelope.r3d; diff $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Tesselation/2/post/$file], 0, [ignore], [ignore])
@@ -22,5 +22,5 @@
 AT_SETUP([Tesselation - Big non-Convex Envelope])
 AT_CHECK([/bin/cp -f ${abs_top_srcdir}/${AUTOTEST_PATH}/Tesselation/3/pre/* .], 0)
-AT_CHECK([../../molecuilder -i test.conf -e ${abs_top_srcdir}/src/ -N 0 --sphere-radius 4. --nonconvex-file NonConvexEnvelope], 0, [stdout], [stderr])
+AT_CHECK([../../molecuilder -i test.conf -e ${abs_top_srcdir}/src/ --select-molecule-by-id 0 -N 4. --nonconvex-file NonConvexEnvelope], 0, [stdout], [stderr])
 AT_CHECK([file=NonConvexEnvelope.dat; diff $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Tesselation/3/post/$file], 0, [ignore], [ignore])
 #AT_CHECK([file=NonConvexEnvelope.r3d; diff $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Tesselation/3/post/$file], 0, [ignore], [ignore])
@@ -30,5 +30,5 @@
 #AT_SETUP([Tesselation - big convex Envelope])
 #AT_CHECK([/bin/cp -f ${abs_top_srcdir}/${AUTOTEST_PATH}/Tesselation/4/pre/* .], 0)
-#AT_CHECK([../../molecuilder -i test.conf -e ${abs_top_srcdir}/src/ --convex-envelope ConvexEnvelope NonConvexEnvelope], 0, [stdout], [stderr])
+#AT_CHECK([../../molecuilder -i test.conf -e ${abs_top_srcdir}/src/ --select-molecule-by-id 0 --convex-envelope ConvexEnvelope NonConvexEnvelope], 0, [stdout], [stderr])
 #AT_CHECK([file=ConvexEnvelope.dat; diff $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Tesselation/4/post/$file], 0, [ignore], [ignore])
 #AT_CHECK([file=ConvexEnvelope.r3d; diff $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Tesselation/4/post/$file], 0, [ignore], [ignore])
